Search in sources :

Example 26 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project mdw-designer by CenturyLinkCloud.

the class AssetSearchQuery method openExternalEvent.

private void openExternalEvent(ExternalEvent eventHandler) {
    try {
        IWorkbenchPage page = MdwPlugin.getActivePage();
        ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
        if (processExplorer != null) {
            processExplorer.setFocus();
            processExplorer.select(eventHandler);
            page.showView("org.eclipse.ui.views.PropertySheet");
        }
    } catch (WorkbenchException ex) {
        PluginMessages.uiError(MdwPlugin.getShell(), ex, "Event Handler", eventHandler.getProject());
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 27 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project tdq-studio-se by Talend.

the class CreateNewAnalysisAction method run.

/*
     * (non-Jsdoc)
     * 
     * @see org.eclipse.ui.intro.config.IIntroAction#run(org.eclipse.ui.intro.IIntroSite, java.util.Properties)
     */
public void run(IIntroSite site, Properties params) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        // $NON-NLS-1$
        MessageDialog.openWarning(// $NON-NLS-1$
        null, // $NON-NLS-1$
        DefaultMessagesImpl.getString("CreateNewAnalysisAction.readOnlyErrorTitle"), // $NON-NLS-1$
        DefaultMessagesImpl.getString("CreateNewAnalysisAction.readOnlyErrorMessage"));
    } else {
        PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (null == workbenchWindow) {
            return;
        }
        IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
        if (null == workbenchPage) {
            return;
        }
        IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
        if (!IBrandingConfiguration.PERSPECTIVE_DQ_ID.equals(currentPerspective.getId())) {
            // show dq perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DQ_ID, workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return;
            }
        }
        run();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 28 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project tdq-studio-se by Talend.

the class PreferredPerspectivePartListener method refresh.

public static void refresh(final IWorkbenchPart part) {
    if (!(part instanceof IPrefersPerspective)) {
        return;
    }
    final IWorkbenchWindow workbenchWindow = part.getSite().getPage().getWorkbenchWindow();
    IPerspectiveDescriptor activePerspective = workbenchWindow.getActivePage().getPerspective();
    final List<String> preferredPerspectiveId = ((IPrefersPerspective) part).getPreferredPerspectiveId();
    if (preferredPerspectiveId == null || preferredPerspectiveId.size() < 1) {
        return;
    }
    if (activePerspective == null || !preferredPerspectiveId.contains(activePerspective.getId())) {
        // Switching of the perspective is delayed using Display.asyncExec because switching the perspective while
        // the workbench is activating parts might cause conflicts.
        Display.getCurrent().asyncExec(new Runnable() {

            public void run() {
                String perspectiveId = preferredPerspectiveId.get(0);
                // $NON-NLS-1$ //$NON-NLS-2$
                log.debug("Switching to preferred perspective " + perspectiveId + " for " + part.getClass());
                try {
                    workbenchWindow.getWorkbench().showPerspective(perspectiveId, workbenchWindow);
                } catch (WorkbenchException e) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    log.warn("Could not switch to preferred perspective " + perspectiveId + " for " + part.getClass(), e);
                }
            }
        });
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 29 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project abstools by abstools.

the class Debugger method startABSRuntime.

/**
 * Used to start the ABS Runtime. If an earlier Runtime is present, it is shut down first.
 *
 * @param projectName
 * @param mainClassName
 * @param genPath
 * @param debuggerArgsSystemObserver
 * @param debuggerArgsTotalScheduler
 * @param debuggerIsInDebugMode
 * @param debuggerArgsRandomSeed
 * @param fliClassPath
 * @param outStream
 * @param ignoreMissingFLIClasses
 * @param useFifoSemantics
 * @throws InvalidRandomSeedException
 */
public static void startABSRuntime(final String projectName, final String mainClassName, final Path genPath, String debuggerArgsSystemObserver, String debuggerArgsTotalScheduler, boolean debuggerIsInDebugMode, String debuggerArgsRandomSeed, boolean terminateOnException, List<URL> fliClassPath, PrintStream outStream, PrintStream errStream, boolean ignoreMissingFLIClasses, boolean useFifoSemantics) throws InvalidRandomSeedException {
    if (DO_DEBUG)
        System.out.println("start internal debugger");
    final ABSRuntime r = new ABSRuntime();
    if (debuggerIsInDebugMode)
        r.enableDebugging(true);
    r.setOutStream(outStream);
    r.setErrStream(errStream);
    r.addFLIClassPath(fliClassPath);
    r.setIgnoreMissingFLIClasses(ignoreMissingFLIClasses);
    if (useFifoSemantics) {
        r.setScheduableTasksFilter(new ScheduableTasksFilterFifo());
    }
    r.terminateOnException(terminateOnException);
    boolean useOurScheduling = addSchedulingStrategy(debuggerArgsTotalScheduler, r);
    final boolean useOurSystemObserver = addSystemObservers(debuggerArgsSystemObserver, r);
    if (debuggerArgsRandomSeed != null && !debuggerArgsRandomSeed.isEmpty()) {
        String seedString = debuggerArgsRandomSeed.replace("-Dabs.randomseed=", "");
        Long seedNumber = getSeed(seedString);
        r.setRandomSeed(seedNumber);
    }
    final ThreadGroup tg = new ThreadGroup("ABS " + mainClassName);
    tg.setDaemon(true);
    final Thread debuggerRunner = new Thread(tg, new Runnable() {

        @Override
        public void run() {
            try {
                if (DO_DEBUG) {
                    System.out.println("Start ABSRuntime .. ");
                    System.out.println("path: " + genPath.toString());
                    System.out.println("name:" + mainClassName);
                }
                r.start(genPath.toFile(), mainClassName);
            } catch (ClassNotFoundException e) {
                exceptionHandling(e);
            } catch (InstantiationException e) {
                exceptionHandling(e);
            } catch (IllegalAccessException e) {
                exceptionHandling(e);
            }
        }

        private void exceptionHandling(final Exception e) {
            standardExceptionHandling(e);
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    showErrorMessage("Not able to start ABSRuntime.\n" + e.getMessage());
                }
            });
        }
    });
    if (useOurScheduling) {
        enableHightlighting();
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                try {
                    PlatformUI.getWorkbench().showPerspective(ABSDEBUGPERSPECTIVE_ID, PlatformUI.getWorkbench().getActiveWorkbenchWindow());
                    getDebugger().initDebugger(projectName, r, debuggerRunner, useOurSystemObserver);
                    if (DebugUtils.getRunAutomatically()) {
                        DebugUtils.getSchedulerRef().resumeAutomaticScheduling();
                    }
                } catch (WorkbenchException e) {
                    standardExceptionHandling(e);
                    showErrorMessage("Could not open ABS debug perspective");
                }
            }
        });
    } else {
        debuggerRunner.start();
    }
}
Also used : ScheduableTasksFilterFifo(abs.backend.java.scheduling.ScheduableTasksFilterFifo) WorkbenchException(org.eclipse.ui.WorkbenchException) WorkbenchException(org.eclipse.ui.WorkbenchException) ABSException(abs.backend.java.lib.runtime.ABSException) ABSRuntime(abs.backend.java.lib.runtime.ABSRuntime)

Example 30 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project hale by halestudio.

the class ShowLayoutMenuHandler method execute.

/**
 * @see IHandler#execute(ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IViewPart viewPart = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().findView(StyledMapView.ID);
    if (viewPart instanceof MapView) {
        // view visible - show layout menu
        final MenuManager manager = new MenuManager();
        manager.setRemoveAllWhenShown(true);
        final IconPainterLayoutContribution contribution = new IconPainterLayoutContribution();
        manager.addMenuListener(new IMenuListener() {

            @Override
            public void menuAboutToShow(IMenuManager manager) {
                // populate context menu
                manager.add(contribution);
            }
        });
        Shell shell = HandlerUtil.getActiveShell(event);
        final Menu menu = manager.createContextMenu(shell);
        // determine location
        Point cursorLocation = Display.getCurrent().getCursorLocation();
        // default to cursor location
        Point location = cursorLocation;
        // try to determine from control
        Control cursorControl = Display.getCurrent().getCursorControl();
        if (cursorControl != null) {
            if (cursorControl instanceof ToolBar) {
                ToolBar bar = (ToolBar) cursorControl;
                ToolItem item = bar.getItem(bar.toControl(cursorLocation));
                if (item != null) {
                    Rectangle bounds = item.getBounds();
                    location = bar.toDisplay(bounds.x, bounds.y + bounds.height);
                }
            } else {
                // show below control
                location = cursorControl.toDisplay(0, cursorControl.getSize().y);
            }
        }
        menu.setLocation(location);
        menu.addMenuListener(new MenuListener() {

            @Override
            public void menuShown(MenuEvent e) {
            // do nothing
            }

            @Override
            public void menuHidden(MenuEvent e) {
                Display.getCurrent().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        /*
							 * Dispose everything as it is used only once. Done
							 * asynchronously as otherwise we interfere with the
							 * menu click handling.
							 */
                        manager.dispose();
                        contribution.dispose();
                        menu.dispose();
                    }
                });
            }
        });
        // show menu
        menu.setVisible(true);
    } else {
        // view not visible - just show map perspective
        try {
            PlatformUI.getWorkbench().showPerspective(StyledMapPerspective.ID, HandlerUtil.getActiveWorkbenchWindow(event));
        } catch (WorkbenchException e) {
            log.error("Could not open map perspective", e);
        }
    }
    return null;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) MenuListener(org.eclipse.swt.events.MenuListener) IMenuListener(org.eclipse.jface.action.IMenuListener) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) WorkbenchException(org.eclipse.ui.WorkbenchException) IMenuListener(org.eclipse.jface.action.IMenuListener) Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolBar(org.eclipse.swt.widgets.ToolBar) StyledMapView(eu.esdihumboldt.hale.ui.views.styledmap.StyledMapView) MapView(de.fhg.igd.mapviewer.view.MapView) IconPainterLayoutContribution(eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.IconPainterLayoutContribution) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

WorkbenchException (org.eclipse.ui.WorkbenchException)37 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)16 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)15 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)11 IMemento (org.eclipse.ui.IMemento)7 IOException (java.io.IOException)6 IWorkbench (org.eclipse.ui.IWorkbench)5 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)5 StringReader (java.io.StringReader)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)2 BufferedReader (java.io.BufferedReader)2