org.openide.util.Parameters Java Examples
The following examples show how to use
org.openide.util.Parameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: J2SEProjectUtil.java From netbeans with Apache License 2.0 | 6 votes |
public static boolean isCompileOnSaveSupported(final J2SEProject 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 BuildArtifactMapper.isCompileOnSaveSupported(); }
Example #2
Source File: StringUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Implode collection of strings to one string using delimiter. * @param items collection of strings to be imploded, can be empty (but not <code>null</code>) * @param delimiter delimiter to be used * @return one string of imploded strings using delimiter, never <code>null</code> * @see #explode(String, String) * @since 2.14 */ public static String implode(Collection<String> items, String delimiter) { Parameters.notNull("items", items); Parameters.notNull("delimiter", delimiter); if (items.isEmpty()) { return ""; // NOI18N } StringBuilder buffer = new StringBuilder(200); boolean first = true; for (String s : items) { if (!first) { buffer.append(delimiter); } buffer.append(s); first = false; } return buffer.toString(); }
Example #3
Source File: SourceUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Returns a {@link FileObject} in which the Element is defined. * @param element for which the {@link FileObject} should be located * @param cpInfo the classpaths context * @return the defining {@link FileObject} or null if it cannot be * found * * @deprecated use {@link getFile(ElementHandle, ClasspathInfo)} */ public static FileObject getFile (Element element, final ClasspathInfo cpInfo) { Parameters.notNull("element", element); //NOI18N Parameters.notNull("cpInfo", cpInfo); //NOI18N Element prev = isPkgOrMdl(element.getKind()) ? element : null; while (!isPkgOrMdl(element.getKind())) { prev = element; element = element.getEnclosingElement(); } final ElementKind kind = prev.getKind(); if (!(kind.isClass() || kind.isInterface() || isPkgOrMdl(kind))) { return null; } final ElementHandle<? extends Element> handle = ElementHandle.create(prev); return getFile (handle, cpInfo); }
Example #4
Source File: JFXProjectUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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); }
Example #5
Source File: IdentifiersUtil.java From netbeans with Apache License 2.0 | 6 votes |
/** * Checks whether the given <code>packageName</code> represents a * valid name for a package. * * @param packageName the package name to check; must not be null. * @return true if the given <code>packageName</code> is a valid package * name, false otherwise. */ public static boolean isValidPackageName(String packageName) { Parameters.notNull("packageName", packageName); // NOI18N if ("".equals(packageName)) { // NOI18N return true; } if (packageName.startsWith(".") || packageName.endsWith(".")) { // NOI18N return false; } String[] tokens = packageName.split("\\."); // NOI18N if (tokens.length == 0) { return Utilities.isJavaIdentifier(packageName); } for(String token : tokens) { if (!Utilities.isJavaIdentifier(token)) { return false; } } return true; }
Example #6
Source File: JavaActionProvider.java From netbeans with Apache License 2.0 | 6 votes |
protected ScriptAction ( @NonNull final String command, @NullAllowed final String dispalyName, final boolean platformSensitive, final boolean javaModelSensitive, final boolean scanSensitive, final boolean cosEnabled) { Parameters.notNull("command", command); //NOI18N this.command = command; this.displayName = dispalyName; this.actionFlags = EnumSet.noneOf(ActionProviderSupport.ActionFlag.class); if (platformSensitive) { this.actionFlags.add(ActionProviderSupport.ActionFlag.PLATFORM_SENSITIVE); } if (javaModelSensitive) { this.actionFlags.add(ActionProviderSupport.ActionFlag.JAVA_MODEL_SENSITIVE); } if (scanSensitive) { this.actionFlags.add(ActionProviderSupport.ActionFlag.SCAN_SENSITIVE); } if (cosEnabled) { this.actionFlags.add(ActionProviderSupport.ActionFlag.COS_ENABLED); } }
Example #7
Source File: FileUtil.java From netbeans with Apache License 2.0 | 6 votes |
private static File normalizeFileImpl(File file) { // XXX should use NIO in JDK 7; see #6358641 Parameters.notNull("file", file); //NOI18N File retFile; LOG.log(Level.FINE, "FileUtil.normalizeFile for {0}", file); // NOI18N long now = System.currentTimeMillis(); if ((BaseUtilities.isWindows() || (BaseUtilities.getOperatingSystem() == BaseUtilities.OS_OS2))) { retFile = normalizeFileOnWindows(file); } else if (BaseUtilities.isMac()) { retFile = normalizeFileOnMac(file); } else { retFile = normalizeFileOnUnixAlike(file); } File ret = (file.getPath().equals(retFile.getPath())) ? file : retFile; long took = System.currentTimeMillis() - now; if (took > 500) { LOG.log(Level.WARNING, "FileUtil.normalizeFile({0}) took {1} ms. Result is {2}", new Object[]{file, took, ret}); } return ret; }
Example #8
Source File: FileUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Save a file. * @param dataObject file to be saved * @since 2.54 */ public static void saveFile(@NonNull DataObject dataObject) { Parameters.notNull("dataObject", dataObject); // NOI18N SaveCookie saveCookie = dataObject.getLookup().lookup(SaveCookie.class); if (saveCookie != null) { try { try { saveCookie.save(); } catch (UserQuestionException uqe) { // #216194 NotifyDescriptor.Confirmation desc = new NotifyDescriptor.Confirmation(uqe.getLocalizedMessage(), NotifyDescriptor.Confirmation.OK_CANCEL_OPTION); if (DialogDisplayer.getDefault().notify(desc).equals(NotifyDescriptor.OK_OPTION)) { uqe.confirmed(); saveCookie.save(); } } } catch (IOException ioe) { LOGGER.log(Level.WARNING, ioe.getLocalizedMessage(), ioe); } } }
Example #9
Source File: CustomizerRun.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example #10
Source File: GenerationUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Adds an annotation to a method. This is equivalent to {@link TreeMaker#addModifiersAnnotation}, * but it creates and returns a new <code>MethodTree, not a new <code>ModifiersTree</code>. * * @param methodTree the method to add the annotation to; cannot be null. * @param annotationTree the annotation to add; cannot be null. * @return a new method annotated with the new annotation; never null. */ public MethodTree addAnnotation(MethodTree methodTree, AnnotationTree annotationTree) { Parameters.notNull("methodTree", methodTree); // NOI18N Parameters.notNull("annotationTree", annotationTree); // NOI18N TreeMaker make = getTreeMaker(); return make.Method( make.addModifiersAnnotation(methodTree.getModifiers(), annotationTree), methodTree.getName(), methodTree.getReturnType(), methodTree.getTypeParameters(), methodTree.getParameters(), methodTree.getThrows(), methodTree.getBody(), (ExpressionTree)methodTree.getDefaultValue()); }
Example #11
Source File: ErrorDescriptionFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** * Acquires read lock on the provided document to assure consistency */ public static @NonNull ErrorDescription createErrorDescription(@NonNull Severity severity, @NonNull String description, @NonNull List<Fix> fixes, @NonNull Document doc, @NonNull Position start, @NonNull Position end) { Parameters.notNull("severity", severity); Parameters.notNull("description", description); Parameters.notNull("fixes", fixes); Parameters.notNull("doc", doc); Parameters.notNull("start", start); Parameters.notNull("end", end); return createErrorDescription(severity, description, new StaticFixList(fixes), doc, start, end); }
Example #12
Source File: ProgressEvent.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates ProgressEvent instance. * @param source Source of the event. * @param eventId ID of the event. * @param operationType Source-specific number identifying source operation that * is being processed. * @param count Number of steps that the processed opration consists of. */ public ProgressEvent(@NonNull Object source, int eventId, int operationType, int count) { super(source); Parameters.notNull("source", source); // NOI18N this.eventId = eventId; this.operationType = operationType; this.count = count; }
Example #13
Source File: SpringScope.java From netbeans with Apache License 2.0 | 5 votes |
private static Project getSpringProject(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.getProject(); }
Example #14
Source File: RuntimePlatformProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void propertyChange(@NonNull final PropertyChangeEvent evt) { Parameters.notNull("evt", evt); //NOI18N final String propName = evt.getPropertyName(); if (JavaPlatformManager.PROP_INSTALLED_PLATFORMS.equals(propName) || ProjectProperties.JAVAC_TARGET.equals(propName) || ProjectProperties.JAVAC_PROFILE.equals(propName)) { resetAndFire(); } }
Example #15
Source File: TypeProvider.java From netbeans with Apache License 2.0 | 5 votes |
Result( @NonNull final Collection<? super TypeDescriptor> result, @NonNull final String[] message, @NonNull final Context context) { Parameters.notNull("result", result); //NOI18N Parameters.notNull("message", message); //NOI18N Parameters.notNull("context", context); //NOI18N if (message.length != 1) { throw new IllegalArgumentException("Message.length != 1"); //NOI18N } this.result = result; this.message = message; this.highlightText = context.getText(); }
Example #16
Source File: MultiModuleJavadocForBinaryQueryImpl.java From netbeans with Apache License 2.0 | 5 votes |
R( @NonNull final URI artefact, @NonNull final String jdocProperty, @NonNull final MultiModule modules, @NonNull final PropertyEvaluator evaluator, @NonNull final AntProjectHelper helper, @NonNull final String moduleName, @NonNull final String prop) { Parameters.notNull("artefact", artefact); //NOI18N Parameters.notNull("jdocProperty", jdocProperty); //NOI18N Parameters.notNull("modules", modules); //NOI18N Parameters.notNull("evaluator", evaluator); //NOI18N Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("moduleName", moduleName); //NOI18N Parameters.notNull("prop", prop); //NOI18N this.artefact = artefact; this.jdocProperty = jdocProperty; this.modules = modules; this.evaluator = evaluator; this.helper = helper; this.moduleName = moduleName; this.prop = prop; this.listeners = new ChangeSupport(this); this.cache = new AtomicReference<>(); this.currentModuleExists = new AtomicBoolean(true); this.modules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.modules)); this.evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, this.evaluator)); }
Example #17
Source File: Source.java From netbeans with Apache License 2.0 | 5 votes |
/** * Gets a <code>Source</code> instance for a file. The <code>FileObject</code> * passed to this method has to be a valid data file. There is no <code>Source</code> * representation for a folder. * * @param fileObject The file to get <code>Source</code> for. * * @return The <code>Source</code> for the given file or <code>null</code> * if the file doesn't exist. */ // XXX: this should really be called 'get' public static Source create ( FileObject fileObject ) { Parameters.notNull("fileObject", fileObject); //NOI18N if (!fileObject.isValid() || !fileObject.isData()) { return null; } return _get(fileObject.getMIMEType(), fileObject, Lookup.getDefault()); }
Example #18
Source File: NotificationDisplayerImpl.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Notification notify(String title, Icon icon, JComponent balloonDetails, JComponent popupDetails, Priority priority, Category category) { Parameters.notNull("balloonDetails", balloonDetails); //NOI18N Parameters.notNull("popupDetails", popupDetails); //NOI18N NotificationImpl n = createNotification(title, icon, priority, category); n.setDetails(balloonDetails, popupDetails); add(n); return n; }
Example #19
Source File: ClassPathProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
/** * Sets a property name containing build classes directory. * @param buildClassesDirProperty the name of property containing the build classes directory, by default "build.classes.dir" * @return {@link Builder} */ @NonNull public Builder setBuildClassesDirProperty(@NonNull final String buildClassesDirProperty) { Parameters.notNull("buildClassesDirProperty", buildClassesDirProperty); //NOI18N this.buildClassesDir = buildClassesDirProperty; return this; }
Example #20
Source File: ModuleClassPaths.java From netbeans with Apache License 2.0 | 5 votes |
ModuleInfoClassPathImplementation( @NonNull final ClassPath base, @NonNull final ClassPath sources, @NonNull final ClassPath systemModules, @NonNull final ClassPath userModules, @NonNull final ClassPath legacyClassPath, @NullAllowed final Function<URL,Boolean> filter) { super(null); Parameters.notNull("base", base); //NOI18N Parameters.notNull("sources", sources); //NOI18N Parameters.notNull("systemModules", systemModules); //NOI18N Parameters.notNull("userModules", userModules); //NOI18N Parameters.notNull("legacyClassPath", legacyClassPath); //NOI18N this.base = base; this.sources = sources; this.systemModules = systemModules; this.userModules = userModules; this.legacyClassPath = legacyClassPath; this.filter = filter == null ? (url) -> null : filter; this.selfRes = new ThreadLocal<>(); this.compilerOptions = new AtomicReference<>(); this.moduleInfos = Collections.emptyList(); this.sources.addPropertyChangeListener(WeakListeners.propertyChange(this, this.sources)); this.systemModules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.systemModules)); this.userModules.addPropertyChangeListener(WeakListeners.propertyChange(this, this.base)); this.legacyClassPath.addPropertyChangeListener(WeakListeners.propertyChange(this, this.legacyClassPath)); }
Example #21
Source File: CancelSupport.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void setCancelSupport(@NonNull final CancelSupportImplementation cancelSupport) { Parameters.notNull("cancelSupport", cancelSupport); //NOI18N final CancelSupport cs = getDefault(); if (cs.selfSpi.get() == null) { cs.selfSpi.set(cancelSupport); } }
Example #22
Source File: GenerationUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new annotation argument whose value is a member of a type. For * example it can be used to generate <code>@Target(ElementType.CONSTRUCTOR)</code>. * * @param argumentName the argument name; cannot be null. * @param argumentType the fully-qualified name of the type whose member is to be invoked * (e.g. <code>java.lang.annotations.ElementType</code> in the previous * example); cannot be null. * @param argumentTypeField a field of <code>argumentType</code> * (e.g. <code>CONSTRUCTOR</code> in the previous example); * cannot be null. * @return the new annotation argument; never null. */ public ExpressionTree createAnnotationArgument(String argumentName, String argumentType, String argumentTypeField) { Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N Parameters.notNull("argumentType", argumentType); // NOI18N Parameters.javaIdentifier("argumentTypeField", argumentTypeField); // NOI18N TreeMaker make = getTreeMaker(); MemberSelectTree argumentValueTree = make.MemberSelect(createQualIdent(argumentType), argumentTypeField); if (argumentName == null) { return argumentValueTree; } else { return make.Assignment(make.Identifier(argumentName), argumentValueTree); } }
Example #23
Source File: ParseTreeToXml.java From netbeans with Apache License 2.0 | 5 votes |
public ParseTreeToXml ( @NonNull final JsonLexer lexer, @NonNull final JsonParser parser) { Parameters.notNull("lexer", lexer); //NOI18N Parameters.notNull("parser", parser); //NOI18N this.lexer = lexer; this.parser = parser; currentNode = new ArrayDeque<>(); }
Example #24
Source File: JsTestingProviders.java From netbeans with Apache License 2.0 | 5 votes |
/** * Set given JS testing provider for the given project. If there already is any JS testing provider * and if it is the same as the given one, this method does nothing. * @param project project to be configured * @param jsTestingProvider JS testing provider to be set * @since 1.54 */ public void setJsTestingProvider(@NonNull Project project, @NonNull JsTestingProvider jsTestingProvider) { Parameters.notNull("project", project); // NOI18N Parameters.notNull("jsTestingProvider", jsTestingProvider); // NOI18N JsTestingProvider currentTestingProvider = getJsTestingProvider(project, false); if (currentTestingProvider != null) { if (currentTestingProvider.getIdentifier().equals(jsTestingProvider.getIdentifier())) { // already set the same one return; } currentTestingProvider.notifyEnabled(project, false); } jsTestingProvider.notifyEnabled(project, true); }
Example #25
Source File: PositionBoundsResolver.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new resolver for the given <code>dataObject</code>. * @param dataObject the data object that is being refactored. Must have an * associated <code>CloneableEditorSupport</code> and must not be null. * @param elementName the element that is being refactored. If the element represents class, * it should be its fully qualified name. If a <code>null</code> is given, {@link #getPositionBounds} * returns PositionBounds that represents the beginning of the file. * @throws IllegalArgumentException if the given <code>dataObject</code> was null * or if didn't have CloneableEditorSupport associated. */ public PositionBoundsResolver(DataObject dataObject, String elementName) { Parameters.notNull("dataObject", dataObject); this.dataObject = dataObject; this.editorSupport = findCloneableEditorSupport(); if (this.editorSupport == null){ throw new IllegalArgumentException("Couldn't get CloneableEditorSupport for " + dataObject); //NO18N } this.elementName = elementName; }
Example #26
Source File: J2SEProjectBuilder.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new instance of {@link J2SEProjectBuilder} * @param projectDirectory the directory in which the project should be created * @param name the name of the project */ public J2SEProjectBuilder( final @NonNull File projectDirectory, final @NonNull String name) { Parameters.notNull("projectDirectory", projectDirectory); //NOI18N Parameters.notNull("name", name); //NOI18N this.projectDirectory = projectDirectory; this.name = name; this.sourceRoots = new ArrayList<File>(); this.testRoots = new ArrayList<File>(); this.jvmArgs = new StringBuilder(); this.compileLibraries = new ArrayList<Library>(); this.runtimeLibraries = new ArrayList<Library>(); this.platform = JavaPlatformManager.getDefault().getDefaultPlatform(); }
Example #27
Source File: ParserManager.java From netbeans with Apache License 2.0 | 5 votes |
/** * Runs given task in parser thread. * @param mimetype specifying the parser * @param userTask a user task * @throws ParseException encapsulating the user exception */ public static void parse ( @NonNull final String mimeType, @NonNull final UserTask userTask ) throws ParseException { Parameters.notNull("mimeType", mimeType); //NOI18N Parameters.notNull("userTask", userTask); //NOI18N final Parser pf = findParser(mimeType); TaskProcessor.runUserTask (new MimeTaskAction(pf, userTask), Collections.<Source>emptyList ()); }
Example #28
Source File: MultiModuleNodeFactory.java From netbeans with Apache License 2.0 | 5 votes |
private Builder( @NonNull final UpdateHelper helper, @NonNull final PropertyEvaluator eval, @NonNull final ReferenceHelper refHelper) { Parameters.notNull("helper", helper); //NOI18N Parameters.notNull("eval", eval); //NOI18N Parameters.notNull("refHelper", refHelper); //NOI18N this.helper = helper; this.eval = eval; this.refHelper = refHelper; this.procGenSourcesProp = ProjectProperties.ANNOTATION_PROCESSING_SOURCE_OUTPUT; }
Example #29
Source File: HistorySupport.java From netbeans with Apache License 2.0 | 5 votes |
HistoryModel( @NonNull final HistorySupport history, @NonNull final String emptyMessage) { Parameters.notNull("history", history); //NOI18N listeners = new CopyOnWriteArrayList<ListDataListener>(); this.history = history; this.emptyMessage = emptyMessage; this.history.addPropertyChangeListener(WeakListeners.propertyChange(this, history)); }
Example #30
Source File: ProjectOperations.java From netbeans with Apache License 2.0 | 5 votes |
/** * Sets the name of property referencing the project build script. * If not set the {@link ProjectProperties#BUILD_SCRIPT} is used. * @param propertyName the name of property holding the name of project's build script. * @return the {@link ProjectOperationsBuilder} */ @NonNull public ProjectOperationsBuilder setBuildScriptProperty(@NonNull final String propertyName) { Parameters.notNull("propertyName", propertyName); //NOI18N this.buildScriptProperty = propertyName; return this; }