Example #1
0
 private Theme loadUserTheme(String themeName) {
   try {
     byte[] array =
         Platform.getPreferencesService()
             .getByteArray(
                 ThemePlugin.PLUGIN_ID, THEMES_NODE + "/" + themeName, null, null); // $NON-NLS-1$
     if (array == null) {
       return null;
     }
     Properties props = new OrderedProperties();
     props.load(new ByteArrayInputStream(array));
     return new Theme(ThemePlugin.getDefault().getColorManager(), props);
   } catch (IllegalArgumentException iae) {
     // Fallback to load theme that was saved in prefs as XML string
     String xml =
         Platform.getPreferencesService()
             .getString(
                 ThemePlugin.PLUGIN_ID, THEMES_NODE + "/" + themeName, null, null); // $NON-NLS-1$
     if (xml != null) {
       try {
         Properties props = new OrderedProperties();
         props.loadFromXML(new ByteArrayInputStream(xml.getBytes("UTF-8"))); // $NON-NLS-1$
         // Now store it as byte array explicitly so we don't run into this!
         Theme theme = new Theme(ThemePlugin.getDefault().getColorManager(), props);
         theme.save();
         return theme;
       } catch (Exception e) {
         ThemePlugin.logError(e);
       }
     }
   } catch (IOException e) {
     ThemePlugin.logError(e);
   }
   return null;
 }
 private void init() {
   String qualifier = HTMLCorePlugin.getDefault().getBundle().getSymbolicName();
   fTagCase =
       Platform.getPreferencesService()
           .getInt(qualifier, HTMLCorePreferenceNames.TAG_NAME_CASE, 0, null);
   fAttrCase =
       Platform.getPreferencesService()
           .getInt(qualifier, HTMLCorePreferenceNames.ATTR_NAME_CASE, 0, null);
 }
 protected static String getLineDelimiterPreference(IFile file) {
   IScopeContext[] scopeContext;
   if (file != null && file.getProject() != null) {
     // project preference
     scopeContext = new IScopeContext[] {new ProjectScope(file.getProject())};
     String lineDelimiter =
         Platform.getPreferencesService()
             .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
     if (lineDelimiter != null) return lineDelimiter;
   }
   // workspace preference
   scopeContext = new IScopeContext[] {InstanceScope.INSTANCE};
   return Platform.getPreferencesService()
       .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
 }
 public Map<String, ? extends Object> getInitServerProperties() {
   final Map<String, Object> map = new HashMap<String, Object>();
   final IPreferencesService preferences = Platform.getPreferencesService();
   final AtomicReference<double[]> dpi = new AtomicReference<double[]>();
   dpi.set(
       RGraphicsPreferencePage.parseDPI(
           preferences.getString(
               RGraphics.PREF_DISPLAY_QUALIFIER,
               RGraphics.PREF_DISPLAY_CUSTOM_DPI_KEY,
               null,
               null)));
   if (dpi.get() == null) {
     Display.getDefault()
         .syncExec(
             new Runnable() {
               public void run() {
                 final Point point = Display.getCurrent().getDPI();
                 dpi.set(new double[] {point.x, point.y});
               }
             });
     if (dpi.get() == null) {
       dpi.set(new double[] {96.0, 96.0});
     }
   }
   map.put("display.ppi", dpi.get()); // $NON-NLS-1$
   return map;
 }
  public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
    String defaultGdbCommand =
        Platform.getPreferencesService()
            .getString(
                GdbPlugin.PLUGIN_ID,
                IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
                "",
                null); //$NON-NLS-1$
    configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand);

    CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
    CommandFactoryDescriptor defDesc =
        cfManager.getDefaultDescriptor(IGDBJtagConstants.DEBUGGER_ID);
    configuration.setAttribute(
        IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, defDesc.getName());
    configuration.setAttribute(
        IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]);
    configuration.setAttribute(
        IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE,
        IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
    configuration.setAttribute(
        IGDBJtagConstants.ATTR_USE_REMOTE_TARGET, IGDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
    configuration.setAttribute(
        IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND,
        IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT);
  }
  /**
   * Early inits. Preferences set here might be overridden by plug-in preferences.ini, product .ini
   * or command line option.
   */
  @Override
  public void initializeDefaultPreferences() {

    if (Activator.getInstance().isDebugging()) {
      System.out.println("DefaultPreferenceInitializer.initializeDefaultPreferences()");
    }

    DefaultPreferences.putBoolean(
        PersistentPreferences.GDB_SERVER_DO_START, DefaultPreferences.DO_START_GDB_SERVER_DEFAULT);

    DefaultPreferences.putString(
        PersistentPreferences.GDB_CLIENT_COMMANDS,
        DefaultPreferences.GDB_CLIENT_OTHER_COMMANDS_DEFAULT);

    DefaultPreferences.putBoolean(
        PersistentPreferences.TAB_MAIN_CHECK_PROGRAM,
        DefaultPreferences.TAB_MAIN_CHECK_PROGRAM_DEFAULT);

    // When the 'ilg.gnuarmeclipse.managedbuild.cross' node is completely
    // added to /default, a NodeChangeEvent is raised.
    // This is the moment when all final default values are in, possibly
    // set by product or command line.

    Preferences prefs = Platform.getPreferencesService().getRootNode().node(DefaultScope.SCOPE);
    if (prefs instanceof IEclipsePreferences) {
      ((IEclipsePreferences) prefs).addNodeChangeListener(new LateInitializer());
    }
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
    refreshEditorsPrecommitListener = new RefreshEditorsPrecommitListener(domain);

    resourceSet = domain.getResourceSet();
    sessionResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.aird", true);
    semanticResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.ecore", true);

    sessionResource = resourceSet.getResource(sessionResourceURI, true);

    final DRepresentation firstDRepresentation =
        getFirstElement(sessionResource, DRepresentation.class);
    refreshFilterStub = new RefreshFilterStub(firstDRepresentation);
    RefreshFilterManager.INSTANCE.addRefreshFilter(refreshFilterStub);

    oldRefreshAutoMode =
        Platform.getPreferencesService()
            .getBoolean(
                SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
    InstanceScope.INSTANCE
        .getNode(SiriusPlugin.ID)
        .putBoolean(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
  }
Example #8
0
 public static boolean getUseCache() {
   final IPreferencesService service = Platform.getPreferencesService();
   if (service == null) {
     return false;
   }
   return service.getBoolean(Activator.PLUGIN_ID, USE_CACHE, false, null);
 }
Example #9
0
  private boolean login(final MonitorServer server) {
    boolean firstTry = true;
    SecureLoginDialog loginDialog = new SecureLoginDialog(null);
    while (!(MonitorServerManager.getInstance().getLoginSucess())) {
      IPreferencesService service = Platform.getPreferencesService();
      boolean auto_login =
          service.getBoolean(Application.PLUGIN_ID, GeneralPreferencePage.AUTO_LOGIN, false, null);
      MonitorServer details = loginDialog.getConnectionDetails();
      if (!auto_login || details == null || !firstTry) {
        if (loginDialog.open() != Window.OK) return false;
        details = loginDialog.getConnectionDetails();
      }
      firstTry = false;

      //			session.setConnectionDetails(details);
      //			MonitorServerManager.getInstance().registerServer(server);
      MonitorServerManager.getInstance().setCurServer(details);
      try {
        MonitorServerManager.getInstance().registerServer(details);
      } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (NotBoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      connectWithProgress(details);
    }
    return true;
  }
Example #10
0
  /**
   * look up a preference value.
   *
   * <p>will return user settings if available or default settings if not. If a system property with
   * the given key is defined it will overrule any existing setting in the preference store. if the
   * key is not defined, this method returns the given default..
   *
   * @param key
   * @return the value or specified default if no such key exists..
   */
  public String getPreferenceValue(String key, String defaultValue) {

    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = getBundle().getSymbolicName();
    String value = service.getString(qualifier, key, defaultValue, null);
    return System.getProperty(key, value);
  }
 public Base() {
   super(CodeSmellType.TOO_COMPLEX_EXPRESSIONS);
   reportTooComplexExpressionSize =
       Platform.getPreferencesService()
           .getInt(
               Activator.PLUGIN_ID, PreferenceConstants.TOO_COMPLEX_EXPRESSIONS_SIZE, 7, null);
 }
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(
        new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
    setControl(composite);

    initializeDialogUnits(parent);

    // Actual contents
    Composite appSettings = new Composite(composite, SWT.NULL);
    appSettings.setLayout(new GridLayout(2, false));

    Label label = new Label(appSettings, SWT.NONE);
    label.setText(Messages.HerokuDeployWizardPage_ApplicationNameLabel);

    appName = new Text(appSettings, SWT.SINGLE | SWT.BORDER);
    appName.setLayoutData(new GridData(250, SWT.DEFAULT));
    // Set default name to project name
    appName.setText(getProjectName());
    appName.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            getContainer().updateButtons();
          }
        });

    publishButton = new Button(composite, SWT.CHECK);
    publishButton.setText(Messages.HerokuDeployWizardPage_PublishApplicationLabel);
    publishButton.setSelection(
        Platform.getPreferencesService()
            .getBoolean(
                HerokuPlugin.getPluginIdentifier(),
                IPreferenceConstants.HEROKU_AUTO_PUBLISH,
                true,
                null));

    if (doesntHaveGitRepo()) {
      Label note = new Label(composite, SWT.WRAP);
      // We need this italic, we may need to set a font explicitly here to get it
      Font dialogFont = JFaceResources.getDialogFont();
      FontData[] data = SWTUtils.italicizedFont(JFaceResources.getDialogFont());
      final Font italic = new Font(dialogFont.getDevice(), data);
      note.setFont(italic);
      note.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              if (!italic.isDisposed()) {
                italic.dispose();
              }
            }
          });

      note.setLayoutData(new GridData(400, SWT.DEFAULT));
      note.setText(Messages.HerokuDeployWizardPage_NoGitRepoNote);
    }

    Dialog.applyDialogFont(composite);
  }
 public AbstractValidationSettingsPage() {
   super();
   fCombos = new ArrayList();
   fExpandables = new ArrayList();
   fPreferencesService = Platform.getPreferencesService();
   fValidation = ValidationFramework.getDefault();
 }
 private boolean isDerivedEncodingStoredSeparately(IProject project) {
   // be careful looking up for our node so not to create any nodes as side effect
   Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
   try {
     // TODO once bug 90500 is fixed, should be as simple as this:
     //			String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES;
     //			return node.nodeExists(path) ?
     // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false;
     // for now, take the long way
     if (!node.nodeExists(project.getName()))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(project.getName());
     if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(ResourcesPlugin.PI_RESOURCES);
     return node.getBoolean(
         ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS,
         ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
     return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
   }
 }
  private void loadViewPanesVisibility() {
    String visiblePanes =
        Platform.getPreferencesService()
            .getString(DebugUIPlugin.getUniqueIdentifier(), getVisibilityPrefId(), null, null);

    if (visiblePanes != null && visiblePanes.length() > 0) {
      StringTokenizer tokenizer = new StringTokenizer(visiblePanes, ","); // $NON-NLS-1$
      while (tokenizer.hasMoreTokens()) {
        String paneId = tokenizer.nextToken();
        fVisibleViewPanes.add(paneId);
      }
    } else {
      for (int i = 0; i < defaultVisiblePaneIds.length; i++) {
        fVisibleViewPanes.add(defaultVisiblePaneIds[i]);
      }
    }

    Enumeration<String> enumeration = fViewPaneControls.keys();
    while (enumeration.hasMoreElements()) {
      String paneId = enumeration.nextElement();
      boolean visible = false;
      if (fVisibleViewPanes.contains(paneId)) visible = true;

      Control control = fViewPaneControls.get(paneId);
      control.setVisible(visible);

      IMemoryViewPane viewPane = fViewPanes.get(paneId);
      viewPane.setVisible(visible);
    }

    fSashForm.layout();
  }
Example #16
0
 public static int getCacheMaxSize() {
   final IPreferencesService service = Platform.getPreferencesService();
   if (service == null) {
     return 100;
   }
   return service.getInt(Activator.PLUGIN_ID, CACHE_MAX_SIZE, 100, null);
 }
 @Before
 public void setUp() throws Exception {
   storer = new TestPersister();
   restorer = new TestPersister();
   preferences = Platform.getPreferencesService().getRootNode().node(NODE_ID);
   monitor = new NullProgressMonitor();
 }
Example #18
0
  @Override
  public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type)
      throws TmfTraceException {
    try {
      String tracedExecutable = resource.getPersistentProperty(EXEC_KEY);
      if (tracedExecutable == null) {
        throw new TmfTraceException(Messages.GdbTrace_ExecutableNotSet);
      }

      String defaultGdbCommand =
          Platform.getPreferencesService()
              .getString(
                  GdbPlugin.PLUGIN_ID,
                  IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND,
                  IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT,
                  null);

      fGdbTpRef = new DsfGdbAdaptor(this, defaultGdbCommand, path, tracedExecutable);
      fNbFrames = getNbFrames();
    } catch (CoreException e) {
      throw new TmfTraceException(Messages.GdbTrace_FailedToInitializeTrace, e);
    }

    super.initTrace(resource, path, type);
  }
 /**
  * Gets the current value of the CONFIGURATION configuration attribute.
  *
  * @return the current value for the configuration attribute
  */
 private static String getConfigurationAttribute() {
   return Platform.getPreferencesService()
       .getString(
           FrameworkUtil.getBundle(WorkspaceConfigurationStatusUtil.class).getSymbolicName(),
           WorkspaceConfigurationConstants.CONFIG_CONFIGURED,
           "",
           null);
 }
Example #20
0
 /**
  * Returns workspace-level default for the stop at main option.
  *
  * @since 4.0
  */
 public static boolean getStopAtMainDefault() {
   return Platform.getPreferencesService()
       .getBoolean(
           GdbPlugin.PLUGIN_ID,
           IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN,
           ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_DEFAULT,
           null);
 }
Example #21
0
 /**
  * Returns workspace-level default for the stop at main symbol.
  *
  * @since 4.0
  */
 public static String getStopAtMainSymbolDefault() {
   return Platform.getPreferencesService()
       .getString(
           GdbPlugin.PLUGIN_ID,
           IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
           ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT,
           null);
 }
Example #22
0
 /**
  * Returns workspace-level default for the Non-Stop mode.
  *
  * @since 4.0
  */
 public static boolean getIsNonStopModeDefault() {
   return Platform.getPreferencesService()
       .getBoolean(
           GdbPlugin.PLUGIN_ID,
           IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP,
           IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT,
           null);
 }
 private boolean isPreferenceEnabled(IProject p) {
   return Platform.getPreferencesService()
       .getBoolean(
           SpringPropertiesEditorPlugin.PLUGIN_ID,
           AUTO_CONFIGURE_APT_GRADLE_PREF,
           AUTO_CONFIGURE_APT_GRADLE_DEFAULT,
           null);
 }
 @Override
 protected void tearDown() throws Exception {
   for (String qualifier : fQualifiers) {
     Platform.getPreferencesService().setDefaultLookupOrder(qualifier, null, null);
   }
   getPrefsScope().getNode("").removeNode();
   super.tearDown();
 }
 public static ToolEnablementPreferences getPreferences(IProject project) {
   IEclipsePreferences rootNode = Platform.getPreferencesService().getRootNode();
   Preferences prefs =
       rootNode
           .node(ProjectScope.SCOPE)
           .node(project.getName())
           .node("org.eclipse.bpmn2.modeler.tools");
   return new ToolEnablementPreferences(prefs);
 }
  @Override
  public void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
      return;
    }

    lastTimeChecked = timestamp;

    Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
      return;
    }

    if (myStatementBlock != null) {
      myStatementBlock.checkRunsOnScope(timestamp, assignment, reference, "call");
    }

    switch (assignment.getAssignmentType()) {
      case A_FUNCTION_RVAL:
      case A_EXT_FUNCTION_RVAL:
        location.reportConfigurableSemanticProblem(
            Platform.getPreferencesService()
                .getString(
                    ProductConstants.PRODUCT_ID_DESIGNER,
                    PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES,
                    GeneralConstants.WARNING,
                    null),
            MessageFormat.format(UNUSEDRETURN1, assignment.getFullName()));
        break;
      case A_FUNCTION_RTEMP:
      case A_EXT_FUNCTION_RTEMP:
        location.reportConfigurableSemanticProblem(
            Platform.getPreferencesService()
                .getString(
                    ProductConstants.PRODUCT_ID_DESIGNER,
                    PreferenceConstants.REPORTUNUSEDFUNCTIONRETURNVALUES,
                    GeneralConstants.WARNING,
                    null),
            MessageFormat.format(UNUSEDRETURN2, assignment.getFullName()));
        break;
      default:
        break;
    }
  }
Example #27
0
 /**
  * @param key the name of the preference (optionally including its path)
  * @param defaultValue the value to use if the preference is not defined
  * @param project optional project object to honor project scoped preferences
  * @return the value of the preference or the given default value
  */
 private String getStringPreferencesValue(String key, String defaultValue, IProject project) {
   IPreferencesService service = Platform.getPreferencesService();
   String qualifier = getSymbolicName();
   if (project != null) {
     IScopeContext[] contexts = new IScopeContext[] {new ProjectScope(project)};
     return service.getString(qualifier, key, defaultValue, contexts);
   } else {
     return service.getString(qualifier, key, defaultValue, null);
   }
 }
 public void testBadContext() {
   IScopeContext context = new BadTestScope();
   IPreferencesService service = Platform.getPreferencesService();
   try {
     context.getNode("qualifier");
     fail("0.5"); // should throw an exception
   } catch (RuntimeException e) {
     // expected
   }
   assertNull("1.0", service.getString("qualifier", "foo", null, new IScopeContext[] {context}));
 }
Example #29
0
  /**
   * Determine if the last saved metadata index version number matches the expected value. Return
   * false if they do not match
   *
   * @return
   */
  protected boolean versionChanged() {
    double expectedVersion =
        Platform.getPreferencesService()
            .getDouble( //
                this.getPluginId(), //
                this.getIndexVersionKey(), //
                getDefaultIndexVersion(), //
                null //
                );

    return expectedVersion != this.getIndexVersion();
  }
Example #30
0
  /**
   * Returns the preferences of line seperator.
   *
   * @param project
   * @return
   */
  public static String getLineSeparator(IProject project) {
    if (Platform.isRunning()) {
      String lineSeparator = null;
      // line delimiter in project preference
      IScopeContext[] scopeContext;
      if (project != null) {
        scopeContext = new IScopeContext[] {new ProjectScope(project)};
        lineSeparator =
            Platform.getPreferencesService()
                .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
        if (lineSeparator != null) return lineSeparator;
      }

      // line delimiter in workspace preference
      scopeContext = new IScopeContext[] {InstanceScope.INSTANCE};
      lineSeparator =
          Platform.getPreferencesService()
              .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
      if (lineSeparator != null) return lineSeparator;
    }
    return System.getProperty("line.separator");
  }