Exemplo n.º 1
0
 private void setHeader() {
   form.setFont(JFaceResources.getDialogFont());
   form.setImage(ActionHover.getActionImage(action));
   form.setText(action.getText());
   //		form.setSeparatorVisible(true);
   //		toolkit.decorateFormHeading(form);
 }
Exemplo n.º 2
0
  private void addOptions() {
    Map<String, Composite> sections = new HashMap<String, Composite>();

    for (IOption option : action.getConfiguration().getOptions()) {
      Composite parent = body;
      if (option instanceof Option) {
        if (((Option) option).isFixed()) continue;
        String sectionName = ((Option) option).getSection();
        if (sectionName != null) {
          parent = sections.get(sectionName);
          if (parent == null) {
            Section section =
                toolkit.createSection(body, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
            section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
            section.setExpanded(false);
            section.addExpansionListener(
                new ExpansionAdapter() {
                  public void expansionStateChanged(ExpansionEvent e) {
                    form.reflow(true);
                  }
                });
            section.setText(sectionName);
            //						section.setDescription("This is the description that goes below the title");
            Composite sectionClient = toolkit.createComposite(section);
            sectionClient.setLayout(new GridLayout());
            section.setClient(sectionClient);
            sections.put(sectionName, sectionClient);
            parent = sectionClient;
          }
        }
      }
      addOption(parent, option);
    }

    runLink = toolkit.createImageHyperlink(body, SWT.NONE);
    //		runLink.setFont(JFaceResources.getHeaderFont());
    runLink.setImage(runImage);
    runLink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    runLink.setText("Run");
    updateRunButton();

    runLink.addHyperlinkListener(
        new HyperlinkAdapter() {
          @Override
          public void linkActivated(HyperlinkEvent e) {
            safeRun();
          }
        });
  }
Exemplo n.º 3
0
  private void addOption(Composite parent, IOption option) {
    if (option instanceof StringOption) {
      StringOptionWidget widget =
          new StringOptionWidget(parent, toolkit, (StringOption) option) {
            protected void accept() {
              safeRun();
            }

            protected void modified() {
              updateRunButton();
            }
          };
      widgets.add(widget);
    } else if (option instanceof IntegerOption) {
      IntegerOptionWidget widget =
          new IntegerOptionWidget(parent, toolkit, (IntegerOption) option) {
            protected void accept() {
              safeRun();
            }

            protected void modified() {
              updateRunButton();
            }
          };
      widgets.add(widget);
    } else if (option instanceof BooleanOption) {
      widgets.add(new BooleanOptionWidget(parent, toolkit, (BooleanOption) option));
    } else if (option instanceof GenericOption) {
      widgets.add(
          new GenericOptionWidget(parent, toolkit, (GenericOption) option, action.getSpace()));
    } else if (option instanceof IterableOption) {
      widgets.add(new IterableOptionWidget(parent, toolkit, (IterableOption) option));
    } else if (option instanceof MultipleStringOption) {
      widgets.add(new MultipleStringOptionWidget(parent, toolkit, (MultipleStringOption) option));
    } else {
      // FIXME
      System.err.println("UI cannot handle option " + option);
    }
  }
Exemplo n.º 4
0
  private void doRun() {
    for (OptionWidget optionWidget : widgets) optionWidget.setOptionValue();

    action.run();
    close();
  }