private boolean containsKeys(IEclipsePreferences aRoot) throws BackingStoreException { final boolean result[] = new boolean[] {false}; IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) throws BackingStoreException { if (node.keys().length != 0) result[0] = true; return !result[0]; } }; aRoot.accept(visitor); return result[0]; }
private boolean containsKeys(IEclipsePreferences aRoot) throws BackingStoreException { final boolean result[] = new boolean[] {false}; IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() { @Override public boolean visit(IEclipsePreferences node) throws BackingStoreException { if (node.keys().length != 0) result[0] = true; return !result[0]; } }; aRoot.accept(visitor); return result[0]; }
private IEclipsePreferences mergeTrees(IEclipsePreferences[] trees) throws BackingStoreException { if (trees.length == 1) return trees[0]; final IEclipsePreferences result = ExportedPreferences.newRoot(); if (trees.length == 0) return result; IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) throws BackingStoreException { Preferences destination = result.node(node.absolutePath()); copyFromTo(node, destination, null, 0); return true; } }; for (int i = 0; i < trees.length; i++) trees[i].accept(visitor); return result; }
private IEclipsePreferences mergeTrees(IEclipsePreferences[] trees) throws BackingStoreException { if (trees.length == 1) return trees[0]; final IEclipsePreferences result = ExportedPreferences.newRoot(); if (trees.length == 0) return result; IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() { @Override public boolean visit(IEclipsePreferences node) throws BackingStoreException { Preferences destination = result.node(node.absolutePath()); copyFromTo(node, destination, null, 0); return true; } }; for (int i = 0; i < trees.length; i++) trees[i].accept(visitor); return result; }
public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException { if (!visitor.visit(this)) return; IEclipsePreferences[] toVisit = getChildren(true); for (int i = 0; i < toVisit.length; i++) toVisit[i].accept(visitor); }
@Override public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException { if (!visitor.visit(this)) return; IEclipsePreferences[] toVisit = getChildren(true); for (int i = 0; i < toVisit.length; i++) toVisit[i].accept(visitor); }
@Override public IEclipsePreferences preApply(IEclipsePreferences node) { try { node.accept(new Visitor()); } catch (BackingStoreException e) { PDECore.log(e); } return node; } }
@Override public IEclipsePreferences preApply(IEclipsePreferences node) { try { // force VMs to be initialized before we import the new VMs node.accept(new Visitor()); } catch (BackingStoreException e) { DebugPlugin.log(e); } return node; }
/** * Filter the given tree so it only contains values which apply to the specified filters * then apply the resulting tree to the main preference tree. */ private void internalApply(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException { ArrayList<IEclipsePreferences> trees = new ArrayList<>(); for (int i = 0; i < filters.length; i++) trees.add(trimTree(tree, filters[i])); // merge the union of the matching filters IEclipsePreferences toApply = mergeTrees(trees.toArray(new IEclipsePreferences[trees.size()])); // fire an event to give people a chance to modify the tree toApply = firePreApplyEvent(toApply); // actually apply the settings IPreferenceNodeVisitor visitor = new IPreferenceNodeVisitor() { @Override public boolean visit(IEclipsePreferences node) throws BackingStoreException { String[] keys = node.keys(); if (keys.length == 0) return true; copyFromTo(node, getRootNode().node(node.absolutePath()), keys, 0); return true; } }; toApply.accept(visitor); }
/** * Enumerates all content types whose settings satisfy the given file spec type mask. */ public Collection getDirectlyAssociated(final ContentTypeCatalog catalog, final String fileSpec, final int typeMask) { //TODO: make sure we include built-in associations as well final IEclipsePreferences root = context.getNode(ContentTypeManager.CONTENT_TYPE_PREF_NODE); final Set result = new HashSet(3); try { root.accept(new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) { if (node == root) return true; String[] fileSpecs = ContentTypeSettings.getFileSpecs(node, typeMask); for (int i = 0; i < fileSpecs.length; i++) if (fileSpecs[i].equalsIgnoreCase(fileSpec)) { ContentType associated = catalog.getContentType(node.name()); if (associated != null) result.add(associated); break; } return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } return result == null ? Collections.EMPTY_SET : result; }
/** * Enumerates all content types whose settings satisfy the given file spec type mask. */ public Collection getDirectlyAssociated(final ContentTypeCatalog catalog, final String fileSpec, final int typeMask) { //TODO: make sure we include built-in associations as well final IEclipsePreferences root = context.getNode(ContentTypeManager.CONTENT_TYPE_PREF_NODE); final Set result = new HashSet(3); try { root.accept(new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) { if (node == root) return true; String[] fileSpecs = ContentTypeSettings.getFileSpecs(node, typeMask); for (int i = 0; i < fileSpecs.length; i++) if (fileSpecs[i].equalsIgnoreCase(fileSpec)) { ContentType associated = catalog.getContentType(node.name()); if (associated != null) result.add(associated); break; } return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } return result == null ? Collections.EMPTY_SET : result; }
@Override public IEclipsePreferences preApply(IEclipsePreferences node) { try { // force VMs to be initialized before we import the new VMs JavaRuntime.getVMInstallTypes(); node.accept(new Visitor()); } catch (BackingStoreException e) { LaunchingPlugin.log(e); } return node; }
@Override public IEclipsePreferences preApply(IEclipsePreferences node) { try { // force VMs to be initialized before we import the new VMs JavaRuntime.getVMInstallTypes(); node.accept(new Visitor()); } catch (BackingStoreException e) { LaunchingPlugin.log(e); } return node; }
@Override public void accept(IPreferenceNodeVisitor visitor) throws BackingStoreException { checkRemoved(); if (!visitor.visit(this)) { return; } for (String childName : childrenNames()) { ((IEclipsePreferences) node(childName)).accept(visitor); } }
public Collection<? extends ContentType> getMatchingRegexpAssociated(ContentTypeCatalog catalog, String fileName, final int typeMask) { if ((typeMask & IContentType.FILE_PATTERN_SPEC) == 0) { throw new IllegalArgumentException("This method only applies for FILE_REGEXP_SPEC."); //$NON-NLS-1$ } final IEclipsePreferences root = context.getNode(ContentTypeManager.CONTENT_TYPE_PREF_NODE); final Set<ContentType> result = new HashSet<>(3); try { root.accept(node -> { if (node == root) return true; String[] fileSpecs = ContentTypeSettings.getFileSpecs(node, typeMask); for (String fileSpecification : fileSpecs) if (Pattern.matches(catalog.toRegexp(fileSpecification), fileName)) { ContentType associated = catalog.getContentType(node.name()); if (associated != null) result.add(associated); break; } return false; }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } return result == null ? Collections.EMPTY_SET : result; }
/** * Applies any existing preferences to content types as a batch operation. */ private void applyPreferences() { try { final ContentTypeCatalog localCatalog = catalog; final IEclipsePreferences root = localCatalog.getManager().getPreferences(); root.accept(new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) { if (node == root) return true; ContentType contentType = localCatalog.internalGetContentType(node.name()); if (contentType != null) contentType.processPreferences(node); // content type nodes don't have any children anyway return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } }
/** * Applies any existing preferences to content types as a batch operation. */ private void applyPreferences() { try { final ContentTypeCatalog localCatalog = catalog; final IEclipsePreferences root = localCatalog.getManager().getPreferences(); root.accept(new IPreferenceNodeVisitor() { @Override public boolean visit(IEclipsePreferences node) { if (node == root) return true; ContentType contentType = localCatalog.internalGetContentType(node.name()); if (contentType != null) contentType.processPreferences(node); // content type nodes don't have any children anyway return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } }
/** * Applies any existing preferences to content types as a batch operation. */ private void applyPreferences() { try { final ContentTypeCatalog localCatalog = catalog; final IEclipsePreferences root = localCatalog.getManager().getPreferences(); root.accept(new IPreferenceNodeVisitor() { @Override public boolean visit(IEclipsePreferences node) { if (node == root) return true; ContentType contentType = localCatalog.internalGetContentType(node.name()); if (contentType != null) contentType.processPreferences(node); // content type nodes don't have any children anyway return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } }
/** * Applies any existing preferences to content types as a batch operation. */ private void applyPreferences() { try { final ContentTypeCatalog localCatalog = catalog; final IEclipsePreferences root = localCatalog.getManager().getPreferences(); root.accept(new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) { if (node == root) return true; ContentType contentType = localCatalog.internalGetContentType(node.name()); if (contentType != null) contentType.processPreferences(node); // content type nodes don't have any children anyway return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } }
/** * Applies any existing preferences to content types as a batch operation. */ private void applyPreferences() { try { final ContentTypeCatalog localCatalog = catalog; final IEclipsePreferences root = localCatalog.getManager().getPreferences(); root.accept(new IPreferenceNodeVisitor() { public boolean visit(IEclipsePreferences node) { if (node == root) return true; ContentType contentType = localCatalog.internalGetContentType(node.name()); if (contentType != null) contentType.processPreferences(node); // content type nodes don't have any children anyway return false; } }); } catch (BackingStoreException bse) { ContentType.log(ContentMessages.content_errorLoadingSettings, bse); } }