use of java.awt.event.ItemListener in project jadx by skylot.
the class JadxSettingsWindow method makeDecompilationGroup.
private SettingsGroup makeDecompilationGroup() {
JCheckBox fallback = new JCheckBox();
fallback.setSelected(settings.isFallbackMode());
fallback.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setFallbackMode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox showInconsistentCode = new JCheckBox();
showInconsistentCode.setSelected(settings.isShowInconsistentCode());
showInconsistentCode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setShowInconsistentCode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox resourceDecode = new JCheckBox();
resourceDecode.setSelected(settings.isSkipResources());
resourceDecode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setSkipResources(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
final JSpinner threadsCount = new JSpinner();
threadsCount.setValue(settings.getThreadsCount());
threadsCount.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
settings.setThreadsCount((Integer) threadsCount.getValue());
}
});
JCheckBox autoStartJobs = new JCheckBox();
autoStartJobs.setSelected(settings.isAutoStartJobs());
autoStartJobs.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setAutoStartJobs(e.getStateChange() == ItemEvent.SELECTED);
}
});
JCheckBox escapeUnicode = new JCheckBox();
escapeUnicode.setSelected(settings.escapeUnicode());
escapeUnicode.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setEscapeUnicode(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
JCheckBox replaceConsts = new JCheckBox();
replaceConsts.setSelected(settings.isReplaceConsts());
replaceConsts.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
settings.setReplaceConsts(e.getStateChange() == ItemEvent.SELECTED);
needReload();
}
});
SettingsGroup other = new SettingsGroup(NLS.str("preferences.decompile"));
other.addRow(NLS.str("preferences.threads"), threadsCount);
other.addRow(NLS.str("preferences.start_jobs"), autoStartJobs);
other.addRow(NLS.str("preferences.showInconsistentCode"), showInconsistentCode);
other.addRow(NLS.str("preferences.escapeUnicode"), escapeUnicode);
other.addRow(NLS.str("preferences.replaceConsts"), replaceConsts);
other.addRow(NLS.str("preferences.fallback"), fallback);
other.addRow(NLS.str("preferences.skipResourcesDecode"), resourceDecode);
return other;
}
use of java.awt.event.ItemListener in project intellij-plugins by JetBrains.
the class MarkdownPreviewSettingsForm method createUIComponents.
private void createUIComponents() {
//noinspection unchecked
final List<MarkdownHtmlPanelProvider.ProviderInfo> providerInfos = ContainerUtil.mapNotNull(MarkdownHtmlPanelProvider.getProviders(), provider -> {
if (provider.isAvailable() == MarkdownHtmlPanelProvider.AvailabilityInfo.UNAVAILABLE) {
return null;
}
return provider.getProviderInfo();
});
myPreviewPanelModel = new CollectionComboBoxModel<>(providerInfos, providerInfos.get(0));
myPreviewProvider = new ComboBox(myPreviewPanelModel);
mySplitLayoutModel = new EnumComboBoxModel<>(SplitFileEditor.SplitEditorLayout.class);
myDefaultSplitLayout = new ComboBox(mySplitLayoutModel);
myLastItem = myPreviewProvider.getSelectedItem();
myPreviewProvider.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
final Object item = e.getItem();
if (e.getStateChange() != ItemEvent.SELECTED || !(item instanceof MarkdownHtmlPanelProvider.ProviderInfo)) {
return;
}
final MarkdownHtmlPanelProvider provider = MarkdownHtmlPanelProvider.createFromInfo((MarkdownHtmlPanelProvider.ProviderInfo) item);
final MarkdownHtmlPanelProvider.AvailabilityInfo availability = provider.isAvailable();
if (!availability.checkAvailability(myMainPanel)) {
myPreviewProvider.setSelectedItem(myLastItem);
} else {
myLastItem = item;
updateUseGrayscaleEnabled();
}
}
});
}
use of java.awt.event.ItemListener in project JMRI by JMRI.
the class RosterGroupsPanel method getButtons.
private JToolBar getButtons() {
JToolBar controls = new JToolBar();
controls.setLayout(new GridLayout(1, 0, 0, 0));
controls.setFloatable(false);
final JToggleButton addGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Add.png")), false);
final JToggleButton actGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Action.png")), false);
addGroupBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new CreateRosterGroupAction("", scrollPane.getTopLevelAncestor()).actionPerformed(e);
addGroupBtn.setSelected(false);
}
});
actGroupBtn.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent ie) {
if (ie.getStateChange() == ItemEvent.SELECTED) {
TreePath g = new TreePath(_model.getPathToRoot(_groups));
if (_tree.getSelectionPath() != null) {
if (_tree.getSelectionPath().getLastPathComponent().toString().equals(Roster.ALLENTRIES)) {
allEntriesMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - allEntriesMenu.getPreferredSize().height);
} else if (g.isDescendant(_tree.getSelectionPath()) && !_tree.getSelectionPath().isDescendant(g)) {
groupsMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - groupsMenu.getPreferredSize().height);
}
}
}
}
});
PopupMenuListener PML = new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
// do nothing
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
actGroupBtn.setSelected(false);
}
@Override
public void popupMenuCanceled(PopupMenuEvent pme) {
actGroupBtn.setSelected(false);
}
};
allEntriesMenu.addPopupMenuListener(PML);
groupsMenu.addPopupMenuListener(PML);
controls.add(addGroupBtn);
controls.add(actGroupBtn);
return controls;
}
use of java.awt.event.ItemListener in project JMRI by JMRI.
the class AbstractNetworkConnectionConfig method loadDetails.
@Override
public void loadDetails(final JPanel details) {
_details = details;
setInstance();
if (!init) {
//Build up list of options
//Hashtable<String, AbstractPortController.Option> adapterOptions = ((AbstractPortController)adapter).getOptionList();
String[] optionsAvailable = adapter.getOptions();
options = new Hashtable<String, Option>();
for (String i : optionsAvailable) {
JComboBox<String> opt = new JComboBox<String>(adapter.getOptionChoices(i));
opt.setSelectedItem(adapter.getOptionState(i));
// check that it worked
if (!adapter.getOptionState(i).equals(opt.getSelectedItem())) {
// no, set 1st option choice
opt.setSelectedIndex(0);
// log before setting new value to show old value
log.warn("Loading found invalid value for option {}, found \"{}\", setting to \"{}\"", i, adapter.getOptionState(i), opt.getSelectedItem());
adapter.setOptionState(i, (String) opt.getSelectedItem());
}
options.put(i, new Option(adapter.getOptionDisplayName(i), opt, adapter.isOptionAdvanced(i)));
}
}
if (hostNameField.getActionListeners().length > 0) {
hostNameField.removeActionListener(hostNameField.getActionListeners()[0]);
}
if (adapter.getSystemConnectionMemo() != null) {
systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
NUMOPTIONS = NUMOPTIONS + 2;
}
NUMOPTIONS = NUMOPTIONS + options.size();
hostNameField.setText(adapter.getHostName());
hostNameFieldLabel = new JLabel(rb.getString("HostFieldLabel"));
hostNameField.setToolTipText(rb.getString("HostFieldToolTip"));
if (adapter.getHostName() == null || adapter.getHostName().equals("")) {
hostNameField.setText(p.getComboBoxLastSelection(adapter.getClass().getName() + ".hostname"));
adapter.setHostName(hostNameField.getText());
}
portField.setToolTipText(rb.getString("PortFieldToolTip"));
portField.setEnabled(true);
portField.setText("" + adapter.getPort());
portFieldLabel = new JLabel(rb.getString("PortFieldLabel"));
adNameField.setToolTipText(rb.getString("AdNameFieldToolTip"));
adNameField.setEnabled(false);
adNameField.setText("" + adapter.getAdvertisementName());
adNameFieldLabel = new JLabel(rb.getString("AdNameFieldLabel"));
adNameFieldLabel.setEnabled(false);
serviceTypeField.setToolTipText(rb.getString("ServiceTypeFieldToolTip"));
serviceTypeField.setEnabled(false);
serviceTypeField.setText("" + adapter.getServiceType());
serviceTypeFieldLabel = new JLabel(rb.getString("ServiceTypeFieldLabel"));
serviceTypeFieldLabel.setEnabled(false);
showAutoConfig.setFont(showAutoConfig.getFont().deriveFont(9f));
showAutoConfig.setForeground(Color.blue);
showAutoConfig.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setAutoNetworkConfig();
}
});
showAutoConfig.setSelected(adapter.getMdnsConfigure());
setAutoNetworkConfig();
showAdvanced.setFont(showAdvanced.getFont().deriveFont(9f));
showAdvanced.setForeground(Color.blue);
showAdvanced.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
showAdvancedItems();
}
});
showAdvancedItems();
// need to reload action listeners
init = false;
checkInitDone();
}
use of java.awt.event.ItemListener in project JMRI by JMRI.
the class AbstractSimulatorConnectionConfig method loadDetails.
@Override
public void loadDetails(final JPanel details) {
_details = details;
setInstance();
if (!init) {
String[] optionsAvailable = adapter.getOptions();
options = new Hashtable<String, Option>();
for (String i : optionsAvailable) {
JComboBox<String> opt = new JComboBox<String>(adapter.getOptionChoices(i));
opt.setSelectedItem(adapter.getOptionState(i));
// check that it worked
if (!adapter.getOptionState(i).equals(opt.getSelectedItem())) {
// no, set 1st option choice
opt.setSelectedIndex(0);
// log before setting new value to show old value
log.warn("Loading found invalid value for option {}, found \"{}\", setting to \"{}\"", i, adapter.getOptionState(i), opt.getSelectedItem());
adapter.setOptionState(i, (String) opt.getSelectedItem());
}
options.put(i, new Option(adapter.getOptionDisplayName(i), opt, adapter.isOptionAdvanced(i)));
}
}
if (adapter.getSystemConnectionMemo() != null) {
systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
}
NUMOPTIONS = NUMOPTIONS + options.size();
showAdvanced.setFont(showAdvanced.getFont().deriveFont(9f));
showAdvanced.setForeground(Color.blue);
showAdvanced.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
showAdvancedItems();
}
});
showAdvancedItems();
// need to reload action listeners
init = false;
checkInitDone();
}
Aggregations