public void setSpecificConfiguration(
     Map<String, String> newPropertyValues,
     Map<String, Integer> newMessageSeverities,
     IProject project) {
   if (project != null && hasProjectSpecificOptions(project)) {
     for (Map.Entry<String, String> entry : newPropertyValues.entrySet()) {
       SpringCorePreferences.getProjectPreferences(project)
           .putString(PROPERTY_PREFIX + entry.getKey(), entry.getValue());
     }
     for (Map.Entry<String, Integer> entry : newMessageSeverities.entrySet()) {
       SpringCorePreferences.getProjectPreferences(project)
           .putString(MESSAGE_PREFIX + entry.getKey(), Integer.toString(entry.getValue()));
     }
   } else {
     for (Map.Entry<String, String> entry : newPropertyValues.entrySet()) {
       SpringCore.getDefault()
           .getPluginPreferences()
           .setValue(PROPERTY_PREFIX + entry.getKey(), entry.getValue());
     }
     for (Map.Entry<String, Integer> entry : newMessageSeverities.entrySet()) {
       SpringCore.getDefault()
           .getPluginPreferences()
           .setValue(MESSAGE_PREFIX + entry.getKey(), Integer.toString(entry.getValue()));
     }
   }
 }
  /** {@inheritDoc} */
  @Override
  protected void doConfigure(
      final MavenProject mavenProject,
      IProject project,
      ProjectConfigurationRequest request,
      final IProgressMonitor monitor)
      throws CoreException {

    if (configureNature(project, mavenProject, GAE_NATURE_ID, false, monitor)) {

      // Remove DN support if we use GAE
      if (mavenProject.getPlugin("org.datanucleus:maven-datanucleus-plugin") != null) {
        for (ProjectBuilderDefinition builderDefinition :
            ProjectBuilderDefinitionFactory.getProjectBuilderDefinitions()) {
          if (DN_BUILDER_ID.equals(builderDefinition.getId())) {
            builderDefinition.setEnabled(false, project);
            break;
          }
        }
      }
    } else {
      // Make sure that we add DN support if DN is being used in the pom.xml
      if (mavenProject.getPlugin("org.datanucleus:maven-datanucleus-plugin") != null) {
        for (ProjectBuilderDefinition builderDefinition :
            ProjectBuilderDefinitionFactory.getProjectBuilderDefinitions()) {
          if (DN_BUILDER_ID.equals(builderDefinition.getId())) {
            SpringCorePreferences.getProjectPreferences(project)
                .putBoolean(SpringCore.PROJECT_PROPERTY_ID, true);
            builderDefinition.setEnabled(true, project);
            break;
          }
        }
      }
    }
  }
 protected void readSpecificConfiguration(IProject project) {
   if (project != null && hasProjectSpecificOptions(project)) {
     for (Map.Entry<String, String> entry : originalPropertyValues.entrySet()) {
       String value =
           SpringCorePreferences.getProjectPreferences(project)
               .getString(PROPERTY_PREFIX + entry.getKey(), entry.getValue());
       propertyValues.put(entry.getKey(), value);
     }
     for (Map.Entry<String, Integer> entry : originalMessageSeverities.entrySet()) {
       String value =
           SpringCorePreferences.getProjectPreferences(project)
               .getString(MESSAGE_PREFIX + entry.getKey(), Integer.toString(entry.getValue()));
       messageSeverities.put(entry.getKey(), Integer.valueOf(value));
     }
   } else {
     for (Map.Entry<String, String> entry : originalPropertyValues.entrySet()) {
       String value =
           SpringCore.getDefault()
               .getPluginPreferences()
               .getString(PROPERTY_PREFIX + entry.getKey());
       if (StringUtils.hasText(value)) {
         propertyValues.put(entry.getKey(), value);
       }
     }
     for (Map.Entry<String, Integer> entry : originalMessageSeverities.entrySet()) {
       String value =
           SpringCore.getDefault()
               .getPluginPreferences()
               .getString(MESSAGE_PREFIX + entry.getKey());
       if (StringUtils.hasText(value)) {
         messageSeverities.put(entry.getKey(), Integer.valueOf(value));
       }
     }
   }
   rulePropertiesInitialized = false;
 }
Ejemplo n.º 4
0
  public Control createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 3;
    layout.marginWidth = 3;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label description = new Label(composite, SWT.WRAP);
    description.setText(BeansUIPlugin.getResourceString(DESCRIPTION));
    description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite tableAndButtons = new Composite(composite, SWT.NONE);
    tableAndButtons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    tableAndButtons.setLayout(layout);

    // Create table and viewer for Spring bean config files
    configsTable =
        new Table(
            tableAndButtons,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = TABLE_WIDTH;
    data.heightHint = TABLE_WIDTH;
    configsTable.setLayoutData(data);
    configsTable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleTableSelectionChanged();
          }
        });
    configsViewer = new TableViewer(configsTable);
    configsViewer.setContentProvider(new ConfigFilesContentProvider(project));
    configsViewer.setLabelProvider(new PropertiesModelLabelProvider());
    configsViewer.setInput(this); // activate content provider
    configsViewer.setSorter(new ConfigFilesSorter());

    if (this.selectedElement != null) {
      configsViewer.setSelection(new StructuredSelection(selectedElement), true);
    }

    if (BeansConfigLocatorFactory.hasEnabledBeansConfigLocatorDefinitions(project.getProject())) {
      Label note = new Label(composite, SWT.WRAP);
      note.setText(BeansUIPlugin.getResourceString(NOTE_LABEL));
      note.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    Label options = new Label(composite, SWT.WRAP);
    options.setText("Options:");
    options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create enable import checkbox
    enableImportText =
        SpringUIUtils.createCheckBox(
            composite, BeansUIPlugin.getResourceString(ENABLE_IMPORT_LABEL));
    enableImportText.setSelection(project.isImportsEnabled());
    enableImportText.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleImportEnabledChanged();
          }
        });

    // Create ignore missing namespace handler checkbox
    ignoreMissingNamespaceHandlerText =
        SpringUIUtils.createCheckBox(
            composite, BeansUIPlugin.getResourceString(IGNORE_MISSING_NAMESPACEHANDLER_LABEL));
    ignoreMissingNamespaceHandlerText.setSelection(
        SpringCorePreferences.getProjectPreferences(project.getProject(), BeansCorePlugin.PLUGIN_ID)
            .getBoolean(
                BeansCorePlugin.IGNORE_MISSING_NAMESPACEHANDLER_PROPERTY,
                BeansCorePlugin.IGNORE_MISSING_NAMESPACEHANDLER_PROPERTY_DEFAULT));
    ignoreMissingNamespaceHandlerText.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            hasUserMadeChanges = true;
          }
        });

    // Create suffix text field
    suffixesText =
        SpringUIUtils.createTextField(composite, BeansUIPlugin.getResourceString(SUFFIXES_LABEL));
    suffixesText.setText(StringUtils.collectionToDelimitedString(project.getConfigSuffixes(), ","));
    suffixesText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            handleSuffixesTextModified();
          }
        });

    // Create error label
    errorLabel = new Label(composite, SWT.NONE);
    errorLabel.setLayoutData(
        new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    errorLabel.setForeground(JFaceColors.getErrorText(parent.getDisplay()));
    errorLabel.setBackground(JFaceColors.getErrorBackground(parent.getDisplay()));
    // Create button area
    Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttonArea.setLayout(layout);
    buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    addButton =
        SpringUIUtils.createButton(
            buttonArea, BeansUIPlugin.getResourceString(ADD_BUTTON), buttonListener);
    removeButton =
        SpringUIUtils.createButton(
            buttonArea, BeansUIPlugin.getResourceString(REMOVE_BUTTON), buttonListener, 0, false);
    scanButton = SpringUIUtils.createButton(buttonArea, "Scan...", buttonListener);
    model.addChangeListener(modelChangeListener);
    handleSuffixesTextModified();
    hasUserMadeChanges = false;
    // handleSuffixTextModified() has set this to true

    handleTableSelectionChanged();
    return composite;
  }