org.eclipse.ui.WorkbenchException Java Examples

The following examples show how to use org.eclipse.ui.WorkbenchException. 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: OpenWSDLEditorAction.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
public void run(IIntroSite site, Properties params) {
    PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());

    IPerspectiveDescriptor currentPerspective = site.getPage().getPerspective();
    if (!PERSPECTIVE_ID.equals(currentPerspective.getId())) {
        // show required perspective
        IWorkbenchWindow workbenchWindow = site.getWorkbenchWindow();
        try {
            workbenchWindow.getWorkbench().showPerspective(PERSPECTIVE_ID, workbenchWindow);
        } catch (WorkbenchException e) {
            ExceptionHandler.process(e);
            return;
        }
    }

    // find repository node
    repositoryNode = (RepositoryNode) RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"),
            false);
    if (null != repositoryNode) {
        // expand/select node item
        RepositoryManagerHelper.getRepositoryView().getViewer().setSelection(new StructuredSelection(repositoryNode));
        init(repositoryNode);
        doRun();
    }
}
 
Example #2
Source File: IndexedJsniJavaRefTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public void testLoad() throws WorkbenchException {
  // Test loading from a well-formed XML fragment
  IndexedJsniJavaRef ref = loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.IndexedJsniJavaRef\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\">@com.hello.Hello::sayHi(Ljava/lang/String;)</JavaRef>");
  assertNotNull(ref);
  assertEquals(25, ref.getOffset());
  assertEquals("/MyProject/src/com/hello/Hello.java",
      ref.getSource().toString());
  assertEquals("com.hello.Hello", ref.className());
  assertEquals("sayHi", ref.memberName());
  assertEquals("Ljava/lang/String;", ref.paramTypesString());

  // Test fragment missing the Java ref string
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.IndexedJsniJavaRef\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\"></JavaRef>"));

  // Test fragment with malformed Java ref string
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.IndexedJsniJavaRef\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\">ABC!@#</JavaRef>"));

  // Test fragment missing the source attribute
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.IndexedJsniJavaRef\" offset=\"25\">@com.hello.Hello::sayHi(Ljava/lang/String;)</JavaRef>"));

  // Test fragment missing the offset attribute
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.IndexedJsniJavaRef\" source=\"/MyProject/src/com/hello/Hello.java\">@com.hello.Hello::sayHi(Ljava/lang/String;)</JavaRef>"));
}
 
Example #3
Source File: JsniJavaRefParamTypeTest.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public void testLoad() throws WorkbenchException {
  // Test loading from a well-formed XML fragment
  JsniJavaRefParamType ref = loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.JsniJavaRefParamType\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\">Ljava/lang/String;</JavaRef>");
  assertNotNull(ref);

  // Test fragment missing the Java ref string
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.JsniJavaRefParamType\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\"></JavaRef>"));

  // Test fragment with malformed Java ref string
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.JsniJavaRefParamType\" offset=\"25\" source=\"/MyProject/src/com/hello/Hello.java\">ABC!@#</JavaRef>"));

  // Test fragment missing the source attribute
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.JsniJavaRefParamType\" offset=\"25\">Ljava/lang/String;</JavaRef>"));

  // Test fragment missing the offset attribute
  assertNull(loadRef("<JavaRef class=\"com.google.gwt.eclipse.plugin.search.JsniJavaRefParamType\" source=\"/MyProject/src/com/hello/Hello.java\">Ljava/lang/String;</JavaRef>"));
}
 
Example #4
Source File: OpenJavaBrowsingPerspectiveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_BROWSING_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaBrowsingPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaBrowsingPerspectiveAction_error_open_failed);
	}
}
 
Example #5
Source File: OpenJavaPerspectiveAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaPerspectiveAction_error_open_failed);
	}
}
 
Example #6
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	super.init(site, memento);
	if (memento == null) {
		String persistedMemento= fDialogSettings.get(TAG_MEMENTO);
		if (persistedMemento != null) {
			try {
				memento= XMLMemento.createReadRoot(new StringReader(persistedMemento));
			} catch (WorkbenchException e) {
				// don't do anything. Simply don't restore the settings
			}
		}
	}
	fMemento= memento;
	if (memento != null) {
		restoreLayoutState(memento);
		restoreLinkingEnabled(memento);
		restoreRootMode(memento);
	}
	if (getRootMode() == WORKING_SETS_AS_ROOTS) {
		createWorkingSetModel();
	}
}
 
Example #7
Source File: RCPTestSetupHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Close all open windows, editors, perspectives. Open and reset default perspective.
 */
private static void resetWorkbench() {
    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        
        Shell activeShell = Display.getCurrent().getActiveShell();
        if (activeShell != null && activeShell != workbenchWindow.getShell()) {
            activeShell.close();
        }
        
        page.closeAllEditors(false);
        page.resetPerspective();
        
        String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective();
        workbench.showPerspective(defaultPerspectiveId, workbenchWindow);
        page.resetPerspective();
        
        page.showView("org.eclipse.ui.internal.introview");
    } catch (WorkbenchException e) {
        throw new RuntimeException(e);
    }
}
 
Example #8
Source File: OpenTypeHierarchyUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, IJavaElement[] input) throws WorkbenchException, JavaModelException {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IJavaElement perspectiveInput= input.length == 1 ? input[0] : null;

	if (perspectiveInput != null && input[0] instanceof IMember) {
		if (input[0].getElementType() != IJavaElement.TYPE) {
			perspectiveInput= ((IMember)input[0]).getDeclaringType();
		} else {
			perspectiveInput= input[0];
		}
	}
	IWorkbenchPage page= workbench.showPerspective(JavaUI.ID_HIERARCHYPERSPECTIVE, window, perspectiveInput);

	TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY);
	if (part != null) {
		part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
	}
	part= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY);
	part.setInputElements(input);
	if (perspectiveInput != null) {
		if (page.getEditorReferences().length == 0) {
			JavaUI.openInEditor(input[0], false, false); // only open when the perspective has been created
		}
	}
	return part;
}
 
Example #9
Source File: UIHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Opens the new window containing the new perspective
 * 
 * @param perspectiveId
 *            new perspective
 * @param input
 *            IAdaptable, or null if no input
 * @return IWorkbenchWindow instance
 * 
 */
public static IWorkbenchWindow openPerspectiveInNewWindow(String perspectiveId, IAdaptable input) {
	IWorkbench workbench = Activator.getDefault().getWorkbench();
	IWorkbenchWindow window = null;
	try {
		// avoids flicking, from implementation above
		window = workbench.openWorkbenchWindow(perspectiveId, input);

		// show intro
		if (InitialPerspective.ID.equals(perspectiveId) && workbench.getIntroManager().hasIntro()) {
			// IIntroPart intro =
			workbench.getIntroManager().showIntro(window, true);
		}

	} catch (WorkbenchException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return window;
}
 
Example #10
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Switching to the default Avaloq perspective and resets it.
 */
public static void switchAndResetPerspective() {
  PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

    @Override
    public void run() {
      final IWorkbench workbench = PlatformUI.getWorkbench();
      final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
      IWorkbenchPage page = null;
      try {
        page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window);
      } catch (final WorkbenchException exception) {
        // Try customer perspective
        try {
          page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window);
        } catch (final WorkbenchException second) {
          // Both perspectives are missing
          throw new AssertionFailedException("Could not switch to Avaloq Perspective: " + exception.getLocalizedMessage());
        }
      }
      if (page != null) {
        page.resetPerspective();
      }
    }
  });
}
 
Example #11
Source File: GlobalsTwoPanelElementSelector2.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void restoreDialog(IDialogSettings settings) {
    super.restoreDialog(settings);

    String setting = settings.get(WORKINGS_SET_SETTINGS);
    if (setting != null) {
        try {
            IMemento memento = XMLMemento.createReadRoot(new StringReader(setting));
            workingSetFilterActionGroup.restoreState(memento);
        } catch (WorkbenchException e) {
            StatusManager.getManager().handle(
                    new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$
            // don't do anything. Simply don't restore the settings
        }
    }

    addListFilter(workingSetFilter);

    applyFilter();
}
 
Example #12
Source File: DebuggerTestUtils.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This method can be used to switch to a given perspective
 * @param perspectiveId the id of the perspective that should be activated.
 * @return the exception raised or null.
 */
public void switchToPerspective(final String perspectiveId) {
    final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench();
    Display display = workBench.getDisplay();

    // Make sure to run the UI thread.
    display.syncExec(new Runnable() {

        @Override
        public void run() {
            IWorkbenchWindow window = workBench.getActiveWorkbenchWindow();
            try {
                workBench.showPerspective(perspectiveId, window);
            } catch (WorkbenchException e) {
                failException = e;
            }
        }
    });
}
 
Example #13
Source File: AbstractFindbugsView.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 *
 */
final void showPerspective() {
    IWorkbenchPage page = getSite().getPage();
    IWorkbenchWindow window = getSite().getWorkbenchWindow();
    IAdaptable input;
    if (page != null) {
        input = page.getInput();
    } else {
        input = ResourcesPlugin.getWorkspace().getRoot();
    }
    try {
        PlatformUI.getWorkbench().showPerspective(FindBugsPerspectiveFactory.ID, window, input);
    } catch (WorkbenchException e) {
        FindbugsPlugin.getDefault().logException(e, "Failed to open SpotBugs Perspective");
    }
}
 
Example #14
Source File: BugExplorerView.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
    viewMemento = memento;
    if (memento == null) {
        IDialogSettings dialogSettings = FindbugsPlugin.getDefault().getDialogSettings();
        String persistedMemento = dialogSettings.get(TAG_MEMENTO);
        if (persistedMemento == null) {
            // See bug 2504068. First time user opens a view, no settings
            // are defined
            // but we still need to enforce initialisation of content
            // provider
            // which can only happen if memento is not null
            memento = XMLMemento.createWriteRoot("bugExplorer");
        } else {
            try {
                memento = XMLMemento.createReadRoot(new StringReader(persistedMemento));
            } catch (WorkbenchException e) {
                // don't do anything. Simply don't restore the settings
            }
        }
    }
    super.init(site, memento);
}
 
Example #15
Source File: NewProjectFromSourcesWizard.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean performFinish() {
	IProject newProject = NewProjectCreator.createFromSources(firstPage.getSettings());
	if (newProject == null) {
		return false;
	}
	selectAndReveal(newProject);
	
	try {
           PerspectiveUtils.promptAndOpenPerspective(getWorkbench(), XdsPerspectiveFactory.DEVELOPMENT_PERSPECTIVE_ID, Messages.NewProjectWizard_PerspectiveSwitch, Messages.NewProjectWizard_DoYouWantToSwitsh);
       } catch (WorkbenchException e) {
           LogHelper.logError(e);
       }
	
	return true;
}
 
Example #16
Source File: XdsResourcesUpdater.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void applyInstanceResourceUpdates(UpdateDirDescriptor desc) throws URISyntaxException, WorkbenchException, IOException {
	InstalledUpdatesRegistry installedUpdatesRegistry = InstalledUpdatesManager.getInstance().loadInstalledUpdatesRegistry();
	boolean isNewUpdatesInstalled = false;
	
	String eclipseInstallDir = System.getProperty(ECLIPSE_HOME_LOCATION_PROPERTY);
	for (InstanceDirectoryUpdate instanceDirectoryUpdate : desc.instanceDirectoryUpdates) {
		File targetDirectory = new File(new URL(FilenameUtils.concat(eclipseInstallDir, instanceDirectoryUpdate.name)).toURI());
		if (!targetDirectory.exists()) {
			LogHelper.logError(String.format("Resource update : incorrect instance directory specified : '%s'", targetDirectory)); //$NON-NLS-1$
			continue;
		}
		List<FileUpdate> fileUpdates = instanceDirectoryUpdate.fileUpdates;
		for (FileUpdate fileUpdate : fileUpdates) {
			if (updateResource(installedUpdatesRegistry, desc.updateDirPath, fileUpdate.source, targetDirectory, 
					 fileUpdate.name, null, fileUpdate.version, false)) {
				isNewUpdatesInstalled = true;
			}
		}
	}
	if (isNewUpdatesInstalled) {
		InstalledUpdatesManager.getInstance().saveInstalledUpdatesRegistry(installedUpdatesRegistry);
	}
}
 
Example #17
Source File: SwitchPaletteMode.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieves the root memento from the workspace preferences if there were
 * existing palette customizations.
 * 
 * @return the root memento if there were existing customizations; null
 *         otherwise
 */
private XMLMemento getExistingCustomizations() {
	if (preferences != null) {
		String sValue = preferences.getString(PALETTE_CUSTOMIZATIONS_ID);
		if (sValue != null && sValue.length() != 0) { //$NON-NLS-1$
			try {
				XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue));
				return rootMemento;
			} catch (WorkbenchException e) {
				Trace.catching(GefPlugin.getInstance(), GefDebugOptions.EXCEPTIONS_CATCHING, getClass(),
						"Problem creating the XML memento when saving the palette customizations.", //$NON-NLS-1$
						e);
				Log.warning(GefPlugin.getInstance(), GefStatusCodes.IGNORED_EXCEPTION_WARNING,
						"Problem creating the XML memento when saving the palette customizations.", //$NON-NLS-1$
						e);
			}
		}
	}
	return null;
}
 
Example #18
Source File: PerspectiveImportService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void openPerspective(IPerspectiveDescriptor iPerspectiveDescriptor){
	try {
		IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		PlatformUI.getWorkbench().showPerspective(iPerspectiveDescriptor.getId(), win);
	} catch (WorkbenchException e) {
		LoggerFactory.getLogger(PerspectiveImportService.class)
			.error("cannot open perspective [{}]", iPerspectiveDescriptor.getId(), e);
	}
}
 
Example #19
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void restoreDialog(IDialogSettings settings) {
	super.restoreDialog(settings);

	if (! BUG_184693) {
		boolean showContainer= settings.getBoolean(SHOW_CONTAINER_FOR_DUPLICATES);
		fShowContainerForDuplicatesAction.setChecked(showContainer);
		fTypeInfoLabelProvider.setContainerInfo(showContainer);
	} else {
		fTypeInfoLabelProvider.setContainerInfo(true);
	}

	if (fAllowScopeSwitching) {
		String setting= settings.get(WORKINGS_SET_SETTINGS);
		if (setting != null) {
			try {
				IMemento memento= XMLMemento.createReadRoot(new StringReader(setting));
				fFilterActionGroup.restoreState(memento);
			} catch (WorkbenchException e) {
				// don't do anything. Simply don't restore the settings
				JavaPlugin.log(e);
			}
		}
		IWorkingSet ws= fFilterActionGroup.getWorkingSet();
		if (ws == null || (ws.isAggregateWorkingSet() && ws.isEmpty())) {
			setSearchScope(SearchEngine.createWorkspaceScope());
			setSubtitle(null);
		} else {
			setSearchScope(JavaSearchScopeFactory.getInstance().createJavaSearchScope(ws, true));
			setSubtitle(ws.getLabel());
		}
	}

	// TypeNameMatch[] types = OpenTypeHistory.getInstance().getTypeInfos();
	//
	// for (int i = 0; i < types.length; i++) {
	// TypeNameMatch type = types[i];
	// accessedHistoryItem(type);
	// }
}
 
Example #20
Source File: XsemanticsSwtbotTestBase.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected static void openPluginPerspective() throws InterruptedException {
	Display.getDefault().syncExec(new Runnable() {
		public void run() {
			try {
				PlatformUI.getWorkbench().showPerspective(IPDEUIConstants.PERSPECTIVE_ID,       
				         PlatformUI.getWorkbench().getActiveWorkbenchWindow());
			} catch (WorkbenchException e) {
				e.printStackTrace();
			}
		}
	});
}
 
Example #21
Source File: PerspectiveUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void promptAndOpenPerspective(IWorkbench workbench, String perspectiveId, String title, String message) throws WorkbenchException {
    IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();

    if (!perspectiveId.equals(activeWindow.getActivePage().getPerspective().getId())) {
        if (MessageDialog.openConfirm(activeWindow.getShell(), title, message)) {
            workbench.showPerspective(perspectiveId, activeWindow);
        }
    }
}
 
Example #22
Source File: TmfPerspectiveManager.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Switches to the specified perspective.
 *
 * @param window
 *            the workbench window
 * @param id
 *            perspective identifier
 */
protected void switchToPerspective(IWorkbenchWindow window, String id) {
    try {
        window.getWorkbench().showPerspective(id, window);
    } catch (WorkbenchException e) {
        TraceUtils.displayErrorMsg(
                Messages.TmfPerspectiveManager_SwitchPerspectiveErrorTitle,
                Messages.TmfPerspectiveManager_SwitchPerspectiveErrorMessage,
                e);
    }
}
 
Example #23
Source File: PerspectiveUtils.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void showPerspective(String perspectiveId, IWorkbenchWindow window) {
 	Display.getDefault().asyncExec(() -> {
 		IWorkbench workbench = PlatformUI.getWorkbench();
try {
	workbench.showPerspective(perspectiveId, window);
} catch (WorkbenchException e) {
	LogHelper.logError(e);
}
 	});
 }
 
Example #24
Source File: XdsResourcesUpdater.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void applyPluginResourceUpdates(UpdateDirDescriptor desc) throws WorkbenchException, IOException {
	InstalledUpdatesRegistry installedUpdatesRegistry = InstalledUpdatesManager.getInstance().loadInstalledUpdatesRegistry();
	
	boolean isNewUpdatesInstalled = false;
	
	String updateDirPath = desc.updateDirPath;
	List<Update> updates = desc.updates;
	Map<String, Bundle> pluginName2Bundle = new HashMap<String, Bundle>();
	Set<String> unresolvedBundleNames = new HashSet<String>();
	for (Update update : updates) {
		Bundle bundle = pluginName2Bundle.get(update.targetPluginName);
		if (bundle == null) {
			bundle = Platform.getBundle(update.targetPluginName);
			if (bundle == null) {
				unresolvedBundleNames.add(update.targetPluginName);
				continue;
			}
			pluginName2Bundle.put(update.targetPluginName, bundle);
		}
		if (updateResource(installedUpdatesRegistry, bundle, updateDirPath, update)) {
			isNewUpdatesInstalled = true;
		}
	}
	if (isNewUpdatesInstalled) {
		InstalledUpdatesManager.getInstance().saveInstalledUpdatesRegistry(installedUpdatesRegistry);
	}
	
	for (String unresolvedBundleName : unresolvedBundleNames) {
		LogHelper.logError(String.format("Bundle '%s' was not found during update", unresolvedBundleName)); //$NON-NLS-1$
	}
}
 
Example #25
Source File: InstalledUpdatesManager.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public InstalledUpdatesRegistry loadInstalledUpdatesRegistry() throws IOException, WorkbenchException {
	if (installedUpdatesRegistry == null) {
		File installedUpdatesRegistryFile = getInstalledUpdatesRegistryFile();
		if (installedUpdatesRegistryFile.exists()) {
			Reader reader = new FileReader(installedUpdatesRegistryFile);
			XMLMemento memento = XMLMemento.createReadRoot(reader);
			installedUpdatesRegistry = loadInstalledUpdatesRegistry(memento);
		}
		else {
			installedUpdatesRegistry = new InstalledUpdatesRegistry(new HashMap<String, InstalledUpdate>());
		}
	}
	return installedUpdatesRegistry;
}
 
Example #26
Source File: FindBugsAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected static void switchPerspective(IWorkbenchPart part) {
    IWorkbenchWindow window = getWindow(part);
    IWorkbenchPage page = window.getActivePage();
    IAdaptable input;
    if (page != null) {
        input = page.getInput();
    } else {
        input = ResourcesPlugin.getWorkspace().getRoot();
    }
    try {
        PlatformUI.getWorkbench().showPerspective(FindBugsPerspectiveFactory.ID, window, input);
    } catch (WorkbenchException e) {
        FindbugsPlugin.getDefault().logException(e, "Failed to open SpotBugs Perspective");
    }
}
 
Example #27
Source File: FindBugsPerspectiveTest.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testShowPerspective() throws WorkbenchException {
    // Show the perspective
    IWorkbenchPage page = showFindBugsPerspective();

    // Reset the perspective to its default state
    page.resetPerspective();

    // Assert the FindBugs explorer view is visible
    IViewPart bugExplorerView = page.findView(AbstractPluginTest.BUG_EXPLORER_VIEW_ID);
    assertNotNull(bugExplorerView);
    assertTrue(page.isPartVisible(bugExplorerView));
}
 
Example #28
Source File: UIHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Switch current perspective
 * 
 * @param perspectiveId
 * @return
 */
public static IWorkbenchPage switchPerspective(String perspectiveId) {
	Assert.isNotNull(perspectiveId, "PerspectiveId is null");
	IWorkbench workbench = PlatformUI.getWorkbench();
	IWorkbenchWindow window = getActiveWindow();
	Assert.isNotNull(workbench, "Workbench is null");
	Assert.isNotNull(window, "Window is null");
	try {
		IWorkbenchPage page = workbench.showPerspective(perspectiveId, window);

		// show intro
		if (InitialPerspective.ID.equals(perspectiveId) && workbench.getIntroManager().hasIntro()) {
			page.resetPerspective();
			// We are no longer showing the Intro view. The following will
			// probably
			// be replaced by something that shows the view we want. 09 Oct
			// 2009
			// workbench.getIntroManager().showIntro(window, false);
			openView(ToolboxWelcomeView.ID);

		}

		return page;
	} catch (WorkbenchException e) {
		Activator.getDefault().logError("Error switching a perspective to " + perspectiveId, e);
	}

	return null;
}
 
Example #29
Source File: FilteredItemsSelectionDialog.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Restores dialog using persisted settings. The default implementation
 * restores the status of the details line and the selection history.
 *
 * @param settings
 *            settings used to restore dialog
 */
protected void restoreDialog(IDialogSettings settings) {
	boolean toggleStatusLine = true;

	if (settings.get(SHOW_STATUS_LINE) != null) {
		toggleStatusLine = settings.getBoolean(SHOW_STATUS_LINE);
	}

	toggleStatusLineAction.setChecked(toggleStatusLine);

	details.setVisible(toggleStatusLine);

	String setting = settings.get(HISTORY_SETTINGS);
	if (setting != null) {
		try {
			IMemento memento = XMLMemento.createReadRoot(new StringReader(
					setting));
			this.contentProvider.loadHistory(memento);
		} catch (WorkbenchException e) {
			// Simply don't restore the settings
			StatusManager
					.getManager()
					.handle(
							new Status(
									IStatus.ERROR,
									PlatformUI.PLUGIN_ID,
									IStatus.ERROR,
									WorkbenchMessages.FilteredItemsSelectionDialog_restoreError,
									e));
		}
	}
}
 
Example #30
Source File: AbstractNewProjectWizard.java    From typescript.java with MIT License 5 votes vote down vote up
private static void openInNewWindow(IPerspectiveDescriptor desc) {

		// Open the page.
		try {
			PlatformUI.getWorkbench().openWorkbenchWindow(desc.getId(), ResourcesPlugin.getWorkspace().getRoot());
		} catch (WorkbenchException e) {
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
			if (window != null) {
				ErrorDialog.openError(window.getShell(), WINDOW_PROBLEMS_TITLE, e.getMessage(), e.getStatus());
			}
		}
	}