Search in sources :

Example 6 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project core by jcryptool.

the class ShowPluginViewHandler method execute.

public Object execute(ExecutionEvent event) {
    try {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        page.showView(viewId);
        if (viewId.contains("org.jcryptool.games") || viewId.contains("org.jcryptool.visual")) {
            // $NON-NLS-1$ //$NON-NLS-2$
            page.setPartState(page.getActivePartReference(), IWorkbenchPage.STATE_MAXIMIZED);
        }
    } catch (WorkbenchException ex) {
        LogUtil.logError(CorePlugin.PLUGIN_ID, ex);
    }
    return (null);
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 7 with WorkbenchException

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

the class NewDataModelAction method run.

public void run(IIntroSite site, Properties params) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(null, Messages.NewDataModelAction_UserAuthority, Messages.NewDataModelAction_CanNotCreateModel);
    } 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_MDM_ID.equals(currentPerspective.getId())) {
            // show mdm perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_MDM_ID, workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return;
            }
        }
        // 
        // $NON-NLS-1$
        IRepositoryViewObject folderViewObj = ContainerCacheService.get(IServerObjectRepositoryType.TYPE_DATAMODEL, "");
        selectObj = folderViewObj;
        if (folderViewObj != null && folderViewObj instanceof FolderRepositoryObject) {
            Item pItem = folderViewObj.getProperty().getItem();
            if (pItem instanceof ContainerItem) {
                setParentItem((ContainerItem) pItem);
            }
        }
        run();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 8 with WorkbenchException

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

the class CommitMessageHistory method getCommitHistory.

/**
 * @return saved commit messages
 */
public static Set<String> getCommitHistory() {
    String all = getPreferenceStore().getString(UIPreferences.COMMIT_DIALOG_HISTORY_MESSAGES);
    if (all.length() == 0)
        return Collections.emptySet();
    int max = getCommitHistorySize();
    if (max < 1)
        return Collections.emptySet();
    XMLMemento memento;
    try {
        memento = XMLMemento.createReadRoot(new StringReader(all));
    } catch (WorkbenchException e) {
        org.eclipse.egit.ui.Activator.logError("Error reading commit message history", // $NON-NLS-1$
        e);
        return Collections.emptySet();
    }
    Set<String> messages = new LinkedHashSet<>();
    for (IMemento child : memento.getChildren(KEY_MESSAGE)) {
        messages.add(child.getTextData());
        if (messages.size() == max)
            break;
    }
    return messages;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) XMLMemento(org.eclipse.ui.XMLMemento) StringReader(java.io.StringReader) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento)

Example 9 with WorkbenchException

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

the class BranchProjectTracker method getProjectPaths.

/**
 * 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) {
        // $NON-NLS-1$
        Activator.logError("Error reading branch-project associations", e);
        return new String[0];
    }
    IMemento[] children = memento.getChildren(KEY_PROJECT);
    if (children.length == 0)
        return new String[0];
    List<String> projects = new ArrayList<>(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()]);
}
Also used : XMLMemento(org.eclipse.ui.XMLMemento) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento)

Example 10 with WorkbenchException

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

the class ChangePerspectiveAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    if (!perspectiveId.equals(page.getPerspective().getId())) {
        try {
            workbench.showPerspective(perspectiveId, workbench.getActiveWorkbenchWindow());
        } catch (WorkbenchException e) {
            // $NON-NLS-1$
            IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, IStatus.OK, "Show perspective failed.", e);
            CorePlugin.getDefault().getLog().log(status);
        }
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    IViewPart findView = page.findView(CHEAT_SHEET_VIEW);
    if (PERSPECTIVE_ID.equals(perspectiveId)) {
        if (preferenceStore.getBoolean(CHEAT_SHEET_VIEW)) {
            try {
                page.showView(CHEAT_SHEET_VIEW);
            } catch (PartInitException e) {
                log.error(e, e);
            }
        }
        action.perspectiveId = SE_ID;
        action.setToolTipText(SWITCH_TO_DATA_DISCOVERY);
        IPerspectiveDescriptor fp = registry.findPerspectiveWithId(SE_ID);
        if (fp != null) {
            action.setImageDescriptor(fp.getImageDescriptor());
        }
    } else {
        preferenceStore.setValue(CHEAT_SHEET_VIEW, findView != null);
        if (findView != null) {
            page.hideView(findView);
        }
        action.perspectiveId = PERSPECTIVE_ID;
        action.setToolTipText(SWITCH_TO_DATA_PROFILING);
        IPerspectiveDescriptor fp = registry.findPerspectiveWithId(PERSPECTIVE_ID);
        if (fp != null) {
            action.setImageDescriptor(fp.getImageDescriptor());
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) PartInitException(org.eclipse.ui.PartInitException) WorkbenchException(org.eclipse.ui.WorkbenchException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

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