Search in sources :

Example 36 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project Malai by arnobl.

the class WidgetEditor method doSaveAs.

/**
 * This also changes the editor's input.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSaveAs() {
    SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
    saveAsDialog.open();
    IPath path = saveAsDialog.getResult();
    if (path != null) {
        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (file != null) {
            doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 37 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project xtext-eclipse by eclipse.

the class MarkerResolutionGenerator method getEditor.

// handled by org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext.getXtextDocument(URI)
@Deprecated
public XtextEditor getEditor(IResource resource) {
    XtextEditor result = findEditor(resource);
    if (result == null) {
        IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
        try {
            IFile file = ResourceUtil.getFile(resource);
            IEditorInput input = new FileEditorInput(file);
            IEditorPart editor = page.openEditor(input, getEditorId());
            if (editor instanceof XtextEditor) {
                result = (XtextEditor) editor;
            } else if (editor != null) {
                result = (XtextEditor) editor.getAdapter(XtextEditor.class);
            }
        } catch (PartInitException e) {
            return null;
        }
    }
    return result;
}
Also used : IFile(org.eclipse.core.resources.IFile) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 38 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project eclipse.platform.text by eclipse.

the class ZoomTest method setUp.

@Before
public void setUp() throws Exception {
    IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
    if (intro != null) {
        PlatformUI.getWorkbench().getIntroManager().closeIntro(intro);
    }
    IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
    editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new FileEditorInput(file), desc.getId());
    editor.setFocus();
    text = (StyledText) editor.getAdapter(Control.class);
    // make sure we start from a clean state
    initialFontSize = text.getFont().getFontData()[0].getHeight();
}
Also used : IIntroPart(org.eclipse.ui.intro.IIntroPart) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) Before(org.junit.Before)

Example 39 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project eclipse.platform.text by eclipse.

the class FileDocumentProvider method handleElementMoved.

/**
 * Sends out the notification that the file serving as document input has been moved.
 *
 * @param fileEditorInput the input of an text editor
 * @param path the path of the new location of the file
 */
protected void handleElementMoved(IFileEditorInput fileEditorInput, IPath path) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFile newFile = workspace.getRoot().getFile(path);
    fireElementMoved(fileEditorInput, new FileEditorInput(newFile));
}
Also used : IFile(org.eclipse.core.resources.IFile) IWorkspace(org.eclipse.core.resources.IWorkspace) IFileEditorInput(org.eclipse.ui.IFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 40 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project eclipse.platform.text by eclipse.

the class EditorOpener method showWithReuse.

private IEditorPart showWithReuse(IFile file, IWorkbenchPage page, String editorId, boolean activate) throws PartInitException {
    IEditorInput input = new FileEditorInput(file);
    IEditorPart editor = page.findEditor(input);
    if (editor != null) {
        page.bringToTop(editor);
        if (activate) {
            page.activate(editor);
        }
        return editor;
    }
    IEditorReference reusedEditorRef = fReusedEditor;
    if (reusedEditorRef != null) {
        boolean isOpen = reusedEditorRef.getEditor(false) != null;
        boolean canBeReused = isOpen && !reusedEditorRef.isDirty() && !reusedEditorRef.isPinned();
        if (canBeReused) {
            boolean showsSameInputType = reusedEditorRef.getId().equals(editorId);
            if (!showsSameInputType) {
                page.closeEditors(new IEditorReference[] { reusedEditorRef }, false);
                fReusedEditor = null;
            } else {
                editor = reusedEditorRef.getEditor(true);
                if (editor instanceof IReusableEditor) {
                    ((IReusableEditor) editor).setInput(input);
                    page.bringToTop(editor);
                    if (activate) {
                        page.activate(editor);
                    }
                    return editor;
                }
            }
        }
    }
    editor = page.openEditor(input, editorId, activate);
    if (editor instanceof IReusableEditor) {
        IEditorReference reference = (IEditorReference) page.getReference(editor);
        fReusedEditor = reference;
    } else {
        fReusedEditor = null;
    }
    return editor;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IReusableEditor(org.eclipse.ui.IReusableEditor) IEditorPart(org.eclipse.ui.IEditorPart) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

FileEditorInput (org.eclipse.ui.part.FileEditorInput)262 IFile (org.eclipse.core.resources.IFile)187 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)99 PartInitException (org.eclipse.ui.PartInitException)96 IEditorPart (org.eclipse.ui.IEditorPart)64 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)58 IPath (org.eclipse.core.runtime.IPath)57 IEditorInput (org.eclipse.ui.IEditorInput)55 CoreException (org.eclipse.core.runtime.CoreException)51 IResource (org.eclipse.core.resources.IResource)39 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)38 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)35 SaveAsDialog (org.eclipse.ui.dialogs.SaveAsDialog)35 EObject (org.eclipse.emf.ecore.EObject)33 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)33 HashMap (java.util.HashMap)32 Resource (org.eclipse.emf.ecore.resource.Resource)32 ISelection (org.eclipse.jface.viewers.ISelection)32 URI (org.eclipse.emf.common.util.URI)31