org.eclipse.ui.progress.UIJob Java Examples

The following examples show how to use org.eclipse.ui.progress.UIJob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalAppEngineConsole.java    From google-cloud-eclipse with Apache License 2.0 8 votes vote down vote up
/**
 * 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();
}
 
Example #2
Source File: Popup.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private static void show(Image image, String title, String text) {
	UIJob job = new UIJob("Open popup") {

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor) {
			Display display = getDisplay();
			if (display == null || display.isDisposed())
				return Status.CANCEL_STATUS;
			Notifier.notify(
					image,
					title != null ? title : "?",
					text != null ? text : "?",
					NotifierTheme.YELLOW_THEME);
			return Status.OK_STATUS;
		}
	};
	job.schedule();
}
 
Example #3
Source File: EclipseMessageUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Displays the given file in an editor using the Java perspective.  
 * If something goes wrong, this method has no effect. 
 * 
 * @param file The file to display.
 * @param workbench The workbench.
 */
public static void displayInEditor(IFile file, IWorkbench workbench) {
	new UIJob("Display in editor") {
		@Override
		public IStatus runInUIThread(IProgressMonitor m) {
			try {
				IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
				IDE.openEditor(window.getActivePage(), file);
				workbench.showPerspective("org.eclipse.jdt.ui.JavaPerspective", window);
				return Status.OK_STATUS;
			}
			catch (NullPointerException | WorkbenchException e) {
				return Status.CANCEL_STATUS;
			}
		}
	}.schedule();
}
 
Example #4
Source File: PyEditorHoverConfigurationBlock.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: PyGoToDefinition.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #6
Source File: BrowserViewPart.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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;

}
 
Example #7
Source File: PerspectiveChangeResetListener.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #8
Source File: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #9
Source File: TempleteFrameWizard.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@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;
  }
 
Example #10
Source File: OpenThemePreferencesHandler.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: SCTPerspectiveManager.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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();
}
 
Example #12
Source File: ExampleDropSupportRegistrar.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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();
}
 
Example #13
Source File: BugAig931Test.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
    }
  };
}
 
Example #14
Source File: NewSpecHandler.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * 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();
}
 
Example #15
Source File: TLCUIActivator.java    From tlaplus with MIT License 6 votes vote down vote up
public void start(BundleContext context) throws Exception
  {
      super.start(context);
      plugin = this;

      changedColor = new Color(null, 255, 200, 200);
      addedColor = new Color(null, 255, 255, 200);
      deletedColor = new Color(null, 240, 240, 255);
      

if (Display.getCurrent() != null && ExecutionStatisticsCollector.promptUser()) { // Display is null during unit test execution.
	final UIJob j = new UIJob(Display.getCurrent(), "TLA+ execution statistics approval.") {
		@Override
		public IStatus runInUIThread(final IProgressMonitor monitor) {
			new ExecutionStatisticsDialog(false, PlatformUI.createDisplay().getActiveShell()).open();
			return Status.OK_STATUS;
		}
	};
	j.schedule(5 * 60 * 1000L);
}
  }
 
Example #16
Source File: OptInDialogTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #17
Source File: ControlView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void componentChanged(final ITraceControlComponent component) {
    if (fTreeViewer.getTree().isDisposed()) {
        return;
    }

    UIJob myJob = new UIJob("Refresh") { //$NON-NLS-1$
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            if (fTreeViewer.getTree().isDisposed()) {
                return Status.OK_STATUS;
            }

            fTreeViewer.refresh(component);

            // Change selection needed
            final ISelection sel = fTreeViewer.getSelection();
            fTreeViewer.setSelection(null);
            fTreeViewer.setSelection(sel);

            // Show component that was changed
            fTreeViewer.reveal(component);

            return Status.OK_STATUS;
        }
    };
    myJob.setUser(false);
    myJob.setSystem(true);
    myJob.schedule();
}
 
Example #18
Source File: WorkbenchUtil.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #19
Source File: PyRefactorAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Actually executes this action.
 *
 * Checks preconditions... if
 */
@Override
public void run(final IAction action) {
    // Select from text editor
    request = null; //clear the cache from previous runs
    ps = PySelectionFromEditor.createPySelectionFromEditor(getTextEditor());

    RefactoringRequest req;
    try {
        req = getRefactoringRequest();
    } catch (MisconfigurationException e2) {
        Log.log(e2);
        return;
    }
    IPyRefactoring pyRefactoring = AbstractPyRefactoring.getPyRefactoring();
    if (areRefactorPreconditionsOK(req, pyRefactoring) == false) {
        return;
    }

    UIJob job = new UIJob("Performing: " + this.getClass().getName()) {

        @Override
        public IStatus runInUIThread(final IProgressMonitor monitor) {
            try {
                Operation o = new Operation(action);
                o.execute(monitor);
            } catch (Exception e) {
                Log.log(e);
            }
            return Status.OK_STATUS;
        }

    };
    job.setSystem(true);
    job.schedule();
}
 
Example #20
Source File: OfflineActionTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Installs this target. I.e. adds all required listeners.
 */
private void install() {
    if (fInstalled)
        return;

    StyledText text = fTextViewer.getTextWidget();
    if (text == null)
        return;

    text.addMouseListener(this);
    text.addFocusListener(this);
    fTextViewer.addTextListener(this);

    ISelectionProvider selectionProvider = fTextViewer.getSelectionProvider();
    if (selectionProvider != null)
        selectionProvider.addSelectionChangedListener(this);

    if (fTextViewer instanceof ITextViewerExtension)
        ((ITextViewerExtension) fTextViewer).prependVerifyKeyListener(this);
    else
        text.addVerifyKeyListener(this);

    keyAssistDialog = new KeyAssistDialog(this.fEdit);
    fInstalled = true;

    //Wait a bit until showing the key assist dialog
    new UIJob("") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            synchronized (lock) {
                if (fInstalled && keyAssistDialog != null) {
                    keyAssistDialog.open(OfflineActionTarget.this.fEdit.getOfflineActionDescriptions(),
                            OfflineActionTarget.this);
                }
            }
            return Status.OK_STATUS;
        }
    }.schedule(700);
}
 
Example #21
Source File: CommonEditorPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void start(BundleContext context) throws Exception
{
	super.start(context);
	plugin = this;

	// Update occurrence colors
	listenForThemeChanges();

	// Activate indexing
	// FIXME Why can't we just have the indexing plugin load lazily on-demand?
	IndexPlugin.getDefault();

	differentiator = new FilenameDifferentiator();
	differentiator.schedule();
	// FIXME initialize spelling preferences lazily
	spellingPreferences = new SpellingPreferences();

	new UIJob("adding part listener") //$NON-NLS-1$
	{

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor)
		{
			addPartListener();
			return Status.OK_STATUS;
		}
	}.schedule();

}
 
Example #22
Source File: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static boolean showPromptDialog(final String title, final String message)
{
	if (Display.getCurrent() == null)
	{
		UIJob job = new UIJob(title)
		{
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor)
			{
				if (showPromptDialogUI(title, message))
				{
					return Status.OK_STATUS;
				}
				return Status.CANCEL_STATUS;
			}
		};
		job.setPriority(Job.INTERACTIVE);
		job.setUser(true);
		job.schedule();
		try
		{
			job.join();
		}
		catch (InterruptedException e)
		{
		}
		return job.getResult() == Status.OK_STATUS;
	}
	else
	{
		return showPromptDialogUI(title, message);
	}
}
 
Example #23
Source File: UIUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Schedules a message dialog to be displayed safely in the UI thread
 * 
 * @param runnable
 *            Something that gets run if the message dialog return code is Window.OK
 * @param runnableCondition
 *            The return code from SafeMessageDialogRunnable.openMessageDialog() that would trigger
 *            SafeMessageDialogRunnable.run()
 */
public static void showMessageDialogFromBgThread(final SafeMessageDialogRunnable runnable,
		final int runnableCondition)
{
	UIJob job = new UIJob("Modal Message Dialog Job") //$NON-NLS-1$
	{

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor)
		{
			// If the system dialog is shown, then the active shell would be null
			if (Display.getDefault().getActiveShell() == null)
			{
				if (!monitor.isCanceled())
				{
					schedule(1000);
				}
			}
			else if (!monitor.isCanceled())
			{
				if (runnable.openMessageDialog() == runnableCondition)
				{
					try
					{
						runnable.run();
					}
					catch (Exception e)
					{
						IdeLog.logError(UIPlugin.getDefault(), e);
					}
				}
			}
			return Status.OK_STATUS;
		}
	};
	EclipseUtil.setSystemForJob(job);
	job.schedule();
}
 
Example #24
Source File: RdCommandInterpreter.java    From typescript.java with MIT License 5 votes vote down vote up
@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();
		}
	}
}
 
Example #25
Source File: WorkbenchHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static void runInUI(final String title, final int scheduleTime, final Consumer<IProgressMonitor> run) {
	final UIJob job = new UIJob(title) {

		@Override
		public IStatus runInUIThread(final IProgressMonitor monitor) {

			run.accept(monitor);
			return Status.OK_STATUS;
		}

	};
	job.schedule(scheduleTime);
}
 
Example #26
Source File: BackgroundInitiatedYesNoDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Displays a yes/no dialog of a specified type with a specified title,a specified message, and a
 * specified default value, then blocks until the user responds or interrupts the dialog.
 * 
 * @param type the dialog type, specified by one of the int constants in {@link MessageDialog}
 * @param title the specified title
 * @param message the specified message
 * @param defaultIsYes
 *     {@link true} if the specified default value is <i>yes</i>, false if the specified default
 *      value is <i>no</i>
 * @return
 *     {@code true} if the user responded <i>yes</i>, {@code false} if the user responded
 *     <i>no</i>, or the value of {@code defaultValueIsYes} if the user interrupts the dialog
 */
public boolean userAnsweredYes(
    final int type, final String title, final String message, final boolean defaultIsYes) {
  final int defaultPosition = defaultIsYes ? YesOrNo.YES.ordinal() : YesOrNo.NO.ordinal();
  if (Display.getCurrent() == null) {
    // This is not a UI thread. Schedule a UI job to call displayDialogAndGetAnswer, and block
    // this thread until the UI job is complete.
    final Semaphore barrier = new Semaphore(0);
    final AtomicBoolean responseContainer = new AtomicBoolean();
    UIJob dialogJob =
        new UIJob("background-initiated question dialog"){
          @Override public IStatus runInUIThread(IProgressMonitor monitor) {
            boolean result = displayDialogAndGetAnswer(type, title, message, defaultPosition);
            responseContainer.set(result);
            barrier.release();
            return Status.OK_STATUS;
          }
        };
    dialogJob.schedule();
    try {
      barrier.acquire();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      return defaultIsYes;
    }
    return responseContainer.get();
  } else {
    // This is the UI thread. Simply call displayDialogAndGetAnswer in this thread.
    // (Scheduling a UIJob and blocking until it completes would result in deadlock.)
    return displayDialogAndGetAnswer(type, title, message, defaultPosition);
  }
}
 
Example #27
Source File: CdCommandInterpreter.java    From typescript.java with MIT License 5 votes vote down vote up
@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();
	}
}
 
Example #28
Source File: DelCommandInterpreter.java    From typescript.java with MIT License 5 votes vote down vote up
@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();
		}
	}
}
 
Example #29
Source File: ControlView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the selected components in the tree
 * @param components - array of components to select
 */
public void setSelection(ITraceControlComponent[] components) {
    final StructuredSelection selection = new StructuredSelection(components);
    UIJob myJob = new UIJob("Select") { //$NON-NLS-1$
        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            fTreeViewer.setSelection(selection);
            return Status.OK_STATUS;
        }
    };
    myJob.setUser(false);
    myJob.schedule();
}
 
Example #30
Source File: RenameInformationPopup.java    From typescript.java with MIT License 4 votes vote down vote up
public void open() {
		// Must cache here, since editor context is not available in menu from popup shell:
		fOpenDialogBinding= getOpenDialogBinding();

		Shell workbenchShell= fEditor.getSite().getShell();
		final Display display= workbenchShell.getDisplay();

		fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
		fPopupLayout= new GridLayout(3, false);
		fPopupLayout.marginWidth= 1;
		fPopupLayout.marginHeight= 1;
		fPopupLayout.marginLeft= 4;
		fPopupLayout.horizontalSpacing= 0;
		fPopup.setLayout(fPopupLayout);

		createContent(fPopup);
		updatePopupLocation(true);
		new PopupVisibilityManager().start();

		// Leave linked mode when popup loses focus
		// (except when focus goes back to workbench window or menu is open):
		fPopup.addShellListener(new ShellAdapter() {
			@Override
			public void shellDeactivated(ShellEvent e) {
				if (fIsMenuUp)
					return;

				final Shell editorShell= fEditor.getSite().getShell();
				display.asyncExec(new Runnable() {
					// post to UI thread since editor shell only gets activated after popup has lost focus
					@Override
					public void run() {
						Shell activeShell= display.getActiveShell();
						if (activeShell != editorShell) {
							fRenameLinkedMode.cancel();
						}
					}
				});
			}
		});

		if (! MAC) { // carbon and cocoa draw their own border...
			fPopup.addPaintListener(new PaintListener() {
				@Override
				public void paintControl(PaintEvent pe) {
					pe.gc.drawPolygon(getPolygon(true));
				}
			});
		}

//		fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//		fPopup.moveBelow(workbenchShell.getShells()[0]);

		UIJob delayJob= new UIJob(display, RefactoringMessages.RenameInformationPopup_delayJobName) {
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor) {
				fDelayJobFinished= true;
				if (fPopup != null && ! fPopup.isDisposed()) {
					updateVisibility();
				}
				return Status.OK_STATUS;
			}
		};
		delayJob.setSystem(true);
		delayJob.setPriority(Job.INTERACTIVE);
		delayJob.schedule(POPUP_VISIBILITY_DELAY);
	}