List of usage examples for javax.swing SwingUtilities isEventDispatchThread
public static boolean isEventDispatchThread()
From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java
private void loadJobs() { if (SwingUtilities.isEventDispatchThread()) { logger.warn("BrowserPanel.loadJobs called from EDT"); }/*ww w .j a v a 2 s . c om*/ final List<Job> jobList; if (currentSelectedView instanceof FavoriteView) { jobList = requestManager.loadFavoriteJobs(jenkinsSettings.getFavoriteJobs()); } else { jobList = requestManager.loadJenkinsView(currentSelectedView); } jenkinsSettings.setLastSelectedView(currentSelectedView.getName()); jenkins.setJobs(jobList); }
From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java
private void watch() { if (!SwingUtilities.isEventDispatchThread()) { logger.warn("BrowserPanel.watch called from outside EDT"); }/*from w ww . j a va 2 s .c o m*/ if (!watchedJobs.isEmpty()) { for (final Map.Entry<String, Job> entry : watchedJobs.entrySet()) { final Job job = entry.getValue(); final Build lastBuild = job.getLastBuild(); new Task.Backgroundable(project, "Jenkins build watch", true, JenkinsLoadingTaskOption.INSTANCE) { private Build build; @Override public void onSuccess() { if (lastBuild.isBuilding() && !build.isBuilding()) { notifyInfoJenkinsToolWindow(String.format("Status of build for Changelist \"%s\" is %s", entry, build.getStatus().getStatus())); } job.setLastBuild(build); } @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); build = requestManager.loadBuild(lastBuild); } }.queue(); } } }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Selects the command mode, simpler than the program mode. It allows the * user to see immediately the effect of the typed commands. *///from w w w. j a va2s .co m public void setCommandMode() { // We check if we are not already in this mode. if (!commandMode) { if (programDividerLocation != null) { programDividerLocation[0] = jSplitPane1.getDividerLocation(); programDividerLocation[1] = jSplitPane2.getDividerLocation(); } Runnable commandModeRun = new Runnable() { @Override public void run() { graphicsPane.freeze(false); ((java.awt.CardLayout) modePanel.getLayout()).show(modePanel, "commandMode"); //$NON-NLS-1$ banner.setCommandMode(); commandPane.requestFocusInWindow(); commandMode = true; console.disableDragAndDrop(); if (popupManager != null) popupManager.closePopup(); if (commandDividerLocation != null) { jSplitPane1.setDividerLocation(commandDividerLocation[0]); // InvokeLater is required here, otherwise this second // setDividerLocation is ignored SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jSplitPane2.setDividerLocation(commandDividerLocation[1]); } }); } } }; if (SwingUtilities.isEventDispatchThread()) { commandModeRun.run(); } else { try { SwingUtilities.invokeAndWait(commandModeRun); } catch (InterruptedException e) { LOG.error(e); } catch (InvocationTargetException e) { LOG.error(e); } } } }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Selects program mode, more complex than the command mode. It allows the * user to insert commands from the history list. *//*from www . j av a 2 s. c om*/ public void setProgramMode() { // We check if we are not already in this mode. if (commandMode) { if (commandDividerLocation == null) { commandDividerLocation = new int[2]; } commandDividerLocation[0] = jSplitPane1.getDividerLocation(); commandDividerLocation[1] = jSplitPane2.getDividerLocation(); Runnable programModeRun = new Runnable() { @Override public void run() { graphicsPane.freeze(true); ((java.awt.CardLayout) modePanel.getLayout()).show(modePanel, "programMode"); //$NON-NLS-1$ banner.setProgramMode(); getProgramManager().requestFocus(); commandMode = false; console.enableDragAndDrop(); if (popupManager != null) popupManager.closePopup(); if (programDividerLocation != null) { jSplitPane1.setDividerLocation(programDividerLocation[0]); // InvokeLater is required here, otherwise this second // setDividerLocation is ignored SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jSplitPane2.setDividerLocation(programDividerLocation[1]); } }); } } }; if (SwingUtilities.isEventDispatchThread()) { programModeRun.run(); } else { try { SwingUtilities.invokeAndWait(programModeRun); } catch (InterruptedException e) { LOG.error(e); } catch (InvocationTargetException e) { LOG.error(e); } } } }
From source file:org.colombbus.tangara.update.UpdateCheckRunner.java
private static void runInEventDispatcherThread(Runnable displayer) { if (SwingUtilities.isEventDispatchThread()) { displayer.run();/* www. j a v a 2 s. co m*/ } else { SwingUtilities.invokeLater(displayer); } }
From source file:org.datavyu.controllers.component.MixerController.java
private static void runInEDT(final Runnable task) { if (SwingUtilities.isEventDispatchThread()) { task.run();/*from www . j a v a 2 s. c o m*/ } else { SwingUtilities.invokeLater(task); } }
From source file:org.datavyu.controllers.component.MixerController.java
private void updateZoomSlide(final ViewportState viewport) { assert SwingUtilities.isEventDispatchThread(); if (isUpdatingZoomSlide) { return;//w w w . j a v a 2 s.c o m } try { isUpdatingZoomSlide = true; zoomSlide.setValue((int) Math .round((viewport.getZoomLevel() * (zoomSlide.getMaximum() - zoomSlide.getMinimum() + 1)) + zoomSlide.getMinimum())); } finally { isUpdatingZoomSlide = false; } }
From source file:org.datavyu.controllers.component.MixerController.java
/** * Update scroll bar values./* w ww .j ava 2 s . co m*/ */ private void updateTracksScrollBar(final ViewportState viewport) { assert SwingUtilities.isEventDispatchThread(); if (isUpdatingTracksScrollBar) { return; } try { isUpdatingTracksScrollBar = true; final int startValue = (int) Math .round((double) viewport.getViewStart() * TRACKS_SCROLL_BAR_RANGE / viewport.getMaxEnd()); final int extentValue = (int) Math .round((double) (viewport.getViewDuration()) * TRACKS_SCROLL_BAR_RANGE / viewport.getMaxEnd()); tracksScrollBar.setValues(startValue, extentValue, 0, TRACKS_SCROLL_BAR_RANGE); tracksScrollBar.setUnitIncrement(extentValue / 20); tracksScrollBar.setBlockIncrement(extentValue / 2); tracksScrollBar.setVisible((viewport.getViewDuration()) < viewport.getMaxEnd()); } finally { isUpdatingTracksScrollBar = false; tracksPanel.validate(); } }
From source file:org.datavyu.controllers.component.TrackController.java
public void bindTrackActions(final CustomActions actions) { Runnable edtTask = new Runnable() { @Override/* w ww .j av a2 s .c om*/ public void run() { Map<String, String> constraints = Maps.newHashMap(); constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH)); constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT)); String template = "w ${width}!, h ${height}!"; StrSubstitutor sub = new StrSubstitutor(constraints); String cons = sub.replace(template); if (actions.getActionButton1() != null) { header.add(actions.getActionButton1(), cons + ", cell 2 2"); } if (actions.getActionButton2() != null) { header.add(actions.getActionButton2(), cons + ", cell 3 2"); } if (actions.getActionButton3() != null) { header.add(actions.getActionButton3(), cons + ", cell 4 2"); } header.validate(); } }; if (SwingUtilities.isEventDispatchThread()) { edtTask.run(); } else { SwingUtilities.invokeLater(edtTask); } }
From source file:org.eclipse.jubula.rc.swing.driver.EventThreadQueuerAwtImpl.java
/** {@inheritDoc} */ public Object invokeAndWait(String name, IRunnable runnable) throws StepExecutionException { Validate.notNull(runnable, "runnable must not be null"); //$NON-NLS-1$ RunnableWrapper wrapper = new RunnableWrapper(name, runnable); try {/*from w w w . j a v a2 s .com*/ if (SwingUtilities.isEventDispatchThread()) { wrapper.run(); } else { SwingUtilities.invokeAndWait(wrapper); } StepExecutionException exception = wrapper.getException(); if (exception != null) { throw new InvocationTargetException(exception); } } catch (InterruptedException ie) { // this (the waiting) thread was interrupted -> error log.error(ie); throw new StepExecutionException(ie); } catch (InvocationTargetException ite) { // the run() method from IRunnable has thrown an exception // -> log on info // -> throw a StepExecutionException Throwable thrown = ite.getTargetException(); if (thrown instanceof StepExecutionException) { if (log.isInfoEnabled()) { log.info(ite); } throw (StepExecutionException) thrown; } // any other (unchecked) Exception from IRunnable.run() log.error("exception thrown by '" + wrapper.getName() //$NON-NLS-1$ + "':", thrown); //$NON-NLS-1$ throw new StepExecutionException(thrown); } return wrapper.getResult(); }