/** Save an object to global plugin's preference store. */ public static void toPreferenceStore(String globalPreferenceKey, Object object) { final IPreferenceStore prefStore = WorkbenchCorePlugin.getDefault().getPreferenceStore(); try { prefStore.setValue(globalPreferenceKey, toString(object)); } catch (IOException e) { Utils.logError(e, false); } }
public SaveAttributesAction(String text) { super(text, IAction.AS_DROP_DOWN_MENU); setImageDescriptor(WorkbenchCorePlugin.getImageDescriptor("icons/save_e.gif")); setMenuCreator( new MenuManagerCreator() { protected MenuManager createMenu() { return SaveAttributesAction.this.createMenu(); } }); }
/** * Read an object from the global plugin's preference store. May return <code>null</code> if an * error occurred. */ public static <T> T fromPreferenceStore(Class<T> clazz, String globalPreferenceKey) { final IPreferenceStore prefStore = WorkbenchCorePlugin.getDefault().getPreferenceStore(); final String xml = prefStore.getString(globalPreferenceKey); if (!StringUtils.isEmpty(xml)) { try { return fromString(clazz, xml); } catch (IOException e) { Utils.logError(e, false); } } return null; }
/** * Removes {@link Internal} non-configuration attributes (such as "resource-lookup") from the * provided map. */ private static void removeInternalNonConfigurationAttributes( Map<String, Object> attrs, String componentId) { BindableDescriptor desc = WorkbenchCorePlugin.getDefault().getComponentDescriptor(componentId); attrs .keySet() .removeAll( desc.flatten() .only(new InternalAttributePredicate(false)) .attributeDescriptors .keySet()); }
/** * @return Returns the filename hint for an attribute set. The first take is the attribute sets * resource associated with the algorithm. If this fails, we try to name the file after the * algorithm itself. */ static IPath getDefaultHint(String componentId, String prefix) { final ProcessingComponentDescriptor component = WorkbenchCorePlugin.getDefault().getComponent(componentId); String nameHint = component.getAttributeSetsResource(); if (StringUtils.isBlank(nameHint)) { // Try a fallback. nameHint = FileDialogs.sanitizeFileName(prefix + componentId + "-attributes.xml"); } return new Path(nameHint); }
/** Default attribute value set for a given component. */ @SuppressWarnings("unchecked") static AttributeValueSet getDefaultAttributeValueSet(String componentId) { BindableDescriptor desc = WorkbenchCorePlugin.getDefault().getComponentDescriptor(componentId); final HashMap<String, Object> defaults = Maps.newHashMap(); for (Map.Entry<String, AttributeDescriptor> e : desc.flatten().only(Input.class).attributeDescriptors.entrySet()) { defaults.put(e.getKey(), e.getValue().defaultValue); } removeSpecialKeys(defaults); removeInternalNonConfigurationAttributes(defaults, componentId); AttributeValueSet result = new AttributeValueSet("defaults"); result.setAttributeValues(defaults); return result; }