/*
   * (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#okPressed()
   */
  protected void okPressed() {
    // TODO: move to preference manager
    IEclipsePreferences prefs = new InstanceScope().getNode(PHPDebugEPLPlugin.PLUGIN_ID);

    // general
    prefs.put(XDebugPreferenceMgr.XDEBUG_PREF_PORT, portTextBox.getText());
    prefs.putBoolean(XDebugPreferenceMgr.XDEBUG_PREF_SHOWSUPERGLOBALS, showGlobals.getSelection());
    prefs.putInt(XDebugPreferenceMgr.XDEBUG_PREF_ARRAYDEPTH, variableDepth.getSelection());
    prefs.putInt(XDebugPreferenceMgr.XDEBUG_PREF_CHILDREN, maxChildren.getSelection());
    prefs.putBoolean(XDebugPreferenceMgr.XDEBUG_PREF_MULTISESSION, useMultiSession.getSelection());
    prefs.putInt(
        XDebugPreferenceMgr.XDEBUG_PREF_REMOTESESSION, acceptRemoteSession.getSelectionIndex());

    // capture output
    prefs.putInt(XDebugPreferenceMgr.XDEBUG_PREF_CAPTURESTDOUT, captureStdout.getSelectionIndex());
    prefs.putInt(XDebugPreferenceMgr.XDEBUG_PREF_CAPTURESTDERR, captureStderr.getSelectionIndex());

    // proxy
    prefs.putBoolean(XDebugPreferenceMgr.XDEBUG_PREF_USEPROXY, useProxy.getSelection());
    prefs.put(XDebugPreferenceMgr.XDEBUG_PREF_IDEKEY, idekeyTextBox.getText());
    prefs.put(XDebugPreferenceMgr.XDEBUG_PREF_PROXY, proxyTextBox.getText());
    DBGpProxyHandler.instance.configure();

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      PHPDebugEPLPlugin.logError(e);
    }
    super.okPressed();
  }
  public void initializeDefaultPreferences() {
    final IEclipsePreferences p = new DefaultScope().getNode(Activator.getPluginId());

    p.putInt(GitCorePreferences.core_packedGitWindowSize, 8 * 1024);
    p.putInt(GitCorePreferences.core_packedGitLimit, 10 * MB);
    p.putBoolean(GitCorePreferences.core_packedGitMMAP, false);
    p.putInt(GitCorePreferences.core_deltaBaseCacheLimit, 10 * MB);
    p.putInt(GitCorePreferences.core_streamFileThreshold, 50 * MB);
    p.putBoolean(GitCorePreferences.core_autoShareProjects, false);
  }
 public void testIsUsingProjectSettings() throws Exception {
   boolean b1 = AspectJPreferences.isUsingProjectSettings(project);
   assertFalse("by default, should not be using project compiler settings", b1); // $NON-NLS-1$
   projectNode.putBoolean(AspectJPreferences.OPTION_UseProjectSettings, true);
   b1 = AspectJPreferences.isUsingProjectSettings(project);
   assertTrue("project should now be using project compiler settings", b1); // $NON-NLS-1$
   projectNode.putBoolean(AspectJPreferences.OPTION_UseProjectSettings, false);
   b1 = AspectJPreferences.isUsingProjectSettings(project);
   assertFalse("project should now be using workbench compiler settings", b1); // $NON-NLS-1$
 }
  @Override
  public void initializeDefaultPreferences() {
    IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(YAMLPlugin.PLUGIN_ID);
    prefs.putBoolean(IPreferenceConstants.EDITOR_AUTO_INDENT, true);
    prefs.putBoolean(IPreferenceConstants.EDITOR_ENABLE_FOLDING, true);
    prefs.putBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);
    prefs.putInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 2);

    // mark occurrences
    prefs.putBoolean(
        com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
  }
 private void savePreferences() {
   IEclipsePreferences prefs = new InstanceScope().getNode(PHPDebugEPLPlugin.PLUGIN_ID);
   prefs.putBoolean(
       PHPDebugCorePreferenceNames.OPEN_IN_BROWSER, this.fOpenInBrowser.getSelection());
   prefs.putBoolean(
       PHPDebugCorePreferenceNames.OPEN_DEBUG_VIEWS, this.fOpenDebugViews.getSelection());
   try {
     prefs.flush();
   } catch (BackingStoreException e) {
     PHPDebugEPLPlugin.logError(e);
   }
 }
 /*
  * (non-Javadoc)
  * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
  */
 @Override
 public void initializeDefaultPreferences() {
   IEclipsePreferences prefs = new DefaultScope().getNode(CorePlugin.PLUGIN_ID);
   prefs.putBoolean(ICorePreferenceConstants.PREF_SHOW_SYSTEM_JOBS, DEFAULT_DEBUG_MODE);
   prefs.putBoolean(
       ICorePreferenceConstants.PREF_AUTO_MIGRATE_OLD_PROJECTS, DEFAULT_AUTO_MIGRATE_OLD_PROJECTS);
   prefs.putBoolean(
       ICorePreferenceConstants.PREF_AUTO_REFRESH_PROJECTS, DEFAULT_AUTO_REFRESH_PROJECTS);
   prefs.put(ICorePreferenceConstants.PREF_DEBUG_LEVEL, IdeLog.StatusLevel.ERROR.toString());
   prefs.put(
       ICorePreferenceConstants.PREF_WEB_FILES,
       "*.js;*.htm;*.html;*.xhtm;*.xhtml;*.css;*.xml;*.xsl;*.xslt;*.fla;*.gif;*.jpg;*.jpeg;*.php;*.asp;*.jsp;*.png;*.as;*.sdoc;*.swf;*.shtml;*.txt;*.aspx;*.asmx;"); //$NON-NLS-1$
 }
 @Override
 public void initializeDefaultPreferences() {
   IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(CoreIOPlugin.PLUGIN_ID);
   prefs.putBoolean(IPreferenceConstants.UPLOAD_UPDATE_PERMISSIONS, true);
   prefs.putBoolean(IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, true);
   prefs.putLong(IPreferenceConstants.UPLOAD_FILE_PERMISSION, DEFAULT_FILE_PERMISSIONS);
   prefs.putLong(IPreferenceConstants.UPLOAD_FOLDER_PERMISSION, DEFAULT_DIRECTORY_PERMISSIONS);
   prefs.putBoolean(IPreferenceConstants.DOWNLOAD_UPDATE_PERMISSIONS, true);
   prefs.putBoolean(IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, true);
   prefs.putLong(IPreferenceConstants.DOWNLOAD_FILE_PERMISSION, DEFAULT_FILE_PERMISSIONS);
   prefs.putLong(IPreferenceConstants.DOWNLOAD_FOLDER_PERMISSION, DEFAULT_DIRECTORY_PERMISSIONS);
   prefs.put(IPreferenceConstants.GLOBAL_CLOAKING_EXTENSIONS, DEFAULT_CLOAK_EXPRESSIONS);
 }
  /** {@inheritDoc} */
  @Override
  public void initializeDefaultPreferences() {

    IEclipsePreferences prefs = new DefaultScope().getNode(CheckstylePlugin.PLUGIN_ID);
    prefs.putBoolean(PREF_INCLUDE_RULE_NAMES, false);
    prefs.putBoolean(PREF_INCLUDE_MODULE_IDS, false);
    prefs.putBoolean(PREF_LIMIT_MARKERS_PER_RESOURCE, false);
    prefs.putInt(PREF_MARKER_AMOUNT_LIMIT, MARKER_LIMIT);

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      CheckstyleLog.log(e);
    }
  }
    private void launchDialog(
        final IServer server, AS7DeploymentScannerUtility.Scanner[] scanners) {
      ModifyDeploymentScannerIntervalDialog d =
          new ModifyDeploymentScannerIntervalDialog(
              server, scanners, Display.getDefault().getActiveShell());
      int ret = d.open();

      final AS7DeploymentScannerUtility.Scanner[] changedArray = d.getChangedScanners();
      boolean neverAskAgainSetting = d.getAskAgainSelection();

      if (neverAskAgainSetting) {
        IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JBossServerUIPlugin.PLUGIN_ID);
        prefs.putBoolean(AS7_IGNORE_ZERO_INTERVAL_SCANNER_SETTING, true);
        try {
          prefs.flush();
        } catch (BackingStoreException e) {
        }
      }

      if (ret == Window.OK && changedArray.length > 0) {
        new Job(Messages.DeploymentScannerUpdateJobTitle) {
          protected IStatus run(IProgressMonitor monitor) {
            return updateServersScanners(server, changedArray);
          }
        }.schedule();
      }
    }
  private static void initializeTextEditiongPreferences(final IPreferenceStore store) {
    //		// set the default values from ExtendedTextEditor
    //
    //	store.setValue(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE,
    // true);
    final DefaultScope scope = new DefaultScope();
    final IEclipsePreferences prefs = scope.getNode(StatetUIPlugin.PLUGIN_ID);
    final ThemeUtil theme = new ThemeUtil();

    // EditorPreferences
    prefs.putBoolean(DecorationPreferences.MATCHING_BRACKET_ENABLED_KEY, true);
    prefs.put(
        DecorationPreferences.MATCHING_BRACKET_COLOR_KEY,
        theme.getColorPrefValue(IWaThemeConstants.MATCHING_BRACKET_COLOR));

    {
      final IEclipsePreferences node =
          scope.getNode(IStatetUIPreferenceConstants.CAT_EDITOR_OPTIONS_QUALIFIER);
      final AssistPreferences assistPrefs = IStatetUIPreferenceConstants.EDITING_ASSIST_PREFERENCES;
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoActivationEnabledPref(), Boolean.TRUE);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoActivationDelayPref(), 200);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoInsertSinglePref(), Boolean.FALSE);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoInsertPrefixPref(), Boolean.FALSE);
      node.put(
          "Parameters.background",
          theme.getColorPrefValue(IWaThemeConstants.INFORMATION_BACKGROUND_COLOR)); // $NON-NLS-1$
      node.put(
          "Parameters.foreground",
          theme.getColorPrefValue(IWaThemeConstants.INFORMATION_COLOR)); // $NON-NLS-1$
    }
    //		store.setDefault(EDITOROUTLINE_SORT, false);
    //		store.setDefault(EDITOROUTLINE_LINKWITHEDITOR, true);
  }
  @BeforeClass
  public static void init() throws Exception {
    importMavenProject("projects/testDeployableContainer.zip", TEST_PROJECT_NAME);
    JobUtils.waitForIdle(1000);
    IProject project = getProject(TEST_PROJECT_NAME);
    addArquillianSupport(project);
    JobUtils.waitForIdle(1000);
    if (!ArquillianUtility.isValidatorEnabled(project)) {
      IEclipsePreferences prefs =
          new ProjectScope(project).getNode(ArquillianCoreActivator.PLUGIN_ID);
      prefs.putBoolean(ArquillianConstants.TEST_ARQUILLIAN_CONTAINER, true);
      prefs.flush();
    }
    IProjectConfigurationManager configurationManager =
        MavenPlugin.getProjectConfigurationManager();
    ResolverConfiguration configuration = configurationManager.getResolverConfiguration(project);

    configuration.setSelectedProfiles("JBOSS_AS_REMOTE_7.X, JBOSS_AS_MANAGED_7.X");
    boolean isSet = configurationManager.setResolverConfiguration(project, configuration);
    if (isSet) {
      MavenUpdateRequest request = new MavenUpdateRequest(project, true, true);
      configurationManager.updateProjectConfiguration(request, new NullProgressMonitor());
    }

    JobUtils.waitForIdle(1000);
  }
  /**
   * This test ensures that any previously set project settings are not overwritten if say so, but
   * they are as default.
   *
   * @throws Exception
   */
  public void testSetUsingProjectSettings2() throws Exception {

    assertFalse(
        "by default, should not be using project compiler settings", //$NON-NLS-1$
        AspectJPreferences.isUsingProjectSettings(project));

    projectNode.putBoolean(AspectJPreferences.OPTION_XHasMember, true);

    AspectJPreferences.setUsingProjectSettings(project, true, false);
    boolean b1 = projectNode.getBoolean(AspectJPreferences.OPTION_XHasMember, false);
    assertTrue("should not have reset OPTION_XHasMember to default", b1); // $NON-NLS-1$

    AspectJPreferences.setUsingProjectSettings(project, true);
    b1 = projectNode.getBoolean(AspectJPreferences.OPTION_XHasMember, false);
    assertFalse("should have reset OPTION_XHasMember to default", b1); // $NON-NLS-1$

    AspectJPreferences.setUsingProjectSettings(project, false);
    try {
      projectNode.keys();
      projectNode.getBoolean(AspectJPreferences.OPTION_XHasMember, false);
      fail("Should have thrown an exception.  There should be no project settings"); // $NON-NLS-1$
    } catch (IllegalStateException e) {
      // we expect this exception because setting "use project settings" to false
      // should clear all keys and consequently throw this exception.
    }
  }
Exemple #13
0
  private IProject initializeWorkspace() {
    IEclipsePreferences node = new InstanceScope().getNode(ResourcesPlugin.PI_RESOURCES);
    node.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, true);
    try {
      node.flush();
    } catch (BackingStoreException e) {
      e.printStackTrace();
    }

    WorkspaceJob job =
        new WorkspaceJob("init workspace") {

          @Override
          public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
            MyPart.this.project =
                TwitterContentUtil.getOrCreateTwitterDemoProject(workspace, monitor);
            return Status.OK_STATUS;
          }
        };

    job.setRule(workspace.getRoot());
    job.schedule();

    return TwitterContentUtil.getTwitterDemoProject(workspace);
  }
Exemple #14
0
 @Override
 public void earlyStartup() {
   IEclipsePreferences pref = ConfigurationScope.INSTANCE.getNode(this.getClass().getName());
   if (pref.getBoolean(CFG_SHOW_PERSPECTIVE_KEY, true)) {
     pref.putBoolean(CFG_SHOW_PERSPECTIVE_KEY, false);
     try {
       pref.flush();
     } catch (BackingStoreException e) {
       Activator.error(e);
     }
     final IWorkbench workbench = PlatformUI.getWorkbench();
     workbench
         .getDisplay()
         .asyncExec(
             new Runnable() {
               public void run() {
                 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
                 if (window != null && window.getActivePage() != null) {
                   IPerspectiveDescriptor desc =
                       PlatformUI.getWorkbench()
                           .getPerspectiveRegistry()
                           .findPerspectiveWithId(TYPESCRIPT_PERSPECTIVE_ID);
                   window.getActivePage().setPerspective(desc);
                 }
               }
             });
   }
 }
 /* (non-Javadoc)
  * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
  */
 public void initializeDefaultPreferences() {
   IEclipsePreferences defaultscope = DefaultScope.INSTANCE.getNode(RhinoDebugPlugin.PLUGIN_ID);
   defaultscope.putBoolean(Constants.SUSPEND_ON_STDIN_LOAD, false);
   try {
     defaultscope.flush();
   } catch (BackingStoreException e) {
     RhinoDebugPlugin.log(e);
   }
 }
  private static void updateProjectPrefs(final NewLiferayPluginProjectOp op) {
    try {
      final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ProjectCore.PLUGIN_ID);

      prefs.put(
          ProjectCore.PREF_DEFAULT_PLUGIN_PROJECT_BUILD_TYPE_OPTION,
          op.getProjectProvider().text());
      prefs.putBoolean(ProjectCore.PREF_INCLUDE_SAMPLE_CODE, op.getIncludeSampleCode().content());
      prefs.putBoolean(ProjectCore.PREF_CREATE_NEW_PORLET, op.getCreateNewPortlet().content());

      if ("maven".equalsIgnoreCase(op.getProjectProvider().text())) {
        prefs.put(ProjectCore.PREF_DEFAULT_PLUGIN_PROJECT_MAVEN_GROUPID, op.getGroupId().content());
      }

      prefs.flush();
    } catch (Exception e) {
      final String msg = "Error updating default project build type."; // $NON-NLS-1$
      ProjectCore.logError(msg, e);
    }
  }
    @Override
    public void putPreferences(IEclipsePreferences preferences, ColorThemeSetting setting) {
      // Set the color itself
      super.putPreferences(preferences, setting);

      // Enables the color setting
      preferences.putBoolean(pluginKey + "Enabled", true);

      // Set style
      preferences.putInt(pluginKey + "Style", getStyleValue(setting));
    }
 /**
  * Initializes the given preference store with the default values.
  *
  * @param store the preference store to be initialized
  */
 public static void initializeDefaultValues() {
   IEclipsePreferences node = new DefaultScope().getNode(TernNodejsCorePlugin.PLUGIN_ID);
   // By default native node.js install is used.
   node.put(TernNodejsCoreConstants.NODEJS_INSTALL, NodejsInstall.NODE_NATIVE);
   node.put(TernNodejsCoreConstants.NODEJS_PATH, IDENodejsProcessHelper.getNodejsPath());
   // timeout to start node.js
   node.putLong(TernNodejsCoreConstants.NODEJS_TIMEOUT, NodejsTernHelper.DEFAULT_TIMEOUT);
   // test number to start node.js
   node.putInt(TernNodejsCoreConstants.NODEJS_TEST_NUMBER, NodejsTernHelper.DEFAULT_TEST_NUMBER);
   // node.js persistent (not auto-shutdown ?)
   node.putBoolean(TernNodejsCoreConstants.NODEJS_PERSISTENT, false);
 }
  public static void setChangedInPreference(
      StructureType structure, IProject project, boolean newValue) {

    IEclipsePreferences node =
        new InstanceScope().getNode(net.bioclipse.qsar.ui.Activator.PLUGIN_ID);
    node.putBoolean(project.getName() + "_" + structure.getId(), newValue);
    try {
      node.flush();
    } catch (BackingStoreException e) {
      e.printStackTrace();
    }
  }
  private boolean setPrefBool(String prefKey, boolean def, Button button) {
    IEclipsePreferences prefs = DartCore.getPlugin().getPrefs();
    boolean oldValue = prefs.getBoolean(prefKey, def);
    boolean newValue = button.getSelection();
    prefs.putBoolean(prefKey, newValue);
    try {
      prefs.flush();
    } catch (BackingStoreException e) {

    }
    return oldValue != newValue;
  }
  /**
   * If the preview preference is disabled or a Teiid server does not exist, a dialog is shown
   * asking the user if they want to enable preview and create a server.
   *
   * @param shell the shell used to display dialog if necessary
   * @return <code>true</code> if preview is enabled, a Teiid server exists, and a connection to the
   *     server has been made
   */
  public static boolean ensurePreviewEnabled(Shell shell) {
    boolean previewEnabled = isPreviewEnabled();
    boolean previewServerExists = previewServerExists();

    // dialog message (null if preview preference enabled and server exists)
    String msg = null;

    if (!previewEnabled && !previewServerExists) {
      msg = UTIL.getString(PREFIX + "previewDisabledNoTeiidInstanceMsg"); // $NON-NLS-1$
    } else if (!previewEnabled) {
      msg = UTIL.getString(PREFIX + "previewDisabledMsg"); // $NON-NLS-1$
    } else if (!previewServerExists) {
      msg = UTIL.getString(PREFIX + "noTeiidInstanceMsg"); // $NON-NLS-1$
    }

    // if necessary open question dialog
    if ((msg != null)
        && MessageDialog.openQuestion(
            shell, UTIL.getString(PREFIX + "confirmEnablePreviewTitle"), msg)) { // $NON-NLS-1$
      // if necessary change preference
      if (!previewEnabled) {
        IEclipsePreferences prefs = DqpPlugin.getInstance().getPreferences();
        prefs.putBoolean(PreferenceConstants.PREVIEW_ENABLED, true);

        // save
        try {
          prefs.flush();
        } catch (BackingStoreException e) {
          UTIL.log(e);
        }
      }

      // if necessary create new server
      if (!previewServerExists) {
        runNewServerAction(shell);
      }
    }

    // if dialog was shown get values again
    if (msg != null) {
      previewEnabled = isPreviewEnabled();
      previewServerExists = previewServerExists();

      // if preview is not enabled or server does not exist then user canceled the dialog or the new
      // server wizard
      if (!previewEnabled || !previewServerExists) {
        return false;
      }
    }

    // abort preview if server is not connected
    return serverConnectionExists(shell);
  }
  /**
   * {@inheritDoc}
   *
   * @see org.teiid.designer.ui.preferences.IGeneralPreferencePageContributor#performOk()
   */
  @Override
  public boolean performOk() {
    IEclipsePreferences prefs = getPreferences();
    prefs.putBoolean(PreferenceConstants.AUTO_CREATE_DATA_SOURCE, this.chkEnabled.getSelection());

    // save
    try {
      prefs.flush();
      return true;
    } catch (BackingStoreException e) {
      return false;
    }
  }
 @Override
 public void putPreferences(IEclipsePreferences preferences, ColorThemeSetting setting) {
   preferences.putBoolean(pluginKey + separator + "enabled", true); // $NON-NLS-1$
   preferences.put(pluginKey + separator + "color", setting.getColor().asRGB());
   if (setting.isBoldEnabled() != null) {
     preferences.putBoolean(
         pluginKey + separator + "bold", setting.isBoldEnabled()); // $NON-NLS-1$
   }
   if (setting.isItalicEnabled() != null) {
     preferences.putBoolean(
         pluginKey + separator + "italic", setting.isItalicEnabled()); // $NON-NLS-1$
   }
   if (setting.isUnderlineEnabled() != null) {
     preferences.putBoolean(
         pluginKey + separator + "underline", setting.isUnderlineEnabled()); // $NON-NLS-1$
   }
   if (setting.isStrikethroughEnabled() != null) {
     preferences.putBoolean(
         pluginKey + separator + "strikethrough", // $NON-NLS-1$
         setting.isStrikethroughEnabled());
   }
 }
 /**
  * Method called when the check box {@link Button} is called. It persists the check box selection
  * state in the {@link IDialogSettings}.
  */
 private void performButtonSelection() {
   // persist whether or not to show the tooltip
   IEclipsePreferences preferences = getEclipsePreferences();
   preferences.putBoolean(DIALOG_SETTINGS__IS_TOOLTIP_DISPLAYED, showToolTipButton.getSelection());
   try {
     preferences.flush();
   } catch (BackingStoreException bse) {
     StudioLogger.error(
         TooltipDisplayConfigContriutionItem.class.toString(),
         "Preferences for snippets could not be saved.",
         bse); //$NON-NLS-1$
   }
 }
 private static void setBoolean(IJavaProject jproject, String optionName, boolean value) {
   IScopeContext context =
       (null != jproject) ? new ProjectScope(jproject.getProject()) : InstanceScope.INSTANCE;
   IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID);
   // get old val as a String, so it can be null if setting doesn't exist yet
   String oldValue = node.get(optionName, null);
   node.putBoolean(optionName, value);
   if (jproject != null && oldValue == null || (value != Boolean.parseBoolean(oldValue))) {
     AptProject aproj = AptPlugin.getAptProject(jproject);
     aproj.preferenceChanged(optionName);
   }
   flushPreference(optionName, node);
 }
 @Override
 public Object execute(final ExecutionEvent event) throws ExecutionException {
   // final Command command = event.getCommand();
   // final boolean oldValue = HandlerUtil.toggleCommandState(command);
   final String filterId = event.getParameter("org.erlide.ui.filterId");
   final IEclipsePreferences prefsNode = ErlangOutlinePage.getPrefsNode();
   final boolean oldValue = prefsNode.getBoolean(filterId, false);
   final boolean value = !oldValue;
   final Object activePart = HandlerUtil.getVariable(event, "activePart");
   if (activePart instanceof ContentOutline) {
     OutlineFilterUtils.addFilter(filterId, value, activePart);
   }
   prefsNode.putBoolean(filterId, value);
   try {
     prefsNode.flush();
   } catch (final BackingStoreException e) {
     ErlLogger.error(e);
   }
   return null;
 }
Exemple #27
0
  public void save() {
    IEclipsePreferences prefs =
        EclipsePreferencesUtils.getInstanceScope().getNode(UiPlugin.PLUGIN_ID);
    prefs.putBoolean(PREF_PROJECT_TASKS_VISIBLE, this.projectTasksVisible);
    prefs.putBoolean(PREF_TASK_SELECTORS_VISIBLE, this.taskSelectorsVisible);
    prefs.putBoolean(PREF_PRIVATE_TASKS_VISIBLE, this.privateTasksVisible);
    prefs.putBoolean(PREF_SORT_BY_TYPE, this.sortByType);
    prefs.putBoolean(PREF_SORT_BY_VISIBILITY, this.sortByVisibility);
    prefs.putBoolean(PREF_LINK_TO_SELECTION, this.linkToSelection);
    prefs.putBoolean(PREF_SHOW_TREE_HEADER, this.showTreeHeader);
    prefs.putInt(PREF_HEADER_NAME_COLUMN_WIDTH, this.headerNameColumnWidth);
    prefs.putInt(PREF_HEADER_DESCRIPTION_COLUMN_WIDTH, this.headerDescriptionColumnWidth);

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      UiPlugin.logger().error("Unable to store task view preferences.", e);
    }
  }
  @Override
  public void initializeDefaultPreferences() {

    IEclipsePreferences node = new DefaultScope().getNode(J2EEPlugin.PLUGIN_ID);

    node.put(Keys.J2EE_VERSION, Defaults.J2EE_VERSION);
    node.putBoolean(Keys.CREATE_EJB_CLIENT_JAR, Defaults.CREATE_EJB_CLIENT_JAR);
    node.putBoolean(Keys.EJB_CLIENT_JAR_CP_COMPATIBILITY, Defaults.EJB_CLIENT_JAR_CP_COMPATIBILITY);
    node.putBoolean(Keys.INCREMENTAL_DEPLOYMENT_SUPPORT, Defaults.INCREMENTAL_DEPLOYMENT_SUPPORT);

    // since 2.0
    node.put(
        Keys.J2EE_WEB_CONTENT, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER));
    node.put(
        Keys.STATIC_WEB_CONTENT, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER));
    // since 2.0
    node.put(Keys.JAVA_SOURCE, FacetCorePlugin.getJavaSrcFolder());
    // done in CommonFrameworksPref..Initializer
    // node.put(Keys.DEFAULT_SOURCE_FOLDER,
    // ProductManager.getProperty(IProductConstants.DEFAULT_SOURCE_FOLDER));
    node.put(
        Keys.APPLICATION_CONTENT_FOLDER,
        ProductManager.getProperty(IProductConstants.APPLICATION_CONTENT_FOLDER));
    node.put(
        Keys.WEB_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.WEB_CONTENT_FOLDER));
    node.put(
        Keys.APP_CLIENT_CONTENT_FOLDER,
        ProductManager.getProperty(IProductConstants.APP_CLIENT_CONTENT_FOLDER));
    node.put(
        Keys.EJB_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.EJB_CONTENT_FOLDER));
    node.put(
        Keys.JCA_CONTENT_FOLDER, ProductManager.getProperty(IProductConstants.JCA_CONTENT_FOLDER));
    node.put(
        Keys.ADD_TO_EAR_BY_DEFAULT,
        ProductManager.getProperty(IProductConstants.ADD_TO_EAR_BY_DEFAULT));
    node.put(
        Keys.ADD_TO_EAR_RUNTIME_EXCEPTIONS,
        ProductManager.getProperty(IProductConstants.ADD_TO_EAR_RUNTIME_EXCEPTIONS));
    // done in CommonFrameworksPref..Initializer
    // node.put(Keys.OUTPUT_FOLDER, ProductManager.getProperty(IProductConstants.OUTPUT_FOLDER));

    // since 2.0, for java ee projects
    node.putBoolean(Keys.APPLICATION_GENERATE_DD, false);
    // for ee5 jee web projects default it to true so that we can create servlets, otherwise false
    String generateDynamicWebDD =
        ProductManager.getProperty(IProductConstants.DYNAMIC_WEB_GENERATE_DD);
    boolean generateDynamicWebDDDefault =
        (generateDynamicWebDD != null)
            ? Boolean.parseBoolean(generateDynamicWebDD)
            : Defaults.DYNAMIC_WEB_GENERATE_DD;
    node.putBoolean(Keys.DYNAMIC_WEB_GENERATE_DD, generateDynamicWebDDDefault);
    node.putBoolean(Keys.EE6_DYNAMIC_WEB_GENERATE_DD, false);
    node.putBoolean(Keys.EJB_GENERATE_DD, false);
    node.putBoolean(Keys.APP_CLIENT_GENERATE_DD, false);
    String ee6ConnectorGenerateDD =
        ProductManager.getProperty(IProductConstants.EE6_CONNECTOR_GENERATE_DD);
    boolean ee6ConnectorGenerateDDDefault =
        (ee6ConnectorGenerateDD != null)
            ? Boolean.parseBoolean(ee6ConnectorGenerateDD)
            : Defaults.EE6_CONNECTOR_GENERATE_DD;
    node.putBoolean(Keys.EE6_CONNECTOR_GENERATE_DD, ee6ConnectorGenerateDDDefault);
    String ee7ConnectorGenerateDD =
        ProductManager.getProperty(IProductConstants.EE7_CONNECTOR_GENERATE_DD);
    boolean ee7ConnectorGenerateDDDefault =
        (ee7ConnectorGenerateDD != null)
            ? Boolean.parseBoolean(ee7ConnectorGenerateDD)
            : Defaults.EE7_CONNECTOR_GENERATE_DD;
    node.putBoolean(Keys.EE7_CONNECTOR_GENERATE_DD, ee7ConnectorGenerateDDDefault);

    node.putBoolean(Keys.USE_EAR_LIBRARIES, true);
    node.putBoolean(Keys.USE_WEB_APP_LIBRARIES, true);
    node.putBoolean(Keys.USE_EAR_LIBRARIES_JDT_EXPORT, Defaults.USE_EAR_LIBRARIES_JDT_EXPORT);
    String perspectiveID =
        ProductManager.getProperty(IProductConstants.ID_PERSPECTIVE_HIERARCHY_VIEW);
    node.put(
        Keys.ID_PERSPECTIVE_HIERARCHY_VIEW,
        (perspectiveID != null) ? perspectiveID : Defaults.ID_PERSPECTIVE_HIERARCHY_VIEW);
    String allowClasspathDep = ProductManager.getProperty(IProductConstants.ALLOW_CLASSPATH_DEP);
    boolean allowClasspathDepDefault =
        (allowClasspathDep != null)
            ? Boolean.parseBoolean(allowClasspathDep)
            : Defaults.ALLOW_CLASSPATH_DEP;
    node.putBoolean(Keys.ALLOW_CLASSPATH_DEP, allowClasspathDepDefault);
    String validateDupClasspathCompURIs =
        ProductManager.getProperty(IProductConstants.VALIDATE_DUPLICATE_CLASSPATH_COMPONENT_URI);
    boolean validateDupClasspathCompURIsDefault =
        (validateDupClasspathCompURIs != null)
            ? Boolean.parseBoolean(validateDupClasspathCompURIs)
            : Defaults.VALIDATE_DUPLICATE_CLASSPATH_COMPONENT_URI;
    node.putBoolean(
        Keys.VALIDATE_DUPLICATE_CLASSPATH_COMPONENT_URI, validateDupClasspathCompURIsDefault);
    String showJavaEEModuleDependencyPage =
        ProductManager.getProperty(IProductConstants.SHOW_JAVA_EE_MODULE_DEPENDENCY_PAGE);
    boolean showJavaEEModuleDependencyPageDefault =
        (showJavaEEModuleDependencyPage != null)
            ? Boolean.parseBoolean(showJavaEEModuleDependencyPage)
            : Defaults.SHOW_JAVA_EE_MODULE_DEPENDENCY_PAGE;
    node.putBoolean(
        Keys.SHOW_JAVA_EE_MODULE_DEPENDENCY_PAGE, showJavaEEModuleDependencyPageDefault);

    node.put(Keys.DYN_WEB_SRC_FOLDER, getDynamicWebDefaultSourceFolder());
    node.put(Keys.DYN_WEB_OUTPUT_FOLDER, getDynamicWebDefaultOuputFolderName());
    node.put(Keys.APP_CLIENT_OUTPUT_FOLDER, getAppClientDefaultOutputFolderName());
    node.put(Keys.EJB_OUTPUT_FOLDER, getEJBDefaultOutputFolderName());
    node.put(Keys.JCA_OUTPUT_FOLDER, getJCADefaultOutputFolderName());

    String ejbBusinessInterfaceAnnotationInBean =
        ProductManager.getProperty(IProductConstants.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_BEAN);
    boolean ejbBusinessInterfaceAnnotationInBeanDefault =
        (ejbBusinessInterfaceAnnotationInBean != null)
            ? Boolean.parseBoolean(ejbBusinessInterfaceAnnotationInBean)
            : Defaults.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_BEAN;
    node.putBoolean(
        Keys.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_BEAN,
        ejbBusinessInterfaceAnnotationInBeanDefault);

    String ejbBusinessInterfaceAnnotationInInterface =
        ProductManager.getProperty(
            IProductConstants.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_INTERFACE);
    boolean ejbBusinessInterfaceAnnotationInInterfaceDefault =
        (ejbBusinessInterfaceAnnotationInInterface != null)
            ? Boolean.parseBoolean(ejbBusinessInterfaceAnnotationInInterface)
            : Defaults.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_INTERFACE;
    node.putBoolean(
        Keys.EJB_BUSINESS_INTERFACE_ANNOTATION_IN_INTERFACE,
        ejbBusinessInterfaceAnnotationInInterfaceDefault);

    node.put(
        Keys.EJB_INTERFACE_PACKAGE_SUFFIX,
        ProductManager.getProperty(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX));
  }
  /**
   * Set a boolean preference for the given preference id.
   *
   * @param prefId the preference id
   * @param value the boolean value
   * @throws BackingStoreException if this operation cannot be completed due to a failure in the
   *     backing store, or inability to communicate with it.
   */
  public static void setBoolean(String prefId, boolean value) throws BackingStoreException {

    IEclipsePreferences prefs = new InstanceScope().getNode(CheckstylePlugin.PLUGIN_ID);
    prefs.putBoolean(prefId, value);
    prefs.flush();
  }
  /**
   * @see
   *     org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
   */
  @Override
  public void initializeDefaultPreferences() {

    IEclipsePreferences node =
        new DefaultScope().getNode(CorePlugin.getDefault().getBundle().getSymbolicName());

    // Building temporary files directory path
    IPath tempPath =
        new Path(System.getProperty("user.dir"))
            .append("temp"); // NON-NLS-1$// NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
    File tempFile = tempPath.toFile();
    if (!tempFile.exists()) {
      tempFile.mkdirs();
    }
    node.put(ITalendCorePrefConstants.FILE_PATH_TEMP, tempPath.toOSString());

    String os = Platform.getOS();
    String javaPath = System.getProperty("java.home"); // NON-NLS-1$ //$NON-NLS-1$
    if (os.equals(Platform.OS_WIN32)) {
      node.put(ITalendCorePrefConstants.JAVA_INTERPRETER, javaPath + JAVA_WIN32_INTERPRETER);
    } else if (os.equals(Platform.OS_LINUX)) {
      node.put(ITalendCorePrefConstants.JAVA_INTERPRETER, javaPath + JAVA_LINUX_INTERPRETER_PATH);
    }

    // Sets default language
    node.put(ITalendCorePrefConstants.LANGUAGE_SELECTOR, Locale.getDefault().getLanguage());

    node.put(ITalendCorePrefConstants.PREVIEW_LIMIT, "50"); // $NON-NLS-1$

    node.putBoolean(ITalendCorePrefConstants.ALWAYS_WELCOME, true);

    String languageType = Locale.getDefault().getLanguage();
    if (Locale.getDefault().equals(Locale.CHINA)) {
      languageType = Locale.SIMPLIFIED_CHINESE.toString();
    }

    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.LANGUAGE_SELECTOR, languageType);
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.SQL_ADD_QUOTE, false);

    // As default, sets the choice which automatic generate corresponding documentation files if job
    // is saved to
    // true:
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.DOC_GENERATION, false);
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.USE_CSS_TEMPLATE, false);
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.CONTEXT_GROUP_BY_SOURCE, true);
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.DOC_GENERATESOURCECODE, false);
    // CorePlugin.getDefault().getPreferenceStore().setDefault(ITalendCorePrefConstants.DOC_HIDEPASSWORDS, true);

    //
    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.SQL_ADD_WARNING, true);

    CorePlugin.getDefault()
        .getPreferenceStore()
        .setDefault(ITalendCorePrefConstants.FORBIDDEN_MAPPING_LENGTH_PREC_LOGIC, false);
  }