Search in sources :

Example 91 with IEditorReference

use of org.eclipse.ui.IEditorReference in project dsl-devkit by dsldevkit.

the class EditorRegExMatcher method matches.

/**
 * {@inheritDoc}
 */
public boolean matches(final Object item) {
    if (item instanceof IEditorReference) {
        IEditorReference ref = (IEditorReference) item;
        regExMatcher.reset(ref.getName());
        if (regExMatcher.matches()) {
            return true;
        }
    }
    return false;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference)

Example 92 with IEditorReference

use of org.eclipse.ui.IEditorReference in project soot by Sable.

the class SootDeltaVisitor method updateJimpleOutline.

// only updates after a save or Soot run
// (if editor is currently "dirty" the outline will be potenially incorrect
private void updateJimpleOutline(IFile file) {
    IWorkbenchWindow activeWorkbenchWindow = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null)
        return;
    IEditorReference[] refs = activeWorkbenchWindow.getActivePage().getEditorReferences();
    for (int i = 0; i < refs.length; i++) {
        if (refs[i] == null)
            continue;
        if (refs[i].getName() == null)
            continue;
        if (refs[i].getName().equals(file.getName())) {
            JimpleEditor ed = (JimpleEditor) refs[i].getEditor(true).getAdapter(JimpleEditor.class);
            if (ed != null) {
                if (ed.getPage() != null) {
                    ed.getPage().getContentOutline();
                    ed.getPage().getViewer().setInput(ed.getPage().getContentOutline());
                    ed.getPage().getViewer().refresh();
                    ed.getPage().getViewer().expandAll();
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference)

Example 93 with IEditorReference

use of org.eclipse.ui.IEditorReference in project eclipse-integration-commons by spring-projects.

the class DocumentFetcher method evalNonFileBufferDocuments.

/**
 * @return returns a map from IFile to IDocument for all open, dirty editors.
 */
private Map<IFile, IDocument> evalNonFileBufferDocuments() {
    Map<IFile, IDocument> result = new HashMap<IFile, IDocument>();
    IWorkbench workbench = SearchPlugin.getDefault().getWorkbench();
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
        IWorkbenchPage[] pages = windows[i].getPages();
        for (int x = 0; x < pages.length; x++) {
            IEditorReference[] editorRefs = pages[x].getEditorReferences();
            for (int z = 0; z < editorRefs.length; z++) {
                IEditorPart ep = editorRefs[z].getEditor(false);
                if (ep instanceof ITextEditor && ep.isDirty()) {
                    // only dirty editors
                    evaluateTextEditor(result, ep);
                }
            }
        }
    }
    return result;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) HashMap(java.util.HashMap) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbench(org.eclipse.ui.IWorkbench) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IDocument(org.eclipse.jface.text.IDocument)

Example 94 with IEditorReference

use of org.eclipse.ui.IEditorReference in project eclipse-integration-commons by spring-projects.

the class QuickSearchContext method getOpenFiles.

private Collection<IFile> getOpenFiles() {
    try {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            Collection<IFile> files = new ArrayList<IFile>();
            IEditorReference[] editors = page.getEditorReferences();
            if (editors != null) {
                for (IEditorReference editor : editors) {
                    try {
                        IEditorInput input = editor.getEditorInput();
                        if (input != null) {
                            IFile file = (IFile) input.getAdapter(IFile.class);
                            if (file != null) {
                                files.add(file);
                            }
                        }
                    } catch (PartInitException e) {
                    // Ignore silently. See: https://issuetracker.springsource.com/browse/STS-4156
                    // Rationale: Whatever may be the reason we can't obtain a 'input' for the editor.
                    // It likely means there's no text to search in that editor, so it is safe to ignore
                    // without loss of functionality to the quicksearch engine.
                    // QuickSearchActivator.log(e);
                    }
                }
                lastOpenFiles = files;
                return files;
            }
        }
        return lastOpenFiles;
    } finally {
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 95 with IEditorReference

use of org.eclipse.ui.IEditorReference in project eclipse-integration-commons by spring-projects.

the class IdeUiPlugin method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    // avoid cyclic startup dependency on org.eclipse.mylyn.tasks.ui
    Job startupJob = new UIJob("Spring Tool Suite Initialization") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            migrateBlogFeeds();
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    if (window != null) {
                        // prevent loading if already opened by workspace
                        // restore
                        IEditorReference[] references = window.getActivePage().getEditorReferences();
                        for (IEditorReference reference : references) {
                            if (DashboardEditorInputFactory.FACTORY_ID.equals(reference.getFactoryId())) {
                                return;
                            }
                        }
                        if (getPreferenceStore().getBoolean(IIdeUiConstants.PREF_OPEN_DASHBOARD_STARTUP)) {
                            // don't show if welcome page is visible
                            if (window.getWorkbench().getIntroManager().getIntro() != null) {
                                // scheduleUpdateJob();
                                return;
                            }
                            ShowDashboardAction showDashboard = new ShowDashboardAction();
                            showDashboard.init(window);
                            showDashboard.run(null);
                            return;
                        }
                    }
                // scheduleUpdateJob();
                }
            });
            return Status.OK_STATUS;
        }
    };
    startupJob.setSystem(true);
    startupJob.schedule();
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) ShowDashboardAction(org.springsource.ide.eclipse.dashboard.ui.actions.ShowDashboardAction) UIJob(org.eclipse.ui.progress.UIJob) Job(org.eclipse.core.runtime.jobs.Job) UIJob(org.eclipse.ui.progress.UIJob)

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