Esempio n. 1
0
  /** Allows the user to enter a user property */
  private void addProperty() {
    String title = "Add";
    AddPropertyDialog dialog =
        new AddPropertyDialog(
            propsTableViewer.getControl().getShell(), title, new String[] {"", "", ""});
    if (dialog.open() == Window.CANCEL) {
      return;
    }

    String[] pair = dialog.getNameValuePair();
    String name = pair[0];
    /*
    if (!overwrite(name)) {
        return;
    }
    */

    List<ConfigPropType> propList = aoDef.getAoConfigProps();

    ConfigPropType prop = new ConfigPropType();
    prop.setName(name);
    prop.setType(pair[1]);
    prop.setValue(pair[2]);
    ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
    propList.add(prop);
    container.update();
  }
Esempio n. 2
0
  private void remove(TableViewer viewer) {
    PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
    IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
    ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
    aoDef.getAoConfigProps().remove(prop);
    propContentProvider.remove(sel);

    container.update();
  }
Esempio n. 3
0
  /**
   * createControl
   *
   * @param parent Composite
   * @see IDialogPage#createControl(Composite)
   */
  public void createControl(Composite parent) {
    aoDef = new AdminObjectType();
    List<AdminObjectType> aoTypes = new ArrayList<AdminObjectType>();
    aoTypes.add(aoDef);
    ((CodeGenWizard) getWizard()).getDef().setAdminObjects(aoTypes);

    List<ConfigPropType> propList = aoDef.getAoConfigProps();
    if (propList == null) {
      propList = new ArrayList<ConfigPropType>();
      aoDef.setAoConfigProps(propList);
    }

    Composite wholeContainer = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    wholeContainer.setLayout(layout);
    layout.numColumns = 1;

    Composite inContainer = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    inContainer.setLayout(layout);
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    Label label = new Label(inContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getResourceString("gen.adminobject") + ":");
    final Button aoButton = new Button(inContainer, SWT.CHECK);

    aoButton.setSelection(true);
    ((CodeGenWizard) getWizard()).getDef().setGenAdminObject(true);

    label = new Label(inContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getResourceString("adminobject.raa") + ":");

    final Button raaButton = new Button(inContainer, SWT.CHECK);

    raaButton.setSelection(true);
    ((CodeGenWizard) getWizard()).getDef().setAdminObjectImplRaAssociation(true);
    raaButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {

            ((CodeGenWizard) getWizard())
                .getDef()
                .setAdminObjectImplRaAssociation(raaButton.getSelection());
          }
        });

    label = new Label(inContainer, SWT.NULL);
    label.setText(
        ((CodeGenWizard) getWizard()).getResourceString("adminobject.interface.name") + ":");

    aoButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {

            ((CodeGenWizard) getWizard()).getDef().setGenAdminObject(aoButton.getSelection());
            if (aoButton.getSelection()) {
              raaButton.setEnabled(true);
              aoText.setEnabled(true);
              aoImplText.setEnabled(true);
            } else {
              raaButton.setEnabled(false);
              aoText.setEnabled(false);
              aoImplText.setEnabled(false);
            }
          }
        });

    aoText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
    aoText.setBounds(5, 5, 600, 10);
    aoText.setText(((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "AdminObject");
    aoDef.setAdminObjectInterface(
        ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "AdminObject");
    aoText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String string = aoText.getText();
            if (string.length() > 0) {
              aoDef.setAdminObjectInterface(string);
              updateStatus(null);
            }
            dialogChanged();
          }
        });

    label = new Label(inContainer, SWT.NULL);
    label.setText(((CodeGenWizard) getWizard()).getResourceString("adminobject.class.name") + ":");

    aoImplText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
    aoImplText.setBounds(5, 5, 600, 10);
    aoImplText.setText(
        ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "AdminObjectImpl");
    aoDef.setAdminObjectClass(
        ((CodeGenWizard) getWizard()).getDef().getDefaultValue() + "AdminObjectImpl");
    aoImplText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String string = aoImplText.getText();
            if (string.length() > 0) {
              aoDef.setAdminObjectClass(string);
              updateStatus(null);
            }
            dialogChanged();
          }
        });

    label = new Label(inContainer, SWT.NULL);
    label.setText(
        ((CodeGenWizard) getWizard()).getResourceString("adminobject.config.properties") + ":");

    container = new Composite(wholeContainer, SWT.NULL);
    layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;

    propsTableViewer = createTableViewer(container);

    Composite buttonGroup = new Composite(container, SWT.NONE);
    GridLayout layoutBtns = new GridLayout();
    layoutBtns.marginHeight = 0;
    layoutBtns.marginWidth = 0;
    buttonGroup.setLayout(layoutBtns);
    buttonGroup.setLayoutData(
        new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
    buttonGroup.setFont(buttonGroup.getFont());

    addButtonsToButtonGroup(buttonGroup);

    initialize();
    dialogChanged();
    setControl(wholeContainer);
  }