Java Code Examples for java.util.prefs.Preferences

The following examples show how to use java.util.prefs.Preferences. These examples are extracted from open source projects. 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 Project: netbeans   Source File: ProxyPreferencesTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        assertTrue(prefsId + " doesn't contain node '" + nodePath + "'", prefs.nodeExists(nodePath));
        Preferences node = prefs.node(nodePath);

        String realValue = node.get(key, null);
        assertNotNull(prefsId + ", '" + nodePath + "' node doesn't contain key '" + key + "'", realValue);
        assertEquals(prefsId + ", '" + nodePath + "' node, '" + key + "' contains wrong value", value, realValue);
    }
}
 
Example 2
Source Project: editorconfig-netbeans   Source File: CodeStyleOperation.java    License: MIT License 6 votes vote down vote up
protected boolean operate(String simpleValueName, boolean value) {
  boolean codeStyleChangeNeeded = false;

  Preferences codeStyle = CodeStylePreferences.get(file, file.getMIMEType()).getPreferences();
  boolean currentValue = codeStyle.getBoolean(simpleValueName, false);

  LOG.log(Level.INFO, "\u00ac Current value: {0}", currentValue);
  LOG.log(Level.INFO, "\u00ac New value: {0}", value);

  if (currentValue == value) {
    LOG.log(Level.INFO, "\u00ac No change needed");
  } else {
    codeStyle.putBoolean(simpleValueName, value);
    codeStyleChangeNeeded = true;
    LOG.log(Level.INFO, "\u00ac Changing value from \"{0}\" to \"{1}\"",
            new Object[]{currentValue, value});
  }

  return codeStyleChangeNeeded;
}
 
Example 3
Source Project: whyline   Source File: Whyline.java    License: MIT License 6 votes vote down vote up
private static String loadPreferences() {

		UI.class.getName();
		
		// Load the preferences, if there are any.
		Preferences userPrefs = getPreferences();

		// If no preference is set, use the current working directory.
		String WHYLINE_HOME = userPrefs.get(WHYLINE_HOME_PATH_KEY, System.getProperty("user.dir") + File.separatorChar + "whyline" + File.separatorChar);

		// Now store the preference, in case it wasn't stored before
		userPrefs.put(WHYLINE_HOME_PATH_KEY, WHYLINE_HOME);
		try {
			userPrefs.flush();
		} catch (BackingStoreException e) {
			e.printStackTrace();
		}

		return WHYLINE_HOME;
		
	}
 
Example 4
@Override
public void actionPerformed(ActionEvent e) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setAcceptAllFileFilterUsed(false);
    final FileNameExtensionFilter shapefileFilter = new FileNameExtensionFilter("ESRI Shapefile", "shp");
    fileChooser.addChoosableFileFilter(shapefileFilter);
    fileChooser.setFileFilter(shapefileFilter);
    File lastDir = getLastDirectory();
    fileChooser.setCurrentDirectory(lastDir);
    LayerSourcePageContext pageContext = getContext();
    fileChooser.showOpenDialog(pageContext.getWindow());
    if (fileChooser.getSelectedFile() != null) {
        String filePath = fileChooser.getSelectedFile().getPath();
        fileHistoryModel.setSelectedItem(filePath);
        Preferences preferences = SnapApp.getDefault().getPreferences();
        preferences.put(PROPERTY_LAST_DIR, fileChooser.getCurrentDirectory().getAbsolutePath());
        pageContext.updateState();
    }
}
 
Example 5
Source Project: netbeans   Source File: HistorySettings.java    License: Apache License 2.0 6 votes vote down vote up
private static void migrate() { 
    // migrate pre 7.2 settings 
    String prevPath = "org/netbeans/modules/localhistory"; // NOI18N
    try {
        if(!NbPreferences.root().nodeExists(prevPath)) {
            return;
        }
        Preferences prev = NbPreferences.root().node(prevPath);
        Preferences cur =  NbPreferences.forModule(HistorySettings.class);
        String[] keys = prev.keys();
        for (String key : keys) {
            String value = prev.get(key, null);
            if(value != null && cur.get(key, null) == null) {
                cur.put(key, value);
            }
        }
        prev.removeNode();
    } catch (BackingStoreException ex) {
        Exceptions.printStackTrace(ex);
    }
    
}
 
Example 6
Source Project: halfnes   Source File: PreferencesDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
    //    if ("OK".equals(evt.getActionCommand())) {
    //here we go... save everything and hide the window
    Preferences prefs = PrefsSingleton.get();
    prefs.putBoolean("soundEnable", jCheckSoundEnable.isSelected());
    prefs.putBoolean("soundFiltering", jCheckSoundFiltering.isSelected());
    prefs.putBoolean("maintainAspect", jCheckMaintainAspect.isSelected());
    prefs.putBoolean("TVEmulation", jCheckBoxNTSC.isSelected());
    prefs.putBoolean("Sleep", jCheckBoxSleep.isSelected());
    screenScaling = (Integer) (jSpinnerScale.getModel().getValue());
    prefs.putBoolean("smoothScaling", jCheckBoxSmoothVideo.isSelected());
    prefs.putBoolean("showScope", jCheckBoxShowScope.isSelected());
    prefs.putBoolean("ntView", jCheckBoxNTView.isSelected());
    prefs.putInt("screenScaling", screenScaling);
    prefs.putInt("sampleRate", Integer.parseInt(jSampleRateBox.getSelectedItem().toString()));
    prefs.putInt("outputvol", volumeSlider.getValue());
    prefs.putInt("region", jRegionBox.getSelectedIndex());
    try {
        prefs.flush();
    } catch (BackingStoreException ex) {
        Logger.getLogger(PreferencesDialog.class.getName()).log(Level.SEVERE, null, ex);
    }
    okClicked = true;
    this.setVisible(false);
    //   }
}
 
Example 7
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 8
Source Project: netbeans   Source File: RepositoryRegistry.java    License: Apache License 2.0 6 votes vote down vote up
private String[] getRepoIds(Preferences preferences, String repoId) {
    String[] keys = null;
    try {
        keys = preferences.keys();
    } catch (BackingStoreException ex) {
        BugtrackingManager.LOG.log(Level.SEVERE, null, ex); 
    }
    if (keys == null || keys.length == 0) {
        return new String[0];
    }
    List<String> ret = new ArrayList<String>();
    for (String key : keys) {
        if (key.startsWith(repoId)) {
            ret.add(key.substring(repoId.length()));
        }
    }
    return ret.toArray(new String[ret.size()]);
}
 
Example 9
Source Project: netbeans   Source File: ProxyPreferencesImplTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        assertTrue(prefsId + " doesn't contain node '" + nodePath + "'", prefs.nodeExists(nodePath));
        Preferences node = prefs.node(nodePath);

        String realValue = node.get(key, null);
        assertNotNull(prefsId + ", '" + nodePath + "' node doesn't contain key '" + key + "'", realValue);
        assertEquals(prefsId + ", '" + nodePath + "' node, '" + key + "' contains wrong value", value, realValue);
    }
}
 
Example 10
Source Project: constellation   Source File: ApplicationPreferenceKeys.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * A directory where the webserver can write files to emulate REST requests.
 *
 * @param prefs Application preferences.
 *
 * @return The rest directory.
 */
public static String getRESTDir(final Preferences prefs) {
    String restDir = prefs.get(REST_DIR, "").trim();
    if (restDir.isEmpty()) {
        final RestDirectory rdir = Lookup.getDefault().lookup(RestDirectory.class);
        restDir = rdir.getRESTDirectory().toString();
    }

    final File f = new File(restDir);
    if (!f.exists()) {
        if (!f.mkdirs()) {
            // TODO: warn the user.
        }
    } else if (!f.isDirectory()) {
        // TODO: warn the user.
    }

    return restDir;
}
 
Example 11
Source Project: netbeans   Source File: TaskFilter.java    License: Apache License 2.0 6 votes vote down vote up
void load( Preferences prefs, String prefix ) throws BackingStoreException {
    name = prefs.get( prefix+"_name", "Filter" ); //NOI18N //NOI18N
    if( prefs.getBoolean( prefix+"_types", false ) ) { //NOI18N
        types = new TypesFilter();
        types.load( prefs, prefix+"_types" ); //NOI18N
    } else {
        types = null;
    }
    
    if( prefs.getBoolean( prefix+"_keywords", false ) ) { //NOI18N
        keywords = new KeywordsFilter();
        keywords.load( prefs, prefix+"_keywords" ); //NOI18N
    } else {
        keywords = null;
    }
}
 
Example 12
/**
 * @param args command line arguments.
 */
@SuppressWarnings("deprecation")
public static void main(String[] args) throws BackingStoreException {
  final Preferences machinesPreferenceNode = PreferencesHelper.getPreferenceNode(PreferencesHelper.MakelangeloPreferenceKey.MACHINES);
  Log.message("node name: "+ machinesPreferenceNode.name());
  final boolean wereThereCommandLineArguments = args.length > 0;
  if (wereThereCommandLineArguments) {
    final boolean wasSaveFileFlagFound = wasSearchKeyFoundInArray(SAVE_FILE_FLAG, args);
    if (wasSaveFileFlagFound) {
      final File preferencesFile = MarginallyCleverPreferencesFileFactory.getXmlPreferencesFile();
      try (final OutputStream fileOutputStream = new FileOutputStream(preferencesFile)) {
        PreferencesHelper.getPreferenceNode(PreferencesHelper.MakelangeloPreferenceKey.LEGACY_MAKELANGELO_ROOT).exportSubtree(fileOutputStream);
      } catch (IOException e) {
        Log.error(e.getMessage());
      }
    }
    final boolean wasPurgeFlagFound = wasSearchKeyFoundInArray(PURGE_FLAG, args);
    if (wasPurgeFlagFound) {
      final String[] childrenPreferenceNodeNames = machinesPreferenceNode.childrenNames();
      purgeMachineNamesThatAreLessThanZero(machinesPreferenceNode, childrenPreferenceNodeNames);
    }
  }
}
 
Example 13
Source Project: netbeans   Source File: MarkOccurencesPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void store( ) {
        Preferences node = MarkOccurencesSettings.getCurrentNode();

        for (javax.swing.JCheckBox box : boxes) {
            boolean value = box.isSelected();
            boolean original = node.getBoolean(box.getActionCommand(),
                                               DEFAULT_VALUE);

            if (value != original) {
                node.putBoolean(box.getActionCommand(), value);
            }
        }
        try {
            node.flush();
        }
        catch (BackingStoreException ex) {
            Exceptions.printStackTrace(ex);
        }
        changed = false;
}
 
Example 14
Source Project: netbeans   Source File: ProjectHintSettingPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void settingsFileLocationChanged() {
    if (projectSettings.hasLocation()) {
        final ToolPreferences toolPreferencesFin = toolPreferences = projectSettings.preferencesFrom(settingsFileLocation);
        perProjectPreferences = new MimeType2Preferences() {
            @Override public Preferences getPreferences(String mimeType) {
                return toolPreferencesFin.getPreferences(ProjectSettings.HINTS_TOOL_ID, mimeType);
            }
        };
    } else {
        perProjectPreferences = new MimeType2Preferences() {
            @Override public Preferences getPreferences(String mimeType) {
                return projectSettings.getProjectSettings(mimeType);
            }
        };
    }
}
 
Example 15
private void ensureDefaultDirSet() {
    if (!Files.exists(defaultEndmemberDir)) {
        Path sourceDirPath = ResourceInstaller.findModuleCodeBasePath(SpectralUnmixingDialog.class).resolve("auxdata");
        final ResourceInstaller resourceInstaller = new ResourceInstaller(sourceDirPath, defaultEndmemberDir);
        try {
            resourceInstaller.install(".*", com.bc.ceres.core.ProgressMonitor.NULL);
        } catch (IOException e) {
            // failed, so what
        }
    }

    final String key = DiagramGraphIO.DIAGRAM_GRAPH_IO_LAST_DIR_KEY;
    final Preferences preferences = Config.instance().preferences();
    if (preferences.get(key, null) == null) {
        preferences.put(key, defaultEndmemberDir.toAbsolutePath().toString());
    }
}
 
Example 16
private void writePreferredInputMethod(String path, String descriptorName) {
    if (userRoot != null) {
        Preferences node = userRoot.node(path);

        // record it
        if (descriptorName != null) {
            node.put(descriptorKey, descriptorName);
        } else {
            node.remove(descriptorKey);
        }
    }
}
 
Example 17
Source Project: netbeans   Source File: PreferencesTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testEvents1() throws Exception {
    Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    L listenerA = new L();
    prefsA.addPreferenceChangeListener(listenerA);

    Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
    L listenerB = new L();
    prefsB.addPreferenceChangeListener(listenerB);
    
    assertNotNull("'simple-value-setting-A' should not be null", prefsA.get("simple-value-setting-A", null));
    assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
    assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));

    assertEquals("There should be no A events", 0, listenerA.count);
    assertEquals("There should be no B events", 0, listenerB.count);
    
    prefsA.put("simple-value-setting-A", "new-value");
    assertEquals("Wrong value for 'simple-value-setting-A'", "new-value", prefsA.get("simple-value-setting-A", null));
    assertEquals("The value for 'simple-value-setting-A' was not propagated", "new-value", prefsB.get("simple-value-setting-A", null));
    
    Thread.sleep(500);
    
    assertEquals("Wrong number of A events", 1, listenerA.count);
    assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
    assertEquals("Wrong setting value in the A event", "new-value", listenerA.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
    assertEquals("Wrong number of B events", 1, listenerB.count);
    assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
    assertEquals("Wrong setting value in the B event", "new-value", listenerB.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
}
 
Example 18
Source Project: Universal-FE-Randomizer   Source File: OptionRecorder.java    License: MIT License 5 votes vote down vote up
private static FE9OptionBundle loadFE9Options() {
	Preferences prefs = Preferences.userRoot().node(OptionRecorder.class.getName());
	String jsonString = prefs.get(SettingsKey + FE9Suffix, null);
	if (jsonString != null) {
		Gson gson = new Gson();
		FE9OptionBundle loadedOptions = gson.fromJson(jsonString, FE9OptionBundle.class);
		return FE9OptionBundleVersion != loadedOptions.version ? null : loadedOptions;
	}
	
	return null;
}
 
Example 19
JValueInteger(Preferences _node, String _key) {
  super(_node, _key, ExtPreferences.TYPE_INT);

  int val = node.getInt(key, 0);
  /*
  text = new JTextField("" + val, 20) {{
    addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
          try {
            node.putInt(key, Integer.parseInt(text.getText()));
            setErr(null);
          } catch (Exception e) {
            setErr(e.getClass().getName() + " " + e.getMessage());
          }
        }
      });
  }};
  */

  model = 
    new SpinnerNumberModel(new Integer(val),
                           new Integer(Integer.MIN_VALUE),
                           new Integer(Integer.MAX_VALUE),
                           new Integer(1));
  
  spinner = new JSpinner(model);
  spinner.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent ev) {
        try {
          node.putInt(key, model.getNumber().intValue());
          setErr(null);
        } catch (Exception e) {
          setErr(e.getClass().getName() + " " + e.getMessage());
        }
          }
    });
  add(spinner, BorderLayout.CENTER);
}
 
Example 20
Source Project: netbeans   Source File: FmtOptions.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected String[] keysSpi() throws BackingStoreException {
    Set<String> keys = new HashSet<>();
    for(Preferences p : delegates) {
        keys.addAll(Arrays.asList(p.keys()));
    }
    return keys.toArray(new String[ keys.size() ]);
}
 
Example 21
Source Project: openccg   Source File: DisplayPrefs.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/** Constructor sets initial prefs from current user prefs. */
public DisplayPrefs() {
	Preferences prefs = Preferences.userNodeForPackage(TextCCG.class);
	showFeats = prefs.getBoolean(TextCCG.SHOW_FEATURES, false);
	showSem = prefs.getBoolean(TextCCG.SHOW_SEMANTICS, false);
	featsToShow = prefs.get(TextCCG.FEATURES_TO_SHOW, "");
}
 
Example 22
private Preferences getUserRoot() {
    return AccessController.doPrivileged(new PrivilegedAction<Preferences>() {
        public Preferences run() {
            return Preferences.userRoot();
        }
    });
}
 
Example 23
Source Project: netbeans   Source File: ShellSession.java    License: Apache License 2.0 5 votes vote down vote up
private Preferences createShellPreferences() {
    Project p = env.getProject();
    if (p != null) {
        return ProjectUtils.getPreferences(p, ShellSession.class, false).node("jshell");
    } else {
        return NbPreferences.forModule(ShellSession.class).node("jshell");
    }
}
 
Example 24
private void writePreferredInputMethod(String path, String descriptorName) {
    if (userRoot != null) {
        Preferences node = userRoot.node(path);

        // record it
        if (descriptorName != null) {
            node.put(descriptorKey, descriptorName);
        } else {
            node.remove(descriptorKey);
        }
    }
}
 
Example 25
Source Project: uima-uimaj   Source File: PackageSelectorGUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Opens dialog window to select desired PEAR package file for a given component.
 * 
 * @param componentId
 *          The given component ID.
 * @return Selected PEAR package file for the given component, or <code>null</code>, if the
 *         selection cancelled.
 */
public synchronized File selectPackageFile(String componentId) {
  // get last package file path
  Preferences userPrefs = Preferences.userNodeForPackage(getClass());
  String lastFilePath = (userPrefs != null) ? userPrefs.get(LAST_PACKAGE_FILE_KEY, "") : "";
  File lastFile = lastFilePath.length() > 0 ? new File(lastFilePath) : null;
  File lastDir = lastFile != null ? lastFile.getParentFile() : new File(".");
  // create JFileChooser
  JFileChooser fileChooser = new JFileChooser();
  fileChooser.addChoosableFileFilter(new PackageFileFilter());
  fileChooser.setCurrentDirectory(lastDir);
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  fileChooser.setDialogTitle("Select " + componentId + " PEAR file");
  // show information dialog
  String message = "Select the PEAR file of the\n" + "\n" + componentId + "\n"
          + "\ncomponent using the following file dialog.";
  JOptionPane.showMessageDialog(_dialogFrame, message);
  // open dialog window
  File selectedFile = null;
  int result = fileChooser.showDialog(_dialogFrame, "Select");
  if (result == JFileChooser.APPROVE_OPTION) {
    // set 'selected file'
    selectedFile = fileChooser.getSelectedFile();
    if (selectedFile != null) {
      // set 'last file' in user prefs
      userPrefs.put(LAST_PACKAGE_FILE_KEY, selectedFile.getAbsolutePath());
    }
  }
  return selectedFile;
}
 
Example 26
Source Project: netbeans   Source File: SearchDependencyCustomizer.java    License: Apache License 2.0 5 votes vote down vote up
/** Creates new form SearchDependencyCustomizer */
public SearchDependencyCustomizer(Preferences p) {
    this.p = p;
    initComponents();
    boolean b = p.getBoolean(SearchClassDependencyHint.OPTION_DIALOG, true);
    if (b) {
        jrOptionDialog.setSelected(true);
    }else{
        jrOptionInplace.setSelected(true);
    }
    p.putBoolean(SearchClassDependencyHint.OPTION_DIALOG, jrOptionDialog.isSelected());
}
 
Example 27
Source Project: Universal-FE-Randomizer   Source File: OptionRecorder.java    License: MIT License 5 votes vote down vote up
private static FE4OptionBundle loadFE4Options() {
	Preferences prefs = Preferences.userRoot().node(OptionRecorder.class.getName());
	String jsonString = prefs.get(SettingsKey + FE4Suffix, null);
	if (jsonString != null) {
		Gson gson = new Gson();
		FE4OptionBundle loadedOptions = gson.fromJson(jsonString, FE4OptionBundle.class);
		return FE4OptionBundleVersion != loadedOptions.version ? null : loadedOptions;
	}
	
	return null;
}
 
Example 28
Source Project: netbeans   Source File: JavadocHint.java    License: Apache License 2.0 5 votes vote down vote up
@Hint(id = "error-in-javadoc", category = "JavaDoc", description = "#DESC_ERROR_IN_JAVADOC_HINT", displayName = "#DN_ERROR_IN_JAVADOC_HINT", hintKind = Hint.Kind.INSPECTION, severity = Severity.WARNING, customizerProvider = JavadocHint.CustomizerProviderImplError.class)
@TriggerTreeKind({Kind.METHOD, Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE, Kind.VARIABLE})
public static List<ErrorDescription> errorHint(final HintContext ctx) {
    Preferences pref = ctx.getPreferences();
    boolean correctJavadocForNonPublic = pref.getBoolean(AVAILABILITY_KEY + false, false);

    CompilationInfo javac = ctx.getInfo();
    Boolean publiclyAccessible = AccessibilityQuery.isPubliclyAccessible(javac.getFileObject().getParent());
    boolean isPubliclyA11e = publiclyAccessible == null ? true : publiclyAccessible;

    if (!isPubliclyA11e && !correctJavadocForNonPublic) {
        return null;
    }

    if (javac.getElements().getTypeElement("java.lang.Object") == null) { // NOI18N
        // broken java platform
        return Collections.<ErrorDescription>emptyList();
    }

    TreePath path = ctx.getPath();
    {
        Document doc = null;
        try {
            doc = javac.getDocument();
        } catch (IOException e) {
            Exceptions.printStackTrace(e);
        }
        if (doc != null && isGuarded(path.getLeaf(), javac, doc)) {
            return null;
        }
    }
    
    Access access = Access.resolve(pref.get(SCOPE_KEY, SCOPE_DEFAULT));
    Analyzer a = new Analyzer(javac, path, access, ctx);
    return a.analyze();
}
 
Example 29
Source Project: netbeans   Source File: HintsPanelLogic.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    if( errorTree.getSelectionPath() == null )
        return;
    
    Object o = getUserObject(errorTree.getSelectionPath());
    
    if ( o instanceof POMErrorFixBase ) {
        POMErrorFixBase hint = (POMErrorFixBase) o;
        Preferences p = getPreferences4Modification(hint);
        
        if(hint.getConfiguration().getSeverity(p) != null && severityComboBox.equals( e.getSource() ) )
            hint.getConfiguration().setSeverity(p, index2severity(severityComboBox.getSelectedIndex()));
    }
}
 
Example 30
Source Project: netbeans   Source File: ProxyPreferencesImplTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testSyncTree1() throws BackingStoreException {
    String [] origTree = new String [] {
        "CodeStyle/profile=GLOBAL",
    };
    String [] newTree = new String [] {
        "CodeStyle/text/x-java/tab-size=2",
        "CodeStyle/text/x-java/override-global-settings=true",
        "CodeStyle/text/x-java/expand-tabs=true",
        "CodeStyle/profile=PROJECT",
    };

    Preferences orig = Preferences.userRoot().node(getName());
    write(orig, origTree);
    checkContains(orig, origTree, "Orig");
    checkNotContains(orig, newTree, "Orig");
    
    Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
    checkEquals("Test should be the same as Orig", orig, test);
    
    write(test, newTree);
    checkContains(test, newTree, "Test");

    test.sync();
    checkContains(orig, origTree, "Orig");
    checkNotContains(orig, newTree, "Orig");
    checkContains(test, origTree, "Test");
    checkNotContains(test, newTree, "Test");
}