Search in sources :

Example 26 with IEditorReference

use of org.eclipse.ui.IEditorReference in project cubrid-manager by CUBRID.

the class LayoutUtil method closeAllCubridEditorAndView.

/**
	 * 
	 * Close all opened editor and view part related with CUBRID Manager,not
	 * include query editor
	 * 
	 */
public static void closeAllCubridEditorAndView() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        return;
    }
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr != null && editorRefArr.length > 0) {
        for (IEditorReference editorRef : editorRefArr) {
            try {
                IEditorInput editorInput = editorRef.getEditorInput();
                if (editorInput instanceof ICubridNode) {
                    window.getActivePage().closeEditor(editorRef.getEditor(false), true);
                }
            } catch (PartInitException e) {
                LOGGER.error(e.getMessage());
            }
        }
    }
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr != null && viewRefArr.length > 0) {
        for (IViewReference viewRef : viewRefArr) {
            IViewPart viewPart = viewRef.getView(false);
            if (viewPart instanceof CubridViewPart) {
                page.hideView(viewPart);
            }
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 27 with IEditorReference

use of org.eclipse.ui.IEditorReference in project cubrid-manager by CUBRID.

the class LayoutUtil method getEditorPart.

/**
	 * 
	 * Get the editor part of this CUBRID node and this editorId
	 * 
	 * @param cubridNode the ICubridNode object
	 * @param editorId the editor id
	 * @return the IEditorPart object
	 */
public static IEditorPart getEditorPart(ICubridNode cubridNode, String editorId) {
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return null;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr == null || editorRefArr.length == 0) {
        return null;
    }
    for (IEditorReference editorRef : editorRefArr) {
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            String id = editorRef.getId();
            if (editorInput instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) editorInput;
                if (node.getId().equals(cubridNode.getId()) && editorId.equals(id)) {
                    return editorRef.getEditor(false);
                }
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
    return null;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 28 with IEditorReference

use of org.eclipse.ui.IEditorReference in project cubrid-manager by CUBRID.

the class LayoutUtil method getEditorParts.

/**
	 * 
	 * Get the editor parts of this CUBRID node
	 * 
	 * @param cubridNode the ICubridNode object
	 * @return List<IEditorPart>
	 */
public static List<IEditorPart> getEditorParts(ICubridNode cubridNode) {
    List<IEditorPart> partList = new ArrayList<IEditorPart>();
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return partList;
    }
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr == null || editorRefArr.length == 0) {
        return partList;
    }
    for (IEditorReference editorRef : editorRefArr) {
        try {
            IEditorInput editorInput = editorRef.getEditorInput();
            if (editorInput instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) editorInput;
                if (node.getId().equals(cubridNode.getId())) {
                    partList.add(editorRef.getEditor(false));
                }
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
    return partList;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 29 with IEditorReference

use of org.eclipse.ui.IEditorReference in project cubrid-manager by CUBRID.

the class LayoutUtil method checkAllQueryEditor.

/**
	 * 
	 * When database logout or stop,check query editor whether some transaction
	 * are not commit
	 * 
	 * @param databaseNode the CubridDatabase object
	 * @return <code>true</code> if transaction is commited;<code>false</code>
	 *         otherwise
	 */
public static boolean checkAllQueryEditor(CubridDatabase databaseNode) {
    IWorkbenchPage page = getActivePage();
    if (page == null) {
        return true;
    }
    boolean isContinue = true;
    IEditorReference[] editorRefArr = page.getEditorReferences();
    if (editorRefArr == null || editorRefArr.length == 0) {
        return true;
    }
    for (IEditorReference editorRef : editorRefArr) {
        String editorId = editorRef.getId();
        if (editorId != null && editorId.equals(QueryEditorPart.ID)) {
            QueryEditorPart queryEditor = (QueryEditorPart) editorRef.getEditor(false);
            CubridDatabase db = queryEditor.getSelectedDatabase();
            if (db != null && db.getId().equals(databaseNode.getId())) {
                isContinue = queryEditor.resetJDBCConnection();
            }
        }
    }
    return isContinue;
}
Also used : QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 30 with IEditorReference

use of org.eclipse.ui.IEditorReference in project dbeaver by serge-rider.

the class NavigatorHandlerObjectBase method getCommandTarget.

protected static CommandTarget getCommandTarget(IWorkbenchWindow workbenchWindow, DBNContainer container, Class<?> childType, boolean openEditor) throws DBException {
    final Object parentObject = container.getValueObject();
    DBSObject objectToSeek = null;
    if (parentObject instanceof DBSObject) {
        final DBEStructEditor parentStructEditor = EntityEditorsRegistry.getInstance().getObjectManager(parentObject.getClass(), DBEStructEditor.class);
        if (parentStructEditor != null && RuntimeUtils.isTypeSupported(childType, parentStructEditor.getChildTypes())) {
            objectToSeek = (DBSObject) parentObject;
        }
    }
    if (objectToSeek != null) {
        for (final IEditorReference editorRef : workbenchWindow.getActivePage().getEditorReferences()) {
            final IEditorPart editor = editorRef.getEditor(false);
            if (editor instanceof IDatabaseEditor) {
                final IDatabaseEditorInput editorInput = ((IDatabaseEditor) editor).getEditorInput();
                if (editorInput.getDatabaseObject() == objectToSeek) {
                    workbenchWindow.getActivePage().activate(editor);
                    switchEditorFolder(container, editor);
                    return new CommandTarget((IDatabaseEditor) editor);
                }
            }
        }
        if (openEditor && container instanceof DBNDatabaseNode) {
            final IDatabaseEditor editor = (IDatabaseEditor) NavigatorHandlerObjectOpen.openEntityEditor((DBNDatabaseNode) container, null, workbenchWindow);
            if (editor != null) {
                switchEditorFolder(container, editor);
                return new CommandTarget(editor);
            }
        }
    }
    if (container instanceof DBNDatabaseNode) {
        // No editor found - create new command context
        DBPDataSource dataSource = ((DBNDatabaseNode) container).getObject().getDataSource();
        if (dataSource != null) {
            return new CommandTarget(new SimpleCommandContext(dataSource.getDefaultContext(true), !openEditor));
        }
    }
    return new CommandTarget();
}
Also used : IDatabaseEditorInput(org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IEditorReference(org.eclipse.ui.IEditorReference) SimpleCommandContext(org.jkiss.dbeaver.ui.SimpleCommandContext) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBEStructEditor(org.jkiss.dbeaver.model.edit.DBEStructEditor) IEditorPart(org.eclipse.ui.IEditorPart) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IDatabaseEditor(org.jkiss.dbeaver.ui.editors.IDatabaseEditor)

Aggregations

IEditorReference (org.eclipse.ui.IEditorReference)174 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)83 IEditorPart (org.eclipse.ui.IEditorPart)78 PartInitException (org.eclipse.ui.PartInitException)59 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)55 IFile (org.eclipse.core.resources.IFile)50 IEditorInput (org.eclipse.ui.IEditorInput)49 ArrayList (java.util.ArrayList)34 FileEditorInput (org.eclipse.ui.part.FileEditorInput)28 Item (org.talend.core.model.properties.Item)17 IWorkbench (org.eclipse.ui.IWorkbench)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 IOException (java.io.IOException)12 CoreException (org.eclipse.core.runtime.CoreException)12 ProcessItem (org.talend.core.model.properties.ProcessItem)11 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 Path (org.eclipse.core.runtime.Path)10 IProcess2 (org.talend.core.model.process.IProcess2)10