Java 类org.eclipse.ui.progress.UIJob 实例源码

项目:tlaplus    文件:NewSpecHandler.java   
/**
 * Opens the editor for the given spec (needs access to the UI thus has to
 * run as a UI job)
 */
private void openEditorInUIThread(final Spec spec) {
    // with parsing done, we are ready to open the spec editor
    final UIJob uiJob = new UIJob("NewSpecWizardEditorOpener") {
        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            // create parameters for the handler
            final HashMap<String, String> parameters = new HashMap<String, String>();
            parameters.put(OpenSpecHandler.PARAM_SPEC, spec.getName());

            // runs the command
            UIHelper.runCommand(OpenSpecHandler.COMMAND_ID, parameters);
            return Status.OK_STATUS;
        }
    };
    uiJob.schedule();
}
项目:cft    文件:ServiceToApplicationsBindingAction.java   
@Override
public void run() {
    UIJob uiJob = new UIJob(Messages.MANAGE_SERVICES_TO_APPLICATIONS_TITLE) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                if (serverBehaviour != null) {
                    ServiceToApplicationsBindingWizard wizard = new ServiceToApplicationsBindingWizard(
                            servicesHandler, serverBehaviour.getCloudFoundryServer(), editorPage);
                    WizardDialog dialog = new WizardDialog(editorPage.getSite().getShell(), wizard);
                    dialog.open();
                }
            }
            catch (CoreException e) {
                if (Logger.ERROR) {
                    Logger.println(Logger.ERROR_LEVEL, this, "runInUIThread", "Error launching wizard", e); //$NON-NLS-1$ //$NON-NLS-2$
                }
            }

            return Status.OK_STATUS;
        }

    };
    uiJob.setSystem(true);
    uiJob.setPriority(Job.INTERACTIVE);
    uiJob.schedule();
}
项目:cft    文件:CloneServerPage.java   
@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (visible) {
        // Launch it as a job, to give the wizard time to display
        // the spaces viewer
        UIJob job = new UIJob(Messages.CloneServerPage_JOB_REFRESH_ORG_SPACE) {

            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                updateSpacesDescriptor();
                refreshListOfSpaces();

                return Status.OK_STATUS;
            }

        };
        job.setSystem(true);
        job.schedule();
    }
}
项目:ForgedUI-Eclipse    文件:GenerateCodeActionDelegate.java   
protected void processFile(IFile file) {

        if (file != null
                && file.getFileExtension().equalsIgnoreCase(
                        GUIEditorPlugin.FORGED_UI_EXTENSION)) {

            if (GUIEditorPlugin.getDefault().getWorkbench()
                    .saveAllEditors(true)) {
                // Do the start of the job here.
                Shell shell = PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getShell();
                IProgressService progressService = PlatformUI.getWorkbench()
                        .getProgressService();
                CodeGenJob job = new CodeGenJob(file);
                UIJob runJob = new EditorUIJob(job);
                progressService.showInDialog(shell, runJob);
                // runJob.setRule(ISchedulingRule);
                runJob.schedule();

            }
        }

    }
项目:statecharts    文件:ExampleDropSupportRegistrar.java   
private void registerExampleDropAdapter() {
    UIJob registerJob = new UIJob(Display.getDefault(), "Registering example drop adapter.") {
        {
            setPriority(Job.SHORT);
            setSystem(true);
        }

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            workbench.addWindowListener(workbenchListener);
            IWorkbenchWindow[] workbenchWindows = workbench
                    .getWorkbenchWindows();
            for (IWorkbenchWindow window : workbenchWindows) {
                workbenchListener.hookWindow(window);
            }
            return Status.OK_STATUS;
        }

    };
    registerJob.schedule();
}
项目:statecharts    文件:SCTPerspectiveManager.java   
protected void schedulePerspectiveSwitchJob(final String perspectiveID) {
    Job switchJob = new UIJob(DebugUIPlugin.getStandardDisplay(), "Perspective Switch Job") { //$NON-NLS-1$
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
            if (window != null && !(isCurrentPerspective(window, perspectiveID))) {
                switchToPerspective(window, perspectiveID);
            }
            // Force the debug view to open
            if (window != null) {
                try {
                    window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SIMULATION_VIEW_ID);
                } catch (PartInitException e) {
                    e.printStackTrace();
                }
            }
            return Status.OK_STATUS;
        }
    };
    switchJob.setSystem(true);
    switchJob.setPriority(Job.INTERACTIVE);
    switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this));
    switchJob.schedule();
}
项目:dockerfoundry    文件:ServiceToApplicationsBindingAction.java   
@Override
public void run() {
    UIJob uiJob = new UIJob(Messages.MANAGE_SERVICES_TO_APPLICATIONS_TITLE) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                if (serverBehaviour != null) {
                    ServiceToApplicationsBindingWizard wizard = new ServiceToApplicationsBindingWizard(
                            servicesHandler, serverBehaviour.getCloudFoundryServer(), editorPage);
                    WizardDialog dialog = new WizardDialog(editorPage.getSite().getShell(), wizard);
                    dialog.open();
                }
            }
            catch (CoreException e) {
                if (Logger.ERROR) {
                    Logger.println(Logger.ERROR_LEVEL, this, "runInUIThread", "Error launching wizard", e); //$NON-NLS-1$ //$NON-NLS-2$
                }
            }

            return Status.OK_STATUS;
        }

    };
    uiJob.setSystem(true);
    uiJob.setPriority(Job.INTERACTIVE);
    uiJob.schedule();
}
项目:dockerfoundry    文件:DockerFoundryUiCallback.java   
@Override
public void handleError(final IStatus status) {

    if (status != null && status.getSeverity() == IStatus.ERROR) {

        UIJob job = new UIJob(Messages.DockerFoundryUiCallback_JOB_CF_ERROR) {
            public IStatus runInUIThread(IProgressMonitor monitor) {
                Shell shell = CloudUiUtil.getShell();
                if (shell != null) {
                    new MessageDialog(shell, Messages.DockerFoundryUiCallback_ERROR_CALLBACK_TITLE, null,
                            status.getMessage(), MessageDialog.ERROR, new String[] { Messages.COMMONTXT_OK }, 0)
                            .open();
                }
                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule();

    }
}
项目:gama    文件:EditorToolbar.java   
private void hookToCommands(final ToolItem lastEdit, final ToolItem nextEdit) {
    final UIJob job = new UIJob("Hooking to commands") {

        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            final ICommandService service = WorkbenchHelper.getService(ICommandService.class);
            final Command nextCommand = service.getCommand(IWorkbenchCommandConstants.NAVIGATE_FORWARD_HISTORY);
            nextEdit.setEnabled(nextCommand.isEnabled());
            final ICommandListener nextListener = e -> nextEdit.setEnabled(nextCommand.isEnabled());

            nextCommand.addCommandListener(nextListener);
            final Command lastCommand = service.getCommand(IWorkbenchCommandConstants.NAVIGATE_BACKWARD_HISTORY);
            final ICommandListener lastListener = e -> lastEdit.setEnabled(lastCommand.isEnabled());
            lastEdit.setEnabled(lastCommand.isEnabled());
            lastCommand.addCommandListener(lastListener);
            // Attaching dispose listeners to the toolItems so that they remove the
            // command listeners properly
            lastEdit.addDisposeListener(e -> lastCommand.removeCommandListener(lastListener));
            nextEdit.addDisposeListener(e -> nextCommand.removeCommandListener(nextListener));
            return Status.OK_STATUS;
        }
    };
    job.schedule();

}
项目:APICloud-Studio    文件:OpenThemePreferencesHandler.java   
public Object execute(ExecutionEvent event) throws ExecutionException
{
    UIJob job = new UIJob("Open Theme Preferences") //$NON-NLS-1$
    {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor)
        {
            final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(UIUtils.getActiveShell(),
                    ThemePreferencePage.ID, null, null);
            dialog.open();
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.setRule(PopupSchedulingRule.INSTANCE);
    job.schedule();
    return null;
}
项目:google-cloud-eclipse    文件:LocalAppEngineConsole.java   
/**
 * Update the shown name with the server stop/stopping state.
 */
private void updateName(int serverState) {
  final String computedName;
  if (serverState == IServer.STATE_STARTING) {
    computedName = Messages.getString("SERVER_STARTING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPING) {
    computedName = Messages.getString("SERVER_STOPPING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPED) {
    computedName = Messages.getString("SERVER_STOPPED_TEMPLATE", unprefixedName);
  } else {
    computedName = unprefixedName;
  }
  UIJob nameUpdateJob = new UIJob("Update server name") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      LocalAppEngineConsole.this.setName(computedName);
      return Status.OK_STATUS;
    }
  };
  nameUpdateJob.setSystem(true);
  nameUpdateJob.schedule();
}
项目:angular-eclipse    文件:NgBuildCommandInterpreter.java   
@Override
public void execute(String newWorkingDir) {
    IContainer container = WorkbenchResourceUtil.findContainerFromWorkspace(getWorkingDir());
    if (container != null) {
        IProject project = container.getProject();
        new UIJob(AngularCLIMessages.NgBuildCommandInterpreter_jobName) {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                try {
                    AngularCLIJson cliJson = AngularCLIProject.getAngularCLIProject(project).getAngularCLIJson();
                    IFolder distFolder = project.getFolder(cliJson.getOutDir());
                    distFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
                    if (distFolder.exists()) {
                        // Select dist folder in the Project Explorer.
                        UIInterpreterHelper.selectRevealInDefaultViews(distFolder);
                    }
                } catch (CoreException e) {
                    return new Status(IStatus.ERROR, AngularCLIPlugin.PLUGIN_ID,
                            AngularCLIMessages.NgBuildCommandInterpreter_error, e);
                }
                return Status.OK_STATUS;
            }
        }.schedule();
    }
}
项目:dsl-devkit    文件:BugAig931Test.java   
/**
 * Tests bug https://jira.int.sys.net/browse/AIG-931.
 * 
 * @throws Exception
 *           the exception
 */
@Test
public void testBugAig931() throws Exception {
  final String partialModel = "package p catalog T for grammar com.avaloq.tools.ddk.check.Check { error \"X\" for ";
  final String[] expectedContextTypeProposals = {"EObject - org.eclipse.emf.ecore", "JvmType - org.eclipse.xtext.common.types"};
  new UIJob("compute completion proposals") {
    @SuppressWarnings("restriction")
    @Override
    public IStatus runInUIThread(final IProgressMonitor monitor) {
      try {
        completionsExist(newBuilder().append(partialModel).computeCompletionProposals(), expectedContextTypeProposals);
        // CHECKSTYLE:OFF
      } catch (Exception e) {
        // CHECKSTYLE:ON
        return new Status(Status.ERROR, "com.avaloq.tools.ddk.check.ui.test", 1, e.getMessage(), e);
      }
      return Status.OK_STATUS;
    }
  };
}
项目:cft    文件:CloneServerCommand.java   
public void doRun(final CloudFoundryServer cloudServer) {
    final Shell shell = activePart != null && activePart.getSite() != null ? activePart.getSite().getShell()
            : CFUiUtil.getShell();

    if (shell != null) {
        UIJob job = new UIJob(getJobName()) {

            public IStatus runInUIThread(IProgressMonitor monitor) {
                OrgsAndSpacesWizard wizard = new OrgsAndSpacesWizard(cloudServer);
                WizardDialog dialog = new WizardDialog(shell, wizard);
                dialog.open();

                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule();
    }
    else {
        CloudFoundryPlugin.logError("Unable to find an active shell to open the orgs and spaces wizard."); //$NON-NLS-1$
    }

}
项目:APICloud-Studio    文件:TempleteFrameWizard.java   
@Override
public boolean performFinish()
  {
    final String targetPath = this.page.getSourcePath();
    final String fileName = this.page.getPagePath();
    pageName = this.page.getPageName();
    Job menuJob = new UIJob("")
    {
        public IStatus runInUIThread(IProgressMonitor monitor)
        {
            try {
                doFinish(targetPath, fileName, monitor);
            } catch (CoreException e) {
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }
    };
    menuJob.schedule(300L);
    return true;
  }
项目:APICloud-Studio    文件:UIUtils.java   
private static void showErrorMessage(final String title, final String message, final Throwable exception)
{
    if (Display.getCurrent() == null || exception != null)
    {
        UIJob job = new UIJob(message)
        {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor)
            {
                if (exception == null)
                {
                    showErrorDialog(title, message);
                    return Status.OK_STATUS;
                }
                return new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID, null, exception);
            }
        };
        job.setPriority(Job.INTERACTIVE);
        job.setUser(true);
        job.schedule();
    }
    else
    {
        showErrorDialog(title, message);
    }
}
项目:APICloud-Studio    文件:PerspectiveChangeResetListener.java   
private void resetPerspective(final IWorkbenchPage page)
{
    UIJob job = new UIJob("Resetting Studio perspective...") //$NON-NLS-1$
    {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor)
        {
            if (MessageDialog.openQuestion(UIUtils.getActiveShell(),
                    com.aptana.ui.Messages.UIPlugin_ResetPerspective_Title,
                    com.aptana.ui.Messages.UIPlugin_ResetPerspective_Description))
            {
                page.resetPerspective();
            }
            return Status.OK_STATUS;
        }
    };
    EclipseUtil.setSystemForJob(job);
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
项目:mytourbook    文件:ImageGallery.java   
private void jobUIFilter_10_Create() {

        _jobUIFilter = new UIJob("PicDirImages: Update UI with filtered gallery images") { //$NON-NLS-1$

            @Override
            public IStatus runInUIThread(final IProgressMonitor monitor) {

                _jobUIFilterJobIsScheduled.set(false);

                try {
                    jobUIFilter_30_Run();
                } catch (final Exception e) {
                    StatusUtil.log(e);
                }

                return Status.OK_STATUS;
            }
        };

        _jobUIFilter.setSystem(true);
    }
项目:Beagle    文件:AbortQuestion.java   
/**
 * Shows a dialog to the user, asking whether the analysis should really be aborted.
 * Blocks the caller.
 *
 * @return {@code true} if the analysis should be aborted.
 */
public boolean ask() {
    final AbortConfirmJob askJob = new AbortConfirmJob();
    this.askingThread = Thread.currentThread();
    askJob.schedule();
    try {
        askJob.join();
    } catch (final InterruptedException interrupted) {
        new UIJob(Display.getDefault(), "Close question dialog") {

            @Override
            public IStatus runInUIThread(final IProgressMonitor monitor) {
                AbortQuestion.this.questionDialog.close();
                return Status.OK_STATUS;
            }
        }.schedule();

        return false;
    } finally {
        this.askingThread = null;
    }
    return askJob.wantsToAbort;
}
项目:Beagle    文件:ProgressWindow.java   
/**
 * Initialises this window.
 */
public synchronized void initialise() {
    if (this.progressWindow == null) {
        final UIJob creationJob = inUI(() -> {
            final Shell ourShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            this.progressWindow = new ProgressMessageWindow(ourShell);
        });
        while (this.progressWindow == null) {
            try {
                creationJob.join();
            } catch (final InterruptedException interrupted) {
                // It’s crucial that the window has been created after this point. So
                // we try again.
            }
        }
    }
}
项目:translationstudio8    文件:BrowserViewPart.java   
private Composite createBrowserArea(Composite parent) {
    GridLayout gridLayout = new GridLayout(1, false);
    parent.setLayout(gridLayout);
    GridData gd_displayArea = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    parent.setLayoutData(gd_displayArea);
    tabFolder = new CTabFolder(parent, SWT.TOP|SWT.MULTI|SWT.FLAT);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    UIJob  job = new UIJob(Display.getDefault(),"refresh browser") {            
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            refreshTabContent();
            return Status.OK_STATUS;
        }
        /** (non-Javadoc)
         * @see org.eclipse.core.runtime.jobs.Job#shouldRun()
         */
        @Override
        public boolean shouldRun() {            
            return !tabFolder.isDisposed();
        }
    };
    job.schedule();
    return parent;

}
项目:IDE    文件:ToolPanel.java   
@Override
public void update(Message msg) {
    if (msg.getHeader().getMessageType() == MessageType.MANAGEMENT) {
        UIJob job = new UIJob("Set Text") {

            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                if (msg.getPayload()[0] == 27)
                    textVerificatorOutput.setText(new String(msg.getPayload()));
                else
                    textLoops.setText(new String(msg.getPayload()));
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
}
项目:idecore    文件:ForceIdeUrlDropHandler.java   
public void earlyStartup() {
    UIJob registerJob = new UIJob(PlatformUI.getWorkbench().getDisplay(), "ForceProjectDrop") {
        {
            setPriority(Job.SHORT);
            setSystem(true);
        }

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            workbench.addWindowListener(workbenchListener);
            IWorkbenchWindow[] workbenchWindows = workbench
                    .getWorkbenchWindows();
            for (IWorkbenchWindow window : workbenchWindows) {
                workbenchListener.hookWindow(window);
            }
            return Status.OK_STATUS;
        }

    };
    registerJob.schedule();
}
项目:tool    文件:ModelValidator.java   
public void run() {
    final List<EObject> theResourceContents = resource.getContents();
    if (theResourceContents.isEmpty()) {
        return;
    }
    final EObject theRootModel = theResourceContents.get(0);
    final Job job = new UIJob(Activator.INSTANCE.getString("_UI_ModelValidator_job_name",
            new Object[] { resource.getURI() })) {
        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            handleDiagnostic(validate(theRootModel));
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.DECORATE);
    job.schedule();
}
项目:Pydev    文件:PyGoToDefinition.java   
/**
 * Remove the editor from askReparse and if it's the last one, do the find.
 */
private void doFindIfLast() {
    synchronized (lock) {
        askReparse.remove(editToReparse);
        if (askReparse.size() > 0) {
            return; //not the last one (we'll only do the find when all are reparsed.
        }
    }
    /**
     * Create an ui job to actually make the find.
     */
    UIJob job = new UIJob("Find") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                findDefinitionsAndOpen(true);
            } catch (Throwable e) {
                Log.log(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
项目:Pydev    文件:PyEditorHoverConfigurationBlock.java   
@Override
public void initialize() {
    //need to do this asynchronously, or it has no effect
    new UIJob("Show/Hide Column") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            showColumn(fPreemptColumn, PyHoverPreferencesPage.getCombineHoverInfo());
            showColumn(fModifierColumn, !PyHoverPreferencesPage.getCombineHoverInfo());
            fModifierFieldLabel.setEnabled(!fCombineHovers.getSelection());
            return Status.OK_STATUS;
        }

    }.schedule();
    doInit(true);
}
项目:po-mylyn-integration    文件:TicketEditorAttributesPart.java   
private void updateTicket() {
    new UIJob("Update Ticket") {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                Ticket ticket = getInput();
                client.updateTicket(ticket, monitor);
                setInput(ticket);
            } catch (ProjectOpenException e) {
                throw new RuntimeException(e);
            }

            return Status.OK_STATUS;
        }
    }.schedule();
}
项目:EclipseTracer    文件:SourceLocationNagivator.java   
protected static void searchCompleted(final Object source, final String typeName, final int lineNumber, final IStatus status) {
    UIJob job = new UIJob("link search complete") { //$NON-NLS-1$
        public IStatus runInUIThread(IProgressMonitor monitor) {
            if (source == null) {
                if (status == null) {
                    // did not find source
                    MessageDialog.openInformation(JDIDebugUIPlugin.getActiveWorkbenchShell(), ConsoleMessages.JavaStackTraceHyperlink_Information_1,
                            MessageFormat.format(ConsoleMessages.JavaStackTraceHyperlink_Source_not_found_for__0__2, new Object[] {typeName}));
                } else {
                    JDIDebugUIPlugin.statusDialog(ConsoleMessages.JavaStackTraceHyperlink_3, status);
                }           
            } else {
                processSearchResult(source, typeName, lineNumber);
            }
            return Status.OK_STATUS;
        }
    };
    job.setSystem(true);
    job.schedule();
}
项目:elexis-3-base    文件:Activator.java   
@Override
public void start(BundleContext context) throws Exception{
    super.start(context);
    UIJob job = new UIJob("InitCommandsWorkaround") {

        public IStatus runInUIThread(@SuppressWarnings("unused")
        IProgressMonitor monitor){

            ICommandService commandService =
                (ICommandService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                    .getService(ICommandService.class);
            Command command = commandService.getCommand(LoadESRFileHandler.COMMAND_ID);
            command.isEnabled();
            return new Status(IStatus.OK, "my.plugin.id",
                "Init commands workaround performed succesfully");
        }

    };
    job.schedule();
}
项目:google-cloud-eclipse    文件:OptInDialogTest.java   
private void scheduleClosingDialogAfterOpen(final CloseAction closeAction) {
  dialogCloser = new UIJob("dialog closer") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      if (dialog.getShell() != null && dialog.getShell().isVisible()) {
        closeDialog(closeAction);
      } else {
        schedule(100);
      }
      return Status.OK_STATUS;
    }
  };
  dialogCloser.schedule();
}
项目:google-cloud-eclipse    文件:WorkbenchUtil.java   
/**
 * Opens the specified url in a Web browser instance in a UI thread.
 *
 * @param urlPath the URL to display
 * @param browserId if an instance of a browser with the same id is already opened, it will be
 *   returned instead of creating a new one. Passing null will create a new instance with a
 *   generated id.
 * @param name a name displayed on the tab of the internal browser
 * @param tooltip the text for a tooltip on the <code>name</code> of the internal browser
 */
public static void openInBrowserInUiThread(final String urlPath, final String browserId,
    final String name, final String tooltip) {
  final IWorkbench workbench = PlatformUI.getWorkbench();
  Job launchBrowserJob = new UIJob(workbench.getDisplay(), name) {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      return openInBrowser(workbench, urlPath, browserId, name, tooltip);
    }

  };
  launchBrowserJob.schedule();
}
项目:fluentmark    文件:DoubleClickStrategy.java   
@Override
public void doubleClicked(ITextViewer viewer) {
    final int offset = viewer.getSelectedRange().x;
    if (offset < 0) return;

    PageRoot model = editor.getPageModel();
    PagePart part = model.partAtOffset(offset);

    if (part.getKind() != Kind.TABLE) {
        super.doubleClicked(viewer);
        return;
    }

    UIJob job = new UIJob("Table editor") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            TableDialog dialog = new TableDialog(part);
            int ret = dialog.open();
            if (ret == 0) {
                String newTable = dialog.build();
                ISourceRange range = part.getSourceRange();
                editor.getViewer().setSelectedRange(range.getOffset(), 0);
                TextEdit edit = new ReplaceEdit(range.getOffset(), range.getLength(), newTable);
                try {
                    edit.apply(editor.getDocument());
                } catch (MalformedTreeException | BadLocationException e) {
                    Log.error("Failed to insert new table in part " + part + " (" + e.getMessage() + ")");
                    return Status.CANCEL_STATUS;
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule(200);
}
项目:typescript.java    文件:RdCommandInterpreter.java   
@Override
public void execute(String newWorkingDir) {
    final IContainer[] c = ResourcesPlugin.getWorkspace().getRoot()
            .findContainersForLocation(getWorkingDirPath().append(path));
    if (c != null && c.length > 0) {
        for (int i = 0; i < c.length; i++) {
            UIJob job = new RefreshContainerJob(c[i].getParent(), true);
            job.schedule();
        }
    }
}
项目:typescript.java    文件:CdCommandInterpreter.java   
@Override
public void execute(String newWorkingDir) {
    try {
        final IContainer[] c = ResourcesPlugin.getWorkspace().getRoot()
                .findContainersForLocation(new Path(newWorkingDir));
        if (c != null && c.length > 0) {
            for (int i = 0; i < c.length; i++) {
                UIJob job = new RefreshContainerJob(c[i], false);
                job.schedule();
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
项目:typescript.java    文件:DelCommandInterpreter.java   
@Override
public void execute(String newWorkingDir) {
    final IContainer[] c = ResourcesPlugin.getWorkspace().getRoot()
            .findContainersForLocation(new Path(getWorkingDir()).append(path).removeLastSegments(1));
    if (c != null && c.length > 0) {
        for (int i = 0; i < c.length; i++) {
            UIJob job = new RefreshContainerJob(c[i], true);
            job.schedule();
        }
    }
}
项目:cft    文件:PartsWizardPage.java   
/**
 * Runs the specified runnable asynchronously in a worker thread. Caller is
 * responsible for ensuring that any UI behaviour in the runnable is
 * executed in the UI thread, either synchronously (synch exec through
 * {@link Display} or asynch through {@link Display} or {@link UIJob}).
 * @param runnable
 * @param operationLabel
 */
protected void runAsynchWithWizardProgress(final ICoreRunnable runnable, String operationLabel) {
    if (runnable == null) {
        return;
    }
    if (operationLabel == null) {
        operationLabel = ""; //$NON-NLS-1$
    }

    // Asynch launch as a UI job, as the wizard messages get updated before
    // and after the forked operation
    UIJob job = new UIJob(operationLabel) {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            CoreException cex = null;
            try {
                // Fork in a worker thread.
                CFUiUtil.runForked(runnable, getWizard().getContainer());
            }
            catch (OperationCanceledException e) {
                // Not an error. User can still enter manual values
            }
            catch (CoreException ce) {
                cex = ce;
            }
            // Do not update the wizard with an error, as users can still
            // complete the wizard with manual values.
            if (cex != null) {
                CloudFoundryPlugin.logError(cex);
            }

            return Status.OK_STATUS;
        }

    };
    job.setSystem(true);
    job.schedule();
}
项目:cft    文件:UIWebNavigationHelper.java   
public void navigate() {
    UIJob job = new UIJob(label) {

        public IStatus runInUIThread(IProgressMonitor monitor) {
            CFUiUtil.openUrl(location);
            return Status.OK_STATUS;
        }
    };

    job.schedule();
}
项目:cft    文件:UIWebNavigationHelper.java   
public void navigateExternal() {
    UIJob job = new UIJob(label) {

        public IStatus runInUIThread(IProgressMonitor monitor) {
            CFUiUtil.openUrl(location, WebBrowserPreference.EXTERNAL);
            return Status.OK_STATUS;
        }
    };

    job.schedule();
}
项目:cft    文件:ApplicationMasterPart.java   
private void createRoutesDomainsSection() {

        Section routeSection = toolkit.createSection(getSection().getParent(), Section.TITLE_BAR | Section.TWISTIE);
        routeSection.setLayout(new GridLayout());
        GridDataFactory.fillDefaults().grab(true, true).applyTo(routeSection);
        routeSection.setText(Messages.ApplicationMasterPart_TEXT_ROUTES);
        routeSection.setExpanded(true);

        routeSection.clientVerticalSpacing = 0;

        Composite client = toolkit.createComposite(routeSection);
        client.setLayout(new GridLayout(1, false));
        GridDataFactory.fillDefaults().grab(true, true).applyTo(client);
        routeSection.setClient(client);

        Button button = toolkit.createButton(client, Messages.ApplicationMasterPart_TEXT_REMOVE_BUTTON, SWT.PUSH);
        GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(button);

        button.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                UIJob uiJob = new UIJob(Messages.ApplicationMasterPart_JOB_REMOVE_ROUTE) {

                    public IStatus runInUIThread(IProgressMonitor monitor) {
                        CloudRoutesWizard wizard = new CloudRoutesWizard(cloudServer);

                        WizardDialog dialog = new WizardDialog(editorPage.getEditorSite().getShell(), wizard);
                        dialog.open();
                        return Status.OK_STATUS;
                    }

                };
                uiJob.setSystem(true);
                uiJob.setPriority(Job.INTERACTIVE);
                uiJob.schedule();
            }
        });

    }
项目:jsbuild-eclipse    文件:RunTaskAction.java   
/**
 * @param selectedElement
 *            The element to use as the context for launching
 */
public void run(final IJSBuildFileNode selectedElement) {
    UIJob job = new UIJob(JSBuildFileViewActionMessages.RunTaskAction_2) {
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            launch(selectedElement);
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}