@Override public IAdaptable createElement(IMemento memento) { // Get the file name. String uriString = memento.getString(TAG_URI); if (uriString == null) return null; URI uri; try { uri = new URI(uriString); } catch (URISyntaxException e) { return null; } try { return new FileStoreEditorInput(EFS.getStore(uri)); } catch (CoreException e) { return null; } } }
/** * Create the Editor Input appropriate for the given <code>IFileStore</code>. * The result is a normal file editor input if the file exists in the * workspace and, if not, we create a wrapper capable of managing an * 'external' file using its <code>IFileStore</code>. * * @param fileStore * The file store to provide the editor input for * @return The editor input associated with the given file store * @since 3.3 */ private static IEditorInput getEditorInput(IFileStore fileStore) { IFile workspaceFile = getWorkspaceFile(fileStore); if (workspaceFile != null) return new FileEditorInput(workspaceFile); return new FileStoreEditorInput(fileStore); }
public static boolean openSchema(File file) { // Ensure the file exists if ((file == null) || (file.exists() == false)) { return false; } // Create the editor input IEditorInput input = null; try { IFileStore store = EFS.getStore(file.toURI()); input = new FileStoreEditorInput(store); } catch (CoreException e) { PDEPlugin.logException(e); } return openEditor(input); }
@Override protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { File file = new File(input.getURI()); String name = file.getName(); if (name.endsWith(".product")) { //$NON-NLS-1$ IFileStore store; try { store = EFS.getStore(file.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new ProductInputContext(this, in, true)); } catch (CoreException e) { PDEPlugin.logException(e); } } }
@Override protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { File file = new File(input.getURI()); File siteFile = null; String name = file.getName().toLowerCase(Locale.ENGLISH); if (name.equals("site.xml")) { //$NON-NLS-1$ siteFile = file; if (siteFile.exists()) { IFileStore store; try { store = EFS.getStore(siteFile.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new SiteInputContext(this, in, file == siteFile)); } catch (CoreException e) { PDEPlugin.logException(e); } } } }
@Override protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { File file = new File(input.getURI()); File buildFile = null; File featureFile = null; String name = file.getName().toLowerCase(Locale.ENGLISH); if (name.equals(ICoreConstants.FEATURE_FILENAME_DESCRIPTOR)) { featureFile = file; File dir = file.getParentFile(); buildFile = new File(dir, ICoreConstants.BUILD_FILENAME_DESCRIPTOR); } else if (name.equals(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) { buildFile = file; File dir = file.getParentFile(); featureFile = createFeatureFile(dir); } try { if (featureFile.exists()) { IFileStore store = EFS.getStore(featureFile.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new FeatureInputContext(this, in, file == featureFile)); } if (buildFile.exists()) { IFileStore store = EFS.getStore(buildFile.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new BuildInputContext(this, in, file == buildFile)); } } catch (CoreException e) { PDEPlugin.logException(e); } }
private static IEditorPart openExternalPlugin(File location, String filename) { IEditorInput input = null; if (location.isFile()) { try { ZipFile zipFile = new ZipFile(location); if (zipFile.getEntry(filename) != null) input = new JarEntryEditorInput(new JarEntryFile(zipFile, filename)); } catch (IOException e) { } } else { File file = new File(location, filename); if (file.exists()) { IFileStore store; try { store = EFS.getStore(file.toURI()); input = new FileStoreEditorInput(store); } catch (CoreException e) { } } } return openEditor(input); }
if (manifestFile.exists()) { IFileStore store = EFS.getStore(manifestFile.toURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new BundleInputContext(this, in, file == manifestFile)); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new PluginInputContext(this, in, file == pluginFile, name.equals(ICoreConstants.FRAGMENT_FILENAME_DESCRIPTOR))); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new BuildInputContext(this, in, file == buildFile));
new Path(file.getAbsolutePath())); try { IDE.openEditor(page, new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID); } catch (PartInitException e) {
@Override protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { try { IFileStore store = EFS.getStore(input.getURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new CategoryInputContext(this, in, true)); } catch (CoreException e) { PDEPlugin.logException(e); } }
public void widgetSelected(SelectionEvent e) { try { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchPage workbenchPage = workbench.getActiveWorkbenchWindow().getActivePage(); IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor( LifecycleMappingFactory.LIFECYCLE_MAPPING_METADATA_SOURCE_NAME); IEditorInput input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile( new File(mappingFilePath))); IDE.openEditor(workbenchPage, input, desc.getId()); } catch(PartInitException ex) { log.error(ex.getMessage(), ex); } } });
@Override public void widgetSelected(SelectionEvent e) { IFileStore store = EFS.getLocalFileSystem().getStore( new Path(traceFileLocation.getText())); try { IDE.openEditor(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(), new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID); } catch (PartInitException ex) { Activator.handleError(ex.getMessage(), ex, true); } } });
@Override public void widgetSelected(SelectionEvent e) { IFileStore store = EFS.getLocalFileSystem().getStore( new Path(((FileBasedConfig) editableConfig) .getFile().getAbsolutePath())); try { IDE.openEditor(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(), new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID); } catch (PartInitException ex) { Activator.handleError(ex.getMessage(), ex, true); } } });
@Override public IEditorInput getEditorInput(Object element) { if (element instanceof IFile) { return new FileEditorInput((IFile) element); } if (element instanceof ILineBreakpoint) { return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource()); } if (element instanceof LocalFileStorage) { File file = ((LocalFileStorage) element).getFile(); IFileStore fileStore; try { fileStore = EFS.getStore(file.toURI()); return new FileStoreEditorInput(fileStore); } catch (CoreException e) { AntUIPlugin.log(e); return null; } } return null; }
private void handleOpenTextEditor(FileAdapter adapter, String editorId) { if (adapter == null) return; IWorkbenchPage page = PDEPlugin.getActivePage(); if (editorId == null) { if (adapter.isManifest()) editorId = IPDEUIConstants.MANIFEST_EDITOR_ID; else if (adapter.isSchema()) editorId = IPDEUIConstants.SCHEMA_EDITOR_ID; } try { if (editorId == null || editorId.equals("@system")) //$NON-NLS-1$ editorId = DEFAULT_EDITOR_ID; IFileStore store = EFS.getStore(adapter.getFile().toURI()); IEditorInput in = new FileStoreEditorInput(store); page.openEditor(in, editorId); adapter.setEditorId(editorId); } catch (PartInitException e) { PDEPlugin.logException(e); } catch (CoreException e) { PDEPlugin.logException(e); } }
void openEditor(final String fileName) { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor("settings.xml"); //$NON-NLS-1$ IEditorInput input = new FileStoreEditorInput(EFS.getLocalFileSystem().fromLocalFile(new File(fileName))); try { final IEditorPart editor = IDE.openEditor(page, input, desc.getId()); if(editor == null) { //external editor was opened return; } editor.addPropertyListener(new IPropertyListener() { public void propertyChanged(Object source, int propId) { if(!editor.isDirty()) { log.info("Refreshing settings " + fileName); //$NON-NLS-1$ } } }); } catch(PartInitException ex) { log.error(ex.getMessage(), ex); } }
public static IEditorPart openFeatureEditor(IFeatureModel model) { if (model != null) { IResource resource = model.getUnderlyingResource(); try { IEditorInput input = null; if (resource != null) input = new FileEditorInput((IFile) resource); else { File file = new File(model.getInstallLocation(), ICoreConstants.FEATURE_FILENAME_DESCRIPTOR); IFileStore store = EFS.getStore(file.toURI()); input = new FileStoreEditorInput(store); } return IDE.openEditor(PDEPlugin.getActivePage(), input, IPDEUIConstants.FEATURE_EDITOR_ID, true); } catch (PartInitException e) { PDEPlugin.logException(e); } catch (CoreException e) { PDEPlugin.logException(e); } } else { Display.getCurrent().beep(); } return null; }
protected void createInputContexts(InputContextManager contextManager) { IEditorInput input = getEditorInput(); if (input instanceof IFileEditorInput) { // resource - find the project createResourceContexts(contextManager, (IFileEditorInput) input); } else if (input instanceof IStorageEditorInput) { createStorageContexts(contextManager, (IStorageEditorInput) input); } else if (input instanceof IURIEditorInput) { IURIEditorInput uriEditorInput = (IURIEditorInput) input; try { IFileStore store = EFS.getStore(uriEditorInput.getURI()); if (!EFS.SCHEME_FILE.equals(store.getFileSystem().getScheme())) return; FileStoreEditorInput sinput = new FileStoreEditorInput(store); createSystemFileContexts(contextManager, sinput); } catch (CoreException e) { return; } } }
defaultEditor = overrideDefaultEditorAssociation(new FileStoreEditorInput(fileStore), contentType, defaultEditor); return getEditorDescriptor(name, editorReg, defaultEditor, allowInteractive).getId();
try { fileStore = EFS.getStore(fFile.toURI()); input = new FileStoreEditorInput(fileStore);