use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.
the class ToolEditorDialog method addListeners.
private void addListeners() {
myOutputFiltersButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
OutputFiltersDialog dialog = new OutputFiltersDialog(myOutputFiltersButton, getData().getOutputFilters());
if (dialog.showAndGet()) {
myOutputFilters = dialog.getData();
}
}
});
myInsertCommandMacroButton.addActionListener(new InsertMacroActionListener(myTfCommand));
myInsertParametersMacroButton.addActionListener(new InsertMacroActionListener(myParametersField));
myInsertWorkingDirectoryMacroButton.addActionListener(new InsertMacroActionListener(myTfCommandWorkingDirectory));
myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
handleOKButton();
}
});
myUseConsoleCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
myShowConsoleOnStdOutCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
myShowConsoleOnStdErrCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
}
});
}
use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.
the class ComboBoxVisibilityPanel method setVisibility.
@Override
public void setVisibility(V visibility) {
myComboBox.setSelectedItem(visibility);
myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this));
}
use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.
the class AllFileTemplatesConfigurable method createComponent.
@Override
public JComponent createComponent() {
myUIDisposable = Disposer.newDisposable();
myTemplatesList = new FileTemplateTabAsList(TEMPLATES_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myIncludesList = new FileTemplateTabAsList(INCLUDES_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myCodeTemplatesList = new FileTemplateTabAsList(CODE_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
};
myCurrentTab = myTemplatesList;
final List<FileTemplateTab> allTabs = new ArrayList<>(Arrays.asList(myTemplatesList, myIncludesList, myCodeTemplatesList));
final FileTemplateGroupDescriptorFactory[] factories = Extensions.getExtensions(FileTemplateGroupDescriptorFactory.EXTENSION_POINT_NAME);
if (factories.length != 0) {
myOtherTemplatesList = new FileTemplateTabAsTree(OTHER_TITLE) {
@Override
public void onTemplateSelected() {
onListSelectionChanged();
}
@Override
protected FileTemplateNode initModel() {
SortedSet<FileTemplateGroupDescriptor> categories = new TreeSet<>((o1, o2) -> o1.getTitle().compareTo(o2.getTitle()));
for (FileTemplateGroupDescriptorFactory templateGroupFactory : factories) {
ContainerUtil.addIfNotNull(categories, templateGroupFactory.getFileTemplatesDescriptor());
}
//noinspection HardCodedStringLiteral
return new FileTemplateNode("ROOT", null, ContainerUtil.map2List(categories, s -> new FileTemplateNode(s)));
}
};
allTabs.add(myOtherTemplatesList);
}
myEditor = new FileTemplateConfigurable(myProject);
myEditor.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
onEditorChanged();
}
});
myEditorComponent = myEditor.createComponent();
myEditorComponent.setBorder(JBUI.Borders.empty(10, 0, 10, 10));
myTabs = allTabs.toArray(new FileTemplateTab[allTabs.size()]);
myTabbedPane = new TabbedPaneWrapper(myUIDisposable);
myTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
myLeftPanel = new JPanel(new CardLayout());
myLeftPanel.setBorder(JBUI.Borders.empty(10, 10, 10, 0));
for (FileTemplateTab tab : myTabs) {
myLeftPanel.add(ScrollPaneFactory.createScrollPane(tab.getComponent()), tab.getTitle());
JPanel fakePanel = new JPanel();
fakePanel.setPreferredSize(new Dimension(0, 0));
myTabbedPane.addTab(tab.getTitle(), fakePanel);
}
myTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
onTabChanged();
}
});
DefaultActionGroup group = new DefaultActionGroup();
AnAction removeAction = new AnAction(IdeBundle.message("action.remove.template"), null, AllIcons.General.Remove) {
@Override
public void actionPerformed(AnActionEvent e) {
onRemove();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
e.getPresentation().setEnabled(selectedItem != null && !isInternalTemplate(selectedItem.getName(), myCurrentTab.getTitle()));
}
};
AnAction addAction = new AnAction(IdeBundle.message("action.create.template"), null, AllIcons.General.Add) {
@Override
public void actionPerformed(AnActionEvent e) {
onAdd();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(!(myCurrentTab == myCodeTemplatesList || myCurrentTab == myOtherTemplatesList));
}
};
AnAction cloneAction = new AnAction(IdeBundle.message("action.copy.template"), null, PlatformIcons.COPY_ICON) {
@Override
public void actionPerformed(AnActionEvent e) {
onClone();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(myCurrentTab != myCodeTemplatesList && myCurrentTab != myOtherTemplatesList && myCurrentTab.getSelectedTemplate() != null);
}
};
AnAction resetAction = new AnAction(IdeBundle.message("action.reset.to.default"), null, AllIcons.Actions.Reset) {
@Override
public void actionPerformed(AnActionEvent e) {
onReset();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
final FileTemplate selectedItem = myCurrentTab.getSelectedTemplate();
e.getPresentation().setEnabled(selectedItem instanceof BundledFileTemplate && !selectedItem.isDefault());
}
};
group.add(addAction);
group.add(removeAction);
group.add(cloneAction);
group.add(resetAction);
addAction.registerCustomShortcutSet(CommonShortcuts.INSERT, myCurrentTab.getComponent());
removeAction.registerCustomShortcutSet(CommonShortcuts.getDelete(), myCurrentTab.getComponent());
myToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent();
myToolBar.setBorder(IdeBorderFactory.createEmptyBorder());
JPanel toolbarPanel = new JPanel(new BorderLayout());
toolbarPanel.add(myToolBar, BorderLayout.WEST);
JComponent schemaComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultCompactActionGroup(new ChangeSchemaCombo(this)), true).getComponent();
JPanel schemaPanel = new JPanel(new BorderLayout());
schemaPanel.add(schemaComponent, BorderLayout.EAST);
schemaPanel.add(new JLabel("Schema:"), BorderLayout.WEST);
toolbarPanel.add(schemaPanel, BorderLayout.EAST);
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.add(myTabbedPane.getComponent(), BorderLayout.NORTH);
Splitter splitter = new Splitter(false, 0.3f);
splitter.setDividerWidth(JBUI.scale(10));
splitter.setFirstComponent(myLeftPanel);
splitter.setSecondComponent(myEditorComponent);
centerPanel.add(splitter, BorderLayout.CENTER);
myMainPanel = new JPanel(new BorderLayout());
myMainPanel.add(toolbarPanel, BorderLayout.NORTH);
myMainPanel.add(centerPanel, BorderLayout.CENTER);
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
final String tabName = propertiesComponent.getValue(CURRENT_TAB);
if (selectTab(tabName)) {
//final String selectedTemplateName = propertiesComponent.getValue(SELECTED_TEMPLATE);
//for (FileTemplate template : myCurrentTab.getTemplates()) {
// if (Comparing.strEqual(template.getName(), selectedTemplateName)) {
// myCurrentTab.selectTemplate(template);
// break;
// }
//}
}
return myMainPanel;
}
use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.
the class ChangeSignatureDialogBase method createParametersPanel.
protected JPanel createParametersPanel(boolean hasTabsInDialog) {
myParametersTable = new TableView<ParameterTableModelItem>(myParametersTableModel) {
@Override
public void removeEditor() {
clearEditorListeners();
super.removeEditor();
}
@Override
public void editingStopped(ChangeEvent e) {
super.editingStopped(e);
// to update disabled cells background
repaint();
}
private void clearEditorListeners() {
final TableCellEditor editor = getCellEditor();
if (editor instanceof StringTableCellEditor) {
final StringTableCellEditor ed = (StringTableCellEditor) editor;
ed.clearListeners();
} else if (editor instanceof CodeFragmentTableCellEditorBase) {
((CodeFragmentTableCellEditorBase) editor).clearListeners();
}
}
@Override
public Component prepareEditor(final TableCellEditor editor, final int row, final int column) {
final DocumentAdapter listener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
final TableCellEditor ed = myParametersTable.getCellEditor();
if (ed != null) {
Object editorValue = ed.getCellEditorValue();
myParametersTableModel.setValueAtWithoutUpdate(editorValue, row, column);
updateSignature();
}
}
};
if (editor instanceof StringTableCellEditor) {
final StringTableCellEditor ed = (StringTableCellEditor) editor;
ed.addDocumentListener(listener);
} else if (editor instanceof CodeFragmentTableCellEditorBase) {
((CodeFragmentTableCellEditorBase) editor).addDocumentListener(listener);
}
return super.prepareEditor(editor, row, column);
}
@Override
public void editingCanceled(ChangeEvent e) {
super.editingCanceled(e);
}
};
myParametersTable.setCellSelectionEnabled(true);
myParametersTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myParametersTable.getSelectionModel().setSelectionInterval(0, 0);
myParametersTable.setSurrendersFocusOnKeystroke(true);
myPropagateParamChangesButton.setShortcut(CustomShortcutSet.fromString("alt G"));
if (isListTableViewSupported()) {
myParametersList = createParametersListTable();
final JPanel buttonsPanel = ToolbarDecorator.createDecorator(myParametersList.getTable()).addExtraAction(myPropagateParamChangesButton).createPanel();
myParametersList.getTable().getModel().addTableModelListener(mySignatureUpdater);
return buttonsPanel;
} else {
final JPanel buttonsPanel = ToolbarDecorator.createDecorator(getTableComponent()).addExtraAction(myPropagateParamChangesButton).createPanel();
myPropagateParamChangesButton.setEnabled(false);
myPropagateParamChangesButton.setVisible(false);
myParametersTable.setStriped(true);
myParametersTableModel.addTableModelListener(mySignatureUpdater);
customizeParametersTable(myParametersTable);
return buttonsPanel;
}
}
use of javax.swing.event.ChangeEvent in project intellij-community by JetBrains.
the class DocumentationComponent method createSettingsPanel.
private JComponent createSettingsPanel() {
JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
result.add(new JLabel(ApplicationBundle.message("label.font.size")));
myFontSizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, FontSize.values().length - 1, 3);
myFontSizeSlider.setMinorTickSpacing(1);
myFontSizeSlider.setPaintTicks(true);
myFontSizeSlider.setPaintTrack(true);
myFontSizeSlider.setSnapToTicks(true);
UIUtil.setSliderIsFilled(myFontSizeSlider, true);
result.add(myFontSizeSlider);
result.setBorder(BorderFactory.createLineBorder(JBColor.border(), 1));
myFontSizeSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myIgnoreFontSizeSliderChange) {
return;
}
setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]);
applyFontSize();
}
});
String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel");
result.setToolTipText(tooltipText);
myFontSizeSlider.setToolTipText(tooltipText);
result.setVisible(false);
result.setOpaque(true);
myFontSizeSlider.setOpaque(true);
return result;
}
Aggregations