private void selectPerspective(String id) { for (ToolItem item : bar.getItems()) item.setSelection(((String) item.getData()).equals(id)); try { PlatformUI.getWorkbench() .showPerspective(id, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); DataOverviewView.reset(); } catch (WorkbenchException e) { if (Log.error(this)) Log.error(this, "Unable to change perspective", e); } }
public final void save() { // System.out.println("Content: save: Info=" + info.toString() + " Data=" + this.toString() + " // Data.Data=" + data.toString()); XmlWriter xml = new XmlWriter(); xml.openTag("content"); saveContent(xml); xml.openTag("info"); info.save(xml); xml.closeTag(); xml.closeTag(); try { IFolder folder = data.getFolder(); ResourceUtil.createFolderAndParents(folder); IFile file = folder.getFile("content.xml"); ByteArrayInputStream stream = new ByteArrayInputStream(xml.getXML().getBytes()); if (!file.exists()) file.create(stream, true, null); else file.setContents(stream, 0, null); } catch (Throwable t) { if (Log.error(this)) Log.error(this, "Unable to save data content", t); } }
static void init() { for (IConfigurationElement ext : EclipsePluginExtensionUtil.getExtensionsSubNode(EclipsePlugin.ID, "register", "register")) { try { TypedFileRegister register = EclipsePluginExtensionUtil.createInstance( TypedFileRegister.class, ext, "class", new Object[][] {new Object[] {}}); register.registerTypes(FileTypeRegistry.instance()); FileTypeDetector[] detectors = register.getDetectors(); for (FileTypeDetector d : detectors) { String[] schemes = d.getSpecificURISchemeSupported(); if (schemes != null) for (String scheme : schemes) { scheme = scheme.toLowerCase(); List<FileTypeDetector> list = byScheme.get(scheme); if (list == null) { list = new LinkedList<FileTypeDetector>(); byScheme.put(scheme, list); } list.add(d); } if (d.isSupportingOnlyGivenURIScheme()) continue; String[] extensions = d.getSupportedExtensions(); if (extensions != null) for (String e : extensions) { e = e.toLowerCase(); List<FileTypeDetector> list = byExtension.get(e); if (list == null) { list = new LinkedList<FileTypeDetector>(); byExtension.put(e, list); } list.add(d); } all.add(d); } } catch (ClassNotFoundException e) { if (Log.error(TypedFileRegistry.class)) Log.error( TypedFileRegistry.class, "Unable to register file types from plugin " + ext.getDeclaringExtension().getContributor().getName() + ": class not found. Please check your plug-in configuration.", e); } catch (InstantiationException e) { if (Log.error(TypedFileRegistry.class)) Log.error( TypedFileRegistry.class, "Unable to register file types from plugin " + ext.getDeclaringExtension().getContributor().getName() + ": class not instantiable. Please check your plug-in configuration or that your class is neither an interface nor an abstract class.", e); } catch (IllegalAccessException e) { if (Log.error(TypedFileRegistry.class)) Log.error( TypedFileRegistry.class, "Unable to register file types from plugin " + ext.getDeclaringExtension().getContributor().getName() + ": class not accessible. Please check your plug-in configuration or that your class is accessible (public and published by the plugin).", e); } catch (InvocationTargetException e) { if (Log.error(TypedFileRegistry.class)) Log.error( TypedFileRegistry.class, "Unable to register file types from plugin " + ext.getDeclaringExtension().getContributor().getName() + ": constructor threw an exception.", e.getTargetException()); } } }