Search in sources :

Example 86 with IEditorReference

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

the class CorePlugin method itemIsOpening.

/**
 * check the item's editor is opening or not.
 *
 * @param item
 * @param closeEditor close the editor if it is opening
 * @return
 */
public boolean itemIsOpening(Item item, boolean closeEditor) {
    boolean opening = false;
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorReferences = activePage.getEditorReferences();
    IEditorInput editorInput = null;
    Property property = item.getProperty();
    for (IEditorReference reference : editorReferences) {
        try {
            editorInput = reference.getEditorInput();
            if (editorInput instanceof FileEditorInput) {
                FileEditorInput fileInput = (FileEditorInput) editorInput;
                if (property.eResource() != null) {
                    IPath itemPath = PropertyHelper.getItemPath(property);
                    if (itemPath != null && itemPath.equals(fileInput.getFile().getFullPath())) {
                        opening = true;
                        if (closeEditor) {
                            activePage.closeEditor(reference.getEditor(false), false);
                        }
                        break;
                    }
                }
            } else if (editorInput instanceof AbstractItemEditorInput) {
                AbstractItemEditorInput input = (AbstractItemEditorInput) editorInput;
                Item it = input.getItem();
                if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
                    opening = true;
                    if (closeEditor) {
                        activePage.closeEditor(reference.getEditor(false), false);
                    }
                    break;
                }
            }
        } catch (PartInitException e) {
            log.error(e);
            continue;
        }
    }
    return opening;
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IEditorReference(org.eclipse.ui.IEditorReference) IPath(org.eclipse.core.runtime.IPath) AbstractItemEditorInput(org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IEditorInput(org.eclipse.ui.IEditorInput)

Example 87 with IEditorReference

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

the class CorePlugin method getCurrentOpenAnalysisEditor.

public List<AnalysisEditor> getCurrentOpenAnalysisEditor() {
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorReferences = activePage.getEditorReferences();
    List<AnalysisEditor> result = new ArrayList<AnalysisEditor>();
    for (IEditorReference iEditorReference : editorReferences) {
        IEditorPart editor = iEditorReference.getEditor(false);
        if (editor instanceof AnalysisEditor) {
            result.add((AnalysisEditor) editor);
        }
    }
    return result;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 88 with IEditorReference

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

the class CorePlugin method refreshOpenedEditor.

/**
 * refresh the related connection which is opened in DQ side.
 *
 * @param item
 */
public void refreshOpenedEditor(Item item) {
    if (item == null) {
        return;
    }
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorReferences = activePage.getEditorReferences();
    Property property = item.getProperty();
    for (IEditorReference reference : editorReferences) {
        try {
            IEditorInput input = reference.getEditorInput();
            if (input instanceof AbstractItemEditorInput) {
                AbstractItemEditorInput itemInput = (AbstractItemEditorInput) input;
                Item it = itemInput.getItem();
                if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
                    // make sure the item in editorInput is latest.
                    if (!item.equals(it)) {
                        itemInput.setRepNode(RepositoryNodeHelper.recursiveFind(property));
                    }
                    CommonFormEditor editor = (CommonFormEditor) reference.getEditor(false);
                    editor.refreshEditor();
                    break;
                }
            }
        } catch (PartInitException e) {
            log.error(e);
            continue;
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IEditorReference(org.eclipse.ui.IEditorReference) AbstractItemEditorInput(org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IEditorInput(org.eclipse.ui.IEditorInput) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor)

Example 89 with IEditorReference

use of org.eclipse.ui.IEditorReference in project titan.EclipsePlug-ins by eclipse.

the class AstRunnerJava method init.

public void init(IWorkbenchWindow window) {
    fileNames = new ArrayList<String>();
    files = new ArrayList<IFile>();
    AstRunnerJava.window = window;
    try {
        FileOutputStream fos = new FileOutputStream(props.getProperty("log.path"));
        fos.write("open file".getBytes());
        IWorkbenchPage p = window.getActivePage();
        if (p != null) {
            IEditorPart e = p.getActiveEditor();
            if (e != null) {
                IEditorInput i = e.getEditorInput();
                if (i instanceof IFileEditorInput) {
                    fos.write(((IFileEditorInput) i).getFile().getLocation().toOSString().getBytes());
                }
            }
        }
        fos.write("\n".getBytes());
        for (IWorkbenchPage page : window.getPages()) {
            for (IEditorReference editor : page.getEditorReferences()) {
                IEditorInput input = editor.getEditorInput();
                if (input instanceof IFileEditorInput) {
                    fos.write(((IFileEditorInput) input).getFile().getLocation().toOSString().getBytes());
                }
            }
        }
        fos.flush();
        fos.close();
    } catch (PartInitException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorReference(org.eclipse.ui.IEditorReference) IFileEditorInput(org.eclipse.ui.IFileEditorInput) FileOutputStream(java.io.FileOutputStream) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 90 with IEditorReference

use of org.eclipse.ui.IEditorReference in project epp.mpc by eclipse.

the class AbstractMarketplaceWizardBotTest method marketplaceBrowser.

protected SWTBotBrowser marketplaceBrowser() {
    SWTWorkbenchBot wbBot = new SWTWorkbenchBot();
    Matcher<IEditorReference> marketplaceBrowserMatch = allOf(WidgetMatcherFactory.<IEditorReference>withPartId("org.eclipse.ui.browser.editor"), WidgetMatcherFactory.<IEditorReference>withTitle(containsString("Marketplace")));
    SWTBotEditor browserEditor = wbBot.editor(marketplaceBrowserMatch);
    SWTBotBrowser browser = browserEditor.bot().browser();
    return browser;
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotBrowser(org.eclipse.swtbot.swt.finder.widgets.SWTBotBrowser) IEditorReference(org.eclipse.ui.IEditorReference)

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