List of usage examples for javax.swing.event ChangeEvent getSource
public Object getSource()
From source file:org.gephi.desktop.importer.DesktopImportControllerUI.java
@Override public void importDatabase(Database database, final DatabaseImporter importer) { try {/*from w ww. j av a 2 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; } 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 w w. j ava2 s . co 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 . j a va 2s . com 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.jcurl.core.impl.CurveManager.java
/** One of the initial rocks changed either pos or vel */ public void stateChanged(final ChangeEvent arg0) { final Object src = arg0 == null ? null : arg0.getSource(); if (src == null || src == initialPos || src == initialSpeed) ;// recompute(currentTime, true); else if (initialPos.findI16(src) >= 0) { log.debug("Startpos rock change"); if (getSuspended()) collected |= 1 << initialPos.findI16(src); else/* w w w . j a v a 2 s .com*/ recompute(currentTime, true); } else if (initialSpeed.findI16(src) >= 0) { log.debug("Startvel rock change"); if (getSuspended()) collected |= 1 << initialSpeed.findI16(src); else recompute(currentTime, true); } else log.info(arg0); }
From source file:org.jcurl.core.swing.SumDisplayBase.java
public void stateChanged(final ChangeEvent evt) { final Object tmp = evt.getSource(); if (tmp == null || RockSetUtils.class.isAssignableFrom(tmp.getClass())) this.setPos((RockSet<Pos>) tmp); else//from w ww.j a v a 2 s. c o m log.info(tmp); }
From source file:org.jcurl.core.ui.TrajectoryBroomPromptWrapper.java
public void stateChanged(final ChangeEvent evt) { if (evt.getSource() == getSplitTimeMillis()) updateVelocities();//from w ww. ja va2 s. c om else log.warn("Unprocessed event " + evt); }
From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java
public void stateChanged(final ChangeEvent e) { if (log.isDebugEnabled()) log.debug(e.getSource()); if (e.getSource() == x) { final double nx = x.getValue(); if (broom.getBroom().getX() != nx) getChanger().temporary(new XYMemento(broom, nx, broom.getBroom().getY())); } else if (e.getSource() == y) { final double ny = y.getValue(); if (broom.getBroom().getY() != ny) getChanger().temporary(new XYMemento(broom, broom.getBroom().getX(), ny)); } else/*from ww w . java 2s. c om*/ log.warn("Unprocessed event from " + e.getSource()); }
From source file:org.jcurl.demo.tactics.CurlerSwingBean.java
public void stateChanged(final ChangeEvent e) { log.warn("Unconsumed event from " + e.getSource()); }
From source file:org.jcurl.demo.tactics.sg.BroomPromptScenario.java
public void stateChanged(final ChangeEvent e) { if (e.getSource() instanceof BoundedRangeModel) syncSpeedM2V((BoundedRangeModel) e.getSource()); else/* w w w .j av a 2s. c om*/ log.warn("Unconsumed event from " + e.getSource()); }
From source file:org.jcurl.demo.tactics.TrajectoryScenarioBean.java
public void stateChanged(final ChangeEvent e) { if (e.getSource() instanceof Rock) { // update the rock position, be it initial or current final Rock<Pos> r = (Rock<Pos>) e.getSource(); final Affine n = r2n.get(r); syncM2V(r, n);// www . j ava2 s . c o m // update the trajectory path, current only. if (!Boolean.TRUE.equals(n.getAttribute(ATTR_TRIGGER_CURVE_UPDATE))) return; final int i16 = (Integer) n.getAttribute(ATTR_IDX16); syncM2V(getCurves(), i16, path, tf); } else if (log.isDebugEnabled()) log.debug("Unconsumed event from " + e.getSource()); }