@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; } } }
@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); } } }
private IBaseModel createExternalModel(FileStoreEditorInput input) { File file = input.getAdapter(File.class); if (file == null) { URI uri = input.getURI(); if (uri != null){ file = new File(uri); } else{ return null; } } SchemaDescriptor sd = new SchemaDescriptor(file); ISchema schema = sd.getSchema(false); if (schema instanceof EditableSchema) { ((EditableSchema) schema).setNotificationEnabled(true); } return schema; }
private String computeTitlePath(FileStoreEditorInput editorInput) { return editorInput.getURI().getPath().toString(); }
@Override public String getLabel(Object o) { return ((FileStoreEditorInput) o).getName(); }
@Override public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adaptableObject instanceof FileStoreEditorInput && adapterType.isAssignableFrom(IFileStore.class)) { FileStoreEditorInput editorInput = (FileStoreEditorInput) adaptableObject; try { return adapterType.cast(EFS.getStore(editorInput.getURI())); } catch (CoreException e) { // Ignore to return null. } } return null; }
@Override public ImageDescriptor getImageDescriptor() { return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(getName()); }
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) { 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); } }
/** * Saves the state of the given editor input into the given memento. * * @param memento the storage area for element state * @param input the file editor input */ static void saveState(IMemento memento, FileStoreEditorInput input) { URI uri = input.getURI(); memento.putString(TAG_URI, uri.toString()); }
/** * 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); }
@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); } } } }
URI fileuri = ((FileStoreEditorInput) adaptable).getURI(); return new Resource(new File(fileuri.getPath()));
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); }
@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); } }
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) { File file = new File(input.getURI()); File manifestFile = null; File buildFile = null; 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));
@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); } } });
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(((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); } } });