List of usage examples for java.awt EventQueue isDispatchThread
public static boolean isDispatchThread()
From source file:org.kineticsystem.commons.data.model.swing.BasicList.java
/** * Notify all registered listeners with the given event. The event is fired * directly inside the AWT event-dispatching thread. * @param event The event containing information about changes occurred * inside the list.//from w w w . ja v a 2 s . c o m */ @Override public void fireContentsChanged(ActiveListEvent event) { if (EventQueue.isDispatchThread()) { /* * Flag the event as "0=last" for compatibility with GroupingProxy * and SortingProxy classes. */ event = (ActiveListEvent) event.clone(); event.setSequenceNumber(0); super.fireContentsChanged(event); } else { Launcher runner = new Launcher(event); try { EventQueue.invokeAndWait(runner); // Wait until completion. } catch (InterruptedException ex) { logger.warn(ex); } catch (InvocationTargetException ex) { logger.error(ex); } } }
From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java
/** * Reacts to property changes./*from w w w.j a v a 2s .co m*/ * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(final PropertyChangeEvent evt) { if (EventQueue.isDispatchThread()) { // only handle this event directly if we are in the EDT! handlePropertyChangedEvent(evt); } else { Runnable run = new Runnable() { @Override public void run() { handlePropertyChangedEvent(evt); } }; SwingUtilities.invokeLater(run); } }
From source file:org.parosproxy.paros.control.MenuFileControl.java
public boolean newSession(String fileName) { final Object[] created = { Boolean.TRUE }; waitMessageDialog = view/* ww w. j a v a 2 s . co m*/ .getWaitMessageDialog(Constant.messages.getString("menu.file.newSession.wait.dialogue")); control.newSession(fileName, new SessionListener() { @Override public void sessionSnapshot(Exception e) { } @Override public void sessionSaved(final Exception e) { if (EventQueue.isDispatchThread()) { if (e == null) { view.getSiteTreePanel().getTreeSite().setModel(model.getSession().getSiteTree()); } else { view.showWarningDialog(Constant.messages.getString("menu.file.newSession.error")); log.error("Error creating session file " + model.getSession().getFileName(), e); created[0] = Boolean.FALSE; } if (waitMessageDialog != null) { waitMessageDialog.setVisible(false); waitMessageDialog = null; } } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { sessionSaved(e); } }); } } @Override public void sessionOpened(File file, Exception e) { } }); waitMessageDialog.setVisible(true); return created[0] == Boolean.TRUE; }
From source file:org.parosproxy.paros.control.MenuFileControl.java
public boolean openSession(String session) { final Object[] opened = { Boolean.TRUE }; File sessionFile = new File(session); waitMessageDialog = view.getWaitMessageDialog(Constant.messages.getString("menu.file.loadSession")); log.info("opening session file " + sessionFile.getAbsolutePath()); control.openSession(sessionFile, new SessionListener() { @Override//from w w w. j a v a2 s . c o m public void sessionSnapshot(Exception e) { } @Override public void sessionSaved(Exception e) { } @Override public void sessionOpened(final File file, final Exception e) { if (EventQueue.isDispatchThread()) { if (e != null) { view.showWarningDialog(Constant.messages.getString("menu.file.openSession.error")); log.error("error opening session file " + model.getSession().getFileName(), e); opened[0] = Boolean.FALSE; } view.getSiteTreePanel().getTreeSite().setModel(model.getSession().getSiteTree()); if (waitMessageDialog != null) { waitMessageDialog.setVisible(false); waitMessageDialog = null; } } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { sessionOpened(file, e); } }); } } }); waitMessageDialog.setVisible(true); return opened[0] == Boolean.TRUE; }
From source file:org.parosproxy.paros.extension.ExtensionLoader.java
private void removeViewInEDT(final Extension extension, final ExtensionHook hook) { if (view == null) { return;//from w ww. jav a 2s .c o m } if (EventQueue.isDispatchThread()) { removeView(extension, view, hook); removeMenu(view, hook); } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { removeViewInEDT(extension, hook); } }); } }
From source file:org.parosproxy.paros.extension.history.ExtensionHistory.java
public void removeFromHistoryList(final HistoryReference href) { if (!View.isInitialised() || EventQueue.isDispatchThread()) { this.historyTableModel.removeEntry(href.getHistoryId()); historyIdToRef.remove(Integer.valueOf(href.getHistoryId())); } else {/*from w w w. j a v a 2s .c om*/ EventQueue.invokeLater(new Runnable() { @Override public void run() { removeFromHistoryList(href); } }); } }
From source file:org.parosproxy.paros.extension.history.ExtensionHistory.java
public void notifyHistoryItemChanged(final HistoryReference href) { if (!View.isInitialised() || EventQueue.isDispatchThread()) { this.historyTableModel.refreshEntryRow(href.getHistoryId()); } else {/*from w w w .ja v a2s .c om*/ EventQueue.invokeLater(new Runnable() { @Override public void run() { notifyHistoryItemChanged(href); } }); } }
From source file:org.parosproxy.paros.extension.history.ExtensionHistory.java
private void addHistoryInEventQueue(final HistoryReference ref) { if (!View.isInitialised() || EventQueue.isDispatchThread()) { historyTableModel.addHistoryReference(ref); } else {//from w ww . ja v a 2 s .co m try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { addHistoryInEventQueue(ref); } }); } catch (final Exception e) { logger.error(e.getMessage(), e); } } }
From source file:org.parosproxy.paros.extension.history.ExtensionHistory.java
@Override public void sessionAboutToChange(final Session session) { if (getView() == null || EventQueue.isDispatchThread()) { historyTableModel.clear();/*from w w w.jav a 2s.co m*/ historyIdToRef.clear(); if (getView() != null) { getView().getRequestPanel().clearView(true); getView().getResponsePanel().clearView(false); } } else { try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { sessionAboutToChange(session); } }); } catch (Exception e) { // ZAP: Added logging. logger.error(e.getMessage(), e); } } }
From source file:org.parosproxy.paros.extension.history.ManualRequestEditorDialog.java
private void addHistoryInEventQueue(final HistoryReference ref) { if (EventQueue.isDispatchThread()) { historyList.addElement(ref);//www . j a va2s .c om } else { try { EventQueue.invokeAndWait(new Runnable() { public void run() { historyList.addElement(ref); } }); } catch (Exception e) { } } }