use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class ChildFocusWatcher method eventDispatched.
public void eventDispatched(final AWTEvent event) {
if (event instanceof FocusEvent) {
final FocusEvent fe = (FocusEvent) event;
final Component component = fe.getComponent();
if (component == null)
return;
if (!SwingUtilities.isDescendingFrom(component, myParent))
return;
if (fe.getID() == FocusEvent.FOCUS_GAINED) {
onFocusGained(fe);
} else if (fe.getID() == FocusEvent.FOCUS_LAST) {
onFocusLost(fe);
}
}
}
use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class FileTemplateConfigurable method createComponent.
@Override
public JComponent createComponent() {
myMainPanel = new JPanel(new GridBagLayout());
myNameField = new JTextField();
myExtensionField = new JTextField();
mySplitter = new Splitter(true, myProportion);
myAdjustBox = new JCheckBox(IdeBundle.message("checkbox.reformat.according.to.style"));
myLiveTemplateBox = new JCheckBox(IdeBundle.message("checkbox.enable.live.templates"));
myTemplateEditor = createEditor();
myDescriptionComponent = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
myDescriptionComponent.setEditable(false);
myDescriptionComponent.addHyperlinkListener(new BrowserHyperlinkListener());
myTopPanel = new JPanel(new GridBagLayout());
JPanel descriptionPanel = new JPanel(new GridBagLayout());
descriptionPanel.add(SeparatorFactory.createSeparator(IdeBundle.message("label.description"), null), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsBottom(2), 0, 0));
descriptionPanel.add(ScrollPaneFactory.createScrollPane(myDescriptionComponent), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insetsTop(2), 0, 0));
myMainPanel.add(myTopPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
myMainPanel.add(mySplitter, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
mySplitter.setSecondComponent(descriptionPanel);
setShowInternalMessage(null);
myNameField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(@NotNull FocusEvent e) {
onNameChanged();
}
});
myExtensionField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(@NotNull FocusEvent e) {
onNameChanged();
}
});
myMainPanel.setPreferredSize(JBUI.size(400, 300));
return myMainPanel;
}
use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class CopiesPanel method setFocusableForLinks.
@SuppressWarnings("MethodMayBeStatic")
private void setFocusableForLinks(final LinkLabel label) {
final Border border = new DottedBorder(new Insets(1, 2, 1, 1), JBColor.BLACK);
label.setFocusable(true);
label.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
super.focusGained(e);
label.setBorder(border);
}
@Override
public void focusLost(FocusEvent e) {
super.focusLost(e);
label.setBorder(null);
}
});
label.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyCode()) {
label.doClick();
}
}
});
}
use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class ShareDialog method createFolderPanel.
private JComponent createFolderPanel() {
final Project project = myVCS.getProject();
myCommitMessage = new CommitMessage(project) {
@Override
public Dimension getPreferredSize() {
final Dimension superValue = super.getPreferredSize();
return new Dimension(superValue.width, superValue.height > 90 ? superValue.height : 90);
}
@Override
public void addNotify() {
super.addNotify();
myCommitMessage.getEditorField().getFocusTarget().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
myPrefferedFocused = myCommitMessage.getEditorField();
}
});
}
};
final JPanel panel = new JPanel(new GridBagLayout());
final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);
gb.insets.top = 5;
final JLabel label = new JLabel("Define share target");
label.setFont(label.getFont().deriveFont(Font.BOLD));
panel.add(label, gb);
gb.insets.top = 1;
final ButtonGroup bg = new ButtonGroup();
myExisting = new JRadioButton();
mySameNameAsLocal = new JRadioButton();
myTrunk = new JRadioButton();
bg.add(myExisting);
bg.add(mySameNameAsLocal);
bg.add(myTrunk);
gb.insets.top = 1;
++gb.gridy;
panel.add(myExisting, gb);
++gb.gridy;
panel.add(mySameNameAsLocal, gb);
++gb.gridy;
gb.insets.top = 5;
panel.add(myTrunk, gb);
myCreateStandard = new JCheckBox("Create /tags and /branches");
myTrunk.addChangeListener(e -> myCreateStandard.setEnabled(myTrunk.isSelected()));
myCreateStandard.setSelected(true);
++gb.gridy;
gb.insets.top = 0;
gb.insets.left = 10;
panel.add(myCreateStandard, gb);
++gb.gridy;
gb.gridx = 0;
gb.insets.top = 1;
gb.insets.left = 1;
gb.weightx = 1;
gb.fill = GridBagConstraints.HORIZONTAL;
final LocalChangeList list = ChangeListManager.getInstance(project).getDefaultChangeList();
String text = list.getComment();
text = StringUtil.isEmptyOrSpaces(text) ? (list.hasDefaultName() ? "" : list.getName()) : text;
myCommitMessage.setText(text);
panel.add(myCommitMessage, gb);
myCommitMessage.setSeparatorText("Commit Comment Prefix");
for (EditChangelistSupport support : Extensions.getExtensions(EditChangelistSupport.EP_NAME, project)) {
support.installSearch(myCommitMessage.getEditorField(), myCommitMessage.getEditorField());
}
myTrunk.setSelected(true);
return panel;
}
use of java.awt.event.FocusEvent in project intellij-community by JetBrains.
the class ShareDialog method init.
public void init() {
super.init();
setTitle("Select Share Target");
setOKButtonText("Share");
getRepositoryBrowser().addChangeListener(e -> {
if (getOKAction() != null) {
final String selectedURL = getRepositoryBrowser().getSelectedURL();
updateOptionsTexts(selectedURL);
getOKAction().setEnabled(selectedURL != null);
}
});
getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null);
((RepositoryTreeModel) getRepositoryBrowser().getRepositoryTree().getModel()).setShowFiles(false);
getRepositoryBrowser().getPreferredFocusedComponent().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
myPrefferedFocused = (JComponent) getRepositoryBrowser().getPreferredFocusedComponent();
}
});
}
Aggregations