org.eclipse.ui.PartInitException Java Examples

The following examples show how to use org.eclipse.ui.PartInitException. 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 Project: erflute   Author: dbflute-session   File: ERFluteMultiPageEditor.java    License: Apache License 2.0 6 votes vote down vote up
public void initVirtualPage() { // called by ERDiagram
    final String diagramName = diagram.getDefaultDiagramName();
    if (diagramName != null) {
        try {
            final int pageIndex = removePage(diagramName);

            final ERVirtualDiagram vdiagram = diagram.getDiagramContents().getVirtualDiagramSet().getVdiagramByName(diagramName);
            diagram.setCurrentVirtualDiagram(vdiagram);

            final VirtualDiagramEditor vdiagramEditor =
                    new VirtualDiagramEditor(diagram, vdiagram, editPartFactory, zoomComboContributionItem, outlinePage);
            addPage(getNewPageIndexIfLessThanZero(pageIndex), vdiagramEditor, getEditorInput());
            setPageText(getNewPageIndexIfLessThanZero(pageIndex), Format.null2blank(vdiagram.getName()));
        } catch (final PartInitException e) {
            Activator.showExceptionDialog(e);
        }
    }
}
 
Example #2
Source Project: APICloud-Studio   Author: apicloudcom   File: WorkspaceAction.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Most SVN workspace actions modify the workspace and thus should
 * save dirty editors.
 * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors()
 */
protected boolean needsToSaveDirtyEditors() {

	IResource[] selectedResources = getSelectedResources();
	if (selectedResources != null && selectedResources.length > 0) {
		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
		for (IEditorReference editorReference : editorReferences) {
			if (editorReference.isDirty()) {
				try {
					IEditorInput editorInput = editorReference.getEditorInput();
					if (editorInput instanceof IFileEditorInput) {
						IFile file = ((IFileEditorInput)editorInput).getFile();
						if (needsToSave(file, selectedResources)) {
							return true;
						}
					}
				} catch (PartInitException e) {}
			}
		}
	}
	
	return false;
}
 
Example #3
Source Project: n4js   Author: eclipse   File: AbstractOutlineWorkbenchTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void openOutlineView() throws PartInitException, InterruptedException {
	outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof OutlinePage);
	outlinePage = new SyncableOutlinePage((OutlinePage) adapter);
	outlinePage.resetSyncer();
	try {
		outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
	} catch (TimeoutException e) {
		System.out.println("Expected timeout exceeded: " + EXPECTED_TIMEOUT);// timeout is OK here
	}
	treeViewer = outlinePage.getTreeViewer();
	assertSelected(treeViewer);
	assertExpanded(treeViewer);
	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	List<IOutlineNode> children = rootNode.getChildren();
	assertEquals(1, children.size());
	modelNode = children.get(0);
}
 
Example #4
Source Project: n4js   Author: eclipse   File: EclipseUIUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/** Opens given file in a editor with given ID within given workbench page. Returns opened editor on null. */
public static IEditorPart openFileEditor(final IFile file, final IWorkbenchPage page, String editorId) {
	checkNotNull(file, "Provided file was null.");
	checkNotNull(page, "Provided page was null.");
	checkNotNull(editorId, "Provided editor ID was null.");

	AtomicReference<IEditorPart> refFileEditor = new AtomicReference<>();

	UIUtils.getDisplay().syncExec(new Runnable() {

		@Override
		public void run() {
			try {
				refFileEditor.set(IDE.openEditor(page, file, editorId, true));
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
	});
	return refFileEditor.get();
}
 
Example #5
Source Project: xtext-xtend   Author: eclipse   File: OpenEditorAction.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void run() {
	if (inputFile == null) {
		return;
	}
	IWorkbenchPartSite workbenchPartSite = derivedSourceView.getSite();
	IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
	try {
		IEditorPart editorPart = workbenchPage.openEditor(new FileEditorInput(inputFile),
				COMPILATION_UNIT_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
		if (selectedRegion != null) {
			((ITextEditor) editorPart).selectAndReveal(selectedRegion.getOffset(), selectedRegion.getLength());
		}
	} catch (PartInitException partInitException) {
		throw new WrappedRuntimeException(partInitException);
	}

}
 
Example #6
Source Project: n4js   Author: eclipse   File: N4IDEXpectRunListener.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Called when an atomic test fails.
 *
 * @param failure
 *            describes the test that failed and the exception that was thrown
 */
@Override
public void testFailure(Failure failure) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
Example #7
Source Project: n4js   Author: eclipse   File: N4IDEXpectRunListener.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Called when an atomic test flags that it assumes a condition that is false
 *
 * describes the test that failed and the {@link AssumptionViolatedException} that was thrown
 */
@Override
public void testAssumptionFailure(Failure failure) {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
Example #8
Source Project: n4js   Author: eclipse   File: XpectCompareCommandHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
Example #9
Source Project: xtext-eclipse   Author: eclipse   File: MarkerResolutionGenerator.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Deprecated
public IXtextDocument getXtextDocument(IResource resource) {
	IXtextDocument result = xtextDocumentUtil.getXtextDocument(resource);
	if(result == null) {
		IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
		try {
			IFile file = ResourceUtil.getFile(resource);
			IEditorInput input = new FileEditorInput(file);
			IEditorPart newEditor = page.openEditor(input, getEditorId());
			return xtextDocumentUtil.getXtextDocument(newEditor);
		} catch (PartInitException e) {
			return null;
		}
	}
	return result;
}
 
Example #10
Source Project: dsl-devkit   Author: dsldevkit   File: AbstractUiTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Opens the editor asynchronously.
 *
 * @param file
 *          the file
 * @param editorId
 *          the editor id
 * @param activate
 *          true to activate, false otherwise
 */
protected void openEditorAsync(final IFile file, final String editorId, final boolean activate) {
  asyncExec(new VoidResult() {
    @Override
    public void run() {
      try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
        final int matchFlags = IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT;
        final IEditorInput input = new FileEditorInput(file);
        IEditorPart editor = activePage.openEditor(input, editorId, activate, matchFlags);
        editor.setFocus();
        waitForEditorJobs(editor);
      } catch (PartInitException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e.getMessage(), e);
        }
      }
    }
  });
}
 
Example #11
Source Project: neoscada   Author: eclipse   File: AbstractItemAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run ( final IAction action )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, this.message, null );
    for ( final Item item : this.items )
    {
        try
        {
            processItem ( item );
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
    if ( !status.isOK () )
    {
        showError ( status );
    }
}
 
Example #12
Source Project: xds-ide   Author: excelsior-oss   File: ModulaSearchResultPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void showMatch( Match match, int currentOffset
                        , int currentLength, boolean activate 
                        ) throws PartInitException 
{
    if (match instanceof ModulaSymbolMatch) {
        try {
            ModulaSymbolMatch em = (ModulaSymbolMatch)match;
            IFile f = em.getFile();
            IWorkbenchPage page = WorkbenchUtils.getActivePage();
            IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(f.getName());
            IEditorPart ep = page.openEditor(new FileEditorInput(f), desc.getId());
            ITextEditor te = (ITextEditor)ep;
            Control ctr = (Control)te.getAdapter(Control.class);
            ctr.setFocus();
            te.selectAndReveal(em.getOffset(), em.getLength());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example #13
Source Project: solidity-ide   Author: Yakindu   File: NewFileWizard.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean performFinish() {
	IFile file = mainPage.createNewFile();
	if (file == null) {
		return false;
	}

	selectAndReveal(file);

	// Open editor on new file.
	IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
	try {
		if (dw != null) {
			IWorkbenchPage page = dw.getActivePage();
			if (page != null) {
				IDE.openEditor(page, file, true);
			}
		}
	} catch (PartInitException e) {
		openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
	}

	return true;
}
 
Example #14
Source Project: neoscada   Author: eclipse   File: AbstractAlarmsEventsView.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
    if ( memento != null )
    {
        this.connectionId = memento.getString ( CONNECTION_ID );
        this.connectionUri = memento.getString ( CONNECTION_URI );
    }

    super.init ( site, memento );
    try
    {
        // it is OK to fail at this stage
        reInitializeConnection ( this.connectionId, this.connectionUri );
    }
    catch ( final Exception e )
    {
        logger.warn ( "init () - couldn't recreate connection", e ); //$NON-NLS-1$
        // just reset all values
        this.connectionId = null;
        this.connectionUri = null;
        this.connectionService = null;
        this.connectionTracker = null;
    }
}
 
Example #15
Source Project: tm4e   Author: eclipse   File: TMinGenericEditorTest.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testTMHighlightInGenericEditorEdit() throws IOException, PartInitException {
	f = File.createTempFile("test" + System.currentTimeMillis(), ".ts");
	FileOutputStream fileOutputStream = new FileOutputStream(f);
	fileOutputStream.write("let a = '';".getBytes());
	fileOutputStream.close();
	f.deleteOnExit();
	editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
			f.toURI(), editorDescriptor.getId(), true);
	StyledText text = (StyledText)editor.getAdapter(Control.class);
	Assert.assertTrue(new DisplayHelper() {
		@Override
		protected boolean condition() {
			return text.getStyleRanges().length > 1;
		}
	}.waitForCondition(text.getDisplay(), 3000));
	int initialNumberOfRanges = text.getStyleRanges().length;
	text.setText("let a = '';\nlet b = 10;\nlet c = true;");
	Assert.assertTrue("More styles should have been added", new DisplayHelper() {
		@Override protected boolean condition() {
			return text.getStyleRanges().length > initialNumberOfRanges + 3;
		}
	}.waitForCondition(text.getDisplay(), 300000));
}
 
Example #16
Source Project: LogViewer   Author: anb0s   File: LogDocument.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public LogDocument(LogFile file, String encoding) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, PartInitException {
	super();
	if (file.getEncoding() == null) {
		file.setEncoding(encoding);
	}
	this.file = file;
	this.encoding = file.getEncoding();
	this.charset = Charset.forName(file.getEncoding());
	IPreferenceStore store = LogViewerPlugin.getDefault().getPreferenceStore();
	store.addPropertyChangeListener(new PropertyChangeListener());
	backlogLines = store.getInt(ILogViewerConstants.PREF_BACKLOG);
	setTextStore(new GapTextStore(50, 300, 1f));
	setLineTracker(new DefaultLineTracker());
	completeInitialization();
	reader = new BackgroundReader(file.getType(), file.getPath(), file.getNamePattern(), charset,this);
}
 
Example #17
Source Project: gef   Author: eclipse   File: SyncGraphvizExportHandler.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void openFile(IFile file) {
	IEditorRegistry registry = PlatformUI.getWorkbench()
			.getEditorRegistry();
	if (registry.isSystemExternalEditorAvailable(file.getName())) {

		/**
		 * in case of opening the exported file from an other thread e.g. in
		 * case of listening to an IResourceChangeEvent
		 */
		Display.getDefault().asyncExec(new Runnable() {

			@Override
			public void run() {
				IWorkbenchPage page = PlatformUI.getWorkbench()
						.getActiveWorkbenchWindow().getActivePage();
				try {
					page.openEditor(new FileEditorInput(file),
							IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
				} catch (PartInitException e) {
					DotActivatorEx.logError(e);
				}
			}
		});
	}
}
 
Example #18
Source Project: workspacemechanic   Author: alfsch   File: ShowViewScanner.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void run() {
  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      IWorkbench workbench = PlatformUI.getWorkbench();
      IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
      IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
      for (String viewId : list) {
        try {
          activePage.showView(viewId);
        } catch (PartInitException e) {
          LOG.log(Level.SEVERE, "Can't open view " + viewId, e);
        }
      }
    }
  });
}
 
Example #19
Source Project: corrosion   Author: eclipse   File: RustManager.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static LSPDocumentInfo infoFromOpenEditors() {
	for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
		for (IWorkbenchPage page : window.getPages()) {
			for (IEditorReference editor : page.getEditorReferences()) {
				IEditorInput input;
				try {
					input = editor.getEditorInput();
				} catch (PartInitException e) {
					continue;
				}
				if (input.getName().endsWith(".rs") && editor.getEditor(false) instanceof ITextEditor) { //$NON-NLS-1$
					IDocument document = (((ITextEditor) editor.getEditor(false)).getDocumentProvider())
							.getDocument(input);
					Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor(document,
							capabilities -> Boolean.TRUE.equals(capabilities.getReferencesProvider()));
					if (!infos.isEmpty()) {
						return infos.iterator().next();
					}
				}
			}
		}
	}
	return null;
}
 
Example #20
Source Project: gama   Author: gama-platform   File: FileOpener.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static IEditorPart openFile(final URI uri) {
	if (uri == null) {
		MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found", "Trying to open a null file");
		return null;
	}
	try {
		if (uri.isPlatformResource()) { return FileOpener.openFileInWorkspace(uri); }
		if (uri.isFile()) { return FileOpener.openFileInFileSystem(uri); }
	} catch (final PartInitException e) {
		MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found",
				"The file'" + uri.toString() + "' does not exist on disk.");
	}
	MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found",
			"The file'" + uri.toString() + "' cannot be found.");
	return null;
}
 
Example #21
Source Project: txtUML   Author: ELTE-Soft   File: Exporter.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Opens visualize.html in the default browser
 * 
 * @throws PartInitException
 * @throws MalformedURLException
 */
private void display() throws PartInitException, MalformedURLException {
	// set to use external browser due to internal browser bug
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=501978
	final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();
	browser.openURL(Paths.get(target, FILE_TO_OPEN_IN_BROWSER).toUri().toURL());
}
 
Example #22
Source Project: statecharts   Author: Yakindu   File: NavigatorActionProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void run() {
	if (myDiagram == null || myDiagram.eResource() == null) {
		return;
	}

	IEditorInput editorInput = getEditorInput();
	IWorkbenchPage page = myViewerSite.getPage();
	try {
		page.openEditor(editorInput, ID);
	} catch (PartInitException e) {

		e.printStackTrace();
	}
}
 
Example #23
Source Project: codewind-eclipse   Author: eclipse   File: WelcomePageEditorPart.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (!(input instanceof WelcomePageEditorInput)) {
		Logger.logError("The editor input is not valid for the welcome page: " + input.getClass()); //$NON-NLS-1$
       	throw new PartInitException(Messages.WelcomePageEditorCreateError);
	}
	
	setSite(site);
       setInput(input);
       
       setPartName(Messages.WelcomePageEditorPartName);
       
       CodewindUIPlugin.getUpdateHandler().addUpdateListener(this);
}
 
Example #24
Source Project: spotbugs   Author: spotbugs   File: GroupByActionTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testAction_Project_Priority_Category_PatternType_Pattern_Marker() throws PartInitException {
    runAction(PROJECT_PRIORITY_CATEGORY_PATTERN_TYPE_PATTERN_MARKER_ID);

    assertExpectedGroupTypes(GroupType.Project, GroupType.Confidence, GroupType.Category, GroupType.PatternType,
            GroupType.Pattern, GroupType.Marker);
}
 
Example #25
Source Project: APICloud-Studio   Author: apicloudcom   File: APICloudWizardEditor.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input)
		throws PartInitException {
	setSite(site);
	setInput(input);
	initInfo();
}
 
Example #26
Source Project: LogViewer   Author: anb0s   File: ConsoleOpenAction.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {

	if (!isEnabled()) {
		MessageDialog.openInformation(
			new Shell(),
			"Logfile Viewer",
			"Wrong Selection");
		return;
	}

	for (int i=0;i<resource.length;i++) {

		if (resource[i] == null)
			continue;

		String full_path = resource[i].getClass().toString().replaceFirst("class ", "") + System.getProperty("file.separator") + resource[i].getName();
		LogViewer view = null;

		try {
			view = (LogViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("de.anbos.eclipse.logviewer.plugin.LogViewer");
		} catch (PartInitException e) {
			e.printStackTrace();
		}

		view.checkAndOpenFile(LogFileType.LOGFILE_ECLIPSE_CONSOLE, full_path, null, false);
	}
}
 
Example #27
Source Project: typescript.java   Author: angelozerr   File: AbstractFormEditor.java    License: MIT License 5 votes vote down vote up
@Override
protected void addPages() {
	this.jsonEditor = new StructuredTextEditor();
	jsonEditor.setEditorPart(this);
	try {
		// Add pages like overview, etc
		doAddPages();
		// Add source page
		jsonEditorIndex = addPage(jsonEditor, getEditorInput());
		setPageText(jsonEditorIndex, "Source");
	} catch (PartInitException e) {
		e.printStackTrace();
	}
}
 
Example #28
Source Project: xds-ide   Author: excelsior-oss   File: XBookmarkHandler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Jumps to the xBookmark with the given number, if there is one.
 * When necessary an editor will be opened.
 * If there are multiple marks with the same number then the previous/next
 * one from the current selection will be jumped to (when exactly on
 * a xBookmark that mark isn't considered as a jump target).
 * If after any xBookmark with that number, the search toggles around
 * to the first one and vice versa.
 * 
 * @param markerNumber  the number of the mark to jump to
 * @param backward  true, if the previous mark should be jumped to instead
 *                  of the next one
 */
protected void gotoBookmark (int markerNumber) {
    IResource scope = XBookmarksUtils.getWorkspaceScope();
    if (scope == null) {
        return;
    }
    IMarker marker = XBookmarksUtils.fetchBookmark(scope, markerNumber);
    if (marker == null) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_BM_NotFound, markerNumber));
        return;
    }
    IResource resource = marker.getResource();
    if (! (resource instanceof IFile)) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_BM_HbzWhere, markerNumber));
        return;
    }
    IWorkbenchPage page = WorkbenchUtils.getActivePage();
    if (page == null) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_CantGoBM_NoActivePage, markerNumber));
        return;
    }
    // now try to jump and open the right editor, if necessary
    try {
        IDE.openEditor(page, marker, OpenStrategy.activateOnOpen());
        statusLine.showMessage(
                MessageFormat.format(Messages.BookmarkAction_OnBM, markerNumber),
                XBookmarksPlugin.IMGID_GOTO);
    }
    catch (PartInitException e) {
        XBookmarksUtils.logError(e);
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_CantGoBM, markerNumber));
    }
}
 
Example #29
Source Project: depan   Author: google   File: NodeListEditor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input)
    throws PartInitException {
  setSite(site);
  setInput(input);
  initFromInput(input);
}
 
Example #30
Source Project: texlipse   Author: eclipse   File: ViewerOutputScanner.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void run() {
    
    IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
    if (page == null) {
        return;
    }
    
    try {
        IDE.openEditor(page, marker, false);
    } catch (PartInitException e) {
    }
}