List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:org.freeplane.core.resources.components.OptionPanel.java
/** * This method builds the preferences panel. * A list of IPropertyControl is iterated through and * if the IPropertyControl is an instance of TabProperty, * it creates a new "tab" that can be clicked to reveal the appropriate panel. * If the previous selected tab was saved on close, * the appropriate tab is reopened.//from www. j a v a 2s . c o m * * @param controlsTree This is the data that needs to be built */ public void buildPanel(final DefaultMutableTreeNode controlsTree) { final JPanel centralPanel = new JPanel(); centralPanel.setLayout(new GridLayout(1, 1)); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); FormLayout bottomLayout = null; DefaultFormBuilder bottomBuilder = null; initControls(controlsTree); final Iterator<IPropertyControl> iterator = controls.iterator(); int tabIndex = 0; while (iterator.hasNext()) { final IPropertyControl control = iterator.next(); if (control instanceof TabProperty) { final TabProperty newTab = (TabProperty) control; bottomLayout = new FormLayout(newTab.getName(), ""); bottomBuilder = new DefaultFormBuilder(bottomLayout); bottomBuilder.setDefaultDialogBorder(); final JScrollPane bottomComponent = new JScrollPane(bottomBuilder.getPanel()); UITools.setScrollbarIncrement(bottomComponent); final String tabName = TextUtils.getOptionalText(newTab.getLabel()); tabStringToIndexMap.put(tabName, tabIndex); tabIndexToStringMap.put(tabIndex, tabName); tabbedPane.addTab(tabName, bottomComponent); tabIndex++; } else { control.layout(bottomBuilder); } } tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent event) { final JTabbedPane c = (JTabbedPane) event.getSource(); selectedPanel = tabIndexToStringMap.get(c.getSelectedIndex()); } }); centralPanel.add(tabbedPane); if (selectedPanel != null && tabStringToIndexMap.containsKey(selectedPanel)) { // Without the containsKey call the loading of the tab "behaviour"/"behavior" gives a nullpointer exception tabbedPane.setSelectedIndex(tabStringToIndexMap.get(selectedPanel)); } topDialog.getContentPane().add(centralPanel, BorderLayout.CENTER); final JButton cancelButton = new JButton(); MenuBuilder.setLabelAndMnemonic(cancelButton, TextUtils.getRawText("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { closeWindow(); } }); final JButton okButton = new JButton(); MenuBuilder.setLabelAndMnemonic(okButton, TextUtils.getRawText("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (validate()) { closeWindow(); feedback.writeProperties(getOptionProperties()); } } }); topDialog.getRootPane().setDefaultButton(okButton); topDialog.getContentPane().add(ButtonBarFactory.buildOKCancelBar(cancelButton, okButton), BorderLayout.SOUTH); }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importFile(FileObject fileObject) { try {//www . java 2 s . c o m final FileImporter importer = controller.getFileImporter(FileUtil.toFile(fileObject)); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } //MRU MostRecentFiles mostRecentFiles = Lookup.getDefault().lookup(MostRecentFiles.class); mostRecentFiles.addFile(fileObject.getPath()); ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task fileObject = getArchivedFile(fileObject); final String containerSource = fileObject.getNameExt(); final InputStream stream = fileObject.getInputStream(); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(stream, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); if (fileObject.getPath().startsWith(System.getProperty("java.io.tmpdir"))) { try { fileObject.delete(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importStream(final InputStream stream, String importerName) { try {/* w ww .j a va 2 s . co m*/ final FileImporter importer = controller.getFileImporter(importerName); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.streamSource", importerName); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(stream, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importFile(final Reader reader, String importerName) { try {/*from ww w .jav a2 s . co m*/ final FileImporter importer = controller.getFileImporter(importerName); if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } ImporterUI ui = controller.getUI(importer); if (ui != null) { ui.setup(importer); String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (!result.equals(NotifyDescriptor.OK_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.streamSource", importerName); String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importFile(reader, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importDatabase(Database database, final DatabaseImporter importer) { try {/*w w w . j a v a 2s . c o m*/ if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.error_no_matching_db_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.database.ui.dialog.title"); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); if (database == null) { database = importer.getDatabase(); } } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String containerSource = database != null ? database.getName() : (ui != null ? ui.getDisplayName() : importer.getClass().getSimpleName()); final Database db = database; String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importDatabase(db, importer); if (container != null) { container.setSource(containerSource); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importSpigot(final SpigotImporter importer) { try {/*from w ww .j av a2 s . c o m*/ if (importer == null) { NotifyDescriptor.Message msg = new NotifyDescriptor.Message( NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.error_no_matching_db_importer"), NotifyDescriptor.WARNING_MESSAGE); DialogDisplayer.getDefault().notify(msg); return; } String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.spigotSource", ""); ImporterUI ui = controller.getUI(importer); if (ui != null) { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.spigot.ui.dialog.title", ui.getDisplayName()); JPanel panel = ui.getPanel(); ui.setup(importer); final DialogDescriptor dd = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); } Object result = DialogDisplayer.getDefault().notify(dd); if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) { ui.unsetup(false); return; } ui.unsetup(true); containerSource = ui.getDisplayName(); } ImporterWizardUI wizardUI = controller.getWizardUI(importer); if (wizardUI != null) { containerSource = wizardUI.getCategory() + ":" + wizardUI.getDisplayName(); } LongTask task = null; if (importer instanceof LongTask) { task = (LongTask) importer; } //Execute task final String source = containerSource; String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource); executor.execute(task, new Runnable() { @Override public void run() { try { Container container = controller.importSpigot(importer); if (container != null) { container.setSource(source); finishImport(container); } } catch (Exception ex) { throw new RuntimeException(ex); } } }, taskName, errorHandler); } catch (Exception ex) { Logger.getLogger("").log(Level.WARNING, "", ex); } }
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
private void finishImport(Container container) { if (container.verify()) { Report report = container.getReport(); //Report panel ReportPanel reportPanel = new ReportPanel(); reportPanel.setData(report, container); DialogDescriptor dd = new DialogDescriptor(reportPanel, NbBundle.getMessage(DesktopImportControllerUI.class, "ReportPanel.title")); if (!DialogDisplayer.getDefault().notify(dd).equals(NotifyDescriptor.OK_OPTION)) { reportPanel.destroy();/*from w w w . java2s. c om*/ return; } reportPanel.destroy(); final Processor processor = reportPanel.getProcessor(); //Project Workspace workspace = null; ProjectController pc = Lookup.getDefault().lookup(ProjectController.class); ProjectControllerUI pcui = Lookup.getDefault().lookup(ProjectControllerUI.class); if (pc.getCurrentProject() == null) { pcui.newProject(); workspace = pc.getCurrentWorkspace(); } //Process final ProcessorUI pui = getProcessorUI(processor); final ValidResult validResult = new ValidResult(); if (pui != null) { if (pui != null) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.processor.ui.dialog.title"); JPanel panel = pui.getPanel(); pui.setup(processor); final DialogDescriptor dd2 = new DialogDescriptor(panel, title); if (panel instanceof ValidationPanel) { ValidationPanel vp = (ValidationPanel) panel; vp.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { dd2.setValid(!((ValidationPanel) e.getSource()).isProblem()); } }); dd2.setValid(!vp.isProblem()); } Object result = DialogDisplayer.getDefault().notify(dd2); if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) { validResult.setResult(false); } else { pui.unsetup(); //true validResult.setResult(true); } } }); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); } catch (InvocationTargetException ex) { Exceptions.printStackTrace(ex); } } } if (validResult.isResult()) { controller.process(container, processor, workspace); //StatusLine notify String source = container.getSource(); if (source.isEmpty()) { source = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.status.importSuccess.default"); } StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.status.importSuccess", source)); } } else { System.err.println("Bad container"); } }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jContentPane//from w ww . j a v a 2 s . c om * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(); if (getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB, true)) { tabbedPane.addTab(Messages.getString("GTDFree.Overview"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_overview), getOverviewPane()); } inBasketPane = new InBasketPane(); //inBasketPane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Collect"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_collecting), inBasketPane); processPane = new ProcessPane(); //processPane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Process"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_processing), processPane); organizePane = new OrganizePane(); //organizePane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Organize"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_review), organizePane); executePane = new ExecutePane(); //executePane.setEngine(getEngine()); tabbedPane.addTab(Messages.getString("GTDFree.Execute") + " (" + getSummaryBean().getQueueCount() + ")", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_queue_execute), executePane); executeTabIndex = tabbedPane.getTabCount() - 1; getSummaryBean().addPropertyChangeListener("queueCount", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent evt) { tabbedPane.setTitleAt(executeTabIndex, Messages.getString("GTDFree.Execute") + " (" + getSummaryBean().getQueueCount() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }); if (Boolean.valueOf(getEngine().getConfiguration().getProperty("journal.enabled", "false"))) { //$NON-NLS-1$ //$NON-NLS-2$ journalPane = new JournalPane(); journalPane.setEngine(getEngine()); tabbedPane.addTab("Journal", //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_journaling), journalPane); } tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { enableQuickCollectPanel(); Component c = tabbedPane.getSelectedComponent(); if (c instanceof WorkflowPane && !((WorkflowPane) c).isInitialized()) { ((WorkflowPane) c).initialize(getEngine()); } if (c instanceof GTDFreePane) { getEngine().setActivePane((GTDFreePane) c); } else { getEngine().setActivePane(null); } } }); jContentPane.add(tabbedPane); quickCollectPanel = new QuickCollectPanel(); quickCollectPanel.setEngine(getEngine()); enableQuickCollectPanel(); jContentPane.add(quickCollectPanel, BorderLayout.SOUTH); } return jContentPane; }
From source file:org.jajuk.ui.views.SuggestionView.java
private void addTabChangeListener() { // Refresh tabs on demand only, add changeListerner after tab creation to // avoid the stored tab to be overwriten at startup tabs.addChangeListener(new ChangeListener() { @Override/*from w w w . j a va2s . c o m*/ public void stateChanged(ChangeEvent arg0) { refreshLastFMCollectionTabs(); // store the selected tab Conf.setProperty( getClass().getName() + "_" + ((getPerspective() == null) ? "solo" : getPerspective().getID()), Integer.toString(tabs.getSelectedIndex()).toString()); } }); }
From source file:org.jcurl.demo.zui.BroomPromptDemo.java
public static void main(final String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { final JFrame application = new JFrame(); application.setTitle("JCurl BroomPrompt"); application.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); final PCanvas pc = new PCanvas(); pc.setAnimatingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING); pc.setInteractingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING); // pc.getRoot().getDefaultInputManager().setKeyboardFocus( // new KeyboardZoom(pc.getCamera())); pc.setBackground(new Color(0xE8E8FF)); final PNode ice = new PIceFactory.Fancy().newInstance(); pc.getLayer().addChild(ice); application.getContentPane().add(pc); application.setSize(500, 800); application.setVisible(true); animateToBounds(pc.getCamera(), twelveP, 500); final BroomPromptSimple bp; ice.addChild(bp = new BroomPromptSimple()); final BroomPromptModel bpm; bp.setModel(bpm = new DefaultBroomPromptModel()); bpm.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { // FIXME why doesn't fire this? log.info(evt);//from w w w .java2 s .c o m } }); bpm.getSplitTimeMillis().addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { log.info(e); } }); bpm.setIdx16(1); bpm.setOutTurn(false); bp.animateToPositionScaleRotation(1, 2, 1, -0.1 * Math.PI, 5000); } }); }