List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:pcgen.gui2.dialog.ExportDialog.java
private void maybeOpenFile(File file) { UIPropertyContext context = UIPropertyContext.getInstance(); String value = context.getProperty(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE); Boolean openFile = StringUtils.isEmpty(value) ? null : Boolean.valueOf(value); if (openFile == null) { JCheckBox checkbox = new JCheckBox(); checkbox.setText("Always perform this action"); JPanel message = PCGenFrame.buildMessageLabelPanel("Do you want to open " + file.getName() + "?", checkbox);//from w w w .j a v a 2 s. c o m int ret = JOptionPane.showConfirmDialog(this, message, "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.CLOSED_OPTION) { return; } openFile = BooleanUtils.toBoolean(ret, JOptionPane.YES_OPTION, JOptionPane.NO_OPTION); if (checkbox.isSelected()) { context.setBoolean(UIPropertyContext.ALWAYS_OPEN_EXPORT_FILE, openFile); } } if (!openFile) { return; } if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { pcgenFrame.showErrorMessage("Cannot Open " + file.getName(), "Operating System does not support this operation"); return; } try { Desktop.getDesktop().open(file); } catch (IOException ex) { String message = "Failed to open " + file.getName(); pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message); Logging.errorPrint(message, ex); } }
From source file:pcgen.gui2.PCGenFrame.java
@Override public Boolean maybeShowWarningConfirm(String title, String message, String checkBoxText, final PropertyContext context, final String contextProp) { if (!context.getBoolean(contextProp, true)) { return null; }//from w ww . j av a 2s . c om final JCheckBox checkBox = new JCheckBox(checkBoxText, true); checkBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { context.setBoolean(contextProp, checkBox.isSelected()); } }); JPanel panel = buildMessageLabelPanel(message, checkBox); int ret = JOptionPane.showConfirmDialog(this, panel, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); return ret == JOptionPane.YES_OPTION; }
From source file:pcgen.gui2.PCGenFrame.java
private void showLicenseDialog(String title, String htmlString) { if (htmlString == null) { htmlString = LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$ }//w w w . j a v a 2 s.c om final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; final JDialog aFrame = new JDialog(this, title, true); final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ final JPanel jPanel = new JPanel(); final JCheckBox jCheckBox = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ jPanel.add(jCheckBox); jCheckBox.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_LICENSE)); jCheckBox.addItemListener( evt -> context.setBoolean(PCGenSettings.OPTION_SHOW_LICENSE, jCheckBox.isSelected())); jPanel.add(jClose); jClose.addActionListener(evt -> aFrame.dispose()); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(htmlString, "", theRendererContext); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH); aFrame.setSize(new Dimension(700, 500)); aFrame.setLocationRelativeTo(this); Utility.setComponentRelativeLocation(this, aFrame); aFrame.getRootPane().setDefaultButton(jClose); Utility.installEscapeCloseOperation(aFrame); aFrame.setVisible(true); }
From source file:pcgen.gui2.PCGenFrame.java
private void showMatureDialog(String text) { Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised."); Logging.errorPrint(text);// www.j av a2s. c o m final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true); final JPanel jPanel1 = new JPanel(); final JPanel jPanel3 = new JPanel(); final JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_matureWarningLine1"), //$NON-NLS-1$ SwingConstants.CENTER); final JLabel jLabel2 = new JLabel(LanguageBundle.getString("in_matureWarningLine2"), //$NON-NLS-1$ SwingConstants.CENTER); final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad")); //$NON-NLS-1$ final JButton jClose = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$ jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$ jPanel1.setLayout(new BorderLayout()); jPanel1.add(jLabel1, BorderLayout.NORTH); jPanel1.add(jLabel2, BorderLayout.SOUTH); HtmlPanel htmlPanel = new HtmlPanel(); HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext()); htmlPanel.setHtml(text, "", theRendererContext); jPanel3.add(jCheckBox1); jPanel3.add(jClose); final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT; jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD)); jClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { aFrame.dispose(); } }); jCheckBox1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected()); } }); aFrame.getContentPane().setLayout(new BorderLayout()); aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH); aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER); aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH); aFrame.setSize(new Dimension(456, 176)); Utility.setComponentRelativeLocation(this, aFrame); aFrame.setVisible(true); }
From source file:pl.otros.logview.gui.actions.ChekForNewVersionOnStartupAction.java
@Override protected void handleNewVersionIsAvailable(final String current, String running) { LOGGER.info(String.format("Running version is %s, current is %s", running, current)); DataConfiguration configuration = getOtrosApplication().getConfiguration(); String doNotNotifyThisVersion = configuration .getString(ConfKeys.VERSION_CHECK_SKIP_NOTIFICATION_FOR_VERSION, "2000-01-01"); if (current != null && doNotNotifyThisVersion.compareTo(current) > 0) { return;/* ww w.j a va 2 s .c om*/ } JPanel message = new JPanel(new GridLayout(4, 1, 4, 4)); message.add(new JLabel(String.format("New version %s is available", current))); JButton button = new JButton("Open download page"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop() .browse(new URI("https://sourceforge.net/projects/otroslogviewer/files/?source=app")); } catch (Exception e1) { String msg = "Can't open browser with download page: " + e1.getMessage(); LOGGER.severe(msg); getOtrosApplication().getStatusObserver().updateStatus(msg, StatusObserver.LEVEL_ERROR); } } }); message.add(button); final JCheckBox chboxDoNotNotifyMeAboutVersion = new JCheckBox("Do not notify me about version " + current); message.add(chboxDoNotNotifyMeAboutVersion); final JCheckBox chboxDoNotCheckVersionOnStart = new JCheckBox("Do not check for new version on startup"); message.add(chboxDoNotCheckVersionOnStart); final JDialog dialog = new JDialog((Frame) null, "New version is available"); dialog.getContentPane().setLayout(new BorderLayout(5, 5)); dialog.getContentPane().add(message); JPanel jp = new JPanel(new FlowLayout(FlowLayout.CENTER)); jp.add(new JButton(new AbstractAction("Ok") { /** * */ private static final long serialVersionUID = 7930093775785431184L; @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); if (chboxDoNotNotifyMeAboutVersion.isSelected()) { LOGGER.fine("Disabling new version notificiation for " + current); getOtrosApplication().getConfiguration() .setProperty(ConfKeys.VERSION_CHECK_SKIP_NOTIFICATION_FOR_VERSION, current); } if (chboxDoNotCheckVersionOnStart.isSelected()) { LOGGER.fine("Disabling new version check on start"); getOtrosApplication().getConfiguration().setProperty(ConfKeys.VERSION_CHECK_ON_STARTUP, false); } } })); dialog.getContentPane().add(jp, BorderLayout.SOUTH); dialog.pack(); dialog.setResizable(false); GuiUtils.centerOnScreen(dialog); dialog.setVisible(true); }
From source file:pl.otros.logview.gui.actions.ExitAction.java
protected void askAndExit() { final DataConfiguration configuration = getOtrosApplication().getConfiguration(); boolean doConfirm = configuration.getBoolean(ConfKeys.CONFIRM_QUIT, true); JPanel panel = new JPanel(new MigLayout("left")); panel.add(new JLabel("Do you want to exit OtrosLogViewer and parse logs with 'grep'?"), "growx, wrap"); getOtrosApplication().getConfiguration().getBoolean(ConfKeys.CONFIRM_QUIT, true); final JCheckBox box = new JCheckBox("Always ask before exit", doConfirm); box.addActionListener(e -> configuration.setProperty(ConfKeys.CONFIRM_QUIT, box.isSelected())); panel.add(box, "growx, wrap"); if (!doConfirm || JOptionPane.showConfirmDialog(frame, panel, "Are you sure?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { frame.setVisible(false);/*from w w w .j av a 2s .co m*/ frame.dispose(); System.exit(0); } }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private void initToolbar() { toolBar = new JToolBar(); final JComboBox searchMode = new JComboBox( new String[] { "String contains search: ", "Regex search: ", "Query search: " }); final SearchAction searchActionForward = new SearchAction(otrosApplication, SearchDirection.FORWARD); final SearchAction searchActionBackward = new SearchAction(otrosApplication, SearchDirection.REVERSE); searchFieldCbxModel = new DefaultComboBoxModel(); searchField = new JXComboBox(searchFieldCbxModel); searchField.setEditable(true);//w ww .j a v a2 s . c o m AutoCompleteDecorator.decorate(searchField); searchField.setMinimumSize(new Dimension(150, 10)); searchField.setPreferredSize(new Dimension(250, 10)); searchField.setToolTipText( "<HTML>Enter text to search.<BR/>" + "Enter - search next,<BR/>Alt+Enter search previous,<BR/>" + "Ctrl+Enter - mark all found</HTML>"); final DelayedSwingInvoke delayedSearchResultUpdate = new DelayedSwingInvoke() { @Override protected void performActionHook() { JTextComponent editorComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); int stringEnd = editorComponent.getSelectionStart(); if (stringEnd < 0) { stringEnd = editorComponent.getText().length(); } try { String selectedText = editorComponent.getText(0, stringEnd); if (StringUtils.isBlank(selectedText)) { return; } OtrosJTextWithRulerScrollPane<JTextPane> logDetailWithRulerScrollPane = otrosApplication .getSelectedLogViewPanel().getLogDetailWithRulerScrollPane(); MessageUpdateUtils.highlightSearchResult(logDetailWithRulerScrollPane, otrosApplication.getAllPluginables().getMessageColorizers()); RulerBarHelper.scrollToFirstMarker(logDetailWithRulerScrollPane); } catch (BadLocationException e) { LOGGER.log(Level.SEVERE, "Can't update search highlight", e); } } }; JTextComponent searchFieldTextComponent = (JTextComponent) searchField.getEditor().getEditorComponent(); searchFieldTextComponent.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { delayedSearchResultUpdate.performAction(); } }); final MarkAllFoundAction markAllFoundAction = new MarkAllFoundAction(otrosApplication); final SearchModeValidatorDocumentListener searchValidatorDocumentListener = new SearchModeValidatorDocumentListener( (JTextField) searchField.getEditor().getEditorComponent(), observer, SearchMode.STRING_CONTAINS); SearchMode searchModeFromConfig = configuration.get(SearchMode.class, "gui.searchMode", SearchMode.STRING_CONTAINS); final String lastSearchString; int selectedSearchMode = 0; if (searchModeFromConfig.equals(SearchMode.STRING_CONTAINS)) { selectedSearchMode = 0; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_STRING, ""); } else if (searchModeFromConfig.equals(SearchMode.REGEX)) { selectedSearchMode = 1; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_REGEX, ""); } else if (searchModeFromConfig.equals(SearchMode.QUERY)) { selectedSearchMode = 2; lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_QUERY, ""); } else { LOGGER.warning("Unknown search mode " + searchModeFromConfig); lastSearchString = ""; } Component editorComponent = searchField.getEditor().getEditorComponent(); if (editorComponent instanceof JTextField) { final JTextField sfTf = (JTextField) editorComponent; sfTf.getDocument().addDocumentListener(searchValidatorDocumentListener); sfTf.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() { @Override protected void documentChanged(DocumentEvent e) { try { int length = e.getDocument().getLength(); if (length > 0) { searchResultColorizer.setSearchString(e.getDocument().getText(0, length)); } } catch (BadLocationException e1) { LOGGER.log(Level.SEVERE, "Error: ", e1); } } }); sfTf.addKeyListener(new SearchFieldKeyListener(searchActionForward, sfTf)); sfTf.setText(lastSearchString); } searchMode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SearchMode mode = null; boolean validationEnabled = false; String confKey = null; String lastSearch = ((JTextField) searchField.getEditor().getEditorComponent()).getText(); if (searchMode.getSelectedIndex() == 0) { mode = SearchMode.STRING_CONTAINS; searchValidatorDocumentListener.setSearchMode(mode); validationEnabled = false; searchMode.setToolTipText("Checking if log message contains string (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_STRING; } else if (searchMode.getSelectedIndex() == 1) { mode = SearchMode.REGEX; validationEnabled = true; searchMode .setToolTipText("Checking if log message matches regular expression (case is ignored)"); confKey = ConfKeys.SEARCH_LAST_REGEX; } else if (searchMode.getSelectedIndex() == 2) { mode = SearchMode.QUERY; validationEnabled = true; String querySearchTooltip = "<HTML>" + // "Advance search using SQL-like quries (i.e. level>=warning && msg~=failed && thread==t1)<BR/>" + // "Valid operator for query search is ==, ~=, !=, LIKE, EXISTS, <, <=, >, >=, &&, ||, ! <BR/>" + // "See wiki for more info<BR/>" + // "</HTML>"; searchMode.setToolTipText(querySearchTooltip); confKey = ConfKeys.SEARCH_LAST_QUERY; } searchValidatorDocumentListener.setSearchMode(mode); searchValidatorDocumentListener.setEnable(validationEnabled); searchActionForward.setSearchMode(mode); searchActionBackward.setSearchMode(mode); markAllFoundAction.setSearchMode(mode); configuration.setProperty("gui.searchMode", mode); searchResultColorizer.setSearchMode(mode); List<Object> list = configuration.getList(confKey); searchFieldCbxModel.removeAllElements(); for (Object o : list) { searchFieldCbxModel.addElement(o); } searchField.setSelectedItem(lastSearch); } }); searchMode.setSelectedIndex(selectedSearchMode); final JCheckBox markFound = new JCheckBox("Mark search result"); markFound.setMnemonic(KeyEvent.VK_M); searchField.addKeyListener(markAllFoundAction); configuration.addConfigurationListener(markAllFoundAction); JButton markAllFoundButton = new JButton(markAllFoundAction); final JComboBox markColor = new JComboBox(MarkerColors.values()); markFound.setSelected(configuration.getBoolean("gui.markFound", true)); markFound.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { boolean selected = markFound.isSelected(); searchActionForward.setMarkFound(selected); searchActionBackward.setMarkFound(selected); configuration.setProperty("gui.markFound", markFound.isSelected()); } }); markColor.setRenderer(new MarkerColorsComboBoxRenderer()); // markColor.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); // searchActionForward.setMarkerColors(markerColors); // searchActionBackward.setMarkerColors(markerColors); // markAllFoundAction.setMarkerColors(markerColors); // configuration.setProperty("gui.markColor", markColor.getSelectedItem()); // otrosApplication.setSelectedMarkColors(markerColors); // } // }); markColor.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem(); searchActionForward.setMarkerColors(markerColors); searchActionBackward.setMarkerColors(markerColors); markAllFoundAction.setMarkerColors(markerColors); configuration.setProperty("gui.markColor", markColor.getSelectedItem()); otrosApplication.setSelectedMarkColors(markerColors); } }); markColor.getModel() .setSelectedItem(configuration.get(MarkerColors.class, "gui.markColor", MarkerColors.Aqua)); buttonSearch = new JButton(searchActionForward); buttonSearch.setMnemonic(KeyEvent.VK_N); JButton buttonSearchPrev = new JButton(searchActionBackward); buttonSearchPrev.setMnemonic(KeyEvent.VK_P); enableDisableComponetsForTabs.addComponet(buttonSearch); enableDisableComponetsForTabs.addComponet(buttonSearchPrev); enableDisableComponetsForTabs.addComponet(searchField); enableDisableComponetsForTabs.addComponet(markFound); enableDisableComponetsForTabs.addComponet(markAllFoundButton); enableDisableComponetsForTabs.addComponet(searchMode); enableDisableComponetsForTabs.addComponet(markColor); toolBar.add(searchMode); toolBar.add(searchField); toolBar.add(buttonSearch); toolBar.add(buttonSearchPrev); toolBar.add(markFound); toolBar.add(markAllFoundButton); toolBar.add(markColor); JButton nextMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.FORWARD)); nextMarked.setToolTipText(nextMarked.getText()); nextMarked.setText(""); nextMarked.setMnemonic(KeyEvent.VK_E); enableDisableComponetsForTabs.addComponet(nextMarked); toolBar.add(nextMarked); JButton prevMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.BACKWARD)); prevMarked.setToolTipText(prevMarked.getText()); prevMarked.setText(""); prevMarked.setMnemonic(KeyEvent.VK_R); enableDisableComponetsForTabs.addComponet(prevMarked); toolBar.add(prevMarked); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.SEVERE))); enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.INFO))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.WARNING))); enableDisableComponetsForTabs .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.SEVERE))); }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private void initExperimental() { JMenu menu = new JMenu("Experimental"); menu.add(new JLabel("Experimental features, can have bugs", Icons.LEVEL_WARNING, SwingConstants.LEADING)); menu.add(new JSeparator()); boolean storeOnDisk = StringUtils.equalsIgnoreCase(System.getProperty("cacheEvents"), "true"); JRadioButtonMenuItem radioButtonMemory = new JRadioButtonMenuItem("Memory - faster, more memory required", !storeOnDisk);// w w w . java2 s . c om radioButtonMemory.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.setProperty("cacheEvents", Boolean.FALSE.toString()); } }); JRadioButtonMenuItem radioButtonDisk = new JRadioButtonMenuItem( "Disk with caching - slower, less memory required", storeOnDisk); radioButtonDisk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.setProperty("cacheEvents", Boolean.TRUE.toString()); } }); final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(radioButtonDisk); buttonGroup.add(radioButtonMemory); menu.add(new JSeparator(JSeparator.VERTICAL)); menu.add(new JLabel("Keep parsed log events store:")); menu.add(radioButtonMemory); menu.add(radioButtonDisk); final JCheckBox soapFormatterRemoveMultirefsCbx = new JCheckBox(); soapFormatterRemoveMultirefsCbx .setSelected(configuration.getBoolean(ConfKeys.FORMATTER_SOAP_REMOVE_MULTIREFS, false)); AbstractAction enableMultiRefRemoveFeature = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { SoapMessageFormatter soapMessageFormatter = (SoapMessageFormatter) AllPluginables.getInstance() .getMessageFormatters().getElement(SoapMessageFormatter.class.getName()); soapMessageFormatter.setRemoveMultiRefs(soapFormatterRemoveMultirefsCbx.isSelected()); configuration.setProperty(ConfKeys.FORMATTER_SOAP_REMOVE_MULTIREFS, soapFormatterRemoveMultirefsCbx.isSelected()); } }; enableMultiRefRemoveFeature.putValue(Action.NAME, "Remove mulitRefs from SOAP messages"); soapFormatterRemoveMultirefsCbx.setAction(enableMultiRefRemoveFeature); enableMultiRefRemoveFeature.actionPerformed(null); final JCheckBox soapFormatterRemoveXsiForNilElementsCbx = new JCheckBox(); soapFormatterRemoveXsiForNilElementsCbx .setSelected(configuration.getBoolean(FORMATTER_SOAP_REMOVE_XSI_FOR_NIL, false)); AbstractAction soapFormatterRemoveXsiFromNilAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { SoapMessageFormatter soapMessageFormatter = (SoapMessageFormatter) AllPluginables.getInstance() .getMessageFormatters().getElement(SoapMessageFormatter.class.getName()); soapMessageFormatter .setRemoveXsiForNilElements(soapFormatterRemoveXsiForNilElementsCbx.isSelected()); configuration.setProperty(FORMATTER_SOAP_REMOVE_XSI_FOR_NIL, soapFormatterRemoveXsiForNilElementsCbx.isSelected()); } }; soapFormatterRemoveXsiFromNilAction.putValue(Action.NAME, "Remove xsi for for NIL elements from SOAP messages"); soapFormatterRemoveXsiForNilElementsCbx.setAction(soapFormatterRemoveXsiFromNilAction); soapFormatterRemoveXsiFromNilAction.actionPerformed(null); menu.add(soapFormatterRemoveMultirefsCbx); menu.add(soapFormatterRemoveXsiForNilElementsCbx); getJMenuBar().add(menu); QueryFilter queryFilter = new QueryFilter(); allPluginables.getLogFiltersContainer().addElement(queryFilter); JButton b = new JButton("Throw exception"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (System.currentTimeMillis() % 2 == 0) { throw new RuntimeException("Exception swing action!"); } else { new Thread(new Runnable() { @Override public void run() { throw new RuntimeException("Exception from tread!"); } }).start(); } } }); menu.add(b); }
From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java
@Override public void mouseClicked(MouseEvent event, final StateRenderer2D source) { if (event.getButton() == MouseEvent.BUTTON3) { final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType(); JPopupMenu popup = new JPopupMenu(); for (String type : positions.keySet()) { JMenu menu = new JMenu(type + "s"); for (final AssetPosition p : positions.get(type)) { if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection) continue; Color c = cmap.getColor(1 - (p.getAge() / (7200000.0))); String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue()); menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p) + "</font>").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { source.focusLocation(p.getLoc()); }/* www . j av a 2s . co m*/ }); } popup.add(menu); } popup.addSeparator(); popup.add("Settings").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PluginUtils.editPluginProperties(SituationAwareness.this, true); } }); popup.add("Fetch asset properties").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // for (AssetTrack track : assets.values()) { // track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))); // } fetchAssetProperties(); } }); popup.add("Select location sources").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); for (ILocationProvider l : localizers) { JCheckBox check = new JCheckBox(l.getName()); check.setSelected(true); p.add(check); check.setSelected(updateMethodNames.contains(l.getName())); } int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (op == JOptionPane.CANCEL_OPTION) return; Vector<String> methods = new Vector<String>(); for (int i = 0; i < p.getComponentCount(); i++) { if (p.getComponent(i) instanceof JCheckBox) { JCheckBox sel = (JCheckBox) p.getComponent(i); if (sel.isSelected()) methods.add(sel.getText()); } } updateMethods = StringUtils.join(methods, ", "); propertiesChanged(); } }); popup.add("Select hidden positions types").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); for (String type : positions.keySet()) { JCheckBox check = new JCheckBox(type); check.setSelected(true); p.add(check); check.setSelected(hiddenPosTypes.contains(type)); } int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (op == JOptionPane.CANCEL_OPTION) return; Vector<String> types = new Vector<String>(); for (int i = 0; i < p.getComponentCount(); i++) { if (p.getComponent(i) instanceof JCheckBox) { JCheckBox sel = (JCheckBox) p.getComponent(i); if (sel.isSelected()) types.add(sel.getText()); } } hiddenTypes = StringUtils.join(types, ", "); propertiesChanged(); } }); popup.addSeparator(); popup.add("Decision Support").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dialogDecisionSupport == null) { dialogDecisionSupport = new JDialog(getConsole()); dialogDecisionSupport.setModal(false); dialogDecisionSupport.setAlwaysOnTop(true); dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); } ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>(); LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType(); Vector<AssetPosition> spots = positions.get("SPOT Tag"); Vector<AssetPosition> argos = positions.get("Argos Tag"); if (spots != null) tags.addAll(spots); if (argos != null) tags.addAll(argos); if (!assets.containsKey(getConsole().getMainSystem())) { GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown"); return; } supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags); JXTable table = new JXTable(supportTable); dialogDecisionSupport.setContentPane(new JScrollPane(table)); dialogDecisionSupport.invalidate(); dialogDecisionSupport.validate(); dialogDecisionSupport.setSize(600, 300); dialogDecisionSupport.setTitle("Decision Support Table"); dialogDecisionSupport.setVisible(true); dialogDecisionSupport.toFront(); GuiUtils.centerOnScreen(dialogDecisionSupport); } }); popup.show(source, event.getX(), event.getY()); } super.mouseClicked(event, source); }
From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java
private void jButtonExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExportActionPerformed if (jTreeResults.getModel().getChildCount(jTreeResults.getModel().getRoot()) == 0) { JOptionPane.showMessageDialog(this, "You can't export information without search results.", "Lack of Search Results", JOptionPane.INFORMATION_MESSAGE); return;//from w ww.j av a2 s.co m } ExportData ed; HashMap<String, Boolean> plugins = new HashMap<String, Boolean>(); for (JCheckBox box : this.ranges) { plugins.put(box.getText(), box.isSelected()); } if (!lastQueryAdvanced) { ed = new ExportData(lastQueryExecuted, lastQueryKeywords, plugins); } else { ed = new ExportData(lastQueryExecuted, true, plugins); } ed.setVisible(true); ed.toFront(); }