本文整理汇总了Java中org.openide.util.NbPreferences类的典型用法代码示例。如果您正苦于以下问题:Java NbPreferences类的具体用法?Java NbPreferences怎么用?Java NbPreferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NbPreferences类属于org.openide.util包,在下文中一共展示了NbPreferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.openide.util.NbPreferences; //导入依赖的package包/类
public void load() throws IOException {
filters.clear();
active = -1;
Preferences prefs = NbPreferences.forModule(FilterRepository.class);
prefs = prefs.node("Filters"); //NOI18N
active = prefs.getInt("active", -1);
int count = prefs.getInt("count", 0); //NOI18N
for (int i = 0; i < count; i++) {
NotificationFilter filter = new NotificationFilter();
try {
filter.load(prefs, "Filter_" + i); //NOI18N
} catch (BackingStoreException bsE) {
throw new IOException("Cannot load filter repository", bsE);
}
filters.add(filter);
}
}
示例2: loadTasks
import org.openide.util.NbPreferences; //导入依赖的package包/类
private void loadTasks() {
Preferences pref = NbPreferences.forModule(TaskSchedulingManager.class);
try {
for (String key : pref.keys()) {
if (key.startsWith(PREF_SCHEDULED)) {
String repositoryId = key.substring(PREF_SCHEDULED.length());
String tasks = pref.get(key, "");
for (String taskId : tasks.split(SEP)) {
if (!taskId.isEmpty()) {
getRepositoryTasks(repositoryId).add(taskId);
}
}
}
}
} catch (BackingStoreException ex) {
Logger.getLogger(TaskSchedulingManager.class.getName()).log(Level.INFO, null, ex);
}
}
示例3: M2RepositoryBrowser
import org.openide.util.NbPreferences; //导入依赖的package包/类
private M2RepositoryBrowser() {
super(Children.create(new RootNodes(), true));
setName(NAME);
setDisplayName(CTL_M2RepositoryBrowserTopComponent2(RepositoryPreferences.isIndexRepositories() ? "" : CTL_M2RepositoriesDisabled()));
setShortDescription(HINT_M2RepositoryBrowserTopComponent());
setIconBaseWithExtension(ICON_PATH);
NbPreferences.root().node("org/netbeans/modules/maven/nexus/indexing").addPreferenceChangeListener(new PreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
if (RepositoryPreferences.PROP_INDEX.equals(evt.getKey())) {
setDisplayName(CTL_M2RepositoryBrowserTopComponent2(RepositoryPreferences.isIndexRepositories() ? "" : CTL_M2RepositoriesDisabled()));
}
}
});
}
示例4: registerDatabase
import org.openide.util.NbPreferences; //导入依赖的package包/类
/**
* Registers in the Database Explorer the specified database
* on the local Derby server.
*/
private synchronized DatabaseConnection registerDatabase(String databaseName, String user, String schema, String password, boolean rememberPassword) throws DatabaseException {
JDBCDriver drivers[] = JDBCDriverManager.getDefault().getDrivers(DerbyOptions.DRIVER_CLASS_NET);
if (drivers.length == 0) {
throw new IllegalStateException("The " + DerbyOptions.DRIVER_DISP_NAME_NET + " driver was not found"); // NOI18N
}
Preferences pref = NbPreferences.root().node(PATH_TO_DATABASE_PREFERENCES + databaseName);
pref.put(USER_KEY, user == null ? "" : user);
pref.put(SCHEMA_KEY, schema == null ? "" : schema);
pref.put(PASSWORD_KEY, password == null ? "" : password);
DatabaseConnection dbconn = DatabaseConnection.create(drivers[0], "jdbc:derby://localhost:" + RegisterDerby.getDefault().getPort() + "/" + databaseName, user, schema, password, rememberPassword); // NOI18N
if (ConnectionManager.getDefault().getConnection(dbconn.getName()) == null) {
ConnectionManager.getDefault().addConnection(dbconn);
}
notifyChange();
return dbconn;
}
示例5: protectAgainstErrors
import org.openide.util.NbPreferences; //导入依赖的package包/类
private static boolean protectAgainstErrors(URL targetFolder, FileObject[][] sources, Object context) throws MalformedURLException {
Preferences pref = NbPreferences.forModule(BuildArtifactMapperImpl.class).node(BuildArtifactMapperImpl.class.getSimpleName());
if (!pref.getBoolean(UIProvider.ASK_BEFORE_RUN_WITH_ERRORS, true)) {
return true;
}
sources(targetFolder, sources);
for (FileObject file : sources[0]) {
if (ErrorsCache.isInError(file, true) && !alreadyWarned.contains(context)) {
UIProvider uip = Lookup.getDefault().lookup(UIProvider.class);
if (uip == null || uip.warnContainsErrors(pref)) {
alreadyWarned.add(context);
return true;
}
return false;
}
}
return true;
}
示例6: getProperties
import org.openide.util.NbPreferences; //导入依赖的package包/类
/**
* Returns all existing properties created in the given namespace.
*
* @param namespace string identifying the namespace
* @return list of all existing properties created in the given namespace
*/
public List<InstanceProperties> getProperties(String namespace) {
Preferences prefs = NbPreferences.forModule(InstancePropertiesManager.class);
try {
prefs = prefs.node(namespace);
prefs.flush();
List<InstanceProperties> allProperties = new ArrayList<InstanceProperties>();
synchronized (this) {
for (String id : prefs.childrenNames()) {
Preferences child = prefs.node(id);
InstanceProperties props = cache.get(child);
if (props == null) {
props = new DefaultInstanceProperties(id, this, child);
cache.put(child, props);
}
allProperties.add(props);
}
}
return allProperties;
} catch (BackingStoreException ex) {
LOGGER.log(Level.INFO, null, ex);
throw new IllegalStateException(ex);
}
}
示例7: FindDialogPanel
import org.openide.util.NbPreferences; //导入依赖的package包/类
/** Initializes the Form */
FindDialogPanel() {
regExp = NbPreferences.forModule(Controller.class).getBoolean(KEY_REGEXP, false);
matchCase = NbPreferences.forModule(Controller.class).getBoolean(KEY_MATCHCASE, false);
initComponents();
acceptButton = new JButton();
Mnemonics.setLocalizedText(chbRegExp, NbBundle.getMessage(FindDialogPanel.class, "LBL_Use_RegExp"));
Mnemonics.setLocalizedText(chbMatchCase, NbBundle.getMessage(FindDialogPanel.class, "LBL_Match_Case"));
getAccessibleContext().setAccessibleName(NbBundle.getMessage(FindDialogPanel.class, "ACSN_Find"));
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FindDialogPanel.class, "ACSD_Find"));
findWhat.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FindDialogPanel.class, "ACSD_Find_What"));
acceptButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FindDialogPanel.class, "ACSD_FindBTN"));
findWhat.setModel(new DefaultComboBoxModel(history));
findWhat.getEditor().addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
acceptButton.doClick();
}
});
findWhatLabel.setFocusable(false);
}
示例8: getPreferredPlatform
import org.openide.util.NbPreferences; //导入依赖的package包/类
/**
* Returns a preferred {@link JavaPlatform} for a new project.
* @param platformType the platform type as specified by {@link Specification#getName()}
* @return the preferred {@link JavaPlatform}
*/
@CheckForNull
public static JavaPlatform getPreferredPlatform(@NonNull final String platformType) {
Parameters.notNull("platformType", platformType); //NOI18N
final String platformId = NbPreferences.forModule(PreferredProjectPlatform.class).get(
MessageFormat.format(PREFERRED_PLATFORM, platformType),
null);
final JavaPlatformManager jpm = JavaPlatformManager.getDefault();
if (platformId != null) {
for (JavaPlatform jp : jpm.getInstalledPlatforms()) {
if (platformId.equals(jp.getProperties().get(PLATFORM_ANT_NAME)) &&
platformType.equals(jp.getSpecification().getName()) &&
jp.isValid()) {
return jp;
}
}
}
final JavaPlatform defaultPlatform = jpm.getDefaultPlatform();
return platformType.equals(defaultPlatform.getSpecification().getName())?
defaultPlatform:
null;
}
示例9: windowClosed
import org.openide.util.NbPreferences; //导入依赖的package包/类
public void windowClosed(WindowEvent e) {
optionsPanel.storeUserSize();
// store location of dialog
NbPreferences.forModule(OptionsDisplayerImpl.class).putInt("OptionsX", originalDialog.getX());//NOI18N
NbPreferences.forModule(OptionsDisplayerImpl.class).putInt("OptionsY", originalDialog.getY());//NOI18N
try {
FileUtil.getConfigRoot().getFileSystem().removeFileChangeListener(fcl);
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
if (optionsPanel.needsReinit()) {
synchronized (lookupListener) {
descriptorRef = new WeakReference<DialogDescriptor>(null);
}
}
if (this.originalDialog == dialog) {
dialog = null;
}
log.fine("Options Dialog - windowClosed"); //NOI18N
}
示例10: GoalsPanel
import org.openide.util.NbPreferences; //导入依赖的package包/类
/** Creates new form POMInheritancePanel */
@Messages("HINT_Panel_hide=Click or press {0} to hide/show when the Navigator is active")
public GoalsPanel() {
initComponents();
treeView = (BeanTreeView)jScrollPane1;
preferences = NbPreferences.forModule(GoalsPanel.class).node("goalNavigator");
filtersPanel = new TapPanel();
filtersPanel.setOrientation(TapPanel.DOWN);
// tooltip
KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
String keyText = Utilities.keyToString(toggleKey);
filtersPanel.setToolTipText(HINT_Panel_hide(keyText)); //NOI18N
JComponent buttons = createFilterButtons();
buttons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
filtersPanel.add(buttons);
if( "Aqua".equals(UIManager.getLookAndFeel().getID()) ) {
filtersPanel.setBackground(UIManager.getColor("NbExplorerView.background"));//NOI18N
}
add(filtersPanel, BorderLayout.SOUTH);
}
示例11: setDividerLocation
import org.openide.util.NbPreferences; //导入依赖的package包/类
public void setDividerLocation(int location) {
if (!((CustomSplitterUI)getUI()).isCollapsed()) {
savedDividerLocation = location;
NbPreferences.forModule(CollapsibleSplitPane.class).
putInt(PREF_LOCATION, savedDividerLocation);
}
super.setDividerLocation(location);
}
示例12: clearCache
import org.openide.util.NbPreferences; //导入依赖的package包/类
@Override
protected void clearCache() {
try {
NbPreferences.forModule( RSSFeed.class ).remove( url2path( new URL(url1))) ;
NbPreferences.forModule( RSSFeed.class ).remove( url2path( new URL(url2))) ;
} catch( MalformedURLException mE ) {
//ignore
}
}
示例13: includeCanRenderPathFlag
import org.openide.util.NbPreferences; //导入依赖的package包/类
/**
* If testedFlags has flag that according to preferences should be drawn,
* draw it
* @param flag
* @return true if at least one of flags in testedFlag is set and preferences says that we should render it
*/
private synchronized boolean includeCanRenderPathFlag(int testedFlag) {
for (MapFlag flag : MapFlag.values()) {
// if tested flag has enabled the flag
if ((flag.getFlag() & testedFlag) != 0) {
// if it does, does user says we should render such paths
boolean shouldRender = NbPreferences.forModule(TimelinePanel.class).getBoolean(flag.getPrefKey(), flag.getDefault());
if (shouldRender) {
return true;
}
}
}
return false;
}
示例14: storeRecentConnectionsList
import org.openide.util.NbPreferences; //导入依赖的package包/类
void storeRecentConnectionsList() {
Preferences prefs = NbPreferences.forModule(ConnectionManager.class);
synchronized (recentConnections) {
for (int i = 0; i < recentConnections.size(); i++) {
prefs.put(getConnectoinsHistoryKey(i), ExecutionEnvironmentFactory.toUniqueID(recentConnections.get(i)));
}
}
}
示例15: getJavaModulePreferenes
import org.openide.util.NbPreferences; //导入依赖的package包/类
private Preferences getJavaModulePreferenes() {
try {
ClassLoader cl = Lookup.getDefault().lookup(ClassLoader.class);
Class accpClass = cl.loadClass("org.netbeans.modules.editor.java.AbstractCamelCasePosition"); // NOI18N
if (accpClass == null) {
return null;
}
return NbPreferences.forModule(accpClass);
} catch (ClassNotFoundException ex) {
return null;
}
}