Exemplo n.º 1
0
 private static void flushPreference(String optionName, IEclipsePreferences node) {
   try {
     node.flush();
   } catch (BackingStoreException e) {
     AptPlugin.log(e, "Failed to save preference: " + optionName); // $NON-NLS-1$
   }
 }
    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();
      }
    }
Exemplo n.º 3
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);
                 }
               }
             });
   }
 }
  private void storeViewPaneVisibility() {
    fVisibleViewPanes.clear();
    StringBuffer visibleViewPanes = new StringBuffer();

    Enumeration<String> enumeration = fViewPaneControls.keys();

    while (enumeration.hasMoreElements()) {
      String paneId = enumeration.nextElement();

      Control control = fViewPaneControls.get(paneId);
      if (control.isVisible()) {
        visibleViewPanes.append(paneId);
        visibleViewPanes.append(","); // $NON-NLS-1$
        fVisibleViewPanes.add(paneId);
      }
    }
    IEclipsePreferences node = InstanceScope.INSTANCE.getNode(DebugUIPlugin.getUniqueIdentifier());
    if (node != null) {
      try {
        node.put(getVisibilityPrefId(), visibleViewPanes.toString());
        node.flush();
      } catch (BackingStoreException e) {
        DebugUIPlugin.log(e);
      }
    }
  }
Exemplo n.º 5
0
  /**
   * Check if model version is changed and rebuild PHP projects if necessary.
   *
   * @see PHPCoreConstants.STRUCTURE_VERSION
   */
  private void rebuildProjects() {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(ID);
    String modelVersion = preferences.get(PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, null);
    if (PHPCoreConstants.STRUCTURE_VERSION.equals(modelVersion)) {
      return;
    }

    preferences.put(
        PHPCoreConstants.STRUCTURE_VERSION_PREFERENCE, PHPCoreConstants.STRUCTURE_VERSION);
    try {
      preferences.flush();
    } catch (BackingStoreException e1) {
      Logger.logException(e1);
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject[] projects = workspace.getRoot().getProjects();
    if (workspace.isAutoBuilding()) {
      try {
        for (IProject project : projects) {
          if (PHPToolkitUtil.isPhpProject(project)) {
            project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
          }
        }
      } catch (CoreException e) {
        Logger.logException(e);
      }
    }
  }
Exemplo n.º 6
0
  private void savePrefs(final SelectedRepos repos) {
    if (fREnv.getConfig() == null) {
      return;
    }
    final IScopeContext prefs = InstanceScope.INSTANCE;

    final IEclipsePreferences node = prefs.getNode(fSelectedReposPref.getQualifier());

    PreferencesUtil.setPrefValue(node, fSelectedReposPref, repos.getRepos());
    PreferencesUtil.setPrefValue(node, fSelectedCRANPref, repos.getCRANMirror());
    PreferencesUtil.setPrefValue(node, fBioCVersionPref, repos.getBioCVersion());
    PreferencesUtil.setPrefValue(node, fSelectedBioCPref, repos.getBioCMirror());

    if (repos.getCRANMirror() != null) {
      PreferencesUtil.setPrefValue(prefs, LAST_CRAN_PREF, repos.getCRANMirror());
    }
    if (repos.getBioCMirror() != null) {
      PreferencesUtil.setPrefValue(prefs, LAST_BIOC_PREF, repos.getBioCMirror());
    }

    try {
      node.flush();
    } catch (final BackingStoreException e) {
      RCorePlugin.log(
          new Status(
              IStatus.ERROR,
              RCore.PLUGIN_ID,
              "An error occurred when saving the R package manager preferences.",
              e));
    }
  }
Exemplo n.º 7
0
  /**
   * Set all the processor options in one call. This will delete any options that are not passed in,
   * so callers who do not wish to destroy pre-existing options should use addProcessorOption()
   * instead.
   *
   * @param options a map of keys to values. The keys should not include any automatic options (@see
   *     #isAutomaticProcessorOption(String)), and the "-A" should not be included. That is, to
   *     perform the equivalent of the apt command line "-Afoo=bar", use the key "foo" and the value
   *     "bar". Keys cannot contain spaces; values can contain anything at all. Keys cannot be null,
   *     but values can be.
   */
  public static void setProcessorOptions(Map<String, String> options, IJavaProject jproj) {
    IScopeContext context =
        (null != jproj) ? new ProjectScope(jproj.getProject()) : InstanceScope.INSTANCE;

    // TODO: this call is needed only for backwards compatibility with
    // settings files previous to 2005.11.13.  At some point it should be
    // removed.
    removeOldStyleSettings(context);

    IEclipsePreferences node =
        context.getNode(
            AptPlugin.PLUGIN_ID
                + "/"
                + //$NON-NLS-1$
                AptPreferenceConstants.APT_PROCESSOROPTIONS);
    try {
      node.clear();
      for (Entry<String, String> option : options.entrySet()) {
        String nonNullVal =
            option.getValue() == null ? AptPreferenceConstants.APT_NULLVALUE : option.getValue();
        node.put(option.getKey(), nonNullVal);
      }
      node.flush();
    } catch (BackingStoreException e) {
      AptPlugin.log(e, "Unable to save annotation processor options"); // $NON-NLS-1$
    }
  }
  /*
   * (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();
  }
  @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);
  }
Exemplo n.º 10
0
 public void setPreference(IEclipsePreferences preferences, String key, List<String> vals) {
   if (preferences == null) {
     preferences = getProjectOrWorkspacePreferences(null);
   }
   String concat;
   if (vals == null) {
     concat = "";
   } else {
     // we should escape all ',' that happen to exist in the string, but
     // these should not be here since the strings were validated on entry
     StringBuilder sb = new StringBuilder();
     for (Iterator<String> valIter = vals.iterator(); valIter.hasNext(); ) {
       sb.append(valIter.next());
       if (valIter.hasNext()) {
         sb.append(",");
       }
     }
     concat = sb.toString();
   }
   preferences.put(key, concat);
   try {
     preferences.flush();
   } catch (BackingStoreException e) {
     Util.log(e);
   }
 }
Exemplo n.º 11
0
 @SuppressWarnings("unchecked")
 @Override
 protected void doPut(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   traceRequest(req);
   IEclipsePreferences node = getNode(req, resp, true);
   if (node == null) return;
   String key = req.getParameter("key");
   try {
     if (key != null) {
       node.put(key, req.getParameter("value"));
     } else {
       JSONObject newNode = new JSONObject(new JSONTokener(req.getReader()));
       node.clear();
       for (Iterator<String> it = newNode.keys(); it.hasNext(); ) {
         key = it.next();
         node.put(key, newNode.getString(key));
       }
     }
     prefRoot.flush();
     resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
   } catch (Exception e) {
     handleException(
         resp, NLS.bind("Failed to store preferences for {0}", req.getRequestURL()), e);
     return;
   }
 }
Exemplo n.º 12
0
 public void save() {
   try {
     eclipsePreferences.flush();
   } catch (BackingStoreException e) {
     ServoyLog.logError(e);
   }
 }
Exemplo n.º 13
0
  @Override
  public boolean performOk() {
    // Preferences preferences = Activator.getDefault().getPluginPreferences();

    // InstanceScope is = new InstanceScope();

    final IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);

    if (toolGroups != null) {
      for (final BinDirPanel toolGroup : toolGroups) {
        preferences.put(
            IToolLaunchConfigurationConstants.TOOL_BIN_ID + "." + toolGroup.group,
            toolGroup.binDir.getText()); // $NON-NLS-1$
      }
    }

    try {
      preferences.flush();
    } catch (final BackingStoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // Activator.getDefault().savePluginPreferences();
    return true;
  }
Exemplo n.º 14
0
  public void storeMappings(WorkspaceLanguageConfiguration config) throws CoreException {
    try {
      // Encode mappings as XML and serialize as a String.
      Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      Element rootElement = doc.createElement(WORKSPACE_MAPPINGS);
      doc.appendChild(rootElement);
      addContentTypeMappings(config.getWorkspaceMappings(), rootElement);
      Transformer serializer = createSerializer();
      DOMSource source = new DOMSource(doc);
      StringWriter buffer = new StringWriter();
      StreamResult result = new StreamResult(buffer);
      serializer.transform(source, result);
      String encodedMappings = buffer.getBuffer().toString();

      IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
      node.put(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS, encodedMappings);
      node.flush();
    } catch (ParserConfigurationException e) {
      throw new CoreException(Util.createStatus(e));
    } catch (TransformerException e) {
      throw new CoreException(Util.createStatus(e));
    } catch (BackingStoreException e) {
      throw new CoreException(Util.createStatus(e));
    }
  }
Exemplo n.º 15
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);
  }
Exemplo n.º 16
0
  @Test
  public void testLinkToFolderWithDefaultSCM() throws Exception {
    // enable git autoinit for new projects
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ServerConstants.PREFERENCE_SCOPE);
    String oldValue = prefs.get(ServerConstants.CONFIG_FILE_DEFAULT_SCM, null);
    prefs.put(ServerConstants.CONFIG_FILE_DEFAULT_SCM, "git");
    prefs.flush();

    try {
      // the same check as in
      // org.eclipse.orion.server.git.GitFileDecorator.initGitRepository(HttpServletRequest, IPath,
      // JSONObject)
      String scm = PreferenceHelper.getString(ServerConstants.CONFIG_FILE_DEFAULT_SCM, "");
      Assume.assumeTrue("git".equals(scm)); // $NON-NLS-1$

      URI workspaceLocation = createWorkspace(getMethodName());

      String contentLocation = new File(gitDir, "folder").getAbsolutePath();

      JSONObject newProject =
          createProjectOrLink(workspaceLocation, getMethodName() + "-link", contentLocation);
      String projectContentLocation = newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION);

      // http://<host>/file/<projectId>/
      WebRequest request = getGetFilesRequest(projectContentLocation);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      JSONObject project = new JSONObject(response.getText());
      String childrenLocation = project.getString(ProtocolConstants.KEY_CHILDREN_LOCATION);
      assertNotNull(childrenLocation);

      // http://<host>/file/<projectId>/?depth=1
      request = getGetFilesRequest(childrenLocation);
      response = webConversation.getResponse(request);
      assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
      List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText()));
      String[] expectedChildren = new String[] {"folder.txt"}; // no .git even though auto-git is on
      assertEquals("Wrong number of directory children", expectedChildren.length, children.size());
      assertEquals(expectedChildren[0], children.get(0).getString(ProtocolConstants.KEY_NAME));
    } finally {
      // reset the preference we messed with for the test
      if (oldValue == null) prefs.remove(ServerConstants.CONFIG_FILE_DEFAULT_SCM);
      else prefs.put(ServerConstants.CONFIG_FILE_DEFAULT_SCM, oldValue);
      prefs.flush();
    }
  }
Exemplo n.º 17
0
  /** Tests that we are not allowed to get metadata files */
  @Test
  public void testGetForbiddenFiles() throws IOException, SAXException, BackingStoreException {
    // enable global anonymous read
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ServerConstants.PREFERENCE_SCOPE);
    String oldValue = prefs.get(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, null);
    prefs.put(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, "true");
    prefs.flush();
    try {
      // should not be allowed to get at file root
      WebRequest request = new GetMethodWebRequest(SERVER_LOCATION + FILE_SERVLET_LOCATION);
      setAuthentication(request);
      WebResponse response = webConversation.getResponse(request);
      assertEquals(
          "Should not be able to get the root",
          HttpURLConnection.HTTP_FORBIDDEN,
          response.getResponseCode());

      // should not be allowed to access the metadata directory
      request = new GetMethodWebRequest(SERVER_LOCATION + FILE_SERVLET_LOCATION + ".metadata");
      setAuthentication(request);
      response = webConversation.getResponse(request);
      assertEquals(
          "Should not be able to get metadata",
          HttpURLConnection.HTTP_FORBIDDEN,
          response.getResponseCode());

      // should not be allowed to read specific metadata files
      request =
          new GetMethodWebRequest(
              SERVER_LOCATION
                  + FILE_SERVLET_LOCATION
                  + ".metadata/.plugins/org.eclipse.orion.server.user.securestorage/user_store");
      setAuthentication(request);
      response = webConversation.getResponse(request);
      assertEquals(
          "Should not be able to get metadata",
          HttpURLConnection.HTTP_FORBIDDEN,
          response.getResponseCode());
    } finally {
      // reset the preference we messed with for the test
      if (oldValue == null) prefs.remove(ServerConstants.CONFIG_FILE_ANONYMOUS_READ);
      else prefs.put(ServerConstants.CONFIG_FILE_ANONYMOUS_READ, oldValue);
      prefs.flush();
    }
  }
 private static void setGlobalString(String key, String value) {
   IEclipsePreferences myScope = ConfigurationScope.INSTANCE.getNode(ArduinoConst.NODE_ARDUINO);
   myScope.put(key, value);
   try {
     myScope.flush();
   } catch (BackingStoreException e) {
     e.printStackTrace();
   }
 }
 /* (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);
   }
 }
Exemplo n.º 20
0
 /** Removes this site configuration from the backing store. */
 public void delete() throws CoreException {
   try {
     IEclipsePreferences parent = (IEclipsePreferences) store.parent();
     store.removeNode();
     parent.flush();
   } catch (BackingStoreException e) {
     throw new CoreException(
         new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, "Error saving state"));
   }
 }
Exemplo n.º 21
0
 @Override
 public void put(T element, String key, String value) throws Exception {
   IEclipsePreferences prefs = createPrefs(element);
   if (value == null) {
     prefs.remove(key);
   } else {
     prefs.put(key, value);
   }
   prefs.flush();
 }
Exemplo n.º 22
0
  /**
   * Update the current metadata index version number so that it matches the value returned by
   * getIndexVersion. This is called once the metadata index has been updated
   */
  protected void updateVersionPreference() {
    IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(this.getPluginId());

    prefs.putDouble(this.getIndexVersionKey(), this.getIndexVersion());

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
    }
  }
 private void saveOrientation() {
   IEclipsePreferences node = InstanceScope.INSTANCE.getNode(DebugUIPlugin.getUniqueIdentifier());
   if (node != null) {
     try {
       node.putInt(getOrientationPrefId(), fViewOrientation);
       node.flush();
     } catch (BackingStoreException e) {
       DebugUIPlugin.log(e);
     }
   }
 }
  public boolean performFinish() {
    if (!isRepoValid()) return false;
    boolean res = super.performFinish();
    if (res) {
      final IJavaElement newElement = getCreatedElement();

      IWorkingSet[] workingSets = fFirstPage.getWorkingSets();
      if (workingSets.length > 0) {
        PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(newElement, workingSets);
      }

      BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
      selectAndReveal(fSecondPage.getJavaProject().getProject());

      Display.getDefault()
          .asyncExec(
              new Runnable() {
                public void run() {
                  IWorkbenchPart activePart = getActivePart();
                  if (activePart instanceof IPackagesViewPart) {
                    (new ShowInPackageViewAction(activePart.getSite())).run(newElement);
                  }
                }
              });
      new CeylonNature().addToProject(getCreatedElement().getProject());
    }

    if (!useEmbeddedRepo && repositoryPath != null && !repositoryPath.isEmpty()) {
      IEclipsePreferences node =
          new ProjectScope(getCreatedElement().getProject()).getNode(CeylonPlugin.PLUGIN_ID);
      node.put("repo", repositoryPath);
      try {
        node.flush();
      } catch (BackingStoreException e) {
        e.printStackTrace();
      }
      /*getCreatedElement().getProject()
      .setPersistentProperty(new QualifiedName(CeylonPlugin.PLUGIN_ID, "repo"),
              repositoryPath);*/
      ExportModuleWizard.persistDefaultRepositoryPath(repositoryPath);
    }

    /*IEclipsePreferences node = new ProjectScope(getCreatedElement().getProject())
            .getNode(JavaCore.PLUGIN_ID);
    node.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "*.launch, *.ceylon");
    try {
        node.flush();
    }
    catch (BackingStoreException e) {
        e.printStackTrace();
    }*/

    return res;
  }
Exemplo n.º 25
0
 public void setGroovyCompilerLevel(IProject project, String level) {
   IEclipsePreferences projectPreferences = getProjectScope(project);
   if (projectPreferences != null) {
     projectPreferences.put(GROOVY_COMPILER_LEVEL, level);
     try {
       projectPreferences.flush();
     } catch (BackingStoreException e) {
       Util.log(e);
     }
   }
 }
 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);
   }
 }
Exemplo n.º 27
0
  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();
    }
  }
Exemplo n.º 28
0
  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;
  }
Exemplo n.º 29
0
  /**
   * 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);
  }
 /**
  * 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$
   }
 }