List of usage examples for javax.swing WindowConstants DO_NOTHING_ON_CLOSE
int DO_NOTHING_ON_CLOSE
To view the source code for javax.swing WindowConstants DO_NOTHING_ON_CLOSE.
Click Source Link
From source file:org.nuclos.client.main.MainController.java
void init() throws CommonPermissionException, BackingStoreException { debugFrame = new SwingDebugFrame(this); try {//from w w w .j a va2s . c o m // force to load real permission (tp) SecurityCache.getInstance().revalidate(); cmdExecuteRport = createEntityAction(NuclosEntity.REPORTEXECUTION); /** @todo this is a workaround - because Main.getMainController() is called to get the user name */ Main.getInstance().setMainController(this); LOG.debug(">>> read user rights..."); loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_SECURITYCACHE); if (!getSecurityCache().isActionAllowed(Actions.ACTION_SYSTEMSTART)) { throw new CommonPermissionException(getSpringLocaleDelegate().getMessage("MainController.23", "Sie haben nicht das Recht, {0} zu benutzen.", ApplicationProperties.getInstance().getName())); } loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_ATTRIBUTES); // DefaultCollectableEntityProvider.setInstance(NuclosCollectableEntityProvider.getInstance()); Thread threadGenericObjectMetaDataCache = new Thread("MainController.readMetaData") { @Override public void run() { LOG.debug(">>> read metadata..."); // GenericObjectMetaDataCache.getInstance(); SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_LOMETA); Thread threadSearchFilterCache = new Thread("MainController.readSearchFilter") { @Override public void run() { LOG.debug(">>> read searchfilter..."); // SearchFilterCache.getInstance(); SpringApplicationContextHolder.getBean(SearchFilterCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_SEARCHFILTER); Thread threadRuleCache = new Thread("MainController.readRules") { @Override public void run() { LOG.debug(">>> read rules..."); // RuleCache.getInstance(); SpringApplicationContextHolder.getBean(RuleCache.class); } }; loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_RULES); List<Thread> lstCacheThreads = new ArrayList<Thread>(); lstCacheThreads.add(threadGenericObjectMetaDataCache); lstCacheThreads.add(threadSearchFilterCache); lstCacheThreads.add(threadRuleCache); threadGenericObjectMetaDataCache.start(); threadSearchFilterCache.start(); threadRuleCache.start(); for (Thread t : lstCacheThreads) { try { t.join(); } catch (InterruptedException e) { // do noting here LOG.warn("MainController: " + e); } } // !!! init messagelisteners here. // initialzing chaches in these threads will cause an deadlock situation at realSubscribe in TopicNotificationReceiver. // genericObjectMetaDataCache.initMessageListener(); // searchFilterCache.initMessageListener(); // ruleCache.initMessageListener(); SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class).initMessageListener(); SpringApplicationContextHolder.getBean(SearchFilterCache.class).initMessageListener(); SpringApplicationContextHolder.getBean(RuleCache.class).initMessageListener(); LOG.debug(">>> create mainframe..."); // this.frm = new MainFrame(this.getUserName(), this.getNuclosServerName()); setMainFrame(SpringApplicationContextHolder.getBean(MainFrameSpringComponent.class).getMainFrame()); final MainFrame frm = getMainFrame(); frm.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Attention: Do not use ListenerUtil here! (tp) frm.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent ev) { cmdWindowClosing(new ResultListener<Boolean>() { @Override public void done(Boolean result) { } }); } }); loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINFRAME); LOG.debug(">>> init client communication..."); this.notificationdlg = new NuclosNotificationDialog(frm); getTopicNotificationReceiver().subscribe(JMSConstants.TOPICNAME_RULENOTIFICATION, messagelistener); loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_NOTIFICATION); LOG.debug(">>> setup menus..."); this.setupMenus(); loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINMENU); LOG.debug(">>> create explorer controller..."); this.ctlExplorer = new ExplorerController(); LOG.debug(">>> create task controller..."); this.ctlTasks = new TaskController(getUserName()); this.ctlTasks.setExplorerController(ctlExplorer); this.ctlExplorer.setTaskController(ctlTasks); initActions(); LOG.debug(">>> restore last workspace..."); try { Main.getInstance().getMainFrame().readMainFramePreferences(prefs); getRestoreUtils().restoreWorkspaceThreaded(MainFrame.getLastWorkspaceIdFromPreferences(), MainFrame.getLastWorkspaceFromPreferences(), MainFrame.getLastAlwaysOpenWorkspaceIdFromPreferences(), MainFrame.getLastAlwaysOpenWorkspaceFromPreferences()); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4", "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden."); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } finally { loginController.increaseLoginProgressBar(StartUp.PROGRESS_RESTORE_WORKSPACE); } LOG.debug(">>> show mainFrame..."); frm.setVisible(true); try { LOG.debug(">>> restore last controllers (for migration only)..."); reopenAllControllers(ClientPreferences.getUserPreferences()); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4", "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden."); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } LOG.debug(">>> restore task views (for migration only)..."); try { ctlTasks.restoreGenericObjectTaskViewsFromPreferences(); } catch (Exception ex) { final String sMessage = getSpringLocaleDelegate().getMessage("tasklist.error.restore", "Die Aufgabenlisten konnten nicht wiederhergestellt werden."); LOG.error(sMessage, ex); Errors.getInstance().showExceptionDialog(null, sMessage, ex); } Thread theadTaskController = new Thread("MainController.refreshTasks") { @Override public void run() { LOG.debug(">>> refresh tasks..."); ctlTasks.run(); } }; theadTaskController.start(); /* Release note HACK: Caused by: java.lang.NullPointerException at org.nuclos.client.help.releasenotes.ReleaseNotesController.showNuclosReleaseNotesNotice(ReleaseNotesController.java:148) at org.nuclos.client.help.releasenotes.ReleaseNotesController.showReleaseNotesIfNewVersion(ReleaseNotesController.java:161) at org.nuclos.client.main.MainController.showReleaseNotesIfNewVersion(MainController.java:1752) at org.nuclos.client.main.MainController.<init>(MainController.java:382) */ while (getHomePane() == null) { Thread.sleep(200); } // Show the release notes for this version, if the user hasn't seen it yet. showReleaseNotesIfNewVersion(); // Debug purposes final String sKeyWindowShow = "CtlShiftF11"; frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_F11, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)), sKeyWindowShow); frm.getRootPane().getActionMap().put(sKeyWindowShow, new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { debugFrame.showComponentDetails(frm.findComponentAt(frm.getMousePosition())); } }); //Call wikipage final String sKeyWikiShow = "CtlShiftF1"; frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(KeyEvent.VK_F1, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)), sKeyWikiShow); frm.getRootPane().getActionMap().put(sKeyWikiShow, new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { Component fundComponent = frm.getFocusOwner() != null ? frm.getFocusOwner() : frm.findComponentAt(frm.getMousePosition()); CollectController<?> clctctrl = getControllerForTab(UIUtils.getTabForComponent(fundComponent)); WikiController wikiCtrl = WikiController.getInstance(); wikiCtrl.openURLinBrowser(wikiCtrl.getWikiPageForComponent(fundComponent, clctctrl)); } }); } catch (Throwable e) { LOG.fatal("Creating MainController failed, this is fatal: " + e.toString(), e); throw new ExceptionInInitializerError(e); } }
From source file:org.omegat.gui.align.AlignPanelController.java
/** * Display the align tool. The tool is not modal, so this call will return immediately. * //from ww w . ja va2 s .co m * @param parent * Parent window of the align tool */ public void show(Component parent) { frame = new AlignMenuFrame(); frame.setTitle(OStrings.getString("ALIGNER_PANEL")); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { closeFrame(frame); } }); panel = new AlignPanel(); ActionListener comparisonListener = e -> { ComparisonMode newValue = (ComparisonMode) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.comparisonMode && confirmReset(frame)) { aligner.comparisonMode = newValue; reloadBeads(); } else { panel.comparisonComboBox.setSelectedItem(aligner.comparisonMode); } }; panel.comparisonComboBox.addActionListener(comparisonListener); panel.comparisonComboBox.setRenderer(new EnumRenderer<ComparisonMode>("ALIGNER_ENUM_COMPARISON_MODE_")); ActionListener algorithmListener = e -> { AlgorithmClass newValue = (AlgorithmClass) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.algorithmClass && confirmReset(frame)) { aligner.algorithmClass = newValue; reloadBeads(); } else { panel.algorithmComboBox.setSelectedItem(aligner.algorithmClass); } }; panel.algorithmComboBox.addActionListener(algorithmListener); panel.algorithmComboBox.setRenderer(new EnumRenderer<AlgorithmClass>("ALIGNER_ENUM_ALGORITHM_CLASS_")); ActionListener calculatorListener = e -> { CalculatorType newValue = (CalculatorType) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.calculatorType && confirmReset(frame)) { aligner.calculatorType = newValue; reloadBeads(); } else { panel.calculatorComboBox.setSelectedItem(aligner.calculatorType); } }; panel.calculatorComboBox.addActionListener(calculatorListener); panel.calculatorComboBox.setRenderer(new EnumRenderer<CalculatorType>("ALIGNER_ENUM_CALCULATOR_TYPE_")); ActionListener counterListener = e -> { CounterType newValue = (CounterType) ((JComboBox<?>) e.getSource()).getSelectedItem(); if (newValue != aligner.counterType && confirmReset(frame)) { aligner.counterType = newValue; reloadBeads(); } else { panel.counterComboBox.setSelectedItem(aligner.counterType); } }; panel.counterComboBox.addActionListener(counterListener); panel.counterComboBox.setRenderer(new EnumRenderer<CounterType>("ALIGNER_ENUM_COUNTER_TYPE_")); ActionListener segmentingListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean newValue = ((AbstractButton) e.getSource()).isSelected(); if (newValue != aligner.segment && confirmReset(frame)) { aligner.segment = newValue; reloadBeads(); } else { panel.segmentingCheckBox.setSelected(aligner.segment); frame.segmentingItem.setSelected(aligner.segment); } } }; panel.segmentingCheckBox.addActionListener(segmentingListener); frame.segmentingItem.addActionListener(segmentingListener); ActionListener segmentingRulesListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { SegmentationCustomizer customizer = new SegmentationCustomizer(false, SRX.getDefault(), Core.getSegmenter().getSRX(), null); if (customizer.show(frame)) { customizedSRX = customizer.getResult(); Core.setSegmenter(new Segmenter(customizedSRX)); reloadBeads(); } } } }; panel.segmentingRulesButton.addActionListener(segmentingRulesListener); frame.segmentingRulesItem.addActionListener(segmentingRulesListener); ActionListener filterSettingsListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { FiltersCustomizer customizer = new FiltersCustomizer(false, FilterMaster.createDefaultFiltersConfig(), Core.getFilterMaster().getConfig(), null); if (customizer.show(frame)) { customizedFilters = customizer.getResult(); Core.setFilterMaster(new FilterMaster(customizedFilters)); aligner.clearLoaded(); reloadBeads(); } } } }; panel.fileFilterSettingsButton.addActionListener(filterSettingsListener); frame.fileFilterSettingsItem.addActionListener(filterSettingsListener); TableCellRenderer renderer = new MultilineCellRenderer(); panel.table.setDefaultRenderer(Object.class, renderer); panel.table.setDefaultRenderer(Boolean.class, renderer); panel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { resizeRows(panel.table); } }); ActionListener oneAdjustListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); boolean up = e.getSource().equals(panel.moveUpButton) || e.getSource().equals(frame.moveUpItem); BeadTableModel model = (BeadTableModel) panel.table.getModel(); if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { int trgRow = up ? model.prevBeadFromRow(rows[0]) : model.nextBeadFromRow(rows[rows.length - 1]); moveRows(rows, col, trgRow); } else { int offset = up ? -1 : 1; slideRows(rows, col, offset); } } }; panel.moveUpButton.addActionListener(oneAdjustListener); frame.moveUpItem.addActionListener(oneAdjustListener); panel.moveDownButton.addActionListener(oneAdjustListener); frame.moveDownItem.addActionListener(oneAdjustListener); ActionListener mergeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); BeadTableModel model = (BeadTableModel) panel.table.getModel(); if (rows.length == 1) { rows = new int[] { rows[0], model.nextNonEmptyCell(rows[0], col) }; } int beads = model.beadsInRowSpan(rows); if (beads < 1) { // Do nothing } else if (beads == 1) { mergeRows(rows, col); } else { moveRows(rows, col, rows[0]); } } }; panel.mergeButton.addActionListener(mergeListener); frame.mergeItem.addActionListener(mergeListener); ActionListener splitListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = panel.table.getSelectedRows(); int col = panel.table.getSelectedColumn(); BeadTableModel model = (BeadTableModel) panel.table.getModel(); int beads = model.beadsInRowSpan(rows); if (beads != 1) { // Do nothing } else if (rows.length == 1) { splitRow(rows[0], col); } else { splitBead(rows, col); } } }; panel.splitButton.addActionListener(splitListener); frame.splitItem.addActionListener(splitListener); ActionListener editListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = panel.table.getSelectedRow(); int col = panel.table.getSelectedColumn(); editRow(row, col); } }; panel.editButton.addActionListener(editListener); frame.editItem.addActionListener(editListener); ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateCommandAvailability(panel, frame); } }; panel.table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); panel.table.getSelectionModel().addListSelectionListener(selectionListener); ActionListener saveListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!confirmSaveTMX(panel)) { return; } while (true) { JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(new File(defaultSaveDir, getOutFileName())); chooser.setDialogTitle(OStrings.getString("ALIGNER_PANEL_DIALOG_SAVE")); if (JFileChooser.APPROVE_OPTION == chooser.showSaveDialog(frame)) { File file = chooser.getSelectedFile(); if (file.isFile()) { if (JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(frame, StringUtil.format(OStrings.getString("ALIGNER_PANEL_DIALOG_OVERWRITE"), file.getName()), OStrings.getString("ALIGNER_DIALOG_WARNING_TITLE"), JOptionPane.WARNING_MESSAGE)) { continue; } } List<MutableBead> beads = ((BeadTableModel) panel.table.getModel()).getData(); try { aligner.writePairsToTMX(file, MutableBead.beadsToEntries(aligner.srcLang, aligner.trgLang, beads)); modified = false; } catch (Exception ex) { Log.log(ex); JOptionPane.showMessageDialog(frame, OStrings.getString("ALIGNER_PANEL_SAVE_ERROR"), OStrings.getString("ERROR_TITLE"), JOptionPane.ERROR_MESSAGE); } } break; } } }; panel.saveButton.addActionListener(saveListener); frame.saveItem.addActionListener(saveListener); ActionListener resetListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (confirmReset(frame)) { if (phase == Phase.ALIGN) { aligner.restoreDefaults(); } reloadBeads(); } } }; panel.resetButton.addActionListener(resetListener); frame.resetItem.addActionListener(resetListener); ActionListener reloadListener = e -> { if (confirmReset(frame)) { aligner.clearLoaded(); reloadBeads(); } }; frame.reloadItem.addActionListener(reloadListener); ActionListener removeTagsListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean newValue = ((AbstractButton) e.getSource()).isSelected(); if (newValue != aligner.removeTags && confirmReset(frame)) { aligner.removeTags = newValue; aligner.clearLoaded(); reloadBeads(); } else { panel.removeTagsCheckBox.setSelected(aligner.removeTags); frame.removeTagsItem.setSelected(aligner.removeTags); } } }; panel.removeTagsCheckBox.addActionListener(removeTagsListener); frame.removeTagsItem.addActionListener(removeTagsListener); panel.continueButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { phase = Phase.EDIT; updatePanel(); } }); ActionListener highlightListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doHighlight = ((AbstractButton) e.getSource()).isSelected(); updateHighlight(); } }; panel.highlightCheckBox.addActionListener(highlightListener); frame.highlightItem.addActionListener(highlightListener); ActionListener highlightPatternListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PatternPanelController patternEditor = new PatternPanelController(highlightPattern); highlightPattern = patternEditor.show(frame); Preferences.setPreference(Preferences.ALIGNER_HIGHLIGHT_PATTERN, highlightPattern.pattern()); updateHighlight(); } }; panel.highlightPatternButton.addActionListener(highlightPatternListener); frame.highlightPatternItem.addActionListener(highlightPatternListener); frame.markAcceptedItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.ACCEPTED, panel.table.getSelectedRows()); } }); frame.markNeedsReviewItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.NEEDS_REVIEW, panel.table.getSelectedRows()); } }); frame.clearMarkItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setStatus(MutableBead.Status.DEFAULT, panel.table.getSelectedRows()); } }); frame.toggleSelectedItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleEnabled(panel.table.getSelectedRows()); } }); frame.closeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { closeFrame(frame); } }); frame.keepAllItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAllEnabled(true); } }); frame.keepNoneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAllEnabled(false); } }); frame.realignPendingItem.addActionListener(e -> { realignPending(); }); frame.pinpointAlignStartItem.addActionListener(e -> { phase = Phase.PINPOINT; ppRow = panel.table.getSelectedRow(); ppCol = panel.table.getSelectedColumn(); panel.table.clearSelection(); updatePanel(); }); frame.pinpointAlignEndItem.addActionListener(e -> { pinpointAlign(panel.table.getSelectedRow(), panel.table.getSelectedColumn()); }); frame.pinpointAlignCancelItem.addActionListener(e -> { phase = Phase.EDIT; ppRow = -1; ppCol = -1; panel.table.repaint(); updatePanel(); }); panel.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (phase == Phase.PINPOINT) { JTable table = (JTable) e.getSource(); int row = table.rowAtPoint(e.getPoint()); int col = table.columnAtPoint(e.getPoint()); pinpointAlign(row, col); } } }); frame.resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.SHIFT_DOWN_MASK)); frame.realignPendingItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); frame.saveItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); frame.closeItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // emacs-like keys for table navigation // See javax.swing.plaf.BasicTableUI.Actions for supported action names. setKeyboardShortcut(panel.table, "selectNextRow", 'n'); setKeyboardShortcut(panel.table, "selectNextRowExtendSelection", 'N'); setKeyboardShortcut(panel.table, "selectPreviousRow", 'p'); setKeyboardShortcut(panel.table, "selectPreviousRowExtendSelection", 'P'); setKeyboardShortcut(panel.table, "selectNextColumn", 'f'); setKeyboardShortcut(panel.table, "selectNextColumnExtendSelection", 'F'); setKeyboardShortcut(panel.table, "selectPreviousColumn", 'b'); setKeyboardShortcut(panel.table, "selectPreviousColumnExtendSelection", 'B'); panel.table.setTransferHandler(new AlignTransferHandler()); panel.table.addPropertyChangeListener("dropLocation", new DropLocationListener()); if (Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) { try { String fontName = Preferences.getPreference(Preferences.TF_SRC_FONT_NAME); int fontSize = Integer.parseInt(Preferences.getPreference(Preferences.TF_SRC_FONT_SIZE)); panel.table.setFont(new Font(fontName, Font.PLAIN, fontSize)); } catch (Exception e) { Log.log(e); } } // Set initial state updateHighlight(); updatePanel(); reloadBeads(); frame.add(panel); frame.pack(); frame.setMinimumSize(frame.getSize()); frame.setLocationRelativeTo(parent); frame.setVisible(true); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java
/** Attaches listener to the window listener. */ private void attachListeners() { if (UIUtilities.isMacOS() && model.isMaster()) { try {//w ww. j a va 2 s . c o m MacOSMenuHandler handler = new MacOSMenuHandler(view); handler.initialize(); view.addPropertyChangeListener(this); } catch (Throwable e) { } } view.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); view.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { model.close(); } }); JMenu menu = ImporterFactory.getWindowMenu(); menu.addMenuListener(new MenuListener() { public void menuSelected(MenuEvent e) { Object source = e.getSource(); if (source instanceof JMenu) createWindowsMenuItems((JMenu) source); } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuListener#menuCanceled(MenuEvent) */ public void menuCanceled(MenuEvent e) { } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuListener#menuDeselected(MenuEvent) */ public void menuDeselected(MenuEvent e) { } }); //Listen to keyboard selection menu.addMenuKeyListener(new MenuKeyListener() { public void menuKeyReleased(MenuKeyEvent e) { Object source = e.getSource(); if (source instanceof JMenu) createWindowsMenuItems((JMenu) source); } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuKeyListener#menuKeyPressed(MenuKeyEvent) */ public void menuKeyPressed(MenuKeyEvent e) { } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuKeyListener#menuKeyTyped(MenuKeyEvent) */ public void menuKeyTyped(MenuKeyEvent e) { } }); }
From source file:org.openmicroscopy.shoola.agents.imviewer.util.proj.ProjSavingDialog.java
/** * Initializes the components./*from w w w .j a v a 2 s. c om*/ * * @param imageName The name of the image. * @param type The type of projection. * @param maxZ The maximum number of z-sections. * @param startZ The lower bound of the z-section interval. * @param endZ The upper bound of the z-section interval. */ private void initComponents(String imageName, String type, int maxZ, int startZ, int endZ) { parentsBox = new JComboBox(); parentsBoxListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { DataNode node = (DataNode) parentsBox.getSelectedItem(); if (!node.isDefaultNode() && !node.getDataObject().canLink()) { selectedContainer = null; parentsBox.setSelectedIndex(0); } populateDatasetsBox(null); } } }; parentsBox.removeItemListener(parentsBoxListener); datasetsBox = new JComboBox(); datasetsBoxListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { DataNode node = (DataNode) datasetsBox.getSelectedItem(); if (node != null) { if (!node.isDefaultNode() && !node.getDataObject().canLink()) { //Determine the first dataset that be picked. datasetsBox.setSelectedIndex(0); node = (DataNode) datasetsBox.getSelectedItem(); selectedDataset = (DatasetData) node.getDataObject(); } else selectedDataset = (DatasetData) node.getDataObject(); } } } }; datasetsBox.removeItemListener(datasetsBoxListener); rndSettingsBox = new JCheckBox("Apply same rendering settings"); rndSettingsBox.setToolTipText( UIUtilities.formatToolTipText("Apply the rendering settings to " + "the projected image.")); rndSettingsBox.setSelected(true); zrangeSelection = new TextualTwoKnobsSlider(1, maxZ, startZ, endZ); zrangeSelection.layoutComponents(TextualTwoKnobsSlider.LAYOUT_FIELDS); timeSelection = new TextualTwoKnobsSlider(1, maxT, 1, maxT); timeSelection.layoutComponents(TextualTwoKnobsSlider.LAYOUT_FIELDS); timeSelection.setEnabled(maxT > 1); Map<String, String> map = EditorUtil.PIXELS_TYPE_DESCRIPTION; String[] data = new String[map.size()]; Set set = map.entrySet(); Entry entry; Iterator i = set.iterator(); int index = 0; //String originalType = type; String key; int selectedIndex = 0; while (i.hasNext()) { entry = (Entry) i.next(); key = (String) entry.getKey(); data[index] = (String) entry.getValue(); if (key.equals(type)) selectedIndex = index; index++; } pixelsType = new JComboBox(data); pixelsType.setSelectedIndex(selectedIndex); pixelsType.setEnabled(algorithm == ProjectionParam.SUM_INTENSITY); selectionPane = new JPanel(); selectionPane.setLayout(new BoxLayout(selectionPane, BoxLayout.Y_AXIS)); closeButton = new JButton("Cancel"); closeButton.setToolTipText(UIUtilities.formatToolTipText("Close the window.")); closeButton.setActionCommand("" + CLOSE); closeButton.addActionListener(this); projectButton = new JButton("Save"); projectButton.setToolTipText(UIUtilities.formatToolTipText("Project the image.")); projectButton.setActionCommand("" + PROJECT); projectButton.addActionListener(this); newFolderButton = new JButton("New Dataset..."); newFolderButton.setToolTipText(UIUtilities.formatToolTipText("Create a new Dataset.")); newFolderButton.setActionCommand("" + NEWFOLDER); newFolderButton.addActionListener(this); nameField = new JTextField(); StringBuffer buffer = new StringBuffer(); buffer.append(UIUtilities.removeFileExtension(imageName)); buffer.append(DEFAULT_EXTENSION); nameField.setText(buffer.toString()); nameField.getDocument().addDocumentListener(this); //Display datasets getRootPane().setDefaultButton(projectButton); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close(); } }); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java
/** * Attaches a window listener to the view to discard the model when * the user closes the window. /*from ww w . ja va2s . c om*/ */ private void attachListeners() { if (UIUtilities.isMacOS()) { try { MacOSMenuHandler handler = new MacOSMenuHandler(view); handler.initialize(); view.addPropertyChangeListener(this); } catch (Throwable e) { } } Map browsers = model.getBrowsers(); Iterator i = browsers.values().iterator(); Browser browser; while (i.hasNext()) { browser = (Browser) i.next(); browser.addPropertyChangeListener(this); browser.addChangeListener(this); } view.addWindowFocusListener(this); model.addPropertyChangeListener(this); view.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); view.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { model.closeWindow(); } }); // JMenu menu = TreeViewerFactory.getWindowMenu(); menu.addMenuListener(new MenuListener() { public void menuSelected(MenuEvent e) { Object source = e.getSource(); if (source instanceof JMenu) createWindowsMenuItems((JMenu) source); } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuListener#menuCanceled(MenuEvent) */ public void menuCanceled(MenuEvent e) { } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuListener#menuDeselected(MenuEvent) */ public void menuDeselected(MenuEvent e) { } }); //Listen to keyboard selection menu.addMenuKeyListener(new MenuKeyListener() { public void menuKeyReleased(MenuKeyEvent e) { Object source = e.getSource(); if (source instanceof JMenu) createWindowsMenuItems((JMenu) source); } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuKeyListener#menuKeyPressed(MenuKeyEvent) */ public void menuKeyPressed(MenuKeyEvent e) { } /** * Required by I/F but not actually needed in our case, * no-operation implementation. * @see MenuKeyListener#menuKeyTyped(MenuKeyEvent) */ public void menuKeyTyped(MenuKeyEvent e) { } }); }
From source file:org.openmicroscopy.shoola.util.ui.MessengerDialog.java
/** Initializes the various components. */ private void initComponents() { progress = new JXBusyLabel(new Dimension(16, 16)); progress.setVisible(false);//www . j a v a 2 s .c om progressLabel = new JLabel(); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close(); } }); cancelButton = new JButton("Cancel"); formatButton(cancelButton, 'C', CANCEL_TOOLTIP, CANCEL); sendButton = new JButton("Send"); formatButton(sendButton, 'S', SEND_TOOLTIP, SEND); emailArea = new JTextField(20); emailArea.setToolTipText(EMAIL_TOOLTIP); emailArea.setText(emailAddress); commentArea = new MultilineLabel(); commentArea.setEditable(true); commentArea.setBackground(UIUtilities.BACKGROUND_COLOR); commentArea.setOpaque(true); if (exception != null) { debugArea = buildExceptionArea(); copyButton = new JButton("Copy to Clipboard"); formatButton(copyButton, 'C', COPY_TOOLTIP, COPY); } //getRootPane().setDefaultButton(sendButton); setAlwaysOnTop(true); if (dialogType == COMMENT_TYPE) { sendButton.setEnabled(false); commentArea.getDocument().addDocumentListener(this); } submitStatus = new JXBusyLabel(new Dimension(16, 16)); submitStatus.setText("Uploading files"); submitStatus.setVisible(false); submitFile = new JCheckBox("Files"); submitFile.setSelected(true); submitFile.addActionListener(this); submitFile.setActionCommand("" + SUBMIT); }
From source file:org.parosproxy.paros.view.MainFrame.java
/** * This method initializes this/*from w w w . jav a 2 s. co m*/ */ private void initialize() { this.setJMenuBar(getMainMenuBar()); this.setContentPane(getPaneContent()); this.setPreferredSize(new Dimension(1000, 800)); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { getMainMenuBar().getMenuFileControl().exit(); } }); this.setVisible(false); }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.AbstractExportDialog.java
private void initialize() { defaultContext = new DefaultGuiContext(this, null); guiContext = defaultContext;/*from w ww .j a va2s . c o m*/ final ResourceBundle resources = ResourceBundle.getBundle(SwingCommonModule.BUNDLE_NAME); cancelAction = new CancelAction(resources); confirmAction = new ConfirmAction(resources); formValidator = new ExportDialogValidator(); setModal(true); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowCloseHandler()); messages = new Messages(defaultContext.getLocale(), SwingCommonModule.BUNDLE_NAME, ObjectUtilities.getClassLoader(SwingCommonModule.class)); parametersPanel = new ParameterReportControllerPane(); parametersLayoutPanel = new JPanel(new BorderLayout()); parametersLayoutPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); parametersLayoutPanel.add(parametersPanel, BorderLayout.NORTH); }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.csv.CSVDataExportPlugin.java
/** * Creates the report progress dialog used to monitor the export. * * @return the created dialog./*from ww w . jav a 2 s . c o m*/ */ protected ReportProgressDialog createProgressDialog() { final ReportProgressDialog progressDialog = super.createProgressDialog(); progressDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); progressDialog.setMessage(resources.getString("cvs-export.progressdialog.message")); //$NON-NLS-1$ progressDialog.pack(); LibSwingUtil.positionFrameRandomly(progressDialog); return progressDialog; }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.html.HtmlDirExportPlugin.java
/** * Creates the progress dialog that monitors the export process. * * @return the progress monitor dialog./*from w ww.j a v a2s . c om*/ */ protected ReportProgressDialog createProgressDialog() { final ReportProgressDialog progressDialog = super.createProgressDialog(); progressDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); progressDialog.setMessage(resources.getString("html-export.progressdialog.message")); //$NON-NLS-1$ progressDialog.pack(); LibSwingUtil.positionFrameRandomly(progressDialog); return progressDialog; }