Search in sources :

Example 81 with IEditorInput

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

the class WorkbenchContrItem method processNodeRemoveWhenRefreshContainer.

/**
	 * When refresh the container node and if this child node is deleted, then
	 * close it's editor or view part
	 *
	 * @param eventNode ICubridNode
	 * @param page IWorkbenchPage
	 */
protected void processNodeRemoveWhenRefreshContainer(ICubridNode eventNode, IWorkbenchPage page) {
    synchronized (this) {
        IEditorReference[] editorRefArr = page.getEditorReferences();
        if (editorRefArr != null && editorRefArr.length > 0) {
            for (IEditorReference editorRef : editorRefArr) {
                try {
                    IEditorInput editorInput = editorRef.getEditorInput();
                    if (editorInput instanceof ICubridNode) {
                        ICubridNode editorNode = (ICubridNode) editorInput;
                        ICubridNode parentNode = editorNode.getParent();
                        if (editorNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(editorNode.getId()) == null) {
                            processNodeRemove(editorNode, page);
                        }
                    }
                } catch (PartInitException e1) {
                    LOGGER.error(e1.getMessage());
                }
            }
        }
        IViewReference[] viewRefArr = page.getViewReferences();
        if (viewRefArr != null && viewRefArr.length > 0) {
            for (IViewReference viewRef : viewRefArr) {
                IViewPart viewPart = viewRef.getView(false);
                if (viewPart instanceof CubridViewPart) {
                    ICubridNode viewPartNode = ((CubridViewPart) viewPart).getCubridNode();
                    if (viewPartNode == null) {
                        continue;
                    }
                    ICubridNode parentNode = viewPartNode.getParent();
                    if (viewPartNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(viewPartNode.getId()) == null) {
                        processNodeRemove(viewPartNode, page);
                    }
                }
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IEditorReference(org.eclipse.ui.IEditorReference) CubridViewPart(com.cubrid.common.ui.spi.part.CubridViewPart) IViewReference(org.eclipse.ui.IViewReference) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 82 with IEditorInput

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

the class QueryEditorPart method changeQueryEditorPartName.

/**
	 *
	 * Change query editor part name
	 *
	 * @param text String
	 *
	 */
public void changeQueryEditorPartName(String text) {
    IEditorInput input = getEditorInput();
    if (!(input instanceof QueryUnit) || !isUpdatePartName) {
        return;
    }
    QueryUnit queryUnit = (QueryUnit) input;
    queryUnit.setToolTip(text);
    setPartName("[" + currentEditorIndex + "] " + text);
    editorTabNameOriginal = text;
}
Also used : IEditorInput(org.eclipse.ui.IEditorInput)

Example 83 with IEditorInput

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

the class ImageEditorPart method resourceChanged.

@Override
public void resourceChanged(IResourceChangeEvent event) {
    IResourceDelta delta = event.getDelta();
    if (delta == null) {
        return;
    }
    IEditorInput input = getEditorInput();
    IPath localPath = null;
    if (input instanceof IPathEditorInput) {
        localPath = ((IPathEditorInput) input).getPath();
    }
    if (localPath == null) {
        return;
    }
    localPath = ContentUtils.convertPathToWorkspacePath(localPath);
    delta = delta.findMember(localPath);
    if (delta == null) {
        return;
    }
    if (delta.getKind() == IResourceDelta.CHANGED) {
        // Refresh editor
        DBeaverUI.asyncExec(new Runnable() {

            @Override
            public void run() {
                loadImage();
            }
        });
    }
}
Also used : IPathEditorInput(org.eclipse.ui.IPathEditorInput) IPath(org.eclipse.core.runtime.IPath) IEditorInput(org.eclipse.ui.IEditorInput) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 84 with IEditorInput

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

the class XMLPanelEditor method primeEditorValue.

@Override
public void primeEditorValue(@NotNull DBRProgressMonitor monitor, @NotNull StyledText control, @NotNull DBDContent value) throws DBException {
    monitor.beginTask("Prime content value", 1);
    try {
        monitor.subTask("Prime XML value");
        IEditorInput sqlInput = new ContentEditorInput(valueController, null, null, monitor);
        editor.init(subSite, sqlInput);
    } catch (Exception e) {
        throw new DBException("Can't load XML vaue", e);
    } finally {
        monitor.done();
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) ContentEditorInput(org.jkiss.dbeaver.ui.editors.content.ContentEditorInput) IEditorInput(org.eclipse.ui.IEditorInput) DBCException(org.jkiss.dbeaver.model.exec.DBCException) DBException(org.jkiss.dbeaver.DBException) PartInitException(org.eclipse.ui.PartInitException)

Example 85 with IEditorInput

use of org.eclipse.ui.IEditorInput in project gfm_viewer by satyagraha.

the class MarkdownEditorTrackerDefault method getTrackableFile.

private IFile getTrackableFile(IEditorPart editorPart) {
    IFile result = null;
    IEditorInput editorInput = editorPart.getEditorInput();
    if (editorInput != null) {
        IFile editorFile = ResourceUtil.getFile(editorInput);
        if (editorFile != null) {
            if (markdownFileNature.isTrackableFile(editorFile)) {
                result = editorFile;
            }
        }
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IEditorInput (org.eclipse.ui.IEditorInput)135 IFile (org.eclipse.core.resources.IFile)38 IEditorPart (org.eclipse.ui.IEditorPart)37 PartInitException (org.eclipse.ui.PartInitException)31 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)28 CoreException (org.eclipse.core.runtime.CoreException)25 IFileEditorInput (org.eclipse.ui.IFileEditorInput)22 IDocument (org.eclipse.jface.text.IDocument)17 IEditorReference (org.eclipse.ui.IEditorReference)17 FileEditorInput (org.eclipse.ui.part.FileEditorInput)16 File (java.io.File)14 ArrayList (java.util.ArrayList)14 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)14 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)14 IResource (org.eclipse.core.resources.IResource)13 Shell (org.eclipse.swt.widgets.Shell)13 IViewPart (org.eclipse.ui.IViewPart)13 IPath (org.eclipse.core.runtime.IPath)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)11