SourceLevelSelector( @NonNull final PropertyEvaluator eval, @NonNull final String sourceLevelPropName, @NonNull final List<? extends Supplier<? extends ClassPath>> cpFactories) { Parameters.notNull("eval", eval); //NOI18N Parameters.notNull("sourceLevelPropName", sourceLevelPropName); //NOI18N Parameters.notNull("cpFactories", cpFactories); //NOI18N if (cpFactories.size() != 2) { throw new IllegalArgumentException("Invalid classpaths: " + cpFactories); //NOI18N } for (Supplier<?> f : cpFactories) { if (f == null) { throw new NullPointerException("Classpaths contain null: " + cpFactories); //NOI18N } } this.eval = eval; this.sourceLevelPropName = sourceLevelPropName; this.cpfs = cpFactories; this.listeners = new PropertyChangeSupport(this); this.cps = new ClassPath[2]; this.eval.addPropertyChangeListener(WeakListeners.propertyChange(this, this.eval)); }
/** * Utility method to check the given {@link CompilationUnitTree} for white list violations. * @param unit the {@link CompilationUnitTree} to be analyzed * @param whitelist the {@link WhiteList} to use to check the violations * @param trees the {@link Trees} service * @param cancel the cancel request. If the {@link Callable} returns true the check is canceled * and null is returned. * @return a {@link Map} of {@link Tree}s with attached white list violations or null when the * scan was canceled. */ @CheckForNull public static Map<? extends Tree, ? extends WhiteListQuery.Result> getWhiteListViolations( @NonNull final CompilationUnitTree unit, @NonNull final WhiteListQuery.WhiteList whitelist, @NonNull final Trees trees, @NullAllowed final Callable<Boolean> cancel) { Parameters.notNull("tree", unit); //NOI18N Parameters.notNull("whitelist", whitelist); //NOI18N Parameters.notNull("trees", trees); //NOI18N final Map<Tree,WhiteListQuery.Result> result = new HashMap<Tree, Result>(); final WhiteListScanner scanner = new WhiteListScanner(trees, whitelist, cancel); try { scanner.scan(unit, result); return result; } catch (WhiteListScanner.Cancel ce) { return null; } }
/** * Return a {@link SourceLevelQuery.Profile} for an item obtained from the ComboBoxModel created by * the {@link PlatformUiSupport#createProfileComboBoxModel} method. * This method can return <code>null</code> if the profile is broken. * @param profileKey an item obtained from {@link ComboBoxModel} created by * {@link PlatformUiSupport#createProfileComboBoxModel}. * @return {@link SourceLevelQuery.Profile} or <code>null</code> in case when profile is broken. * @throws IllegalArgumentException if the input parameter is not an object created by profile combobox model. * @since 1.57 */ @CheckForNull public static SourceLevelQuery.Profile getProfile(@NonNull final Object profileKey) { Parameters.notNull("profileKey", profileKey); //NOI18N if (profileKey instanceof Union2) { final Union2 u2 = (Union2)profileKey; if (u2.hasFirst()) { final Object profile = u2.first(); if (profile instanceof SourceLevelQuery.Profile) { return (SourceLevelQuery.Profile) profile; } else { throw new IllegalArgumentException(profile.getClass().getName()); } } else { return null; } } else { throw new IllegalArgumentException(profileKey.getClass().getName()); } }
/** Constructs new filter node with a provided children and lookup. * The lookup is used to implement {@link FilterNode#getCookie} calls that just call * <code>lookup.lookup(clazz)</code>. If this constructor is used, * the code shall not override {@link FilterNode#getCookie} method, but do all * its state manipulation in the lookup. Look at {@link Node#Node} * constructor for best practices usage of this constructor. * * @param original the node we delegate to * @param children the children to use for the filter node or <code>null</code> if * default children should be provided * @param lookup lookup to use. Do not pass <CODE>orginal.getLookup()</CODE> into this parameter. * In such case use the {@link #FilterNode(Node, Children)} constructor. * * @since 4.4 */ public FilterNode(Node original, org.openide.nodes.Children children, Lookup lookup) { super( (children == null) ? (original.isLeaf() ? org.openide.nodes.Children.LEAF : new Children(original)) : children, lookup ); Parameters.notNull("original", original); this.childrenProvided = children != null; this.lookupProvided = lookup != null && !(lookup instanceof FilterLookup); this.original = original; init(); Lookup lkp = internalLookup(false); if (lkp instanceof FilterLookup) { ((FilterLookup) lkp).ownNode(this); } else { if (lkp == null) { // rely on default NodeLookup around getCookie. getNodeListener(); } } }
/** * Creates a simple {@link ScriptAction} for given command performing given targets. * The action just calls the given targets in project's build file. * The action does not support Compile On Save. * @param command the action command * @param requiresValidJavaPlatform if true the action is not executed when the project has invalid platform * @param javaModelSensitive if true the action requires java model * @param scanSensitive if true the action needs to wait for scan finish * @param enabledInCoS if true the action is enabled in compile on save mode * @param targets the targets to execute * @return the newly created {@link ScriptAction} * @since 1.109 */ @NonNull public ScriptAction createSimpleScriptAction( @NonNull final String command, final boolean requiresValidJavaPlatform, final boolean javaModelSensitive, final boolean scanSensitive, final boolean enabledInCoS, @NonNull final String... targets) { Parameters.notNull("targets", targets); //NOI18N return createSimpleScriptAction( command, requiresValidJavaPlatform, javaModelSensitive, scanSensitive, enabledInCoS, (ctx) -> true, () -> targets); }
/** * Removes the path entry from path. * @param path to remove the netry from * @param toRemove the entry to be rmeoved from the path * @return new path with removed entry */ @NonNull public static String removeFromPath(@NonNull final String path, @NonNull final String toRemove) { Parameters.notNull("path", path); //NOI18N Parameters.notNull("toRemove", toRemove); //NOI18N final StringBuilder sb = new StringBuilder(); for (String entry : PropertyUtils.tokenizePath(path)) { if (toRemove.equals(entry)) { continue; } sb.append(entry); sb.append(':'); //NOI18N } return sb.length() == 0 ? sb.toString() : sb.substring(0, sb.length()-1); }
private ProjectOperationsBuilder( @NonNull final Project project, @NonNull final PropertyEvaluator eval, @NonNull final UpdateHelper helper, @NonNull final ReferenceHelper refHelper, @NonNull final SourceRoots sources, @NonNull final SourceRoots tests) { Parameters.notNull("project", project); //NOI18N Parameters.notNull("eval", eval); //NOI18N Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("refHelper", refHelper); //NOI18N Parameters.notNull("sources", sources); //NOI18N Parameters.notNull("tests", tests); //NOI18N this.project = project; this.eval = eval; this.helper = helper; this.refHelper = refHelper; this.sources = sources; this.tests = tests; this.additionalMetadataFiles = new ArrayList<>(); this.additionalDataFiles = new ArrayList<>(); this.cleanTargets = new ArrayList<>(); this.privateProps = new HashSet<>(); this.updatedProps = new HashMap<>(); }
private void init() { errorLabel.setText(" "); // NOI18N GroupLayout containerPanelLayout = new GroupLayout(containerPanel); containerPanel.setLayout(containerPanelLayout); GroupLayout.ParallelGroup horizontalGroup = containerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); GroupLayout.SequentialGroup verticalGroup = containerPanelLayout.createSequentialGroup(); containerPanelLayout.setHorizontalGroup(horizontalGroup); containerPanelLayout.setVerticalGroup( containerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(verticalGroup) ); for (CssPreprocessorUIImplementation.Options options : allOptions) { JComponent component = options.getComponent(); Parameters.notNull("component", component); // NOI18N horizontalGroup.addComponent(component, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); verticalGroup.addComponent(component, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED); } }
public static boolean isCompileOnSaveSupported(final J2SEModularProject project) { Parameters.notNull("project", project); final Map<String,String> props = project.evaluator().getProperties(); if (props == null) { LOG.warning("PropertyEvaluator mapping could not be computed (e.g. due to a circular definition)"); //NOI18N } else { for (Entry<String, String> e : props.entrySet()) { if (e.getKey().startsWith(ProjectProperties.COMPILE_ON_SAVE_UNSUPPORTED_PREFIX)) { if (e.getValue() != null && Boolean.valueOf(e.getValue())) { return false; } } } } return true; }
@Deprecated public static void setBreadcrumbs(@NonNull Document doc, @NonNull final Node root, @NonNull final Node selected) { Parameters.notNull("doc", doc); Parameters.notNull("root", root); Parameters.notNull("selected", selected); final ExplorerManager manager = HolderImpl.get(doc).getManager(); Children.MUTEX.writeAccess(new Action<Void>() { @Override public Void run() { manager.setRootContext(root); manager.setExploredContext(selected); return null; } }); }
DataSource( @NonNull final String propName, @NonNull final JLabel label, @NonNull final JComboBox<?> configCombo, @NonNull final Map<String,Map<String,String>> configs) { Parameters.notNull("propName", propName); //NOI18N Parameters.notNull("label", label); //NOI18N Parameters.notNull("configCombo", configCombo); //NOI18N Parameters.notNull("configs", configs); //NOI18N this.propName = propName; this.label = label; this.configCombo = configCombo; this.configs = configs; basefont = label.getFont(); boldfont = basefont.deriveFont(Font.BOLD); }
/** * Returns the context for given {@link FileObject} indexing. * @param file the {@link FileObject} to get indexing context for * @return the context represented by {@link Lookup} */ @NonNull public static Lookup getContext(@NonNull FileObject file) { Parameters.notNull("file", file); //NOI18N for (ContextProvider cp : getImpls()) { final Lookup res = cp.findContext(file); if (res != null) { return res; } } throw new IllegalStateException("Missing DefaultContextProvider"); //NOI18N }
/** * Finds the Spring scope that contains (or could contain) a given file. * * @param fo a file; never null. * @return the Spring scope or null. */ public static SpringScope getSpringScope(FileObject fo) { Parameters.notNull("fo", fo); Project project = FileOwnerQuery.getOwner(fo); if (project == null) { return null; } ProjectSpringScopeProvider provider = project.getLookup().lookup(ProjectSpringScopeProvider.class); if (provider == null) { return null; } return provider.getSpringScope(); }
/** * Returns a FileObject representing an archive file containing the * FileObject given by the parameter. * <strong>Remember</strong> that any path within the archive is discarded * so you may need to check for non-root entries. * @param fo a file in an archive filesystem * @return the file corresponding to the archive itself, * or null if <code>fo</code> is not an archive entry * @since 4.48 */ public static FileObject getArchiveFile(FileObject fo) { Parameters.notNull("fo", fo); //NOI18N for (ArchiveRootProvider provider : getArchiveRootProviders()) { if (provider.isArchiveArtifact(fo)) { final FileObject file = provider.getArchiveFile(fo); if (file != null) { return file; } } } return null; }
private void runDeferred(@NonNull final Runnable r) { Parameters.notNull("r", r); //NOI18N ProjectManager.mutex().postReadRequest(new Runnable() { @Override public void run() { ProjectManager.mutex().postWriteRequest(r); } }); }
public FileDescription( @NonNull final FileObject file, @NonNull final String ownerPath, @NullAllowed final Project project) { Parameters.notNull("file", file); //NOI18N Parameters.notNull("ownerPath", ownerPath); //NOI18N this.fileObject = file; this.ownerPath = ownerPath; this.project = project; }
@Override @NonNull public IndexDocument createDocument(@NonNull final Indexable indexable) { Parameters.notNull("indexable", indexable); //NOI18N return TransientUpdateSupport.isTransientUpdate() ? IndexManager.createDocument(indexable.getRelativePath()) : ClusteredIndexables.createDocument(indexable.getRelativePath()); }
public void setColorDebug(Color colorDebug) { Parameters.notNull("colorDebug", colorDebug); //NOI18N if (!colorDebug.equals(this.colorDebug)) { Color oldColorDebug = this.colorDebug; this.colorDebug = colorDebug; pcs.firePropertyChange(PROP_COLOR_DEBUG, oldColorDebug, colorDebug); } }
/** * Returns an estimate of a number of classes on given source path (source root) which are * using given package. * @param pkg the package to find the usage frequency for. * @return number of classes using types from given package. */ public int getPackageReferenceCount(@NonNull final ElementHandle<? extends PackageElement> pkg) { Parameters.notNull("pkgName", pkg); //NOI18N if (pkg.getKind() != ElementKind.PACKAGE) { throw new IllegalArgumentException(pkg.toString()); } try { init(); final Integer count = pkgFreqs.get(SourceUtils.getJVMSignature(pkg)[0]); return count == null ? 0 : count; } catch (InterruptedException ie) { return 0; } }
/** * Sets a preferred {@link JavaPlatform} for a new project. * @param platform the preferred {@link JavaPlatform} */ public static void setPreferredPlatform(@NonNull final JavaPlatform platform) { Parameters.notNull("platform", platform); //NOI18N final String platformId = platform.getProperties().get(PLATFORM_ANT_NAME); if (platformId == null) { throw new IllegalArgumentException("Invalid platform, the platform has no platform.ant.name"); //NOI18N } final String platformType = platform.getSpecification().getName(); NbPreferences.forModule(PreferredProjectPlatform.class).put( MessageFormat.format(PREFERRED_PLATFORM, platformType), platformId); }
/** * Creates the new input representing the given file. * * @param file file to represent * @param charset associated charset */ public FileInput(@NonNull File file, @NonNull Charset charset) { Parameters.notNull("file", file); Parameters.notNull("charset", charset); this.file = file; this.charset = charset; }
@NonNull public Builder setProjectMainClassProvider(@NonNull final Function<Boolean,String> mainClassProvider) { Parameters.notNull("mainClassProvider", mainClassProvider); mainClassServices[0] = mainClassProvider; mainClassServices = mainClassServices; return this; }
/** * Deletes a key from the ring. * If the key was not in the ring to begin with, does nothing. * <p> * This method can be called from any thread. * The changes done by multiple calls to {@link #delete(java.lang.String)} * or {@link #save(java.lang.String, char[], java.lang.String)} methods * are guaranteed to be processed in order in which they were called. * * @param key a key identifier */ public static void delete(@NonNull final String key) { Parameters.notNull("key", key); KEYRING_ACCESS.post(new Runnable() { @Override public void run() { Keyring.deleteImpl(key); } }); }
/** * Check whether a file is recommended to be visible. * Default return value is visible unless at least one VisibilityQueryImplementation * provider says hidden. * @param file a file which should be checked * @return true if it is recommended to show this file */ public boolean isVisible(FileObject file) { Parameters.notNull("file", file); for (VisibilityQueryImplementation vqi : getVqiInstances()) { if (!vqi.isVisible(file)) { return false; } } return true; }
public void load(CompilationInfo info, FxModel source) { Parameters.notNull("info", info); this.info = info; try { // initialize java.lang handleWildcard("java.lang", false); // NOI18N source.accept(this); } finally { this.info = null; } }
/** * Sets javac classpath properties for source roots. * @param javacClassPathProperties the names of properties containing the compiler classpath for sources, by default "javac.classpath" * @return {@link Builder} */ @NonNull public Builder setJavacClassPathProperties(@NonNull final String[] javacClassPathProperties) { Parameters.notNull("javacClassPathProperties", javacClassPathProperties); //NOI18N this.javacClasspath = Arrays.copyOf(javacClassPathProperties, javacClassPathProperties.length); return this; }
@CheckForNull public static Pair<List<String>,String> configure( @NonNull final String userName, @NonNull final String host, @NonNull File destFolder) { Parameters.notNull("destFolder", destFolder); //NOI18N Parameters.notNull("userName", userName); //NOI18N Parameters.notNull("host", host); //NOI18N return configureImpl(userName, host, destFolder); }
@Override @CheckForNull public ProfilerSupport create(@NonNull final String id) { Parameters.notNull("id", id); //NOI18N Sampler s = Sampler.createSampler(id); return s != null ? new NbSamplerProfiler(s) : null; }
/** * Return the display name of this CSS preprocessor. The display name is used * in the UI. * @return the display name; never {@code null} */ @NonNull public String getDisplayName() { String displayName = delegate.getDisplayName(); Parameters.notNull("displayName", displayName); // NOI18N return displayName; }
public void testNotEmpty() throws Exception { assertNPEOnNull(Parameters.class.getMethod("notEmpty", CharSequence.class, CharSequence.class)); try { Parameters.notEmpty("param", ""); fail("Should have thrown IAE"); } catch (IllegalArgumentException e) {} Parameters.notEmpty("param", "foo"); }
public JFXProjectOpenedHook(final Lookup lkp) { Parameters.notNull("lkp", lkp); //NOI18N this.prj = lkp.lookup(Project.class); Parameters.notNull("prj", prj); //NOI18N this.eval = lkp.lookup(J2SEPropertyEvaluator.class); Parameters.notNull("eval", eval); //NOI18N }
/** * Removes any modifiers from the given <code>VariableTree</code>. This can be e.g. * used to create a variable suitable for use as a method parameter. * * @param variableTree the <code>VariableTree</code> to remove the modifiers from. * @return a <code>VariableTree</code> with the same properties but no modifiers. */ public VariableTree removeModifiers(VariableTree variableTree) { Parameters.notNull("variableTree", variableTree); TreeMaker make = getTreeMaker(); return make.Variable( createEmptyModifiers(), variableTree.getName(), variableTree.getType(), variableTree.getInitializer()); }
/** * Adds or removes jar files or folders to (from) given classpath. * @deprecated use {@link ClassPathModifierSupport#handleRoots(org.netbeans.api.project.Project, org.netbeans.modules.java.api.common.ant.UpdateHelper, org.netbeans.modules.java.api.common.classpath.ClassPathSupport, org.netbeans.spi.project.support.ant.PropertyEvaluator, org.netbeans.spi.project.support.ant.ReferenceHelper, org.netbeans.modules.java.api.common.project.ui.ClassPathUiSupport.Callback, java.net.URI[], java.lang.String, java.lang.String, int) } */ @Deprecated public static boolean handleRoots ( @NonNull final Project project, @NonNull final AntProjectHelper helper, @NonNull final ClassPathSupport cs, @NonNull final PropertyEvaluator eval, @NullAllowed final ClassPathUiSupport.Callback cpUiSupportCallback, @NonNull final URI[] classPathRoots, @NonNull final String classPathProperty, @NullAllowed final String projectXMLElementName, final int operation) throws IOException { Parameters.notNull("project", project); //NOI18N Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("cs", cs); //NOI18N Parameters.notNull("eval", eval); //NOI18N Parameters.notNull("classPathProperty", classPathRoots); //NOI18N Parameters.notNull("classPathProperty", classPathProperty); //NOI18N return handleRootsImpl( project, helper, cs, eval, null, null, cpUiSupportCallback, classPathRoots, classPathProperty, projectXMLElementName, operation); }
InvalidPlatformData( @NonNull final JavaPlatform jp, @NonNull final SpecificationVersion targetLevel, @NonNull final SourceLevelQuery.Profile profile) { Parameters.notNull("jp", jp); //NOI18N Parameters.notNull("targetLevel", targetLevel); //NOI18N Parameters.notNull("profile", profile); //NOI18N this.jp = jp; this.targetLevel = targetLevel; this.profile = profile; }
/** * Creates a standard lucene query querying the index for * documents having indexed field containing the given value * @param fieldName the name of the field * @param caseInsensitiveFieldName the name of the field containing the case insensitive value * @param value the value to search for * @param kind the type of query, {@link Queries.QueryKind} * @param options the query configuration options * @return the created query * @since 2.31 */ @NonNull public static Query createQuery ( final @NonNull String fieldName, final @NonNull String caseInsensitiveFieldName, final @NonNull String value, final @NonNull QueryKind kind, final @NonNull Map<String,Object> options) { Parameters.notNull("fieldName", fieldName); //NOI18N Parameters.notNull("caseInsensitiveFieldName", caseInsensitiveFieldName); //NOI18N Parameters.notNull("value", value); //NOI18N Parameters.notNull("kind", kind); //NOI18N Parameters.notNull("options", options); //NOI18N return createQueryImpl(fieldName, caseInsensitiveFieldName, value, kind, new StandardQueryFactory(), options); }
/** * Sets javac source level property. * @param javacSource the name of the property containing the javac source level * @return {@link Builder} * @since 1.76 */ @NonNull public Builder setJavacSourceProperty(@NonNull final String javacSource) { Parameters.notNull("javacSource", javacSource); //NOI18N this.javacSource = javacSource; return this; }
BaseResolver( @NonNull final RefType type, @NonNull final String id) { Parameters.notNull("type", type); //NOI18N Parameters.notNull("id", id); //NOI18N this.type = type; this.id = id; }
/** * Adds actions to libraries node. * @param actions the actions to be added. * @return the {@link Builder} */ @NonNull public Builder addLibrariesNodeActions(@NonNull final Action... actions) { Parameters.notNull("actions", actions); //NOI18N Collections.addAll(librariesNodeActions, actions); return this; }
@NbBundle.Messages({ "LBL_BrokenLinksCustomizer_Close=Close", "ACSD_BrokenLinksCustomizer_Close=N/A", "LBL_BrokenLinksCustomizer_Title=Resolve Project Problems - \"{0}\" Project" }) @Override public void showCustomizer(@NonNull Project project) { Parameters.notNull("project", project); //NOI18N BrokenReferencesModel model = new BrokenReferencesModel(project); BrokenReferencesCustomizer customizer = new BrokenReferencesCustomizer(model); JButton close = new JButton (LBL_BrokenLinksCustomizer_Close()); // NOI18N close.getAccessibleContext ().setAccessibleDescription (ACSD_BrokenLinksCustomizer_Close()); // NOI18N String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName(); DialogDescriptor dd = new DialogDescriptor(customizer, LBL_BrokenLinksCustomizer_Title(projectDisplayName), // NOI18N true, new Object[] {close}, close, DialogDescriptor.DEFAULT_ALIGN, null, null); customizer.setNotificationLineSupport(dd.createNotificationLineSupport()); Dialog dlg = null; try { dlg = DialogDisplayer.getDefault().createDialog(dd); dlg.setVisible(true); } finally { if (dlg != null) { dlg.dispose(); } } }
public RepositoryBrowserPanel (final EnumSet<Option> options, File repository, File[] roots, RepositoryInfo info) { Parameters.notNull("roots", roots); this.currRepository = repository; this.root = options.contains(Option.DISPLAY_ALL_REPOSITORIES) ? new AbstractNode(new RepositoriesChildren()) { @Override public Action[] getActions (boolean context) { if (options.contains(Option.ENABLE_POPUP)) { return new Action[] { new OpenRepositoryAction() }; } else { return super.getActions(context); } } } : new RepositoryNode(repository, info); this.manager = new ExplorerManager(); this.options = options; this.roots = roots; initComponents(); if (!options.contains(Option.DISPLAY_TOOLBAR)) { toolbar.setVisible(false); } tree.setRootVisible(false); tree.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); if (!options.contains(Option.DISPLAY_REVISIONS)) { remove(jSplitPane1); add(tree, BorderLayout.CENTER); } if (options.contains(Option.ENABLE_POPUP)) { getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); // NOI18N getActionMap().put("delete", new DeleteAction()); // NOI18N } }