List of usage examples for java.lang Runnable run
public abstract void run();
Runnable
is used to create a thread, starting the thread causes the object's run
method to be called in that separately executing thread. From source file:com.microsoft.tfs.client.common.ui.wit.form.WorkItemForm.java
/** * Initiate a background job that will query for the referenced fields of * all work item links contained within this work item. Completion of the * background job is indicated via a success or failure callback. *///from w w w . j av a 2 s. c o m public void updateWorkItemLinkTargetsColumns() { // Do nothing if all links have already been updated. final LinkCollectionImpl linkCollectionImpl = (LinkCollectionImpl) workItem.getLinks(); if (linkCollectionImpl.allDescriptionsComputed()) { return; } // Create the runnable which will be initiated by a background job. final Runnable runnable = linkCollectionImpl.getDescriptionUpdateRunnable( new WorkItemLinkDescriptionUpdateErrorCallback(), new WorkItemLinkDescriptionUpdateFinishedCallback(linkCollectionImpl)); // Create the background job. final Job job = new Job(Messages.getString("WorkItemForm.UpdateLinkJobTitle")) //$NON-NLS-1$ { @Override protected IStatus run(final IProgressMonitor monitor) { monitor.beginTask(Messages.getString("WorkItemForm.ProgressStatusText"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ try { runnable.run(); return Status.OK_STATUS; } finally { monitor.done(); } } }; // Start the background job. job.schedule(); }
From source file:com.googlecode.vfsjfilechooser2.plaf.basic.BasicVFSDirectoryModel.java
/** * Set the busy state for the model. The model is considered * busy when it is running a separate (interruptable) * thread in order to load the contents of a directory. *//*w ww .j a v a2 s. co m*/ private void setBusy(final boolean busy, int fid) { aLock.writeLock().lock(); try { if (fid == fetchID) { boolean oldValue = this.busy; this.busy = busy; if ((changeSupport != null) && (busy != oldValue)) { Runnable r = (new Runnable() { public void run() { firePropertyChange("busy", !busy, busy); } }); if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeLater(r); } } } } finally { aLock.writeLock().unlock(); } }
From source file:com.moss.greenshell.wizard.ProcessPanel.java
private void transitionStatic(final JPanel oldView, final JPanel newView, final Runnable followupAction) { try {/* w w w . ja va2 s . co m*/ Runnable action = new Runnable() { public void run() { synchronized (view.getActionArea()) { view.getActionArea().removeAll(); view.getActionArea().add(newView); view.getActionArea().invalidate(); view.validate(); if (followupAction != null) followupAction.run(); } } }; if (SwingUtilities.isEventDispatchThread()) { action.run(); } else { SwingUtilities.invokeAndWait(action); } } catch (Exception e) { failCatastrophically(e); } }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java
/** * Set the columns in the ReportQueryDialog.... * This is called from a none swing thread, hence all the invoke and * wait magic.// w w w . j av a 2s .c om * The message is only set if the query string matches the one the * error message is for. * * @param columns The list of columns to set. */ protected void setColumnsFromWorker(final List columns) { try { Runnable r = new Runnable() { public void run() { getReportQueryDialog().setColumns(columns); getReportQueryDialog().getQueryEditorPane().requestFocusInWindow(); } }; if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeAndWait(r); } } catch (Exception e) { // oh well we got interrupted. } }
From source file:de.jcup.egradle.eclipse.ide.IDEUtil.java
/** * Creates or recreates virtual project - this is done asynchronous. If * there exists already a virtual root project it will be deleted full * before the asynchronous creation process starts! * /*w ww .j a v a 2s .c o m*/ * @param postProcessing * - a runnable which will be executed after virtual root project * is (sucessfully) created, can be <code>null</code> * * @throws VirtualRootProjectException */ public static void createOrRecreateVirtualRootProject(Runnable postProcessing) throws VirtualRootProjectException { GradleRootProject rootProject = getRootProject(); if (rootProject == null) { return; } try { EclipseVirtualProjectPartCreator.deleteVirtualRootProjectFull(NULL_PROGESS); } catch (CoreException e1) { throw new VirtualRootProjectException("Was not able to delete former virtual root project", e1); } Job job = new Job("Virtual root project") { @Override protected IStatus run(IProgressMonitor monitor) { EclipseVirtualProjectPartCreator partCreator = new EclipseVirtualProjectPartCreator(rootProject, monitor); try { virtualProjectCreator.createOrUpdate(rootProject, partCreator); if (postProcessing != null) { postProcessing.run(); } return Status.OK_STATUS; } catch (VirtualRootProjectException e) { getDialogSupport().showError(e.getMessage()); logError("Was not able to update virtual root project", e); return Status.CANCEL_STATUS; } } }; job.schedule(1000L); // 1 second delay to give IDE the chance to delete // old parts }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java
/** * Set the columns error message in the ReportQueryDialog.... * This is called from a none swing thread, hence all the invoke and * wait magic./*w w w. j a v a2 s . co m*/ * The message is only set if the query string matches the one the * error message is for. * * @param columns The list of columns to set. */ protected void setColumnErrorFromWork(final String error_msg) { try { Runnable r = new Runnable() { public void run() { getReportQueryDialog().setColumnsError(error_msg); getReportQueryDialog().getQueryEditorPane().requestFocusInWindow(); } }; if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeAndWait(r); } } catch (Exception e) { // oh well we got interrupted. } }
From source file:jetbrains.exodus.env.EnvironmentImpl.java
MetaTree getMetaTree(@Nullable final Runnable beginHook) { synchronized (metaLock) { if (beginHook != null) { beginHook.run(); }/* w w w . java2 s . c o m*/ return metaTree; } }
From source file:com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.java
protected void internalAddItem(T item, Runnable addToData) { checkNotNullArgument(item, "item is null"); backgroundWorker.checkUIAccess();/*w w w.j ava 2 s.c o m*/ checkStateBeforeAdd(); addToData.run(); attachListener(item); modified(item); fireCollectionChanged(Operation.ADD, Collections.singletonList(item)); }
From source file:com.evothings.BLE.java
private void checkPowerState(BluetoothAdapter adapter, CallbackContext cc, Runnable onPowerOn) { if (adapter == null) { return;//from w ww . j a va 2 s . com } if (adapter.getState() == BluetoothAdapter.STATE_ON) { // Bluetooth is ON onPowerOn.run(); } else { mOnPowerOn = onPowerOn; mPowerOnCallbackContext = cc; Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); cordova.startActivityForResult(this, enableBtIntent, 0); } }