예제 #1
0
 public void dispose() {
   model.removeChangeListener(modelChangeListener);
 }
예제 #2
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;
  }