FileEditorInput input = (FileEditorInput) editor.getEditorInput(); StyledText editorControl = ((StyledText) editor.getAdapter(Control.class)); String path = input.getFile().getRawLocationURI().getRawPath();
/** * * @param editorinput * @return null if not found */ public static IFile getFile(IEditorInput editorinput) { FileEditorInput fileEditorInput = (FileEditorInput) editorinput .getAdapter(FileEditorInput.class); if (fileEditorInput == null || fileEditorInput.getFile() == null) { return null; } return fileEditorInput.getFile(); }
@Override public Object getParent(Object o) { return FileEditorInput.this.getFile().getParent(); } });
@Override public String toString() { return getClass().getName() + "(" + getFile().getFullPath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ }
protected IFile getActiveFile() { return DocumentUtils.getActiveEditorInput().getFile(); }
private String getTypesystemId(Object element) { if (element instanceof FileEditorInput) { FileEditorInput editorInput = (FileEditorInput) element; return documentToTypeSystemMap.get(editorInput.getFile().getFullPath().toPortableString()); } return null; }
/** * Saves the server configuration using the given {@link FileEditorInput}. * * @param fei * the {@link FileEditorInput} * @throws ServerConfigurationWriterException * @throws CoreException * @throws IOException */ private void saveConfiguration( FileEditorInput fei, IProgressMonitor monitor ) throws CoreException, IOException { String xml = serverXmlIO.toXml( serverConfiguration ); fei.getFile().setContents( new ByteArrayInputStream( xml.getBytes() ), true, true, monitor ); }
/** * Saves the state of the given file editor input into the given memento. * * @param memento the storage area for element state * @param input the file editor input */ public static void saveState(IMemento memento, FileEditorInput input) { IFile file = input.getFile(); memento.putString(TAG_PATH, file.getFullPath().toString()); } }
@Override public IResource getLaunchableResource(IEditorPart editorpart) { if (editorpart.getEditorInput() instanceof IFileEditorInput) { return ((FileEditorInput)editorpart.getEditorInput()).getFile(); } return null; }
private ISelection extractSelectionFromEditorInput( IEditorInput activeEditorInput) { if (activeEditorInput instanceof FileEditorInput) { IProject project = ((FileEditorInput) activeEditorInput).getFile() .getProject(); return new StructuredSelection(project); } return null; }
private FileEditorInput buildJSInput() throws CoreException { FileEditorInput ourInput = (FileEditorInput)getEditorInput().getAdapter(FileEditorInput.class); IFile ourFile = ourInput.getFile(); // keep our temp file in the same directory as the DFD to avoid collisions IContainer parent = ourFile.getParent(); IPath tmpPath = new Path( ourFile.getName() + "_tmpServerSideJS.js" ); //$NON-NLS-1$ jsFile = parent.getFile(tmpPath); byte jsBytes[] = model.getModel().getServerScript().getBytes(); InputStream jsIn = new ByteArrayInputStream(jsBytes); if (!jsFile.exists()) { jsFile.create(jsIn, IResource.HIDDEN, null); } else { jsFile.setContents(jsIn, 0, null); } return new FileEditorInput(jsFile); }
public static IProject getProject(IWorkbenchWindow window) { IEditorInput editorinput = window.getActivePage().getActiveEditor() .getEditorInput(); FileEditorInput fileEditorInput = (FileEditorInput) editorinput .getAdapter(FileEditorInput.class); if (fileEditorInput == null || fileEditorInput.getFile() == null) { return null; } return fileEditorInput.getFile().getProject(); }
protected File getEditedFile() { IWorkbenchPage page = AntUIPlugin.getActivePage(); if (page == null) { return null; } IEditorPart editor = page.getActiveEditor(); if (editor == null) { return null; } FileEditorInput input = (FileEditorInput) editor.getEditorInput(); String projectPath = input.getFile().getProject().getLocation().toFile().getAbsolutePath(); String projectRelativeFilePath = input.getFile().getFullPath().removeFirstSegments(1).makeRelative().toString(); return new File(projectPath + File.separator + projectRelativeFilePath); }
public SafeWorkspaceJob(String name) { super(name); setPriority(Job.INTERACTIVE); IEditorInput editorInput = JsonEditor.this.getEditorInput(); if (editorInput != null && editorInput instanceof FileEditorInput) { setRule(((FileEditorInput) editorInput).getFile()); } }
private String getMapInfo() { IEditorInput input = getEditorInput(); if ((input != null) && (input instanceof FileEditorInput)) { IFile file = ((FileEditorInput)input).getFile(); return getInfoForModelFile(file.getProject(), file.getLocation()); } return null; }
public void widgetSelected(SelectionEvent e) { // Open a dialog to let the user choose a type system IResource resource = WorkspaceResourceDialog.getWorkspaceResourceElement(Display .getCurrent().getActiveShell(), ResourcesPlugin.getWorkspace().getRoot(), "Select a Type System", "Please select a Type System:"); if (resource != null) { FileEditorInput editorInput = (FileEditorInput) editor.getEditorInput(); setTypeSystemForNextDocumentOnly(editorInput.getFile().getFullPath().toPortableString(), resource.getFullPath().toString()); // Now set the input again to open the editor with the // specified type system editor.reopenEditorWithNewTypeSystem(); } }
public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow() .getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()) .getFile().getProject().equals( event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor .getEditorInput()); pages[i].closeEditor(editorPart, true); } } } });
public boolean visit(IResourceDelta delta) throws CoreException { if (delta.getFlags() != IResourceDelta.MARKERS && delta.getResource().getType() == IResource.FILE) { IResource resource = delta.getResource(); if (resource.equals(fileInput.getFile())) { if (delta.getKind() == IResourceDelta.REMOVED) { handleElementDeleted(fileInput); } else if (delta.getKind() == IResourceDelta.CHANGED) { if (isFileChangeTrackingEnabled) handleElementChanged(fileInput); } } } return true; } };
public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow() .getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()) .getFile().getProject().equals( event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor .getEditorInput()); pages[i].closeEditor(editorPart, true); } } } });