示例#1
0
 public void load() {
   IEclipsePreferences prefs =
       EclipsePreferencesUtils.getInstanceScope().getNode(UiPlugin.PLUGIN_ID);
   this.projectTasksVisible = prefs.getBoolean(PREF_PROJECT_TASKS_VISIBLE, false);
   this.taskSelectorsVisible = prefs.getBoolean(PREF_TASK_SELECTORS_VISIBLE, true);
   this.privateTasksVisible = prefs.getBoolean(PREF_PRIVATE_TASKS_VISIBLE, false);
   this.sortByType = prefs.getBoolean(PREF_SORT_BY_TYPE, true);
   this.sortByVisibility = prefs.getBoolean(PREF_SORT_BY_VISIBILITY, true);
   this.linkToSelection = prefs.getBoolean(PREF_LINK_TO_SELECTION, false);
   this.showTreeHeader = prefs.getBoolean(PREF_SHOW_TREE_HEADER, false);
   this.headerNameColumnWidth = prefs.getInt(PREF_HEADER_NAME_COLUMN_WIDTH, 200);
   this.headerDescriptionColumnWidth = prefs.getInt(PREF_HEADER_DESCRIPTION_COLUMN_WIDTH, 400);
 }
示例#2
0
 /** Update the settings for the global window cache of the workspace. */
 public static void reconfigureWindowCache() {
   final WindowCacheConfig c = new WindowCacheConfig();
   IEclipsePreferences d = DefaultScope.INSTANCE.getNode(Activator.getPluginId());
   IEclipsePreferences p = InstanceScope.INSTANCE.getNode(Activator.getPluginId());
   c.setPackedGitLimit(
       p.getInt(
           GitCorePreferences.core_packedGitLimit,
           d.getInt(GitCorePreferences.core_packedGitLimit, 0)));
   c.setPackedGitWindowSize(
       p.getInt(
           GitCorePreferences.core_packedGitWindowSize,
           d.getInt(GitCorePreferences.core_packedGitWindowSize, 0)));
   c.setPackedGitMMAP(
       p.getBoolean(
           GitCorePreferences.core_packedGitMMAP,
           d.getBoolean(GitCorePreferences.core_packedGitMMAP, false)));
   c.setDeltaBaseCacheLimit(
       p.getInt(
           GitCorePreferences.core_deltaBaseCacheLimit,
           d.getInt(GitCorePreferences.core_deltaBaseCacheLimit, 0)));
   c.setStreamFileThreshold(
       p.getInt(
           GitCorePreferences.core_streamFileThreshold,
           d.getInt(GitCorePreferences.core_streamFileThreshold, 0)));
   c.install();
 }
  public static void checkCurrentOptionsVersion() {
    PreferencesAccess access = PreferencesAccess.getOriginalPreferences();
    ProfileVersioner profileVersioner = new ProfileVersioner();

    IScopeContext instanceScope = access.getInstanceScope();
    IEclipsePreferences uiPreferences = instanceScope.getNode(JavaUI.ID_PLUGIN);
    int version = uiPreferences.getInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, 0);
    if (version >= profileVersioner.getCurrentVersion()) {
      return; // is up to date
    }
    try {
      List<Profile> profiles =
          (new FormatterProfileStore(profileVersioner)).readProfiles(instanceScope);
      if (profiles == null) {
        profiles = new ArrayList<Profile>();
      }
      ProfileManager manager =
          new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
      if (manager.getSelected() instanceof CustomProfile) {
        manager.commitChanges(instanceScope); // updates JavaCore options
      }
      uiPreferences.putInt(
          PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, profileVersioner.getCurrentVersion());
      savePreferences(instanceScope);
    } catch (CoreException e) {
      JavaPlugin.log(e);
    } catch (BackingStoreException e) {
      JavaPlugin.log(e);
    }
  }
 protected void resetSeverities() {
   IEclipsePreferences defaultContext = new DefaultScope().getNode(getPreferenceNodeQualifier());
   for (int i = 0; i < fCombos.size(); i++) {
     ComboData data = (ComboData) ((Combo) fCombos.get(i)).getData();
     int severity = defaultContext.getInt(data.getKey(), ValidationMessage.WARNING);
     data.setSeverity(severity);
     ((Combo) fCombos.get(i)).select(data.getIndex());
   }
 }
  public static void updateTransientProperties(QsarType qsarModel, IProject project) {

    // If exists in prefs, add them
    IEclipsePreferences node =
        new InstanceScope().getNode(net.bioclipse.qsar.ui.Activator.PLUGIN_ID);

    ICDKManager cdk = Activator.getDefault().getJavaCDKManager();

    // NoMols is easy, just count number of structures
    for (ResourceType resource : qsarModel.getStructurelist().getResources()) {
      if (resource.getStructure() != null) {
        resource.setNoMols(resource.getStructure().size());
      }

      int pno2D = node.getInt(project.getName() + "_" + resource.getId() + "_no2d", -1);
      int pno3D = node.getInt(project.getName() + "_" + resource.getId() + "_no3d", -1);
      if (pno2D < 0 || pno3D < 0) {

        // At least one missing attribute, parse and read mols
        // Load molecules into file
        try {
          List<ICDKMolecule> mollist = cdk.loadMolecules(resource.getFile());
          if (mollist != null) {

            // Count no of 2D and 3D
            int no2d = 0;
            int no3d = 0;
            for (ICDKMolecule mol : mollist) {
              if (cdk.has2d(mol)) no2d++;
              if (cdk.has3d(mol)) no3d++;
            }

            resource.setNo2d(no2d);
            resource.setNo3d(no3d);

            // Also store as preferences
            node.putInt(project.getName() + "_" + resource.getId() + "_no2d", no2d);
            node.putInt(project.getName() + "_" + resource.getId() + "_no3d", no3d);

            //                        System.out.println("* No2D and no3D calculated and stored as
            // prefs");

          }
        } catch (Exception e) {
          logger.error("Could not parse molecule file: " + resource.getFile());
        }
      } else {
        resource.setNo2d(pno2D);
        resource.setNo3d(pno3D);
        //                System.out.println("* No2D and no3D read from prefs; no calc required");
      }
    }
  }
  /**
   * Update all formatter settings with the settings of the specified profile.
   *
   * @param profile The profile to write to the preference store
   */
  private void writeToPreferenceStore(Profile profile, IScopeContext context) {
    final Map<String, String> profileOptions = profile.getSettings();

    for (int i = 0; i < fKeySets.length; i++) {
      updatePreferences(
          context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
    }

    final IEclipsePreferences uiPrefs = context.getNode(JavaUI.ID_PLUGIN);
    if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
      uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
    }

    if (context.getName() == InstanceScope.SCOPE) {
      uiPrefs.put(fProfileKey, profile.getID());
    } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
      uiPrefs.put(fProfileKey, profile.getID());
    }
  }
  /**
   * Only to read project specific settings to find out to what profile it matches.
   *
   * @param context The project context
   */
  private Map<String, String> readFromPreferenceStore(
      IScopeContext context, Profile workspaceProfile) {
    final Map<String, String> profileOptions = new HashMap<String, String>();
    IEclipsePreferences uiPrefs = context.getNode(JavaUI.ID_PLUGIN);

    int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
    if (version != fProfileVersioner.getCurrentVersion()) {
      Map<String, String> allOptions = new HashMap<String, String>();
      for (int i = 0; i < fKeySets.length; i++) {
        addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
      }
      CustomProfile profile =
          new CustomProfile(
              "tmp", allOptions, version, fProfileVersioner.getProfileKind()); // $NON-NLS-1$
      fProfileVersioner.update(profile);
      return profile.getSettings();
    }

    boolean hasValues = false;
    for (int i = 0; i < fKeySets.length; i++) {
      KeySet keySet = fKeySets[i];
      IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
      for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
        final String key = keyIter.next();
        String val = preferences.get(key, null);
        if (val != null) {
          hasValues = true;
        } else {
          val = workspaceProfile.getSettings().get(key);
        }
        profileOptions.put(key, val);
      }
    }

    if (!hasValues) {
      return null;
    }

    setLatestCompliance(profileOptions);
    return profileOptions;
  }
 protected int getProperty(String key, int defaultValue) {
   return eclipsePreferences.getInt(DESIGNER_SETTINGS_PREFIX + key, defaultValue);
 }
示例#9
0
  protected int getIntPreference(String key) {

    return preferences.getInt(key, defaultPreferences.getInt(key, 0));
  }