Java Examples for org.eclipse.ui.PartInitException

The following java examples will help you to understand the usage of org.eclipse.ui.PartInitException. These source code samples are taken from different open source projects.

Example 1
Project: android-essentials-toolbox-master  File: OpenPermissionUsageViewHandler.java View source code
/**
	 * Opens the permission usage view
	 */
public Object execute(final ExecutionEvent event) throws ExecutionException {
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            try {
                IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
                IViewPart view = page.showView(PermissionUsageView.ID);
                page.activate(view);
            } catch (PartInitException e) {
                DisplayUtils.showError(e, "Could not load Permissin Usage View.");
            }
        }
    });
    return null;
}
Example 2
Project: erlide-master  File: OpenItemAction.java View source code
private IEditorPart openInEditor(final String name) {
    // search
    IErlModule module;
    try {
        module = ErlangEngine.getInstance().getModel().findModule(name);
    } catch (final ErlModelException e1) {
        e1.printStackTrace();
        return null;
    }
    log.info(module.getFilePath());
    final File fileToOpen = new File(module.getFilePath());
    final IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
    final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    try {
        final IEditorPart p = IDE.openEditorOnFileStore(page, fileStore);
        log.info(p.getClass());
        return p;
    } catch (final PartInitException e) {
        ErlLogger.error(e);
        return null;
    }
}
Example 3
Project: tcf-master  File: ShowConsoleViewCommandHandler.java View source code
/* (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // In Eclipse 4.x, the HandlerUtil.getActiveWorkbenchWindow(event) may return null
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    if (window == null)
        window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null && window.getActivePage() != null) {
        IWorkbenchPage page = window.getActivePage();
        try {
            //$NON-NLS-1$
            page.showView(//$NON-NLS-1$
            "org.eclipse.ui.console.ConsoleView", //$NON-NLS-1$
            null, //$NON-NLS-1$
            IWorkbenchPage.VIEW_VISIBLE);
        } catch (PartInitException /* Failure on part instantiation is ignored */
        e) {
        }
    }
    return null;
}
Example 4
Project: Eclipse-Postfix-Code-Completion-master  File: OpenBrowserUtil.java View source code
public void run() {
    URL helpSystemUrl = PlatformUI.getWorkbench().getHelpSystem().resolve(url.toExternalForm(), true);
    if (// can happen if org.eclipse.help.ui is not available
    helpSystemUrl == null) {
        // the resolve() method already wrote "Unable to instantiate help UI" to the log
        return;
    }
    try {
        IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser;
        if (useExternalBrowser)
            browser = browserSupport.getExternalBrowser();
        else
            browser = browserSupport.createBrowser(null);
        browser.openURL(helpSystemUrl);
    } catch (PartInitException ex) {
        JavaPlugin.logErrorStatus("Opening Javadoc failed", ex.getStatus());
    }
}
Example 5
Project: tdq-studio-se-master  File: PatternEditor.java View source code
@Override
protected void addPages() {
    //$NON-NLS-1$ 
    masterPage = new PatternMasterDetailsPage(this, ID, DefaultMessagesImpl.getString("PatternEditor.patternSettings"));
    // MOD qiongli 2011-3-21,bug 19472.set method 'setPartName(...)' behind method 'addPage(...)'
    try {
        addPage(masterPage);
        setPartName(masterPage.getIntactElemenetName());
    } catch (PartInitException e) {
        ExceptionHandler.process(e, Level.ERROR);
    }
    TdEditorToolBar toolbar = getToolBar();
    if (toolbar != null && masterPage != null) {
        saveAction = new DefaultSaveAction(this);
        toolbar.addActions(saveAction);
    }
}
Example 6
Project: cdt-tests-runner-master  File: ViewMemoryHandler.java View source code
private void showInMemoryView(ICVariable[] variables) {
    try {
        IWorkbenchPage page = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IViewPart newView = page.showView(IDebugUIConstants.ID_MEMORY_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE);
        IMemoryRenderingSite memSite = (IMemoryRenderingSite) newView;
        new AddMemoryBlocks().addMemoryBlocksForVariables(variables, memSite);
    } catch (ClassCastException e) {
        CDebugUIPlugin.log(e);
    } catch (PartInitException e) {
        CDebugUIPlugin.log(e);
    } catch (DebugException e) {
        CDebugUIPlugin.log(e);
    }
}
Example 7
Project: tern.java-master  File: NewJSWizard.java View source code
private void openEditor(final IFile file) {
    if (file != null) {
        fWorkbench.getDisplay().asyncExec(new Runnable() {

            public void run() {
                try {
                    IWorkbenchWindow activeWorkbenchWindow = fWorkbench.getActiveWorkbenchWindow();
                    if (activeWorkbenchWindow != null) {
                        IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
                        if (page != null) {
                            IDE.openEditor(page, file, true, false);
                        }
                    }
                } catch (PartInitException e) {
                    JavaScriptPlugin.log(e);
                }
            }
        });
    }
}
Example 8
Project: codemap-master  File: NewCodemapCreationWizard.java View source code
@Override
public boolean performFinish() {
    String containerName = page.getContainerPath();
    String fileName = page.getFilename();
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IResource resource = root.findMember(new Path(containerName));
    IContainer container = (IContainer) resource;
    final IFile file = container.getFile(new Path(fileName));
    try {
        InputStream stream = openContentStream();
        if (file.exists()) {
            file.setContents(stream, true, true, null);
        } else {
            file.create(stream, true, null);
        }
        stream.close();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            try {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
            } catch (PartInitException ex) {
                throw new RuntimeException(ex);
            }
        }
    });
    return true;
}
Example 9
Project: tmdm-studio-se-master  File: ValidateMarkerUtil.java View source code
@Override
public void run() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page != null && UIUtil.isMDMPerspective(page)) {
        IViewPart view = null;
        try {
            view = page.findView(MDMProblemView.VIEW_ID);
            if (view == null) {
                view = page.showView(MDMProblemView.VIEW_ID, null, IWorkbenchPage.VIEW_CREATE);
            }
            if (view != null) {
                ((MDMProblemView) view).updateViewTitle();
            }
        } catch (PartInitException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Example 10
Project: eclipse.jdt.ui-master  File: OpenBrowserUtil.java View source code
@Override
public void run() {
    URL helpSystemUrl = PlatformUI.getWorkbench().getHelpSystem().resolve(url.toExternalForm(), true);
    if (// can happen if org.eclipse.help.ui is not available
    helpSystemUrl == null) {
        // the resolve() method already wrote "Unable to instantiate help UI" to the log
        return;
    }
    try {
        IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser;
        if (useExternalBrowser)
            browser = browserSupport.getExternalBrowser();
        else
            browser = browserSupport.createBrowser(null);
        browser.openURL(helpSystemUrl);
    } catch (PartInitException ex) {
        JavaPlugin.logErrorStatus("Opening Javadoc failed", ex.getStatus());
    }
}
Example 11
Project: aws-toolkit-eclipse-master  File: OpenStackEditorAction.java View source code
public void run() {
    try {
        IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        activeWindow.getActivePage().openEditor(input, "com.amazonaws.eclipse.explorer.cloudformation.stackEditor");
    } catch (PartInitException e) {
        String errorMessage = "Unable to open the Amazon CloudFormation stack editor: " + e.getMessage();
        Status status = new Status(Status.ERROR, CloudFormationPlugin.PLUGIN_ID, errorMessage, e);
        StatusManager.getManager().handle(status, StatusManager.LOG);
    }
}
Example 12
Project: eclipse-integration-commons-master  File: OpenJavaFxBrowserFunction.java View source code
@Override
public void call(String url) {
    try {
        if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.EXTERNAL) {
            PlatformUI.getWorkbench().getBrowserSupport().createBrowser(null).openURL(new URL(url));
        } else {
            WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(url), SWT.NONE, url);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, JavaFxBrowserEditor.EDITOR_ID);
        }
    } catch (MalformedURLException e) {
        StatusManager.getManager().handle(new Status(IStatus.ERROR, BrowserPlugin.PLUGIN_ID, "Bad page url: " + url, e));
    } catch (PartInitException e) {
        StatusManager.getManager().handle(new Status(IStatus.ERROR, BrowserPlugin.PLUGIN_ID, "Could not find brwoser editor extension", e));
    }
}
Example 13
Project: platform_tools_motodev-master  File: ShowViewHandler.java View source code
/**
     * @see org.eclipse.core.commands.IHandler#execute(ExecutionEvent)
     */
public Object execute(ExecutionEvent event) throws ExecutionException {
    String viewId = event.getParameter(IHandlerConstants.ACTIVE_VIEW_PARAMETER);
    try {
        if (viewId.equals(AndroidView.ANDROID_VIEW_ID)) {
            info("Showing Main Display View by command execution");
            EclipseUtils.showView(MainDisplayView.EMULATOR_MAIN_DISPLAY_VIEW_ID);
        } else if (viewId.equals(MainDisplayView.EMULATOR_MAIN_DISPLAY_VIEW_ID)) {
            info("Showing Android View by command execution");
            EclipseUtils.showView(AndroidView.ANDROID_VIEW_ID);
        } else {
            info("User tried to open an unknown view. Ignoring the action.");
        }
    } catch (PartInitException e) {
        error("The views that were requested to be opened are not accessible programatically");
        EclipseUtils.showErrorDialog(EmulatorNLS.GEN_Error, EmulatorNLS.EXC_AndroidView_ViewNotFound);
    }
    return null;
}
Example 14
Project: xmind-master  File: ExternalWebBrowser.java View source code
public void openURL(URL url) throws PartInitException {
    String urlText = null;
    if (url != null)
        urlText = url.toExternalForm();
    // change spaces to "%20"
    if (urlText != null && !BrowserUtil.isWindows()) {
        //$NON-NLS-1$
        int index = urlText.indexOf(" ");
        while (index >= 0) {
            urlText = //$NON-NLS-1$
            urlText.substring(0, index) + "%20" + urlText.substring(index + 1);
            //$NON-NLS-1$
            index = urlText.indexOf(" ");
        }
    }
    //$NON-NLS-1$
    Program program = Program.findProgram("html");
    if (program != null) {
        if (program.execute(urlText))
            return;
    }
    if (!Program.launch(urlText))
        throw new PartInitException(NLS.bind(BrowserMessages.ExternalWebBrowser_ErrorCouldNotLaunchWebBrowser_message, url.toExternalForm()));
}
Example 15
Project: CodingSpectator-master  File: OpenBrowserUtil.java View source code
public void run() {
    URL helpSystemUrl = PlatformUI.getWorkbench().getHelpSystem().resolve(url.toExternalForm(), true);
    try {
        IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
        IWebBrowser browser;
        if (useExternalBrowser)
            browser = browserSupport.getExternalBrowser();
        else
            browser = browserSupport.createBrowser(null);
        browser.openURL(helpSystemUrl);
    } catch (PartInitException ex) {
        JavaPlugin.logErrorStatus("Opening Javadoc failed", ex.getStatus());
    }
}
Example 16
Project: substeps-eclipse-plugin-master  File: JunitTestResultsView.java View source code
@Override
public void showTestResultsView() {
    final IWorkbenchPage page = window.getActivePage();
    SubstepsFeatureTestRunnerViewPart testRunner = null;
    if (page != null) {
        try {
            // show the result view
            testRunner = (SubstepsFeatureTestRunnerViewPart) page.findView(SubstepsFeatureTestRunnerViewPart.NAME);
            if (testRunner == null) {
                final IWorkbenchPart activePart = page.getActivePart();
                testRunner = (SubstepsFeatureTestRunnerViewPart) page.showView(SubstepsFeatureTestRunnerViewPart.NAME, null, IWorkbenchPage.VIEW_VISIBLE);
                // restore focus
                page.activate(activePart);
            } else {
                page.bringToTop(testRunner);
            }
        } catch (final PartInitException pie) {
            FeatureRunnerPlugin.log(IStatus.ERROR, pie.getMessage());
        }
    }
}
Example 17
Project: WS171-development-master  File: MatchingStrategy.java View source code
public boolean matches(IEditorReference editorRef, IEditorInput input) {
    // first check that the file being opened is a layout file.
    if (input instanceof FileEditorInput) {
        FileEditorInput fileInput = (FileEditorInput) input;
        // get the IFile object and check it's in one of the layout folders.
        IFile iFile = fileInput.getFile();
        ResourceFolder resFolder = ResourceManager.getInstance().getResourceFolder(iFile);
        // file being currently edited by the editor since those are independent of the config.
        if (resFolder != null && resFolder.getType() == ResourceFolderType.LAYOUT) {
            try {
                IEditorInput editorInput = editorRef.getEditorInput();
                if (editorInput instanceof FileEditorInput) {
                    FileEditorInput editorFileInput = (FileEditorInput) editorInput;
                    IFile editorIFile = editorFileInput.getFile();
                    return editorIFile.getProject().equals(iFile.getProject()) && editorIFile.getName().equals(iFile.getName());
                }
            } catch (PartInitException e) {
            }
        }
    }
    return false;
}
Example 18
Project: teiid-designer-master  File: AddToMetadataFavoritesAction.java View source code
@Override
public void doRun() {
    Collection objs = new ArrayList(SelectionUtilities.getSelectedEObjects(getSelection()));
    try {
        IViewPart viewPart = UiUtil.getWorkbenchPage().showView(UiConstants.Extensions.FAVORITES_VIEW_ID);
        if (viewPart instanceof FavoritesView) {
            UiPlugin.getDefault().getEObjectCache().addAll(objs);
        //                ((FavoritesView)viewPart).addToClipboard(objs);
        }
    } catch (final PartInitException err) {
        UiConstants.Util.log(err);
        WidgetUtil.showError(err.getLocalizedMessage());
    }
}
Example 19
Project: warlock2-master  File: NewScriptWizard.java View source code
@Override
public boolean performFinish() {
    File scriptFile = new File(page1.getScriptDir(), page1.getScriptName() + page1.getScriptExt());
    try {
        File dir = scriptFile.getParentFile();
        if (!dir.exists()) {
            dir.mkdirs();
        }
        scriptFile.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    IFilesystemScriptProvider provider = (IFilesystemScriptProvider) ScriptEngineRegistry.getScriptProvider(IFilesystemScriptProvider.class);
    if (provider != null) {
        provider.forceScan();
    }
    IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(scriptFile);
    try {
        page.openEditor(new FileStoreEditorInput(fileStore), "org.eclipse.ui.DefaultTextEditor");
    } catch (PartInitException e) {
        e.printStackTrace();
    }
    return true;
}
Example 20
Project: eclipse-commons-master  File: EditorUtils.java View source code
/**
	 * Returns the editor in which the given file is open, if there is any.
	 */
public static IEditorPart getEditorWithFile(IFile file) {
    IEditorReference[] editorReferences = EditorUtils.getOpenEditors();
    for (IEditorReference editorReference : editorReferences) {
        IEditorInput editorInput;
        try {
            editorInput = editorReference.getEditorInput();
        } catch (PartInitException e) {
            continue;
        }
        if (editorInput instanceof FileEditorInput) {
            FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
            if (fileEditorInput.getFile().equals(file)) {
                return editorReference.getEditor(false);
            }
        }
    }
    return null;
}
Example 21
Project: windowtester-master  File: NewTargetFileWizard.java View source code
/* (non-Javadoc)
     * Method declared on IWizard.
     */
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) {
        ErrorHelper.openError(dw.getShell(), FILE_CREATION_ERROR_MSG, e.getMessage(), e);
    }
    return true;
}
Example 22
Project: cdt-master  File: OpenFiles.java View source code
/**
	 * This method opens a list of files in the editor
	 */
@Override
public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
    ProcessArgument[][] files = args[1].getComplexArrayValue();
    for (ProcessArgument[] file : files) {
        String fileTargetPath = file[0].getSimpleValue();
        String projectName = args[0].getSimpleValue();
        IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
        IFile iFile = projectHandle.getFile(fileTargetPath);
        if (iFile.exists()) {
            // Only open files if they are not open to avoid refresh problem if files have been modified multiple times
            if (!isOpen(iFile)) {
                try {
                    IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), iFile);
                } catch (PartInitException e) {
                    throw new ProcessFailureException(Messages.OpenFiles_CannotOpen_error + fileTargetPath);
                }
            }
        } else {
            throw new ProcessFailureException(Messages.OpenFiles_FileNotExist_error + fileTargetPath);
        }
    }
}
Example 23
Project: EclipseTrader-master  File: ChartOpenHandler.java View source code
/* (non-Javadoc)
     * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
     */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
    IWorkbenchSite site = HandlerUtil.getActiveSite(event);
    if (selection != null && !selection.isEmpty()) {
        for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
            Object target = iter.next();
            if (target instanceof IAdaptable) {
                target = ((IAdaptable) target).getAdapter(ISecurity.class);
            }
            if (target instanceof ISecurity) {
                ISecurity watchList = (ISecurity) target;
                try {
                    IStoreObject storeObject = (IStoreObject) watchList.getAdapter(IStoreObject.class);
                    IDialogSettings dialogSettings = UIActivator.getDefault().getDialogSettingsForView(storeObject.getStore().toURI());
                    site.getPage().showView(ChartViewPart.VIEW_ID, dialogSettings.getName(), IWorkbenchPage.VIEW_ACTIVATE);
                } catch (PartInitException e) {
                    Status status = new Status(IStatus.ERROR, UIActivator.PLUGIN_ID, 0, "Error opening chart", e);
                    UIActivator.log(status);
                }
            }
        }
    }
    return null;
}
Example 24
Project: c4jplugin-master  File: OpenTargetAction.java View source code
public void run(IAction action) {
    IEditorInput editorInput = null;
    try {
        editorInput = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
    } catch (NullPointerException e) {
        return;
    }
    IResource resource = JavaUI.getEditorInputJavaElement(editorInput).getResource();
    IResource target = ContractReferenceModel.getTarget(resource);
    if (target == null)
        return;
    IJavaElement element = JavaCore.create(target);
    try {
        JavaUI.openInEditor(element);
    } catch (PartInitException e) {
        C4JActivator.log(e);
    } catch (JavaModelException e) {
        C4JActivator.log(e);
    }
}
Example 25
Project: liferay-ide-master  File: EditPropertiesFileAction.java View source code
public void perform(Object entry) {
    if (entry instanceof PropertiesFile) {
        final PropertiesFile workflowEntry = (PropertiesFile) entry;
        final FileStoreEditorInput editorInput = new FileStoreEditorInput(workflowEntry.getFileStore());
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        try {
            page.openEditor(editorInput, LiferayPropertiesEditor.ID);
        } catch (PartInitException e) {
            LiferayServerUI.logError("Error opening properties editor.", e);
        }
    }
}