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));
}
}
}
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;
}
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();
}
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));
}
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;
}
Aggregations