當前位置: 首頁>>代碼示例>>Java>>正文


Java WorkbenchException類代碼示例

本文整理匯總了Java中org.eclipse.ui.WorkbenchException的典型用法代碼示例。如果您正苦於以下問題:Java WorkbenchException類的具體用法?Java WorkbenchException怎麽用?Java WorkbenchException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WorkbenchException類屬於org.eclipse.ui包,在下文中一共展示了WorkbenchException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProjectExplorerView

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * Gets the projects explorer view.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return ProjectExplorerView : the explorer view of Convertigo Plugin
 */
public ProjectExplorerView getProjectExplorerView() {
	ProjectExplorerView projectExplorerView = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		IViewPart viewPart =  activePage.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
		if (viewPart != null)
			projectExplorerView = (ProjectExplorerView)viewPart;
		else {
			IWorkbench workbench = PlatformUI.getWorkbench();
			try {
				IWorkbenchPage page = workbench.showPerspective(ConvertigoPlugin.PLUGIN_PERSPECTIVE_ID, workbench.getActiveWorkbenchWindow());
				viewPart =  page.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView");
				if (viewPart != null) {
					projectExplorerView = (ProjectExplorerView)viewPart;
				}
			} catch (WorkbenchException e) {}
		}
	}
	return projectExplorerView;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:26,代碼來源:ConvertigoPlugin.java

示例2: switchAndResetPerspective

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * 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();
      }
    }
  });
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:29,代碼來源:CoreSwtbotTools.java

示例3: openPerspectiveInNewWindow

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:30,代碼來源:UIHelper.java

示例4: resetWorkbench

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:27,代碼來源:RCPTestSetupHelper.java

示例5: init

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	super.init(site, memento);
	String persistedMemento = JSBuildFileUIPlugin.getDefault()
			.getDialogSettingsSection(getClass().getName()).get("memento"); //$NON-NLS-1$
	if (persistedMemento != null) {
		try {
			memento = XMLMemento.createReadRoot(new StringReader(
					persistedMemento));
		} catch (WorkbenchException e) {
			// don't do anything. Simply don't restore the settings
		}
	}
	if (memento != null) {
		restoreViewerInput(memento);
		/*
		 * IMemento child = memento.getChild(TAG_FILTER_INTERNAL_TARGETS);
		 * if (child != null) { filterInternalTargets =
		 * Boolean.valueOf(child.getString(KEY_VALUE)).booleanValue(); }
		 */
	}
}
 
開發者ID:angelozerr,項目名稱:jsbuild-eclipse,代碼行數:23,代碼來源:JSBuildFileView.java

示例6: getProjectPaths

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * Load the project paths associated with the given branch. These paths will
 * be relative to the repository root.
 *
 * @param branch
 * @return non-null but possibly empty array of projects
 */
public String[] getProjectPaths(final String branch) {
	String pref = getPreference(branch);
	String value = Activator.getDefault().getPreferenceStore()
			.getString(pref);
	if (value.length() == 0)
		return new String[0];
	XMLMemento memento;
	try {
		memento = XMLMemento.createReadRoot(new StringReader(value));
	} catch (WorkbenchException e) {
		Activator.logError("Error reading branch-project associations", e); //$NON-NLS-1$
		return new String[0];
	}
	IMemento[] children = memento.getChildren(KEY_PROJECT);
	if (children.length == 0)
		return new String[0];
	List<String> projects = new ArrayList<String>(children.length);
	for (int i = 0; i < children.length; i++) {
		String path = children[i].getTextData();
		if (path != null && path.length() > 0)
			projects.add(path);
	}
	return projects.toArray(new String[projects.size()]);
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:32,代碼來源:BranchProjectTracker.java

示例7: testLoad

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
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\">[email protected]#</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>"));
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:24,代碼來源:IndexedJsniJavaRefTest.java

示例8: testLoad

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
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\">[email protected]#</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>"));
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:18,代碼來源:JsniJavaRefParamTypeTest.java

示例9: execute

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * Creates the new rule on the ZXTM.
 */
/* Override */
protected void execute( IProgressMonitor monitor ) throws CoreException,
   InvocationTargetException, InterruptedException
{
   if( monitor == null ) monitor = new EmptyMonitor();
   monitor.beginTask( ZLang.bind( ZLang.ZL_AddingNewRuleTo, zxtm ), 1 );
   monitor.subTask( "" );
   
   try {
      zxtm.addRule( name );         
   } catch( ModelException e ) {
      throw new WorkbenchException( e.getLocalizedMessage(), e );
   }     
   
   monitor.worked( 1 );
   monitor.done();
}
 
開發者ID:brocade,項目名稱:vTM-eclipse,代碼行數:21,代碼來源:NewRuleOp.java

示例10: execute

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
/**
 * Attempts to update the password, throws an exception if it fails.
 */
/* Override */
protected void execute( IProgressMonitor monitor ) throws CoreException,
   InvocationTargetException, InterruptedException
{
   if( monitor == null ) monitor = new EmptyMonitor();
   monitor.beginTask( ZLang.bind( ZLang.ZL_ChangingPasswordForZXTM, zxtm ), 2 );
   monitor.subTask( ZLang.ZL_ConnectingToZXTM );
   
   try {
      synchronized( ZXTMPlugin.getDefault().getProjectManager() ) {
         zxtm.setUserAndPassword( user, password );
         zxtm.setStorePassword( store );  
         monitor.worked( 1 );           
                 
         monitor.subTask( ZLang.ZL_UpdatingProjectSettings );            
         ZXTMPlugin.getDefault().getProjectManager().update( false );
         monitor.worked( 1 );
      }
      
   } catch( Exception e ) {
      throw new WorkbenchException( e.getLocalizedMessage(), e );
   }     
   monitor.done();
}
 
開發者ID:brocade,項目名稱:vTM-eclipse,代碼行數:28,代碼來源:ChangeZXTMAuthOp.java

示例11: showRawDataView

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
private RawDataView showRawDataView() {

		final IWorkbench workbench = PlatformUI.getWorkbench();
		final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

		try {

			final IViewPart rawDataView = window.getActivePage().findView(RawDataView.ID);

			if (rawDataView == null) {

				// show raw data perspective when raw data view is not visible
				workbench.showPerspective(PerspectiveFactoryRawData.PERSPECTIVE_ID, window);
			}

			// show raw data view
			return (RawDataView) Util.showView(RawDataView.ID, true);

		} catch (final WorkbenchException e) {
			TourLogManager.logEx(e);
		}
		return null;
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:24,代碼來源:RawDataManager.java

示例12: run

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:19,代碼來源:OpenJavaBrowsingPerspectiveAction.java

示例13: run

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:19,代碼來源:OpenJavaPerspectiveAction.java

示例14: init

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
@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();
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:24,代碼來源:PackageExplorerPart.java

示例15: openInPerspective

import org.eclipse.ui.WorkbenchException; //導入依賴的package包/類
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;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:27,代碼來源:OpenTypeHierarchyUtil.java


注:本文中的org.eclipse.ui.WorkbenchException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。