use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.
the class PsiClassTableCellEditor method getTableCellEditorComponent.
public final Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
final Document document = JavaReferenceEditorUtil.createDocument(value == null ? "" : (String) value, myProject, true);
myEditor = new EditorTextField(document, myProject, StdFileTypes.JAVA) {
protected boolean shouldHaveBorder() {
return false;
}
public void addNotify() {
super.addNotify();
final JComponent editorComponent = getEditor().getContentComponent();
editorComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
editorComponent.getActionMap().put("ENTER", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
stopCellEditing();
}
});
}
};
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(myEditor);
final FixedSizeButton button = new FixedSizeButton(myEditor);
panel.add(button, BorderLayout.EAST);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createInheritanceClassChooser(UIBundle.message("choose.class"), mySearchScope, null, true, true, Conditions.alwaysTrue());
chooser.showDialog();
final PsiClass psiClass = chooser.getSelected();
if (psiClass != null) {
myEditor.setText(psiClass.getQualifiedName());
}
}
});
panel.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (!e.isTemporary() && myEditor != null) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myEditor, true);
});
}
}
public void focusLost(FocusEvent e) {
}
});
myEditor.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
if (!e.isTemporary()) {
stopCellEditing();
}
}
});
return panel;
}
use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.
the class AbstractFieldPanel method createComponent.
public void createComponent() {
removeAll();
setLayout(new GridBagLayout());
if (myLabelText != null) {
myLabel = new JLabel(myLabelText);
this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
myLabel.setLabelFor(myComponent);
}
this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
if (myBrowseButtonActionListener != null) {
FixedSizeButton browseButton = new FixedSizeButton(getComponent());
myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton);
browseButton.setFocusable(false);
browseButton.addActionListener(myBrowseButtonActionListener);
myButtons.add(browseButton);
this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0));
}
if (myViewerDialogTitle != null) {
final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent());
if (myBrowseButtonActionListener == null) {
LOG.assertTrue(myDoClickAction == null);
myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton);
}
showViewerButton.setFocusable(false);
showViewerButton.setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
showViewerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Viewer viewer = new Viewer();
viewer.setTitle(myViewerDialogTitle);
viewer.show();
}
});
myButtons.add(showViewerButton);
this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
}
use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.
the class ExternalProjectPathField method createPanel.
@NotNull
public static MyPathAndProjectButtonPanel createPanel(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
final EditorTextField textField = createTextField(project, externalSystemId);
final FixedSizeButton selectRegisteredProjectButton = new FixedSizeButton();
selectRegisteredProjectButton.setIcon(AllIcons.Actions.Module);
String tooltipText = ExternalSystemBundle.message("run.configuration.tooltip.choose.registered.project", externalSystemId.getReadableName());
selectRegisteredProjectButton.setToolTipText(tooltipText);
selectRegisteredProjectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final Ref<JBPopup> popupRef = new Ref<>();
final Tree tree = buildRegisteredProjectsTree(project, externalSystemId);
tree.setBorder(IdeBorderFactory.createEmptyBorder(8));
Runnable treeSelectionCallback = () -> {
TreePath path = tree.getSelectionPath();
if (path != null) {
Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof ExternalSystemNode) {
Object e1 = ((ExternalSystemNode) lastPathComponent).getDescriptor().getElement();
if (e1 instanceof ExternalProjectPojo) {
ExternalProjectPojo pojo = (ExternalProjectPojo) e1;
textField.setText(pojo.getPath());
Editor editor = textField.getEditor();
if (editor != null) {
collapseIfPossible(editor, externalSystemId, project);
}
}
}
}
popupRef.get().closeOk(null);
};
JBPopup popup = new PopupChooserBuilder(tree).setTitle(ExternalSystemBundle.message("run.configuration.title.choose.registered.project", externalSystemId.getReadableName())).setResizable(true).setItemChoosenCallback(treeSelectionCallback).setAutoselectOnMouseMove(true).setCloseOnEnter(false).createPopup();
popupRef.set(popup);
popup.showUnderneathOf(selectRegisteredProjectButton);
}
});
return new MyPathAndProjectButtonPanel(textField, selectRegisteredProjectButton);
}
use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.
the class CommonProgramParametersPanel method createComponentWithMacroBrowse.
protected JComponent createComponentWithMacroBrowse(@NotNull final TextFieldWithBrowseButton textAccessor) {
final FixedSizeButton button = new FixedSizeButton(textAccessor);
button.setIcon(AllIcons.RunConfigurations.Variables);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
List<String> macros = new SmartList<>(PathMacros.getInstance().getUserMacroNames());
if (myModuleContext != null || myHasModuleMacro) {
macros.add(PathMacroUtil.MODULE_DIR_MACRO_NAME);
}
final JList list = new JBList(ArrayUtil.toStringArray(macros));
JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
final Object value = list.getSelectedValue();
if (value instanceof String) {
textAccessor.setText('$' + ((String) value) + '$');
}
}).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
}
});
JPanel panel = new JPanel(new BorderLayout());
panel.add(textAccessor, BorderLayout.CENTER);
panel.add(button, BorderLayout.EAST);
return panel;
}
use of com.intellij.openapi.ui.FixedSizeButton in project intellij-community by JetBrains.
the class ArtifactEditorImpl method createUIComponents.
private void createUIComponents() {
myShowContentCheckBox = new ThreeStateCheckBox();
myShowSpecificContentOptionsButton = new FixedSizeButton(16);
}
Aggregations