Java Code Examples for org.netbeans.api.project.ProjectUtils#getPreferences()

The following examples show how to use org.netbeans.api.project.ProjectUtils#getPreferences() . 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: ProjectDefaultHtmlSourceVersionController.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static HtmlVersion findHtmlVersion(Project project, String namespace, boolean xhtml) {
    Preferences prefs = ProjectUtils.getPreferences(project, HtmlSourceVersionController.class, true);
    String publicId = prefs.get(getPropertyKey(xhtml), null);
    if (publicId == null) {
        return null;
    }
    
    //no-public id versions
    if(xhtml && publicId.equals(HtmlVersion.XHTML5.name())) {
        return HtmlVersion.XHTML5;
    } else if(!xhtml && publicId.equals(HtmlVersion.HTML5.name())) {
        return HtmlVersion.HTML5;
    }
     
    try {
        return HtmlVersion.find(publicId, namespace);
    } catch (IllegalArgumentException e) {
        //no-op
    }
    return null;
}
 
Example 2
Source File: EclipseProjectReference.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void write(Project project, EclipseProjectReference ref) {
    Preferences prefs = ProjectUtils.getPreferences(project, EclipseProjectReference.class, true);
    File baseDir = FileUtil.toFile(project.getProjectDirectory());
    if (CollocationQuery.areCollocated(baseDir, ref.eclipseProjectLocation)) {
        prefs.put("project", PropertyUtils.relativizeFile(baseDir, ref.eclipseProjectLocation)); //NOI18N
    } else {
        prefs.put("project", ref.eclipseProjectLocation.getPath()); //NOI18N
    }
    if (ref.eclipseWorkspaceLocation != null) {
        if (CollocationQuery.areCollocated(baseDir, ref.eclipseWorkspaceLocation)) {
            prefs.put("workspace", PropertyUtils.relativizeFile(baseDir, ref.eclipseWorkspaceLocation)); //NOI18N
        } else {
            prefs.put("workspace", ref.eclipseWorkspaceLocation.getPath()); //NOI18N
        }
    }
    prefs.put("timestamp", Long.toString(ref.getCurrentTimestamp())); //NOI18N
    prefs.put("key", ref.key); //NOI18N
}
 
Example 3
Source File: MissingModuleProblemsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Preferences getPreferences() {
    Preferences prefs = prefsCache.get();
    if (prefs == null) {
        prefs = ProjectUtils.getPreferences(project, MissingModuleProblemsProvider.class, true);
        if (prefsCache.compareAndSet(null, prefs)) {
            prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
        }
    }
    return prefs;
}
 
Example 4
Source File: WSUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static String getOriginalWsdlUrl(Project prj, String id, boolean forService) {
    Preferences prefs = ProjectUtils.getPreferences(prj, MavenWebService.class, true);
    if (prefs != null) {
        // remember original WSDL URL for service
        if (forService) {
            return prefs.get(MavenWebService.SERVICE_PREFIX+id, null);
        } else {
            return prefs.get(MavenWebService.CLIENT_PREFIX+id, null);
        }
    }
    return null;
}
 
Example 5
Source File: MobileConfigurationsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override

    public void setActiveConfiguration(MobileConfigurationImpl c) throws IllegalArgumentException, IOException {
        if (configs == null) {
            calculateConfigs();
        }
        Preferences prefs = ProjectUtils.getPreferences(p, MobileConfigurationsProvider.class, false);
        prefs.put(PROP_CONFIG, c.getId());
    }
 
Example 6
Source File: WebProjectBrowserProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Preferences getPreferences() {
    if (preferences == null) {
        preferences = ProjectUtils.getPreferences(project, MavenProjectSupport.class, false);
        preferences.addPreferenceChangeListener(new PreferenceChangeListener() {

            @Override
            public void preferenceChange(PreferenceChangeEvent evt) {
                if (MavenJavaEEConstants.SELECTED_BROWSER.equals(evt.getKey())) {
                    pcs.firePropertyChange(PROP_BROWSER_ACTIVE, null, null);
                }
            }
        });
    }
    return preferences;
}
 
Example 7
Source File: JSFTargetPanelProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void storeSettings( TargetChooserPanel<FileType> panel ) {
    if (isFacelets()) {
        Preferences preferences = ProjectUtils.getPreferences(
                panel.getProject(), ProjectUtils.class, true);
        String key = "jsf.language";            //NOI18N
        String value = "Facelets";              //NOI18N
        if (!preferences.get(key, "").equals(value)){
            preferences.put(key, value);
        }
    }
    
    panel.getTemplateWizard().putProperty(FileType.IS_XML, false);
    panel.getTemplateWizard().putProperty(FileType.IS_SEGMENT, getUIManager().isSegment());
    panel.getTemplateWizard().putProperty(FileType.IS_FACELETS, getUIManager().isFacelets());
}
 
Example 8
Source File: JsPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Preferences getPreferences(Project project) {
    return ProjectUtils.getPreferences(project, JsPreferences.class, true);
}
 
Example 9
Source File: FormattingCustomizerPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ProjectPreferencesFactory(Project project) {
    this.project = project;
    Preferences p = ProjectUtils.getPreferences(project, IndentUtils.class, true);
    projectPrefs = ProxyPreferences.getProxyPreferences(this, p);
}
 
Example 10
Source File: EnhancedBrowserImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isHighlightSelectionEnabled() {
    Preferences p = ProjectUtils.getPreferences(project, EnhancedBrowserImpl.class, false);
    return p.getBoolean(PROJECT_HIGHLIGHT_SELECTION+"."+browser.getId(), browser.hasNetBeansIntegration()); //NOI18N
}
 
Example 11
Source File: MochaSeleniumPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Preferences getPreferences(Project project) {
    return ProjectUtils.getPreferences(project, MochaSeleniumPreferences.class, false);
}
 
Example 12
Source File: JaxWsClientCreator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void createClient() throws IOException {
    JAXWSLightSupport jaxWsSupport = JAXWSLightSupport.getJAXWSLightSupport(project.getProjectDirectory());
    String wsdlUrl = (String)wiz.getProperty(WizardProperties.WSDL_DOWNLOAD_URL);
    String filePath = (String)wiz.getProperty(WizardProperties.WSDL_FILE_PATH);
    //Boolean useDispatch = (Boolean) wiz.getProperty(ClientWizardProperties.USEDISPATCH);
    //if (wsdlUrl==null) wsdlUrl = "file:"+(filePath.startsWith("/")?filePath:"/"+filePath); //NOI18N
    if(wsdlUrl == null) {
        wsdlUrl = FileUtil.toFileObject(FileUtil.normalizeFile(new File(filePath))).getURL().toExternalForm();
    }
    FileObject localWsdlFolder = jaxWsSupport.getWsdlFolder(true);
    
    boolean hasSrcFolder = false;
    File srcFile = new File (FileUtil.toFile(project.getProjectDirectory()),"src"); //NOI18N
    if (srcFile.exists()) {
        hasSrcFolder = true;
    } else {
        hasSrcFolder = srcFile.mkdirs();
    }
    
    if (localWsdlFolder != null) {
        FileObject wsdlFo = retrieveWsdl(wsdlUrl, localWsdlFolder,
                hasSrcFolder);
        if (wsdlFo != null) {
            final boolean isJaxWsLibrary = MavenModelUtils.hasJaxWsAPI(project);
            final String relativePath = FileUtil.getRelativePath(localWsdlFolder, wsdlFo);
            final String clientName = wsdlFo.getName();

            Preferences prefs = ProjectUtils.getPreferences(project, MavenWebService.class, true);
            if (prefs != null) {
                // remember original wsdlUrl for Client
                prefs.put(MavenWebService.CLIENT_PREFIX+WSUtils.getUniqueId(wsdlFo.getName(), jaxWsSupport.getServices()), wsdlUrl);
            }

            if (!isJaxWsLibrary) {
                try {
                    MavenModelUtils.addMetroLibrary(project);
                    MavenModelUtils.addJavadoc(project);
                } catch (Exception ex) {
                    Logger.getLogger(
                        JaxWsClientCreator.class.getName()).log(
                            Level.INFO, "Cannot add Metro libbrary to pom file", ex); //NOI18N
                }
            }
            
            final String wsdlLocation = wsdlUrl;
            ModelOperation<POMModel> operation = new ModelOperation<POMModel>() {
                @Override
                public void performOperation(POMModel model) {

                    String packageName = (String) wiz.getProperty(WizardProperties.WSDL_PACKAGE_NAME);
                    org.netbeans.modules.maven.model.pom.Plugin plugin =
                            WSUtils.isEJB(project) ?
                                MavenModelUtils.addJaxWSPlugin(model, "2.0") : //NOI18N
                                MavenModelUtils.addJaxWSPlugin(model);

                    MavenModelUtils.addWsimportExecution(plugin, clientName, 
                            relativePath,wsdlLocation, packageName);
                    if (WSUtils.isWeb(project)) { // expecting web project
                        MavenModelUtils.addWarPlugin(model, true);
                    } else { // J2SE Project
                        MavenModelUtils.addWsdlResources(model);
                    }
                }
            };
            Utilities.performPOMModelOperations(project.getProjectDirectory().getFileObject("pom.xml"),
                    Collections.singletonList(operation));

            // execute wsimport goal
            RunConfig cfg = RunUtils.createRunConfig(FileUtil.toFile(
                    project.getProjectDirectory()),
                    project,
                    "JAX-WS:wsimport", //NOI18N
                    Collections.singletonList("compile")); //NOI18N
            
            RunUtils.executeMaven(cfg);
         }
    }
}
 
Example 13
Source File: PhpModuleImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Preferences getPreferences(Class<?> clazz, boolean shared) {
    return ProjectUtils.getPreferences(phpProject, clazz, shared);
}
 
Example 14
Source File: NodeJsPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private synchronized Preferences getPrivatePreferences() {
    if (privatePreferences == null) {
        privatePreferences = ProjectUtils.getPreferences(project, NodeJsPreferences.class, false);
    }
    return privatePreferences;
}
 
Example 15
Source File: GruntPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private synchronized Preferences getPreferences() {
    if (sharedPreferences == null) {
        sharedPreferences = ProjectUtils.getPreferences(project, GruntPreferences.class, true);
    }
    return sharedPreferences;
}
 
Example 16
Source File: DatabaseConnectionSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static Preferences getProjectPreferences(Project project) {
    return ProjectUtils.getPreferences(project, PHPSQLCompletion.class, false);
}
 
Example 17
Source File: SuiteInstallerProjectProperties.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static Preferences prefs(Project suiteProject) {
    return ProjectUtils.getPreferences(suiteProject, SuiteInstallerProjectProperties.class, true);
}
 
Example 18
Source File: WhiteListLookupProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static boolean isWhiteListEnabledInProject(@NonNull Project p, @NonNull String whiteListId) {
    Preferences prefs = ProjectUtils.getPreferences(p, WhiteListQuery.class, true);
    return prefs.getBoolean(PROP_WHITELIST+whiteListId, false);
}
 
Example 19
Source File: WhiteListLookupProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static boolean isWhiteListPanelEnabled(@NonNull Project p) {
    Preferences prefs = ProjectUtils.getPreferences(p, WhiteListQuery.class, true);
    return prefs.getBoolean(PROP_WHITELIST_ENABLED, false);
}
 
Example 20
Source File: MavenProjectSupport.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Returns preferences for the given {@link Project}.
 * 
 * @param project for which we want to find {@link Preferences}
 * @return {@link Preferences} for the given project
 */
public static Preferences getPreferences(@NonNull Project project, boolean shared) {
    return ProjectUtils.getPreferences(project, MavenProjectSupport.class, shared);
}