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);
  }
  /*
   * (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();
  }
 @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;
   }
 }
 /** {@inheritDoc} */
 @Override
 public void initializeDefaultPreferences() {
   final IEclipsePreferences prefs = new DefaultScope().getNode(Activator.getPluginId());
   prefs.put(PreferenceConstants.DATABASE_URL, "");
   prefs.put(PreferenceConstants.DATABASE_USER, "");
   prefs.put(PreferenceConstants.DATABASE_PASSWORD, "");
   prefs.put(PreferenceConstants.META_DATA_DIRECTORY, "./var/tables");
 }
Beispiel #5
0
 public void saveToPreferences() {
   final IEclipsePreferences lStore =
       InstanceScope.INSTANCE.getNode(RelationsConstants.PREFERENCE_NODE);
   lStore.put(RelationsConstants.KEY_DB_PLUGIN_ID, dbConfig.getName());
   lStore.put(RelationsConstants.KEY_DB_HOST, host);
   lStore.put(RelationsConstants.KEY_DB_CATALOG, catalog);
   lStore.put(RelationsConstants.KEY_DB_USER_NAME, username);
   lStore.put(RelationsConstants.KEY_DB_PASSWORD, password);
 }
 /**
  * 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);
 }
 /*
  * (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$
 }
  protected void createProjectSettings(IProject project, String containerPath, String consolePath)
      throws BackingStoreException {

    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(SymfonyCorePlugin.ID);
    String executable = preferences.get(Keys.PHP_EXECUTABLE, null);
    IEclipsePreferences node = new ProjectScope(project).getNode(SymfonyCorePlugin.ID);
    if (executable != null) {
      node.put(Keys.PHP_EXECUTABLE, executable);
      Logger.log(Logger.WARNING, "Executable not found!");
    }
    node.put(Keys.CONSOLE, consolePath);
    node.put(Keys.USE_PROJECT_PHAR, Boolean.FALSE.toString());
    node.put(Keys.DUMPED_CONTAINER, containerPath);
    node.flush();
  }
  public void store(final IEclipsePreferences root) throws BackingStoreException {
    CodePathLocation.clearAll(root);
    root.put(ProjectPreferencesConstants.OUTPUT, output.toPortableString());
    if (requiredRuntimeVersion != null) {
      root.put(
          ProjectPreferencesConstants.REQUIRED_BACKEND_VERSION, requiredRuntimeVersion.toString());
    }
    root.put(ProjectPreferencesConstants.INCLUDES, PathSerializer.packList(includes));
    final Preferences srcNode = root.node(ProjectPreferencesConstants.SOURCES);
    for (final SourceLocation loc : sources) {
      loc.store((IEclipsePreferences) srcNode.node(Integer.toString(loc.getId())));
    }

    root.flush();
  }
  /**
   * 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$
    }
  }
  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);
      }
    }
  }
Beispiel #12
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);
   }
 }
  public static void setBuildTime(IProject project, String time) {

    // If exists in prefs, add them
    IEclipsePreferences node =
        new InstanceScope().getNode(net.bioclipse.qsar.ui.Activator.PLUGIN_ID);
    node.put(project.getName() + "_time", time);
  }
  @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;
  }
Beispiel #15
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));
    }
  }
 protected void setProperty(String key, String value) {
   if (value == null) {
     removeProperty(key);
   } else {
     eclipsePreferences.put(DESIGNER_SETTINGS_PREFIX + key, value);
   }
 }
  /**
   * If modified, also modify the method {@link ModelManager#getDefaultOptionsNoInitialization()}
   */
  @Override
  public void initializeDefaultPreferences() {
    // Get options names set
    HashSet<String> optionNames = ModelManager.getModelManager().optionNames;

    Map<String, String> defaultOptionsMap = new HashMap<String, String>();

    // DLTKCore settings
    defaultOptionsMap.put(DLTKCore.CORE_INCOMPLETE_BUILDPATH, DLTKCore.ERROR);
    defaultOptionsMap.put(DLTKCore.CORE_CIRCULAR_BUILDPATH, DLTKCore.ERROR);
    defaultOptionsMap.put(DLTKCore.CORE_ENABLE_BUILDPATH_EXCLUSION_PATTERNS, DLTKCore.ENABLED);
    defaultOptionsMap.put(DLTKCore.INDEXER_ENABLED, DLTKCore.ENABLED);
    defaultOptionsMap.put(DLTKCore.BUILDER_ENABLED, DLTKCore.ENABLED);
    defaultOptionsMap.put(DLTKCore.CODEASSIST_CAMEL_CASE_MATCH, DLTKCore.ENABLED);

    // encoding setting comes from resource plug-in
    optionNames.add(DLTKCore.CORE_ENCODING);

    // project-specific options
    optionNames.add(DLTKCore.PROJECT_SOURCE_PARSER_ID);

    // Store default values to default preferences
    IEclipsePreferences defaultPreferences = new DefaultScope().getNode(DLTKCore.PLUGIN_ID);
    for (Map.Entry<String, String> entry : defaultOptionsMap.entrySet()) {
      String optionName = entry.getKey();
      defaultPreferences.put(optionName, entry.getValue());
      optionNames.add(optionName);
    }
  }
Beispiel #18
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);
      }
    }
  }
  protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
      IScopeContext projectScope = fPreferencesAccess.getProjectScope(projects[i]);
      IEclipsePreferences node = projectScope.getNode(JavaUI.ID_PLUGIN);
      String profileId = node.get(fProfileKey, null);
      if (oldName.equals(profileId)) {
        if (newProfile == null) {
          node.remove(fProfileKey);
        } else {
          if (applySettings) {
            writeToPreferenceStore(newProfile, projectScope);
          } else {
            node.put(fProfileKey, newProfile.getID());
          }
        }
      }
    }

    IScopeContext instanceScope = fPreferencesAccess.getInstanceScope();
    final IEclipsePreferences uiPrefs = instanceScope.getNode(JavaUI.ID_PLUGIN);
    if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
      writeToPreferenceStore(newProfile, instanceScope);
    }
  }
  public void testGetAdvancedOptionViaProjectPreferences() throws Exception {
    AspectJPreferences.setUsingProjectSettings(project, true);
    assertTrue(
        "should be using project settings", //$NON-NLS-1$
        AspectJPreferences.isUsingProjectSettings(project));
    assertEquals(
        "should have no advanced options set", //$NON-NLS-1$
        " ",
        AspectJPreferences.getAdvancedOptions(project)); // $NON-NLS-1$

    projectNode.put(AspectJPreferences.OPTION_XSerializableAspects, "true"); // $NON-NLS-1$
    assertEquals(
        "should have set -XSerializableAspects option", //$NON-NLS-1$
        " -XserializableAspects ", //$NON-NLS-1$
        AspectJPreferences.getAdvancedOptions(project));

    projectNode.put(AspectJPreferences.OPTION_XSerializableAspects, "false"); // $NON-NLS-1$
    assertEquals(
        "should have no advanced options set", //$NON-NLS-1$
        " ",
        AspectJPreferences.getAdvancedOptions(project)); // $NON-NLS-1$

    projectNode.put(AspectJPreferences.OPTION_XNoInline, "true"); // $NON-NLS-1$
    assertEquals(
        "should have set -XnoInline option", //$NON-NLS-1$
        " -XnoInline ", //$NON-NLS-1$
        AspectJPreferences.getAdvancedOptions(project));

    projectNode.put(AspectJPreferences.OPTION_XNotReweavable, "true"); // $NON-NLS-1$
    assertEquals(
        "should have set -XnotReweavable option", //$NON-NLS-1$
        " -XnoInline -XnotReweavable ", //$NON-NLS-1$
        AspectJPreferences.getAdvancedOptions(project));

    projectNode.put(AspectJPreferences.OPTION_XHasMember, "true"); // $NON-NLS-1$
    assertEquals(
        "should have set -XhasMember option", //$NON-NLS-1$
        " -XnoInline -XnotReweavable -XhasMember ", //$NON-NLS-1$
        AspectJPreferences.getAdvancedOptions(project));

    projectNode.put(AspectJPreferences.OPTION_XHasMember, "false"); // $NON-NLS-1$
    projectNode.put(AspectJPreferences.OPTION_XNotReweavable, "false"); // $NON-NLS-1$
    projectNode.put(AspectJPreferences.OPTION_XNoInline, "false"); // $NON-NLS-1$

    assertEquals(
        "should have no advanced options set", //$NON-NLS-1$
        " ",
        AspectJPreferences.getAdvancedOptions(project)); // $NON-NLS-1$
    AspectJPreferences.setUsingProjectSettings(project, false);
    assertFalse(
        "should not be using project settings", //$NON-NLS-1$
        AspectJPreferences.isUsingProjectSettings(project));
    assertEquals(
        "should have no advanced options set", //$NON-NLS-1$
        " ",
        AspectJPreferences.getAdvancedOptions(project)); // $NON-NLS-1$
  }
 /**
  * Writes the value of the CONFIGURED attribute.
  *
  * @param value the value to set
  */
 private static void writeConfiguredAttribute(String value) {
   IEclipsePreferences rootNode =
       InstanceScope.INSTANCE.getNode(
           FrameworkUtil.getBundle(WorkspaceConfigurationStatusUtil.class).getSymbolicName());
   if (rootNode != null) {
     rootNode.put(WorkspaceConfigurationConstants.CONFIG_CONFIGURED, value);
   }
 }
  @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();
    }
  }
Beispiel #23
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();
   }
 }
 @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();
 }
  /**
   * 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());
    }
  }
  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;
  }
  /** {@inheritDoc} */
  @Override
  public void initializeDefaultPreferences() {

    // get the preferences
    IEclipsePreferences preferences = DefaultScope.INSTANCE.getNode(MvnCoreActivator.PLUGIN_ID);

    // default setting: configured repositories
    preferences.put(
        MvnCoreActivator.PREF_MVN_CURRENT_SETTING,
        MvnConfigurationSettingEnum.USE_CONFIGURED_RESPOSITORIES.name());

    // defaults for configured repositories
    preferences.put(MvnCoreActivator.PREF_MVN_LOCAL_REPO, MvnCoreActivator.DEFAULT_MVN_LOCAL_REPO);
    preferences.put(
        MvnCoreActivator.PREF_MVN_REMOTE_REPO, MvnCoreActivator.DEFAULT_MVN_REMOTE_REPO);

    // defaults for configured repositories
    preferences.put(
        MvnCoreActivator.PREF_MVN_SETTINGSXML, MvnCoreActivator.DEFAULT_MVN_SETTINGSXML);
  }
Beispiel #29
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 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);
    }
  }