public void build() {
    getParent().setLayout(new FormLayout());

    Label leftLabel = new Label(getParent(), SWT.NONE);
    leftLabel.setImage(left);
    FormData fdLeftLabel = new FormData();
    leftLabel.setLayoutData(fdLeftLabel);
    fdLeftLabel.left = new FormAttachment(0, 0);
    fdLeftLabel.top = new FormAttachment(0, 0);
    fdLeftLabel.width = left.getBounds().width;
    fdLeftLabel.height = left.getBounds().height;

    Label rightLabel = new Label(getParent(), SWT.NONE);
    rightLabel.setImage(right);
    FormData fdRightLabel = new FormData();
    rightLabel.setLayoutData(fdRightLabel);
    fdRightLabel.right = new FormAttachment(100, 0);
    fdRightLabel.top = new FormAttachment(0, 0);
    fdRightLabel.height = right.getBounds().height;
    fdRightLabel.width = right.getBounds().width;

    footerCenter = new Composite(getParent(), SWT.NONE);
    footerCenter.setBackgroundImage(bg);
    FormData fdFooterCenter = new FormData();
    footerCenter.setLayoutData(fdFooterCenter);
    fdFooterCenter.left = new FormAttachment(leftLabel);
    fdFooterCenter.right = new FormAttachment(rightLabel);
    fdFooterCenter.top = new FormAttachment(0, 0);
    fdFooterCenter.height = bg.getBounds().height;
  }
示例#2
0
 private FormData createLayoutDataForHeader() {
   FormData layoutData = new FormData();
   layoutData.left = new FormAttachment(0, 0);
   layoutData.right = new FormAttachment(100, 0);
   layoutData.top = new FormAttachment(0, 0);
   layoutData.height = 80;
   return layoutData;
 }
示例#3
0
 /** Creates text area for displaying application environment info */
 private void createTextEnvironment() {
   textEnvironment = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
   textEnvironment.setFont(SharedStyle.FONT_FIXED);
   textEnvironment.setText(Version.getEnvironmentReport());
   textEnvironment.setEditable(false);
   final FormData layout = SharedStyle.relativeTo(labelEnvironment, null, buttonClose, null);
   layout.width = 500;
   layout.height = 150;
   textEnvironment.setLayoutData(layout);
 }
    public void widgetSelected(SelectionEvent e) {
      feederRegistry.select(feederSelectionCombo.getSelectionIndex());

      // all this 'magic' is needed in order to resize everything properly
      // and accommodate feeders with different sizes
      Rectangle bounds = feederRegistry.current().getBounds();
      FormData feederAreaLayoutData = ((FormData) feederArea.getLayoutData());
      feederAreaLayoutData.height = bounds.height;
      feederAreaLayoutData.width = bounds.width;
      relayoutControls();
      shell.layout();

      // reset main window title
      shell.setText(feederRegistry.current().getFeederName() + " - " + Version.NAME);
    }
  public void build() {
    getParent().setLayout(new FillLayout());
    Composite stack = createFrame();
    stack.setLayout(new FormLayout());

    tabBar = new Composite(stack, SWT.NONE);
    tabBar.setLayout(new FormLayout());
    tabBar.setBackgroundImage(tabInactiveBgActive);
    FormData fdTabBar = new FormData();
    tabBar.setLayoutData(fdTabBar);
    fdTabBar.top = new FormAttachment(0);
    fdTabBar.left = new FormAttachment(0);
    fdTabBar.right = new FormAttachment(100);
    fdTabBar.height = tabInactiveBgActive.getBounds().height;

    if (rightCorner != null && leftCorner != null) {
      leftCornerLabel = new Label(stack.getParent(), SWT.NONE);
      leftCornerLabel.setImage(leftCorner);
      FormData fdLeftCorner = new FormData();
      leftCornerLabel.setLayoutData(fdLeftCorner);
      fdLeftCorner.left = new FormAttachment(0, 3);
      fdLeftCorner.top = new FormAttachment(0, 7);

      rightCornerLabel = new Label(stack.getParent(), SWT.NONE);
      rightCornerLabel.setImage(rightCorner);
      FormData fdRightCorner = new FormData();
      rightCornerLabel.setLayoutData(fdRightCorner);
      fdRightCorner.right = new FormAttachment(100, -3);
      fdRightCorner.top = new FormAttachment(0, 7);
      rightCornerLabel.moveAbove(null);
      leftCornerLabel.moveAbove(null);
      labelMap.put(LEFT, leftCornerLabel);
      labelMap.put(RIGHT, rightCornerLabel);
    }

    content = new Composite(stack, SWT.NONE);
    FormData fdContent = new FormData();
    content.setLayoutData(fdContent);
    fdContent.top = new FormAttachment(tabBar);
    fdContent.left = new FormAttachment(0);
    fdContent.right = new FormAttachment(100);
    fdContent.bottom = new FormAttachment(100);
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
   * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
   */
  @Override
  public int estimateRowSize(Composite subComposite, IElementParameter param) {
    if (!estimateInitialized) {
      DecoratedField dField =
          new DecoratedField(
              subComposite,
              SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
              new TextControlCreator());
      Text text = (Text) dField.getControl();
      FormData d = (FormData) text.getLayoutData();
      d.height = text.getLineHeight();
      text.getParent().setSize(subComposite.getSize().x, text.getLineHeight());
      Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
      rowSizeByLine = text.getLineHeight();
      dField.getLayoutControl().dispose();
      rowSizeFixed = ITabbedPropertyConstants.VSPACE + (initialSize.y - rowSizeByLine);
      estimateInitialized = true;
    }

    return rowSizeFixed + (rowSizeByLine * param.getNbLines());
  }
示例#7
0
 /** Draws the logo on logo canvas */
 private void createLogo() {
   logo = new Canvas(shell, SWT.NONE);
   logo.addPaintListener(
       new PaintListener() {
         public void paintControl(final PaintEvent e) {
           e.gc.drawImage(IconFactory.getInstance().getUncachedIcon("hawkscope128.png"), 0, 0);
         }
       });
   logo.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseUp(final MouseEvent event) {
           Program.launch(Version.HOMEPAGE);
         }
       });
   logo.setCursor(SharedStyle.CURSOR_HAND);
   logo.setToolTipText("Click to visit Homepage");
   final FormData layout = SharedStyle.relativeTo(null, null);
   layout.width = 128;
   layout.height = 128;
   logo.setLayoutData(layout);
 }
  @Override
  public Control contribute(Composite parent) {
    Composite result = new Composite(parent, SWT.INHERIT_DEFAULT);
    result.setLayout(new FormLayout());

    Label separator = new Label(result, SWT.NONE);
    separator.setData(RWT.CUSTOM_VARIANT, "footer_separator");
    FormData separatorData = new FormData();
    separator.setLayoutData(separatorData);
    separatorData.top = new FormAttachment(0, 0);
    separatorData.left = new FormAttachment(0, 0);
    separatorData.right = new FormAttachment(100, 0);
    separatorData.height = SEPARATOR_HEIGHT;

    Label versionInfo = new Label(result, SWT.NONE);
    versionInfo.setText(getVersionInfo());
    versionInfo.pack();
    FormData versionInfoData = new FormData();
    versionInfo.setLayoutData(versionInfoData);
    Point size = versionInfo.getSize();
    versionInfoData.top = new FormAttachment(50, -(size.y / 2) + (SEPARATOR_HEIGHT / 2));
    versionInfoData.left = new FormAttachment(50, -(size.x / 2));
    return result;
  }
  public JobEntryInterface open() {
    Shell parentShell = getParent();
    Display display = parentShell.getDisplay();

    shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);

    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
          }
        };

    String datasets[] = null;
    AutoPopulate ap = new AutoPopulate();
    try {

      datasets = ap.parseDatasetsRecordsets(this.jobMeta.getJobCopies());

    } catch (Exception e) {
      System.out.println("Error Parsing existing Datasets");
      System.out.println(e.toString());
      datasets = new String[] {""};
    }

    backupChanged = jobEntry.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText("Limit");

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    shell.setLayout(formLayout);
    shell.setText("Define an ECL Limit");

    FormLayout groupLayout = new FormLayout();
    groupLayout.marginWidth = 10;
    groupLayout.marginHeight = 10;

    // Stepname line
    Group generalGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(generalGroup);
    generalGroup.setText("General Details");
    generalGroup.setLayout(groupLayout);
    FormData generalGroupFormat = new FormData();
    generalGroupFormat.top = new FormAttachment(0, margin);
    generalGroupFormat.width = 400;
    generalGroupFormat.height = 100;
    generalGroupFormat.left = new FormAttachment(middle, 0);
    generalGroup.setLayoutData(generalGroupFormat);

    jobEntryName = buildText("Job Entry Name", null, lsMod, middle, margin, generalGroup);

    // All other contols
    Group limitGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(limitGroup);
    limitGroup.setText("Limit Details");
    limitGroup.setLayout(groupLayout);
    FormData limitGroupFormat = new FormData();
    limitGroupFormat.top = new FormAttachment(generalGroup, margin);
    limitGroupFormat.width = 400;
    limitGroupFormat.height = 300;
    limitGroupFormat.left = new FormAttachment(middle, 0);
    limitGroup.setLayoutData(limitGroupFormat);

    recordsetName = buildText("Result Recordset", null, lsMod, middle, margin, limitGroup);
    recordset = buildCombo("Recordset", recordsetName, lsMod, middle, margin, limitGroup, datasets);
    maxRecs = buildText("Maximum Records", recordset, lsMod, middle, margin, limitGroup);
    errorMessage = buildText("Error Message", maxRecs, lsMod, middle, margin, limitGroup);
    errorCode = buildText("Error Code", errorMessage, lsMod, middle, margin, limitGroup);
    // failClause = buildText("FAIL(<clause>)", maxRecs, lsMod, middle, margin, limitGroup);
    keyed =
        buildCombo(
            "KEYED", errorCode, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    count =
        buildCombo(
            "COUNT", keyed, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    skip =
        buildCombo(
            "SKIP", count, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    // 	onFailTransform = buildText("ONFAIL(<transform>)", skip, lsMod, middle, margin, limitGroup);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText("OK");
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText("Cancel");

    BaseStepDialog.positionBottomButtons(shell, new Button[] {wOK, wCancel}, margin, limitGroup);

    // Add listeners
    Listener cancelListener =
        new Listener() {

          public void handleEvent(Event e) {
            cancel();
          }
        };
    Listener okListener =
        new Listener() {

          public void handleEvent(Event e) {
            ok();
          }
        };
    wCancel.addListener(SWT.Selection, cancelListener);
    wOK.addListener(SWT.Selection, okListener);

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    if (jobEntry.getName() != null) {
      jobEntryName.setText(jobEntry.getName());
    }
    if (jobEntry.getRecordsetName() != null) {
      recordsetName.setText(jobEntry.getRecordsetName());
    }
    if (jobEntry.getRecordset() != null) {
      recordset.setText(jobEntry.getRecordset());
    }
    if (jobEntry.getMaxRecs() != null) {
      maxRecs.setText(jobEntry.getMaxRecs());
    }
    // if (jobEntry.getFailClause() != null) {
    //    failClause.setText(jobEntry.getFailClause());
    // }
    if (jobEntry.getErrorCode() != null) {
      errorCode.setText(jobEntry.getErrorCode());
    }
    if (jobEntry.getErrorMessage() != null) {
      errorMessage.setText(jobEntry.getErrorMessage());
    }

    if (jobEntry.getKeyedString() != null) {
      keyed.setText(jobEntry.getKeyedString());
    }
    if (jobEntry.getCountString() != null) {
      count.setText(jobEntry.getCountString());
    }
    if (jobEntry.getSkipString() != null) {
      skip.setText(jobEntry.getSkipString());
    }
    // if (jobEntry.getOnFailTransform() != null) {
    //     onFailTransform.setText(jobEntry.getOnFailTransform());
    //  }

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    return jobEntry;
  }
  private Composite createFrame() {
    Composite frameComp = new Composite(getParent(), SWT.NONE);
    frameComp.setData(WidgetUtil.CUSTOM_VARIANT, "compGray"); // $NON-NLS-1$
    frameComp.setLayout(new FormLayout());
    frameComp.setBackgroundMode(SWT.INHERIT_FORCE);

    Label left = new Label(frameComp, SWT.NONE);
    left.setData(WidgetUtil.CUSTOM_VARIANT, "stackBorder"); // $NON-NLS-1$
    left.setBackgroundImage(borderLeft);
    FormData fdLeft = new FormData();
    left.setLayoutData(fdLeft);
    fdLeft.top = new FormAttachment(0, borderTop.getBounds().height);
    fdLeft.bottom = new FormAttachment(100, -borderBottom.getBounds().height + 1);
    fdLeft.left = new FormAttachment(0);
    fdLeft.width = borderLeft.getBounds().width;
    labelMap.put(LEFT_BORDER, left);

    Label right = new Label(frameComp, SWT.NONE);
    right.setData(WidgetUtil.CUSTOM_VARIANT, "stackBorder"); // $NON-NLS-1$
    right.setBackgroundImage(borderRight);
    FormData fdRight = new FormData();
    right.setLayoutData(fdRight);
    fdRight.top = new FormAttachment(0, borderTop.getBounds().height);
    fdRight.bottom = new FormAttachment(100, -borderBottom.getBounds().height + 1);
    fdRight.right = new FormAttachment(100);
    fdRight.width = borderRight.getBounds().width;
    labelMap.put(RIGHT_BORDER, right);

    Label top = new Label(frameComp, SWT.NONE);
    top.setData(WidgetUtil.CUSTOM_VARIANT, "stackBorder"); // $NON-NLS-1$
    top.setBackgroundImage(borderTop);
    FormData fdTop = new FormData();
    top.setLayoutData(fdTop);
    fdTop.top = new FormAttachment(0);
    fdTop.left = new FormAttachment(left);
    fdTop.right = new FormAttachment(right);
    fdTop.height = borderTop.getBounds().height;
    labelMap.put(TOP_BORDER, top);

    Label bottom = new Label(frameComp, SWT.NONE);
    bottom.setData(WidgetUtil.CUSTOM_VARIANT, "stackBorder"); // $NON-NLS-1$
    bottom.setBackgroundImage(borderBottom);
    FormData fdBottom = new FormData();
    bottom.setLayoutData(fdBottom);
    fdBottom.bottom = new FormAttachment(100);
    fdBottom.left = new FormAttachment(left);
    fdBottom.right = new FormAttachment(right);
    fdBottom.height = borderBottom.getBounds().height;
    labelMap.put(BOTTOM_BORDER, bottom);

    Composite result = new Composite(frameComp, SWT.NONE);
    result.setData(WidgetUtil.CUSTOM_VARIANT, "compGray"); // $NON-NLS-1$
    FormData fdResult = new FormData();
    result.setLayoutData(fdResult);
    fdResult.top = new FormAttachment(top);
    fdResult.left = new FormAttachment(left);
    fdResult.right = new FormAttachment(right);
    fdResult.bottom = new FormAttachment(bottom);

    return result;
  }
示例#11
0
  /** Initializes the GUI. */
  private void initGUI() {
    try {
      this.setSize(731, 385);
      this.setBackground(SWTResourceManager.getColor(219, 219, 219));
      FormLayout thisLayout = new FormLayout();
      this.setLayout(thisLayout);
      this.setOrientation(SWT.HORIZONTAL);
      this.setToolTipText("MKD- Image SteganoGraphy");
      {
        Enter = new Label(this, SWT.NONE);
        FormData EnterLData = new FormData();
        EnterLData.left = new FormAttachment(0, 1000, 266);
        EnterLData.top = new FormAttachment(0, 1000, 140);
        EnterLData.width = 43;
        EnterLData.height = 15;
        Enter.setLayoutData(EnterLData);
        Enter.setText("Enter");
        Enter.setVisible(false);
      }
      {
        GenPubPara = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData GenPubParaLData = new FormData();
        GenPubParaLData.left = new FormAttachment(0, 1000, 174);
        GenPubParaLData.top = new FormAttachment(0, 1000, 142);
        GenPubParaLData.width = 132;
        GenPubParaLData.height = 25;
        GenPubPara.setLayoutData(GenPubParaLData);
        GenPubPara.setText("Generate Public Values");
        GenPubPara.setVisible(false);
        GenPubPara.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                Random prng = new SecureRandom();
                BigInteger q = BigInteger.probablePrime(32, prng);
                System.out.println("" + q);
                QValue.setText(q.toString());
                // code for generating alpha
                BigInteger alpha;
                primitiveRoot pr = new primitiveRoot();

                for (alpha = BigInteger.valueOf(2);
                    alpha.compareTo(q) > 0;
                    alpha = alpha.add(BigInteger.ONE)) {
                  if (pr.isPrimitive(q, alpha)) break;
                }
                System.out.println("" + alpha);
                AlphaValue.setText(alpha.toString());
              }
            });
      }
      {
        FormData PubKeyLData = new FormData();
        PubKeyLData.left = new FormAttachment(0, 1000, 326);
        PubKeyLData.top = new FormAttachment(0, 1000, 188);
        PubKeyLData.width = 121;
        PubKeyLData.height = 15;
        PubKey = new Text(this, SWT.NONE);
        PubKey.setLayoutData(PubKeyLData);
        PubKey.setVisible(false);
      }
      {
        PUBKey = new Label(this, SWT.NONE);
        FormData PUBKeyLData = new FormData();
        PUBKeyLData.left = new FormAttachment(0, 1000, 217);
        PUBKeyLData.top = new FormAttachment(0, 1000, 187);
        PUBKeyLData.width = 97;
        PUBKeyLData.height = 15;
        PUBKey.setLayoutData(PUBKeyLData);
        PUBKey.setText("Public Key is");
        PUBKey.setVisible(false);
      }
      {
        FormData PKeyLData = new FormData();
        PKeyLData.left = new FormAttachment(0, 1000, 326);
        PKeyLData.top = new FormAttachment(0, 1000, 166);
        PKeyLData.width = 121;
        PKeyLData.height = 15;
        PKey = new Text(this, SWT.NONE);
        PKey.setLayoutData(PKeyLData);
        PKey.setVisible(false);

        PKey.addModifyListener(
            new ModifyListener() {

              @Override
              public void modifyText(ModifyEvent arg0) {
                // TODO Auto-generated method stub
                BigInteger alpha = new BigInteger(AlphaValue.getText());
                BigInteger xa = new BigInteger(PKey.getText());
                BigInteger q = new BigInteger(QValue.getText());
                BigInteger ya = alpha.modPow(xa, q);
                System.out.println("Y a is " + ya);
                PubKey.setText(ya.toString());
                PubKey.setEditable(false);
              }
            });

        /*Adapter() {
        public void widgetSelected(SelectionEvent e){
        	BigInteger alpha=new BigInteger(AlphaValue.getText());
        	BigInteger xa=new BigInteger(PKey.getText());
        	BigInteger q=new BigInteger(QValue.getText());
        	BigInteger ya = alpha.modPow(xa, q);
        	System.out.println("Y a is "+ya);
        	PubKey.setText(ya.toString());
        	PubKey.setEditable(false);
        }});*/
      }
      {
        PKLabel = new Label(this, SWT.NONE);
        FormData PKLabelLData = new FormData();
        PKLabelLData.left = new FormAttachment(0, 1000, 217);
        PKLabelLData.top = new FormAttachment(0, 1000, 166);
        PKLabelLData.width = 97;
        PKLabelLData.height = 15;
        PKLabel.setLayoutData(PKLabelLData);
        PKLabel.setText("Enter Private Key");
        PKLabel.setVisible(false);
      }
      {
        FormData AlphaValueLData = new FormData();
        AlphaValueLData.left = new FormAttachment(0, 1000, 504);
        AlphaValueLData.top = new FormAttachment(0, 1000, 138);
        AlphaValueLData.width = 64;
        AlphaValueLData.height = 15;
        AlphaValue = new Text(this, SWT.NONE);
        AlphaValue.setLayoutData(AlphaValueLData);
        AlphaValue.setVisible(false);
      }
      {
        FormData QValueLData = new FormData();
        QValueLData.left = new FormAttachment(0, 1000, 340);
        QValueLData.top = new FormAttachment(0, 1000, 137);
        QValueLData.width = 107;
        QValueLData.height = 15;
        QValue = new Text(this, SWT.NONE);
        QValue.setLayoutData(QValueLData);
        QValue.setVisible(false);
      }
      {
        Alpha = new Label(this, SWT.NONE);
        FormData AlphaLData = new FormData();
        AlphaLData.left = new FormAttachment(0, 1000, 465);
        AlphaLData.top = new FormAttachment(0, 1000, 138);
        AlphaLData.width = 40;
        AlphaLData.height = 15;
        Alpha.setLayoutData(AlphaLData);
        Alpha.setText("Alpha");
        Alpha.setVisible(false);
      }
      {
        Q = new Label(this, SWT.NONE);
        FormData QLData = new FormData();
        QLData.left = new FormAttachment(0, 1000, 328);
        QLData.top = new FormAttachment(0, 1000, 138);
        QLData.width = 12;
        QLData.height = 15;
        Q.setLayoutData(QLData);
        Q.setText("Q");
        Q.setVisible(false);
      }

      {
        group1 = new Group(this, SWT.NONE);
        GridLayout group1Layout = new GridLayout();
        group1Layout.makeColumnsEqualWidth = true;
        group1.setLayout(group1Layout);
        FormData group1LData = new FormData();
        group1LData.left = new FormAttachment(0, 1000, 149);
        group1LData.top = new FormAttachment(0, 1000, 127);
        group1LData.width = 429;
        group1LData.height = 64;
        group1.setLayoutData(group1LData);
        group1.setText("Diffie-Hellman Key Exchange");
        group1.setVisible(false);
      }
      {
        button1 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData button1LData = new FormData();
        button1LData.width = 100;
        button1LData.height = 32;
        button1LData.right = new FormAttachment(568, 1000, 0);
        button1LData.bottom = new FormAttachment(650, 1000, 0);
        button1LData.top = new FormAttachment(567, 1000, 0);
        button1LData.left = new FormAttachment(431, 1000, 0);
        button1.setLayoutData(button1LData);
        button1.setText("Proceed");
        // button1.setBackground(SWTResourceManager.getColor(128, 0, 255));
        button1.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                String s = new String(Option.getText());
                String s1 = new String("Encrypt the Data into an Image");
                String s2 = new String("Decrypt the Message from an Image");
                if (s.equals(s1)) {
                  xa = PKey.getText();
                  q = QValue.getText();
                  Display display = Display.getDefault();
                  Shell shell = new Shell(display);
                  EncryptWindow inst = new EncryptWindow(shell, SWT.NULL);
                  Point size = inst.getSize();
                  // shell.setLayout(new FillLayout());
                  shell.layout();
                  new Label(shell, SWT.NONE).setText("Operation:");
                  final Label returnVal = new Label(shell, SWT.NONE);
                  // returnVal.setLayoutData(new FillLayout(SWT.NULL));
                  returnVal.setText("");

                  returnVal.setText(Option.getText());
                  if (size.x == 0 && size.y == 0) {
                    inst.pack();
                    shell.pack();
                  } else {
                    Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
                    shell.setSize(shellBounds.width, shellBounds.height);
                  }
                  shell.open();

                  while (!shell.isDisposed()) {
                    if (!display.readAndDispatch()) display.sleep();
                  }
                } else if (s.equals(s2)) {
                  xa = PKey.getText();
                  q = QValue.getText();
                  Display display = Display.getDefault();
                  Shell shell = new Shell(display);
                  DecryptWindow inst = new DecryptWindow(shell, SWT.NULL);
                  Point size = inst.getSize();
                  // shell.setLayout(new FillLayout());
                  shell.layout();
                  new Label(shell, SWT.NONE).setText("Operation:");
                  final Label returnVal = new Label(shell, SWT.NONE);
                  // returnVal.setLayoutData(new FillLayout(SWT.NULL));
                  returnVal.setText("");

                  returnVal.setText(Option.getText());
                  if (size.x == 0 && size.y == 0) {
                    inst.pack();
                    shell.pack();
                  } else {
                    Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
                    shell.setSize(shellBounds.width, shellBounds.height);
                  }
                  shell.open();

                  while (!shell.isDisposed()) {
                    if (!display.readAndDispatch()) display.sleep();
                  }
                }
              }
            });
      }

      {
        Label2 = new Label(this, SWT.NONE);
        FormData Label2LData = new FormData();
        Label2LData.width = 443;
        Label2LData.height = 49;
        Label2LData.bottom = new FormAttachment(144, 1000, 0);
        Label2LData.right = new FormAttachment(811, 1000, 0);
        Label2LData.top = new FormAttachment(16, 1000, 0);
        Label2LData.left = new FormAttachment(205, 1000, 0);
        Label2.setLayoutData(Label2LData);
        Label2.setText("V's Image Steganography ");
        Label2.setFont(SWTResourceManager.getFont("Lucida Handwriting", 22, 1, false, false));
        Label2.setAlignment(SWT.CENTER);
        Label2.setBackground(SWTResourceManager.getColor(219, 219, 219));
      }
      {
        Label1 = new Label(this, SWT.NONE);
        FormData Label1LData = new FormData();
        Label1LData.width = 234;
        Label1LData.height = 22;
        Label1LData.left = new FormAttachment(204, 1000, 0);
        Label1LData.right = new FormAttachment(524, 1000, 0);
        Label1LData.bottom = new FormAttachment(232, 1000, 0);
        Label1LData.top = new FormAttachment(175, 1000, 0);
        Label1.setLayoutData(Label1LData);
        Label1.setText("What you want to do...?");
        Label1.setBackground(SWTResourceManager.getColor(219, 219, 219));
      }
      {
        Option = new Combo(this, SWT.NONE);
        FormLayout OptionLayout = new FormLayout();
        Option.setLayout(OptionLayout);
        FormData OptionLData = new FormData();
        OptionLData.left = new FormAttachment(204, 1000, 0);
        OptionLData.top = new FormAttachment(232, 1000, 0);
        OptionLData.width = 408;
        OptionLData.height = 19;
        OptionLData.right = new FormAttachment(799, 1000, 0);
        OptionLData.bottom = new FormAttachment(287, 1000, 0);
        Option.setLayoutData(OptionLData);
        Option.setText("Select Option");
        Option.setBackground(SWTResourceManager.getColor(192, 192, 192));
        Option.setToolTipText("\r\n");
        Option.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                if (Option.getText().equals("Encrypt the Data into an Image")) {
                  xa = PKey.getText();
                  q = QValue.getText();
                  group1.setVisible(true);
                  PubKey.setVisible(true);
                  PUBKey.setVisible(true);
                  PKey.setVisible(true);
                  PKLabel.setVisible(true);
                  AlphaValue.setVisible(true);
                  QValue.setVisible(true);
                  Alpha.setVisible(true);
                  Q.setVisible(true);
                  GenPubPara.setVisible(true);
                  Enter.setVisible(false);
                }
                if (Option.getText().equals("Decrypt the Message from an Image")) {
                  /*PubKey.setText("");
                  PKey.setText("null");
                  QValue.setText("null");
                  AlphaValue.setText("0");*/
                  group1.setVisible(true);
                  PubKey.setVisible(true);
                  PUBKey.setVisible(true);
                  PKey.setVisible(true);
                  PKLabel.setVisible(true);
                  AlphaValue.setVisible(true);
                  QValue.setVisible(true);
                  Alpha.setVisible(true);
                  Q.setVisible(true);
                  Enter.setVisible(true);
                  GenPubPara.setVisible(false);
                }
              } // Encrypt e=new Encrypt();
            });
        Option.add("Encrypt the Data into an Image");
        Option.add("Decrypt the Message from an Image");
      }
      {
        label1 = new Label(this, SWT.NONE);
        FormData label1LData = new FormData();
        label1LData.left = new FormAttachment(0, 1000, 149);
        label1LData.top = new FormAttachment(0, 1000, 285);
        label1LData.width = 429;
        label1LData.height = 35;
        label1.setLayoutData(label1LData);
        label1.setText(
            "                             Copyright 2012., All Rights Reserved.,\r\n                              Vinaykumar M Kolli & Vaishakh B N  ");
        label1.setBackground(SWTResourceManager.getColor(192, 192, 192));
      }
      {
        menu1 = new Menu(getShell(), SWT.BAR);
        getShell().setMenuBar(menu1);
        /*{
        	fileMenuItem = new MenuItem(menu1, SWT.CASCADE);
        	fileMenuItem.setText("File");
        	{
        		fileMenu = new Menu(fileMenuItem);
        		{
        			openFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
        			openFileMenuItem.setText("Open");
        		}
        		{
        			newFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
        			newFileMenuItem.setText("New");
        		}
        		{
        			saveFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
        			saveFileMenuItem.setText("Save");
        		}
        		{
        			closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
        			closeFileMenuItem.setText("Close");
        		}
        		{
        			exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE);
        			exitMenuItem.setText("Exit");
        		}
        		fileMenuItem.setMenu(fileMenu);
        	}
        }*/
        {
          helpMenuItem = new MenuItem(menu1, SWT.CASCADE);
          helpMenuItem.setText("Help");
          {
            helpMenu = new Menu(helpMenuItem);
            {
              contentsMenuItem = new MenuItem(helpMenu, SWT.CASCADE);
              contentsMenuItem.setText("Help Contents");
              contentsMenuItem.addSelectionListener(new SelectionAdapter() {});
            }
            {
              aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE);
              aboutMenuItem.setText("About");
              aboutMenuItem.addSelectionListener(
                  new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                      Display display = Display.getDefault();
                      Shell shell = new Shell(display);
                      HelpPage help = new HelpPage(shell, SWT.NULL);
                      Point size = help.getSize();
                      // shell.setLayout(new FillLayout());
                      shell.layout();
                      // new Label(shell, SWT.NONE).setText("Operation:");
                      // final Label returnVal = new Label(shell, SWT.NONE);
                      // returnVal.setLayoutData(new FillLayout(SWT.NULL));
                      // returnVal.setText("");

                      // returnVal.setText(Option.getText());
                      if (size.x == 0 && size.y == 0) {
                        help.pack();
                        shell.pack();
                      } else {
                        Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
                        shell.setSize(shellBounds.width, shellBounds.height);
                      }
                      shell.open();

                      while (!shell.isDisposed()) {
                        if (!display.readAndDispatch()) display.sleep();
                      }
                    }
                  });
            }
            helpMenuItem.setMenu(helpMenu);
          }
        }
      }
      this.layout();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public IOSNavBarComposite(Composite parent, BrowserSimImageList imageList) {
    super(parent, SWT.NONE);

    this.setLayout(new FormLayout());

    pageTitleStyledText = new IOSPageTitleStyledText(this, imageList);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(0, 26);
    formData.height = 27;
    pageTitleStyledText.setLayoutData(formData);

    urlText = new AdressBarText(this, SWT.SINGLE);
    formData = new FormData();
    formData.left = new FormAttachment(0, 12);
    formData.right = new FormAttachment(100, -58);
    formData.top = new FormAttachment(0, 33 - AdressBarText.adressBarUrlOffset);
    formData.height = 16;
    urlText.setLayoutData(formData);

    refreshButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh-selected.png"));
    formData = new FormData();
    Rectangle refreshImageBounds = imageList.getImage(BD + "refresh.png").getBounds();
    formData.right = new FormAttachment(100, -8);
    formData.bottom = new FormAttachment(100, -7);
    formData.width = refreshImageBounds.width;
    formData.height = refreshImageBounds.height;
    refreshButtonComposite.setLayoutData(formData);

    stopButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop-selected.png"));
    formData = new FormData();
    Rectangle stopImageBounds = imageList.getImage(BD + "stop.png").getBounds();
    formData.right = new FormAttachment(100, -42);
    formData.bottom = new FormAttachment(100, -12);
    formData.width = stopImageBounds.width;
    formData.height = stopImageBounds.height;
    stopButtonComposite.setLayoutData(formData);

    progressBar = new ProgressBar(this, SWT.NONE);
    progressBar.setVisible(false);
    formData = new FormData();
    formData.left = new FormAttachment(0, 7);
    formData.right = new FormAttachment(100, -36);
    formData.bottom = new FormAttachment(100, -1);
    formData.height = 5;
    progressBar.setLayoutData(formData);

    Composite imagesComposite = new Composite(this, SWT.NONE);
    formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.top = new FormAttachment(0);
    formData.bottom = new FormAttachment(100);
    imagesComposite.setLayoutData(formData);

    GridLayout gridLayout = new GridLayout(5, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;

    imagesComposite.setLayout(gridLayout);

    for (ImageDescriptor descriptor : BODY_DESCRIPTOR) {
      descriptor.createWidget(imagesComposite, imageList);
    }
  }
  public Composite createSashForm(final Composite composite) {
    if (!tv.isTabViewsEnabled()) {
      tableComposite = tv.createMainPanel(composite);
      return tableComposite;
    }

    ConfigurationManager configMan = ConfigurationManager.getInstance();

    int iNumViews = 0;

    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    UISWTViewEventListenerWrapper[] pluginViews = null;
    if (uiFunctions != null) {
      UISWTInstance pluginUI = uiFunctions.getUISWTInstance();

      if (pluginUI != null) {
        pluginViews = pluginUI.getViewListeners(tv.getTableID());
        iNumViews += pluginViews.length;
      }
    }

    if (iNumViews == 0) {
      tableComposite = tv.createMainPanel(composite);
      return tableComposite;
    }

    FormData formData;

    final Composite form = new Composite(composite, SWT.NONE);
    FormLayout flayout = new FormLayout();
    flayout.marginHeight = 0;
    flayout.marginWidth = 0;
    form.setLayout(flayout);
    GridData gridData;
    gridData = new GridData(GridData.FILL_BOTH);
    form.setLayoutData(gridData);

    // Create them in reverse order, so we can have the table auto-grow, and
    // set the tabFolder's height manually

    final int TABHEIGHT = 20;
    tabFolder = new CTabFolder(form, SWT.TOP | SWT.BORDER);
    tabFolder.setMinimizeVisible(true);
    tabFolder.setTabHeight(TABHEIGHT);
    final int iFolderHeightAdj = tabFolder.computeSize(SWT.DEFAULT, 0).y;

    final Sash sash = new Sash(form, SWT.HORIZONTAL);

    tableComposite = tv.createMainPanel(form);
    Composite cFixLayout = tableComposite;
    while (cFixLayout != null && cFixLayout.getParent() != form) {
      cFixLayout = cFixLayout.getParent();
    }
    if (cFixLayout == null) {
      cFixLayout = tableComposite;
    }
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cFixLayout.setLayout(layout);

    // FormData for Folder
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    int iSplitAt = configMan.getIntParameter(tv.getPropertiesPrefix() + ".SplitAt", 3000);
    // Was stored at whole
    if (iSplitAt < 100) {
      iSplitAt *= 100;
    }

    double pct = iSplitAt / 10000.0;
    if (pct < 0.03) {
      pct = 0.03;
    } else if (pct > 0.97) {
      pct = 0.97;
    }

    // height will be set on first resize call
    sash.setData("PCT", new Double(pct));
    tabFolder.setLayoutData(formData);
    final FormData tabFolderData = formData;

    // FormData for Sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(tabFolder);
    formData.height = 5;
    sash.setLayoutData(formData);

    // FormData for table Composite
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(sash);
    cFixLayout.setLayoutData(formData);

    // Listeners to size the folder
    sash.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            final boolean FASTDRAG = true;

            if (FASTDRAG && e.detail == SWT.DRAG) {
              return;
            }

            if (tabFolder.getMinimized()) {
              tabFolder.setMinimized(false);
              refreshSelectedSubView();
              ConfigurationManager configMan = ConfigurationManager.getInstance();
              configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false);
            }

            Rectangle area = form.getClientArea();
            tabFolderData.height = area.height - e.y - e.height - iFolderHeightAdj;
            form.layout();

            Double l = new Double((double) tabFolder.getBounds().height / form.getBounds().height);
            sash.setData("PCT", l);
            if (e.detail != SWT.DRAG) {
              ConfigurationManager configMan = ConfigurationManager.getInstance();
              configMan.setParameter(
                  tv.getPropertiesPrefix() + ".SplitAt", (int) (l.doubleValue() * 10000));
            }
          }
        });

    final CTabFolder2Adapter folderListener =
        new CTabFolder2Adapter() {
          public void minimize(CTabFolderEvent event) {
            tabFolder.setMinimized(true);
            tabFolderData.height = iFolderHeightAdj;
            CTabItem[] items = tabFolder.getItems();
            for (int i = 0; i < items.length; i++) {
              CTabItem tabItem = items[i];
              tabItem.getControl().setVisible(false);
            }
            form.layout();

            UISWTViewCore view = getActiveSubView();
            if (view != null) {
              view.triggerEvent(UISWTViewEvent.TYPE_FOCUSLOST, null);
            }

            ConfigurationManager configMan = ConfigurationManager.getInstance();
            configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", true);
          }

          public void restore(CTabFolderEvent event) {
            tabFolder.setMinimized(false);
            CTabItem selection = tabFolder.getSelection();
            if (selection != null) {
              selection.getControl().setVisible(true);
            }
            form.notifyListeners(SWT.Resize, null);

            UISWTViewCore view = getActiveSubView();
            if (view != null) {
              view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
            }
            refreshSelectedSubView();

            ConfigurationManager configMan = ConfigurationManager.getInstance();
            configMan.setParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false);
          }
        };
    tabFolder.addCTabFolder2Listener(folderListener);

    tabFolder.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            // make sure its above
            try {
              ((CTabItem) e.item).getControl().setVisible(true);
              ((CTabItem) e.item).getControl().moveAbove(null);

              // TODO: Need to viewDeactivated old one
              UISWTViewCore view = getActiveSubView();
              if (view != null) {
                view.triggerEvent(UISWTViewEvent.TYPE_FOCUSGAINED, null);
              }

            } catch (Exception t) {
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });

    tabFolder.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (tabFolder.getMinimized()) {
              folderListener.restore(null);
              // If the user clicked down on the restore button, and we restore
              // before the CTabFolder does, CTabFolder will minimize us again
              // There's no way that I know of to determine if the mouse is
              // on that button!

              // one of these will tell tabFolder to cancel
              e.button = 0;
              tabFolder.notifyListeners(SWT.MouseExit, null);
            }
          }
        });

    form.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event e) {
            if (tabFolder.getMinimized()) {
              return;
            }

            Double l = (Double) sash.getData("PCT");
            if (l != null) {
              tabFolderData.height =
                  (int) (form.getBounds().height * l.doubleValue()) - iFolderHeightAdj;
              form.layout();
            }
          }
        });

    // Call plugin listeners
    if (pluginViews != null) {
      for (UISWTViewEventListenerWrapper l : pluginViews) {
        if (l != null) {
          try {
            UISWTViewImpl view = new UISWTViewImpl(tv.getTableID(), l.getViewID(), l, null);
            addTabView(view);
          } catch (Exception e) {
            // skip, plugin probably specifically asked to not be added
          }
        }
      }
    }

    if (configMan.getBooleanParameter(tv.getPropertiesPrefix() + ".subViews.minimized", false)) {
      tabFolder.setMinimized(true);
      tabFolderData.height = iFolderHeightAdj;
    } else {
      tabFolder.setMinimized(false);
    }

    tabFolder.setSelection(0);

    return form;
  }
示例#14
0
  /**
   * 创建被测进程列表 @Title: createTargetPkgTableView @Description:
   *
   * @param parent void
   * @throws
   */
  private void createTargetPkgTableView(Composite parent) {
    targetPkgTableViewer =
        new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
    ctv = new CheckboxTableViewer(targetPkgTableViewer.getTable());
    ctv.addCheckStateListener(
        new ICheckStateListener() {

          @Override
          public void checkStateChanged(CheckStateChangedEvent event) {
            if (isSupportCheckChangePer) {
              GetCurCheckedStateUtil.update();
            } else {
              APTConsoleFactory.getInstance().APTPrint("Operation forbid");
            }
          }
        });

    // 设置表头内容
    for (int i = 0; i < TARGET_COLUMN_NAME.length; i++) {
      new TableColumn(targetPkgTableViewer.getTable(), SWT.LEFT).setText(TARGET_COLUMN_NAME[i]);
    }
    targetPkgTableViewer.getTable().getColumn(0).setWidth(200);
    targetPkgTableViewer.getTable().getColumn(1).setWidth(50);
    // 设置表头和表格线可见
    targetPkgTableViewer.getTable().setHeaderVisible(true);
    targetPkgTableViewer.getTable().setLinesVisible(true);

    targetPkgTableViewer.setContentProvider(new ViewContentProvider());
    targetPkgTableViewer.setLabelProvider(new ViewLabelProvider());

    targetPkgTableViewer
        .getTable()
        .addMouseListener(
            new MouseListener() {

              @Override
              public void mouseUp(MouseEvent e) {}

              @Override
              public void mouseDown(MouseEvent e) {}

              @Override
              public void mouseDoubleClick(MouseEvent e) {
                if (isSupportAddOrDeleteOper) {
                  APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
                  TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
                  if (selectData == null || selectData.length == 0) {
                    return;
                  }

                  PkgInfo itemData = (PkgInfo) selectData[0].getData();

                  targetPkgTableViewer.remove(itemData);
                  APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
                } else {
                  APTConsoleFactory.getInstance().APTPrint("Operation forbid");
                }
              }
            });

    targetPkgTableViewer.getTable().setToolTipText("双击或者右键菜单可删除被测进程");

    FormData tableViewFormData = new FormData();
    tableViewFormData.left = new FormAttachment(0, 5);
    tableViewFormData.right = new FormAttachment(100, -5);
    tableViewFormData.top = new FormAttachment(pkgNameText, 10);
    tableViewFormData.height = 125;
    Table table = targetPkgTableViewer.getTable();
    table.setLayoutData(tableViewFormData);
  }
示例#15
0
  @Override
  protected void configureShell(Shell newShell) {
    newShell.setText(getTitle());
    newShell.setImage(getImage());
    newShell.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            Shell shell = (Shell) e.getSource();
            Rectangle rect = shell.getClientArea();
            rect.width--;
            rect.height--;
            Color c = new Color(shell.getDisplay(), 0x1E, 0x3E, 0x93);
            e.gc.setForeground(c);
            e.gc.drawRectangle(0, 0, rect.width, rect.height);
            c.dispose();

            c = new Color(shell.getDisplay(), 0xAA, 0xE1, 0xFF);
            e.gc.setForeground(c);
            e.gc.drawRectangle(1, 1, rect.width - 2, rect.height - 2);
            c.dispose();

            c = new Color(shell.getDisplay(), 0x53, 0xAE, 0xF3);
            e.gc.setForeground(c);
            e.gc.drawRectangle(2, 2, rect.width - 4, rect.height - 4);
            c.dispose();

            Color top = new Color(shell.getDisplay(), 0x15, 0x77, 0xD3);
            Color bottom = new Color(shell.getDisplay(), 0x68, 0xB6, 0xF7);
            String title = getTitle();
            Point extent = e.gc.textExtent(title);
            int height = Math.max(18, extent.y + 6);
            e.gc.setForeground(top);
            e.gc.setBackground(bottom);
            e.gc.fillGradientRectangle(2, 2, rect.width - 4, height, true);
            top.dispose();
            bottom.dispose();

            c = new Color(shell.getDisplay(), 0x4F, 0x93, 0xD5);
            e.gc.setForeground(c);
            e.gc.setBackground(shell.getBackground());
            e.gc.drawRectangle(3, 2 + height, rect.width - 6, 2 + height);
            c.dispose();

            Image image = getImage();
            Rectangle imageRect = image.getBounds();
            e.gc.drawImage(getImage(), 4, 2 + ((height - imageRect.height) >> 1));

            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            e.gc.setFont(Resources.getInstance().getDefaultFont());
            e.gc.drawString(
                title, 6 + imageRect.width, Math.max(5, (height - extent.y) >> 1), true);

            bottom = new Color(shell.getDisplay(), 0xCC, 0xEB, 0xFF);
            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            e.gc.setBackground(bottom);
            e.gc.fillGradientRectangle(
                3, 3 + height, rect.width - 5, rect.height - 5 - height, true);
            bottom.dispose();

            Rectangle btnRect = btnDefault.getBounds();
            c = new Color(shell.getDisplay(), 0x9A, 0xBD, 0xE2);
            int x = btnRect.x;
            int y = btnRect.y - 5;
            while (x < rect.width - 3) {
              e.gc.setForeground(c);
              e.gc.drawPoint(x, y);
              e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
              e.gc.drawPoint(x, y + 1);
              x += 3;
            }
            c.dispose();

            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLUE));
            TextLayout layout = new TextLayout(shell.getDisplay());
            layout.setWidth(215);
            layout.setText(getTip());
            layout.setFont(res.getDefaultFont());
            layout.draw(e.gc, 3 + getLeftMargin(), 2 + height + getTopMargin());
            layout.dispose();
          }
        });
    newShell.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            downX = e.x;
            downY = e.y;
            isMove = true;
          }

          @Override
          public void mouseUp(MouseEvent e) {
            isMove = false;
          }
        });
    newShell.addMouseMoveListener(
        new MouseMoveListener() {
          public void mouseMove(MouseEvent e) {
            if (isMove) {
              Point loc = getShell().getLocation();
              int x = loc.x + e.x - downX;
              int y = loc.y + e.y - downY;
              getShell().setLocation(x, y);
            }
          }
        });

    // create default button
    newShell.setLayout(new FormLayout());
    // close button
    Label lblClose = new Label(newShell, SWT.CENTER);
    lblClose.setImage(res.getImage(Resources.bmpCloseNormal));
    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 3);
    fd.height = 16;
    fd.right = new FormAttachment(100, -3);
    fd.width = 17;
    lblClose.setLayoutData(fd);
    lblClose.addMouseTrackListener(
        new MouseTrackAdapter() {
          @Override
          public void mouseEnter(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseHover));
          }

          @Override
          public void mouseExit(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseNormal));
          }
        });
    lblClose.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            Label lbl = (Label) e.getSource();
            lbl.setImage(res.getImage(Resources.bmpCloseDown));
          }

          @Override
          public void mouseUp(MouseEvent e) {
            getShell().close();
          }
        });
    btnDefault = new Slat(newShell);
    btnDefault.setText(getButtonLabel());
    fd = new FormData();
    fd.bottom = new FormAttachment(100, -6);
    fd.left = new FormAttachment(0, 6);
    btnDefault.setLayoutData(fd);
    btnDefault.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            getShell().close();
            onButton();
          }
        });
    btnDefault.setVisible(showButton());
  }
  /** Opens the Dialog Shell. Auto-generated code - any changes you make will disappear. */
  public void open() {
    try {
      preInitGUI();

      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
      dialogShell.setText(getText());

      composite2 = new Composite(dialogShell, SWT.NULL);
      isLocalBtn = new Button(composite2, SWT.CHECK | SWT.LEFT);
      isAbstractBtn = new Button(composite2, SWT.CHECK | SWT.LEFT);
      repositoryIdTxt = new Text(composite2, SWT.BORDER);
      versionTxt = new Text(composite2, SWT.BORDER);
      identifierTxt = new Text(composite2, SWT.BORDER);
      versionLb = new Label(composite2, SWT.NULL);
      repositoryIdLb = new Label(composite2, SWT.NULL);
      idLb = new Label(composite2, SWT.NULL);
      composite3 = new Composite(dialogShell, SWT.NULL);
      cancel = new Button(composite3, SWT.PUSH | SWT.CENTER);
      enter = new Button(composite3, SWT.PUSH | SWT.CENTER);

      dialogShell.setText("Add Module");
      dialogShell.setSize(new org.eclipse.swt.graphics.Point(476, 145));

      GridData composite2LData = new GridData();
      composite2LData.verticalAlignment = GridData.CENTER;
      composite2LData.horizontalAlignment = GridData.BEGINNING;
      composite2LData.widthHint = 464;
      composite2LData.heightHint = 102;
      composite2LData.horizontalIndent = 0;
      composite2LData.horizontalSpan = 1;
      composite2LData.verticalSpan = 1;
      composite2LData.grabExcessHorizontalSpace = false;
      composite2LData.grabExcessVerticalSpace = false;
      composite2.setLayoutData(composite2LData);
      composite2.setSize(new org.eclipse.swt.graphics.Point(464, 102));

      FormData isLocalBtnLData = new FormData();
      isLocalBtnLData.height = 20;
      isLocalBtnLData.width = 70;
      isLocalBtnLData.left = new FormAttachment(519, 1000, 0);
      isLocalBtnLData.right = new FormAttachment(750, 1000, 0);
      isLocalBtnLData.top = new FormAttachment(700, 1000, 0);
      isLocalBtnLData.bottom = new FormAttachment(897, 1000, 0);
      isLocalBtn.setLayoutData(isLocalBtnLData);
      isLocalBtn.setText("is local");
      isLocalBtn.setSize(new org.eclipse.swt.graphics.Point(70, 20));
      final Font isLocalBtnfont = new Font(Display.getDefault(), "Tahoma", 8, 1);
      isLocalBtn.setFont(isLocalBtnfont);

      FormData isAbstractBtnLData = new FormData();
      isAbstractBtnLData.height = 20;
      isAbstractBtnLData.width = 100;
      isAbstractBtnLData.left = new FormAttachment(239, 1000, 0);
      isAbstractBtnLData.right = new FormAttachment(475, 1000, 0);
      isAbstractBtnLData.top = new FormAttachment(700, 1000, 0);
      isAbstractBtnLData.bottom = new FormAttachment(897, 1000, 0);
      isAbstractBtn.setLayoutData(isAbstractBtnLData);
      isAbstractBtn.setText("is abstract");
      isAbstractBtn.setSize(new org.eclipse.swt.graphics.Point(100, 20));
      isAbstractBtn.setFont(isLocalBtnfont);

      FormData repositoryIdTxtLData = new FormData();
      repositoryIdTxtLData.height = 13;
      repositoryIdTxtLData.width = 352;
      repositoryIdTxtLData.left = new FormAttachment(239, 1000, 0);
      repositoryIdTxtLData.right = new FormAttachment(996, 1000, 0);
      repositoryIdTxtLData.top = new FormAttachment(269, 1000, 0);
      repositoryIdTxtLData.bottom = new FormAttachment(465, 1000, 0);
      repositoryIdTxt.setLayoutData(repositoryIdTxtLData);
      repositoryIdTxt.setDoubleClickEnabled(false);
      final Font repositoryIdTxtfont = new Font(Display.getDefault(), "Tahoma", 7, 0);
      repositoryIdTxt.setFont(repositoryIdTxtfont);
      repositoryIdTxt.setEditable(false);
      repositoryIdTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      repositoryIdTxt.setEnabled(false);

      FormData versionTxtLData = new FormData();
      versionTxtLData.height = 13;
      versionTxtLData.width = 352;
      versionTxtLData.left = new FormAttachment(239, 1000, 0);
      versionTxtLData.right = new FormAttachment(996, 1000, 0);
      versionTxtLData.top = new FormAttachment(485, 1000, 0);
      versionTxtLData.bottom = new FormAttachment(691, 1000, 0);
      versionTxt.setLayoutData(versionTxtLData);
      versionTxt.setFont(repositoryIdTxtfont);
      versionTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      versionTxt.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent evt) {
              versionTxtKeyReleased(evt);
            }
          });

      FormData identifierTxtLData = new FormData();
      identifierTxtLData.height = 13;
      identifierTxtLData.width = 352;
      identifierTxtLData.left = new FormAttachment(239, 1000, 0);
      identifierTxtLData.right = new FormAttachment(996, 1000, 0);
      identifierTxtLData.top = new FormAttachment(48, 1000, 0);
      identifierTxtLData.bottom = new FormAttachment(250, 1000, 0);
      identifierTxt.setLayoutData(identifierTxtLData);
      identifierTxt.setFont(repositoryIdTxtfont);
      identifierTxt.setSize(new org.eclipse.swt.graphics.Point(352, 13));
      identifierTxt.setFocus();
      identifierTxt.addKeyListener(
          new KeyAdapter() {
            public void keyReleased(KeyEvent evt) {
              identifierTxtKeyReleased(evt);
            }
          });

      FormData versionLbLData = new FormData();
      versionLbLData.height = 20;
      versionLbLData.width = 90;
      versionLbLData.left = new FormAttachment(11, 1000, 0);
      versionLbLData.right = new FormAttachment(245, 1000, 0);
      versionLbLData.top = new FormAttachment(485, 1000, 0);
      versionLbLData.bottom = new FormAttachment(681, 1000, 0);
      versionLb.setLayoutData(versionLbLData);
      versionLb.setText("Version:");
      versionLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      versionLb.setFont(isLocalBtnfont);

      FormData repositoryIdLbLData = new FormData();
      repositoryIdLbLData.height = 20;
      repositoryIdLbLData.width = 90;
      repositoryIdLbLData.left = new FormAttachment(11, 1000, 0);
      repositoryIdLbLData.right = new FormAttachment(245, 1000, 0);
      repositoryIdLbLData.top = new FormAttachment(269, 1000, 0);
      repositoryIdLbLData.bottom = new FormAttachment(465, 1000, 0);
      repositoryIdLb.setLayoutData(repositoryIdLbLData);
      repositoryIdLb.setText("Repository ID:");
      repositoryIdLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      repositoryIdLb.setFont(isLocalBtnfont);

      FormData idLbLData = new FormData();
      idLbLData.height = 20;
      idLbLData.width = 90;
      idLbLData.left = new FormAttachment(11, 1000, 0);
      idLbLData.right = new FormAttachment(245, 1000, 0);
      idLbLData.top = new FormAttachment(53, 1000, 0);
      idLbLData.bottom = new FormAttachment(250, 1000, 0);
      idLb.setLayoutData(idLbLData);
      idLb.setText("Identifier:");
      idLb.setSize(new org.eclipse.swt.graphics.Point(90, 20));
      idLb.setFont(isLocalBtnfont);
      FormLayout composite2Layout = new FormLayout();
      composite2.setLayout(composite2Layout);
      composite2Layout.marginWidth = 0;
      composite2Layout.marginHeight = 0;
      composite2Layout.spacing = 0;
      composite2.layout();

      GridData composite3LData = new GridData();
      composite3LData.verticalAlignment = GridData.CENTER;
      composite3LData.horizontalAlignment = GridData.BEGINNING;
      composite3LData.widthHint = 466;
      composite3LData.heightHint = 46;
      composite3LData.horizontalIndent = 0;
      composite3LData.horizontalSpan = 1;
      composite3LData.verticalSpan = 1;
      composite3LData.grabExcessHorizontalSpace = false;
      composite3LData.grabExcessVerticalSpace = false;
      composite3.setLayoutData(composite3LData);
      composite3.setSize(new org.eclipse.swt.graphics.Point(466, 46));

      FormData cancelLData = new FormData();
      cancelLData.height = 21;
      cancelLData.width = 80;
      cancelLData.left = new FormAttachment(816, 1000, 0);
      cancelLData.right = new FormAttachment(988, 1000, 0);
      cancelLData.top = new FormAttachment(6, 1000, 0);
      cancelLData.bottom = new FormAttachment(580, 1000, 0);
      cancel.setLayoutData(cancelLData);
      cancel.setText("CANCEL");
      cancel.setSize(new org.eclipse.swt.graphics.Point(80, 21));
      cancel.setFont(isLocalBtnfont);
      cancel.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent evt) {
              cancelMouseDown(evt);
            }
          });

      FormData enterLData = new FormData();
      enterLData.height = 21;
      enterLData.width = 80;
      enterLData.left = new FormAttachment(623, 1000, 0);
      enterLData.right = new FormAttachment(795, 1000, 0);
      enterLData.top = new FormAttachment(6, 1000, 0);
      enterLData.bottom = new FormAttachment(580, 1000, 0);
      enter.setLayoutData(enterLData);
      enter.setText("ENTER");
      enter.setSize(new org.eclipse.swt.graphics.Point(80, 21));
      enter.setFont(isLocalBtnfont);
      enter.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent evt) {
              enterMouseDown(evt);
            }
          });
      FormLayout composite3Layout = new FormLayout();
      composite3.setLayout(composite3Layout);
      composite3Layout.marginWidth = 0;
      composite3Layout.marginHeight = 0;
      composite3Layout.spacing = 0;
      composite3.layout();
      GridLayout dialogShellLayout = new GridLayout(1, true);
      dialogShell.setLayout(dialogShellLayout);
      dialogShellLayout.marginWidth = 5;
      dialogShellLayout.marginHeight = 5;
      dialogShellLayout.numColumns = 1;
      dialogShellLayout.makeColumnsEqualWidth = true;
      dialogShellLayout.horizontalSpacing = 5;
      dialogShellLayout.verticalSpacing = 5;
      dialogShell.layout();
      dialogShell.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {

              isLocalBtnfont.dispose();
              repositoryIdTxtfont.dispose();
            }
          });
      Rectangle bounds = dialogShell.computeTrim(0, 0, 476, 145);
      dialogShell.setSize(bounds.width, bounds.height);
      postInitGUI();
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  // TODO the implementation of this method is horrible and creating too many widgets
  // table/column renderer/editor should be used instead should be used instead
  protected void addInstallButtons() {
    final AtomicInteger enabledButtonCount = new AtomicInteger(0);
    tableViewerCreator.getTableViewer().getControl().setRedraw(false);
    final Table table = tableViewerCreator.getTable();
    manualInstallButtonMap = new HashMap<ModuleToInstall, Button>();
    ILibrariesService librariesService = LibManagerUiPlugin.getDefault().getLibrariesService();

    disposePreviousEditors();
    for (final TableItem item : table.getItems()) {
      TableEditor editor = new TableEditor(table);
      installButtonsEditors.add(editor);
      Control control = null;
      Object obj = item.getData();
      if (obj instanceof ModuleToInstall) {
        final ModuleToInstall data = (ModuleToInstall) obj;
        boolean isInstalled = false;
        try {
          isInstalled =
              librariesService.getLibraryStatus(data.getName()) == ELibraryInstallStatus.INSTALLED;
        } catch (BusinessException e1) { // log the error and consider as unsinstalled
          log.error(e1);
        }
        boolean hasDownloadUrl = data.getUrl_description() != null;
        if (!MavenConstants.DOWNLOAD_MANUAL.equals(
            data.getDistribution())) { // add the button to download
          final Button button = new Button(table, SWT.FLAT);
          control = button;
          enabledButtonCount.incrementAndGet();
          button.setText(
              Messages.getString("ExternalModulesInstallDialog_Download")); // $NON-NLS-1$
          button.setData(item);
          button.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  table.select(table.indexOf(item));
                  launchIndividualDownload(enabledButtonCount, data, button);
                }
              });
          button.setEnabled(!isInstalled);
          button.setToolTipText(data.toString());
        } else { // add the link for manual download
          Composite composite = new Composite(table, SWT.NONE);
          composite.setBackground(color);
          control = composite;
          GridLayout layout = new GridLayout(hasDownloadUrl ? 2 : 1, false);
          layout.marginHeight = 0;
          layout.verticalSpacing = 1;
          composite.setLayout(layout);
          if (hasDownloadUrl) {
            Link openLink = new Link(composite, SWT.NONE);
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(openLink);
            openLink.setBackground(color);
            // openLink.setLayoutData(gData);
            openLink.setText(
                "<a href=\"\">"
                    + Messages.getString("ExternalModulesInstallDialog.openInBrowser")
                    + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            openLink.addSelectionListener(
                new SelectionAdapter() {

                  @Override
                  public void widgetSelected(final SelectionEvent e) {
                    // Program.launch(data.getUrl_description());
                    openURL(data.getUrl_description());
                  }
                });
          } // else no download URL so just add the install buttonb
          enabledButtonCount.incrementAndGet();
          Button importButton = new Button(composite, SWT.FLAT);
          importButton.setImage(ImageProvider.getImage(ECoreImage.IMPORT_JAR));
          importButton.setToolTipText(
              Messages.getString("ImportExternalJarAction.title")); // $NON-NLS-1$
          importButton.addSelectionListener(
              new ImportButtonSelectionListener(enabledButtonCount, item));
          manualInstallButtonMap.put(data, importButton);
          GridDataFactory.fillDefaults()
              .align(SWT.RIGHT, SWT.CENTER)
              .grab(true, false)
              .applyTo(importButton);
          importButton.setEnabled(!isInstalled);
          importButton.setToolTipText(data.toString());
        }
        editor.grabHorizontal = true;
        editor.setEditor(control, item, tableViewerCreator.getColumns().indexOf(installcolumn));
        editor.layout();
        // url
        editor = new TableEditor(table);
        installButtonsEditors.add(editor);
        Composite composite = new Composite(table, SWT.NONE);
        composite.setBackground(color);
        // GridLayout layout = new GridLayout();
        FormLayout layout = new FormLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        composite.setLayout(layout);
        FormData gData = new FormData();
        gData.left = new FormAttachment(0);
        gData.right = new FormAttachment(100);
        gData.top = new FormAttachment(composite, 0, SWT.CENTER);
        final Link openLink = new Link(composite, SWT.NONE);
        openLink.setLayoutData(gData);
        openLink.setBackground(color);
        gData.height = new GC(composite).stringExtent(" ").y; // $NON-NLS-1$
        openLink.setText(
            "<a href=\"\">"
                + (hasDownloadUrl ? data.getUrl_description() : "")
                + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
        openLink.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(final SelectionEvent e) {
                // Program.launch(data.getUrl_description());
                openURL(data.getUrl_description());
              }
            });
        editor.grabHorizontal = true;
        // editor.minimumHeight = 20;
        editor.setEditor(composite, item, tableViewerCreator.getColumns().indexOf(urlcolumn));
        editor.layout();
      }
    }
    tableViewerCreator.getTableViewer().getTable().layout();
    tableViewerCreator.getTableViewer().refresh(true);
    tableViewerCreator.getTableViewer().getControl().setRedraw(true);
  }
示例#18
0
  private void createLWTGroup(Composite container) {
    // data model
    final LWT lwt = connection.getOptions().getLwt();

    final Group group = new Group(container, SWT.NONE);
    group.setText(Messages.OPT_TAB_GROUP_LWT);

    // layout
    FormLayout layout = new FormLayout();
    layout.marginBottom = 10;
    group.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    group.setLayoutData(gd);

    // **********************************************
    // Row: Topic + QoS + Retain
    // **********************************************
    // Topic - label
    Label topicLabel = new Label(group, SWT.NONE);
    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 10);
    fd.left = new FormAttachment(0, 10);
    topicLabel.setLayoutData(fd);
    topicLabel.setText(Messages.OPT_TAB_GROUP_LWT_TOPIC);

    // Topic - input
    final Text topicText = new Text(group, SWT.BORDER);
    fd = new FormData();
    fd.top = new FormAttachment(topicLabel, 10, SWT.CENTER);
    fd.left = new FormAttachment(topicLabel, 40);
    fd.right = new FormAttachment(100, -4);
    topicText.setLayoutData(fd);

    // QoS - label
    Label qosLabel = new Label(group, SWT.NONE);
    fd = new FormData();
    fd.top = new FormAttachment(topicLabel, 10);
    fd.left = new FormAttachment(0, 10);
    qosLabel.setLayoutData(fd);
    qosLabel.setText(Messages.OPT_TAB_GROUP_LWT_QOS);

    // QoS - selection
    CCombo combo = new CCombo(group, SWT.BORDER);
    List<String> qosList = new ArrayList<String>();
    for (QoS qos : QoS.values()) {
      qosList.add(qos.getLabel());
    }
    combo.setItems(qosList.toArray(new String[0]));
    combo.setEditable(false);
    combo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        // Note: need manually set (because NOT using databinding for combo)
                        CCombo combo = (CCombo) e.widget;
                        lwt.setQos(QoS.valueOf(combo.getSelectionIndex()));
                      }
                    });
          }
        });

    // Note: need manually set (because NOT using databinding for combo)
    combo.select(lwt.getQos().getValue());
    fd = new FormData();
    fd.top = new FormAttachment(qosLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(topicText, 0, SWT.LEFT);
    combo.setLayoutData(fd);

    // Retained
    Button retained = new Button(group, SWT.CHECK);
    retained.setText(Messages.OPT_TAB_GROUP_LWT_RETAINED);
    fd = new FormData();
    fd.top = new FormAttachment(qosLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(combo, 10);
    retained.setLayoutData(fd);

    // Hex
    final Button hex = new Button(group, SWT.CHECK);
    hex.setText(Messages.OPT_TAB_GROUP_LWT_HEX);
    fd = new FormData();
    fd.top = new FormAttachment(qosLabel, 0, SWT.CENTER);
    fd.right = new FormAttachment(100, -4);
    hex.setLayoutData(fd);

    // **********************************************
    // Row: Message - label
    // **********************************************
    // Topic - label
    Label messageLabel = new Label(group, SWT.NONE);
    fd = new FormData();
    fd.top = new FormAttachment(topicLabel, 60);
    fd.left = new FormAttachment(0, 10);
    messageLabel.setLayoutData(fd);
    messageLabel.setText(Messages.OPT_TAB_GROUP_LWT_MSG);

    // Message - input
    final Text messageText = new Text(group, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    fd = new FormData();
    fd.top = new FormAttachment(messageLabel, 10, SWT.CENTER);
    fd.left = new FormAttachment(topicText, 0, SWT.LEFT);
    fd.right = new FormAttachment(topicText, 0, SWT.RIGHT);
    // fd.width = 300;
    fd.height = 60;
    messageText.setLayoutData(fd);

    // XXX handle input when in HEX mode
    hex.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        Button button = (Button) e.widget;
                        if (button.getSelection()) {
                          messageText.setText(Strings.toHex(messageText.getText()));
                          messageText.setEditable(false);
                        } else {
                          messageText.setText(Strings.hexToString(messageText.getText()));
                          messageText.setEditable(true);
                        }
                      }
                    });
          }
        });

    // **********************************************
    // DataBinding
    // **********************************************
    final DataBinding dataBinding = DataBindings.createDataBinding();
    dataBinding.bindTextAsBytes(messageText, connection, Connection.PROP_OPT_LWT_PAYLOAD);
    dataBinding.bindSelection(retained, connection, Connection.PROP_OPT_LWT_RETAIN);

    // LWT view updater
    lwtViewUpdater =
        new ViewUpdater<Boolean>() {
          final DecoratedBinding binding;

          {
            binding =
                dataBinding
                    .bindText(
                        topicText,
                        connection,
                        Connection.PROP_OPT_LWT_TOPIC,
                        Validators.publishTopic)
                    .hideDecorations();
          }

          @Override
          public void update(Boolean selected) {
            Widgets.enable(group, selected);
            if (selected) {
              binding.showDecorations();
            } else {
              binding.hideDecorations();
            }
          }
        };
    // dispose dataBinding when UI is disposed
    addDisposeListener(dataBinding);

    // initial state
    Widgets.enable(group, connection.getOptions().isLwtEnabled());
  }
示例#19
0
  void show(
      boolean owned,
      org.eclipse.swt.graphics.Point location,
      org.eclipse.swt.graphics.Point size,
      boolean addressBar,
      boolean menuBar,
      boolean statusBar,
      boolean toolBar) {
    final org.eclipse.swt.widgets.Shell shell = browser.getShell();
    if (owned) {
      if (location != null) {
        shell.setLocation(location);
      }
      if (size != null) {
        shell.setSize(shell.computeSize(size.x, size.y));
      }
    }
    org.eclipse.swt.layout.FormData data = null;
    if (toolBar) {
      toolbar = new org.eclipse.swt.widgets.ToolBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      toolbar.setLayoutData(data);
      itemBack = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemBack.setText(getResourceString("Back"));
      itemForward = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemForward.setText(getResourceString("Forward"));
      final org.eclipse.swt.widgets.ToolItem itemStop =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemStop.setText(getResourceString("Stop"));
      final org.eclipse.swt.widgets.ToolItem itemRefresh =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemRefresh.setText(getResourceString("Refresh"));
      final org.eclipse.swt.widgets.ToolItem itemGo =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemGo.setText(getResourceString("Go"));
      itemBack.setEnabled(browser.isBackEnabled());
      itemForward.setEnabled(!browser.isForwardEnabled());
      org.eclipse.swt.widgets.Listener listener =
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event event) {
              org.eclipse.swt.widgets.ToolItem item =
                  (org.eclipse.swt.widgets.ToolItem) event.widget;
              if (item == itemBack) {
                browser.back();
              } else {
                if (item == itemForward) {
                  browser.forward();
                } else {
                  if (item == itemStop) {
                    browser.stop();
                  } else {
                    if (item == itemRefresh) {
                      browser.refresh();
                    } else {
                      if (item == itemGo) {
                        browser.setUrl(locationBar.getText());
                      }
                    }
                  }
                }
              }
            }
          };
      itemBack.addListener(SWT.Selection, listener);
      itemForward.addListener(SWT.Selection, listener);
      itemStop.addListener(SWT.Selection, listener);
      itemRefresh.addListener(SWT.Selection, listener);
      itemGo.addListener(SWT.Selection, listener);
      canvas = new org.eclipse.swt.widgets.Canvas(parent, SWT.NO_BACKGROUND);
      data = new org.eclipse.swt.layout.FormData();
      data.width = 24;
      data.height = 24;
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      canvas.setLayoutData(data);
      final org.eclipse.swt.graphics.Rectangle rect = images[0].getBounds();
      canvas.addListener(
          SWT.Paint,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              org.eclipse.swt.graphics.Point pt =
                  ((org.eclipse.swt.widgets.Canvas) e.widget).getSize();
              e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
            }
          });
      canvas.addListener(
          SWT.MouseDown,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(getResourceString("Startup"));
            }
          });
      final org.eclipse.swt.widgets.Display display = parent.getDisplay();
      display.asyncExec(
          new java.lang.Runnable() {
            public void run() {
              if (canvas.isDisposed()) {
                return;
              }
              if (busy) {
                index++;
                if (index == images.length) {
                  index = 0;
                }
                canvas.redraw();
              }
              display.timerExec(150, this);
            }
          });
    }
    if (addressBar) {
      locationBar = new org.eclipse.swt.widgets.Text(parent, SWT.BORDER);
      data = new org.eclipse.swt.layout.FormData();
      if (toolbar != null) {
        data.top = new org.eclipse.swt.layout.FormAttachment(toolbar, 0, SWT.TOP);
        data.left = new org.eclipse.swt.layout.FormAttachment(toolbar, 5, SWT.RIGHT);
        data.right = new org.eclipse.swt.layout.FormAttachment(canvas, -5, SWT.DEFAULT);
      } else {
        data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
      }
      locationBar.setLayoutData(data);
      locationBar.addListener(
          SWT.DefaultSelection,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(locationBar.getText());
            }
          });
    }
    if (statusBar) {
      status = new org.eclipse.swt.widgets.Label(parent, SWT.NONE);
      progressBar = new org.eclipse.swt.widgets.ProgressBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.left = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(progressBar, 0, SWT.DEFAULT);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      status.setLayoutData(data);
      data = new org.eclipse.swt.layout.FormData();
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      progressBar.setLayoutData(data);
      browser.addStatusTextListener(
          new org.eclipse.swt.browser.StatusTextListener() {
            public void changed(org.eclipse.swt.browser.StatusTextEvent event) {
              status.setText(event.text);
            }
          });
    }
    parent.setLayout(new org.eclipse.swt.layout.FormLayout());
    org.eclipse.swt.widgets.Control aboveBrowser =
        toolBar
            ? (org.eclipse.swt.widgets.Control) canvas
            : addressBar ? (org.eclipse.swt.widgets.Control) locationBar : null;
    data = new org.eclipse.swt.layout.FormData();
    data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.top =
        aboveBrowser != null
            ? new org.eclipse.swt.layout.FormAttachment(aboveBrowser, 5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
    data.bottom =
        status != null
            ? new org.eclipse.swt.layout.FormAttachment(status, -5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(100, 0);
    browser.setLayoutData(data);
    if (statusBar || toolBar) {
      browser.addProgressListener(
          new org.eclipse.swt.browser.ProgressListener() {
            public void changed(org.eclipse.swt.browser.ProgressEvent event) {
              if (event.total == 0) {
                return;
              }
              int ratio = event.current * 100 / event.total;
              if (progressBar != null) {
                progressBar.setSelection(ratio);
              }
              busy = event.current != event.total;
              if (!busy) {
                index = 0;
                if (canvas != null) {
                  canvas.redraw();
                }
              }
            }

            public void completed(org.eclipse.swt.browser.ProgressEvent event) {
              if (progressBar != null) {
                progressBar.setSelection(0);
              }
              busy = false;
              index = 0;
              if (canvas != null) {
                itemBack.setEnabled(browser.isBackEnabled());
                itemForward.setEnabled(browser.isForwardEnabled());
                canvas.redraw();
              }
            }
          });
    }
    if (addressBar || statusBar || toolBar) {
      browser.addLocationListener(
          new org.eclipse.swt.browser.LocationListener() {
            public void changed(org.eclipse.swt.browser.LocationEvent event) {
              busy = true;
              if (event.top && locationBar != null) {
                locationBar.setText(event.location);
              }
            }

            public void changing(org.eclipse.swt.browser.LocationEvent event) {}
          });
    }
    if (title) {
      browser.addTitleListener(
          new org.eclipse.swt.browser.TitleListener() {
            public void changed(org.eclipse.swt.browser.TitleEvent event) {
              shell.setText(event.title + " - " + getResourceString("window.title"));
            }
          });
    }
    parent.layout(true);
    if (owned) {
      shell.open();
    }
  }
示例#20
0
  private void initGUI() {
    try {
      final FormLayout thisLayout = new FormLayout();
      this.setLayout(thisLayout);
      this.setSize(217, 163);
      {
        filenameHolder = new Composite(this, SWT.NONE);
        final GridLayout filenameHolderLayout = new GridLayout();
        filenameHolderLayout.numColumns = 3;
        filenameHolderLayout.makeColumnsEqualWidth = true;
        final FormData filenameHolderLData = new FormData();
        filenameHolderLData.width = 214;
        filenameHolderLData.height = 47;
        filenameHolderLData.left = new FormAttachment(16, 1000, 0);
        filenameHolderLData.right = new FormAttachment(1000, 1000, 0);
        filenameHolderLData.top = new FormAttachment(21, 1000, 0);
        filenameHolder.setLayoutData(filenameHolderLData);
        filenameHolder.setLayout(filenameHolderLayout);
        {
          scenarioLbl = new Label(filenameHolder, SWT.NONE);
          final GridData scenarioLblLData = new GridData();
          scenarioLblLData.horizontalAlignment = GridData.FILL;
          scenarioLbl.setLayoutData(scenarioLblLData);
          scenarioLbl.setText("Scenario");
          scenarioLbl.setAlignment(SWT.RIGHT);
        }
        {
          scenarioVal = new Label(filenameHolder, SWT.NONE);
          final GridData scenarioValLData = new GridData();
          scenarioValLData.horizontalSpan = 2;
          scenarioValLData.horizontalAlignment = GridData.FILL;
          scenarioValLData.grabExcessHorizontalSpace = true;
          scenarioVal.setLayoutData(scenarioValLData);
          scenarioVal.setText("[pending]");
        }
        {
          controlLabel = new Label(filenameHolder, SWT.NONE);
          final GridData label1LData = new GridData();
          label1LData.horizontalAlignment = GridData.FILL;
          controlLabel.setLayoutData(label1LData);
          controlLabel.setText("Control file");
          controlLabel.setAlignment(SWT.RIGHT);
        }
        {
          controlVal = new Label(filenameHolder, SWT.NONE);
          final GridData label2LData = new GridData();
          label2LData.horizontalSpan = 2;
          label2LData.grabExcessHorizontalSpace = true;
          label2LData.horizontalAlignment = GridData.FILL;
          controlVal.setLayoutData(label2LData);
          controlVal.setText("[pending]");
        }
      }
      {
        scenarioTabs = new TabFolder(this, SWT.NONE);
        {
          multipleTab = new TabItem(scenarioTabs, SWT.NONE);
          multipleTab.setText("Multiple Scenarios");
          {
            composite2 = new Composite(scenarioTabs, SWT.NONE);
            final GridLayout composite2Layout = new GridLayout();
            composite2Layout.makeColumnsEqualWidth = true;
            composite2.setLayout(composite2Layout);
            multipleTab.setControl(composite2);
            {
              multiRunBtnHolder = new Composite(composite2, SWT.NONE);
              final RowLayout multiRunBtnHolderLayout =
                  new RowLayout(org.eclipse.swt.SWT.HORIZONTAL);
              multiRunBtnHolderLayout.fill = true;
              final GridData multiRunBtnHolderLData = new GridData();
              multiRunBtnHolderLData.grabExcessHorizontalSpace = true;
              multiRunBtnHolder.setLayoutData(multiRunBtnHolderLData);
              multiRunBtnHolder.setLayout(multiRunBtnHolderLayout);
              {
                doGenerateButton = new Button(multiRunBtnHolder, SWT.PUSH | SWT.CENTER);
                doGenerateButton.setText("Generate");
              }
              {
                runBtn = new Button(multiRunBtnHolder, SWT.PUSH | SWT.CENTER);
                runBtn.setText("Run all");
              }
            }

            {
              multiTableHolder = new Composite(composite2, SWT.NONE);
              final GridLayout multiTableHolderLayout = new GridLayout();
              multiTableHolderLayout.makeColumnsEqualWidth = true;
              multiTableHolder.setLayout(multiTableHolderLayout);
            }
          }
        }
        final FormData scenarioTabsLData = new FormData();
        scenarioTabsLData.width = 204;
        scenarioTabsLData.left = new FormAttachment(10, 1000, 0);
        scenarioTabsLData.right = new FormAttachment(990, 1000, 0);
        scenarioTabsLData.bottom = new FormAttachment(1000, 1000, 0);
        scenarioTabsLData.height = 79;
        scenarioTabsLData.top = new FormAttachment(0, 1000, 56);
        scenarioTabs.setLayoutData(scenarioTabsLData);
        scenarioTabs.setSelection(1);
      }
      this.layout();
    } catch (final Exception e) {
      e.printStackTrace();
    }
  }
示例#21
0
  private void initGUI() {
    try {
      FontData coudat = new FontData(VigenereBreakerGui.COURIER, 10, SWT.NORMAL);
      Font coufont = new Font(getDisplay(), coudat);

      FormLayout thisLayout = new FormLayout();
      this.setSize(780, 720);
      this.setLayout(thisLayout);
      {
        cselection = new Composite(this, SWT.NONE);
        FormLayout cselectionLayout = new FormLayout();
        FormData cselectionLData = new FormData();
        cselectionLData.left = new FormAttachment(0, 1000, 10);
        cselectionLData.top = new FormAttachment(0, 1000, 0);
        cselectionLData.width = 760;
        cselectionLData.height = 30;
        cselection.setLayoutData(cselectionLData);
        cselection.setLayout(cselectionLayout);
        {
          lsep = new Label(cselection, SWT.SEPARATOR | SWT.HORIZONTAL);
          FormData lsepLData = new FormData();
          lsepLData.left = new FormAttachment(0, 1000, 0);
          lsepLData.top = new FormAttachment(0, 1000, 26);
          lsepLData.width = 760;
          lsepLData.height = 5;
          lsep.setLayoutData(lsepLData);
        }
        {
          lsthree = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lsthreeLData = new FormData();
          lsthreeLData.left = new FormAttachment(0, 1000, 480);
          lsthreeLData.top = new FormAttachment(0, 1000, 0);
          lsthreeLData.width = 238;
          lsthreeLData.height = 24;
          lsthree.setLayoutData(lsthreeLData);
          lsthree.setText(Messages.VigenereGlobal_navi_decryption);
          lsthree.setFont(FontService.getLargeFont());
          lsthree.setEnabled(false);
        }
        {
          lstwo = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lstwoLData = new FormData();
          lstwoLData.left = new FormAttachment(0, 1000, 240);
          lstwoLData.top = new FormAttachment(0, 1000, 0);
          lstwoLData.width = 238;
          lstwoLData.height = 24;
          lstwo.setLayoutData(lstwoLData);
          lstwo.setText(Messages.VigenereGlobal_navi_frequency);
          lstwo.setFont(FontService.getLargeFont());
        }
        {
          lsone = new Label(cselection, SWT.BORDER | SWT.CENTER);
          FormData lsoneLData = new FormData();
          lsoneLData.left = new FormAttachment(0, 1000, 0);
          lsoneLData.top = new FormAttachment(0, 1000, 0);
          lsoneLData.width = 238;
          lsoneLData.height = 24;
          lsone.setLayoutData(lsoneLData);
          lsone.setText(Messages.VigenereGlobal_navi_friedman);
          lsone.setFont(FontService.getLargeFont());
          lsone.setEnabled(false);
        }
      }
      {
        cvariable = new Composite(this, SWT.NONE);
        FormLayout composite3Layout = new FormLayout();
        FormData composite3LData = new FormData();
        composite3LData.left = new FormAttachment(0, 1000, 10);
        composite3LData.top = new FormAttachment(0, 1000, 30);
        composite3LData.width = 760;
        composite3LData.height = 680;
        cvariable.setLayoutData(composite3LData);
        cvariable.setLayout(composite3Layout);
        {
          lpreview = new Label(cvariable, SWT.NONE);
          FormData lpreviewLData = new FormData();
          lpreviewLData.left = new FormAttachment(0, 1000, 0);
          lpreviewLData.top = new FormAttachment(0, 1000, 10);
          lpreviewLData.width = 760;
          lpreviewLData.height = 15;
          lpreview.setLayoutData(lpreviewLData);
          lpreview.setText(Messages.FrequencyGui_label_preview1 + edtitle);
          lpreview.setFont(FontService.getNormalFont());
        }

        {
          thelp = new Text(cvariable, SWT.MULTI | SWT.WRAP);
          FormData tdescrLData = new FormData();
          tdescrLData.left = new FormAttachment(0, 1000, 0);
          tdescrLData.top = new FormAttachment(0, 1000, 380);
          tdescrLData.width = 234;
          tdescrLData.height = 245;
          thelp.setLayoutData(tdescrLData);
          thelp.setText(
              String.format(Messages.FrequencyGui_text_help, plength) + Messages.FrequencyGui_0);
          thelp.setEditable(false);
          thelp.setEnabled(false);
          thelp.setFont(FontService.getNormalFont());
        }
        {
          lsepend = new Label(cvariable, SWT.SEPARATOR | SWT.HORIZONTAL);
          FormData label1LData = new FormData();
          label1LData.left = new FormAttachment(0, 1000, 0);
          label1LData.top = new FormAttachment(thelp, 5);
          label1LData.width = 760;
          label1LData.height = 4;
          lsepend.setLayoutData(label1LData);
        }
        {
          llength = new Label(cvariable, SWT.NONE);
          FormData llengthLData = new FormData();
          llengthLData.left = new FormAttachment(0, 1000, 260);
          llengthLData.top = new FormAttachment(0, 1000, 400);
          llengthLData.width = 200;
          llengthLData.height = 15;
          llength.setLayoutData(llengthLData);
          String l = Messages.FrequencyGui_label_length;
          llength.setText(l + String.valueOf(plength));
          llength.setFont(FontService.getNormalFont());
        }
        {
          tsample = new Text(cvariable, SWT.MULTI | SWT.WRAP | SWT.BORDER);
          FormData text1LData = new FormData();
          text1LData.left = new FormAttachment(0, 1000, 0);
          text1LData.top = new FormAttachment(0, 1000, 25);
          text1LData.width = 752;
          text1LData.height = 84;
          tsample.setLayoutData(text1LData);
          tsample.setFont(coufont);
          tsample.setEditable(false);
          tsample.setEnabled(false);
          tsample.setBackground(new Color(getDisplay(), 250, 250, 250));
        }
        {
          cgraph = new Composite(cvariable, SWT.NONE);
          GridLayout composite4Layout = new GridLayout();
          composite4Layout.makeColumnsEqualWidth = true;
          FormData composite4LData = new FormData();
          composite4LData.left = new FormAttachment(0, 1000, 0);
          composite4LData.top = new FormAttachment(0, 1000, 120);
          composite4LData.width = 760;
          composite4LData.height = 260;
          cgraph.setLayoutData(composite4LData);
          cgraph.setLayout(composite4Layout);
        }
        {
          cphrase = new Composite(cvariable, SWT.NONE);
          FormLayout composite6Layout = new FormLayout();
          FormData composite6LData = new FormData();
          composite6LData.left = new FormAttachment(0, 1000, 250);
          composite6LData.top = new FormAttachment(0, 1000, 422);
          composite6LData.width = 510;
          composite6LData.height = 100;
          cphrase.setLayoutData(composite6LData);
          cphrase.setLayout(composite6Layout);
        }
        {
          bshift = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData bfriedexecLData = new FormData();
          bfriedexecLData.left = new FormAttachment(0, 1000, 260);
          bfriedexecLData.top = new FormAttachment(lsepend, 5);
          bfriedexecLData.height = 25;
          bshift.setLayoutData(bfriedexecLData);
          bshift.setText(Messages.FrequencyGui_button_shift);
          bshift.setFont(FontService.getNormalFont());
          bshift.setToolTipText(Messages.FrequencyGui_ttip_shift);
          bshift.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  shift();
                }
              });
        }
        {
          bdecrypt = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData button1LData = new FormData();
          button1LData.left = new FormAttachment(bshift, 5);
          button1LData.top = new FormAttachment(lsepend, 5);
          button1LData.height = 25;
          bdecrypt.setLayoutData(button1LData);
          bdecrypt.setText(Messages.FrequencyGui_button_decrypt);
          bdecrypt.setFont(FontService.getNormalFont());
          bdecrypt.setToolTipText(Messages.FrequencyGui_ttip_decrypt);
          bdecrypt.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent evt) {
                  decrypt();
                }
              });
        }
        {
          bback = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData bbackLData = new FormData();
          bbackLData.left = new FormAttachment(0, 1000, 0);
          bbackLData.top = new FormAttachment(lsepend, 5);
          bbackLData.height = 25;
          bbackLData.width = 90;
          bback.setLayoutData(bbackLData);
          bback.setText(Messages.FrequencyGui_button_back);
          bback.setFont(FontService.getNormalFont());
          bback.setToolTipText(Messages.FrequencyGui_ttip_back);
          bback.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  back();
                }
              });
        }
        {
          bnext = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData button1LData = new FormData();
          button1LData.left = new FormAttachment(0, 1000, 670);
          button1LData.top = new FormAttachment(lsepend, 5);
          button1LData.height = 25;
          button1LData.width = 90;
          bnext.setLayoutData(button1LData);
          bnext.setText(Messages.FrequencyGui_button_next);
          bnext.setFont(FontService.getNormalFont());
          bnext.setToolTipText(Messages.FrequencyGui_ttip_next);
          bnext.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  next();
                }
              });
        }
        {
          boptions = new Button(cvariable, SWT.PUSH | SWT.CENTER);
          FormData boptionsLData = new FormData();
          boptionsLData.left = new FormAttachment(0, 1000, 570);
          boptionsLData.top = new FormAttachment(lsepend, 5);
          boptionsLData.height = 25;
          boptionsLData.width = 90;
          boptions.setLayoutData(boptionsLData);
          boptions.setText(Messages.FrequencyGui_button_options);
          boptions.setFont(FontService.getNormalFont());
          boptions.setToolTipText(Messages.FrequencyGui_ttip_options);
          boptions.addSelectionListener(
              new SelectionAdapter() {
                public void widgetSelected(SelectionEvent event) {
                  showOptions();
                }
              });
        }
      }

      prepare();
      this.layout();
    } catch (Exception ex) {
      LogUtil.logError(ex);
    }
  }
示例#22
0
  private Composite getFightPane(Composite parent) {
    // creates the composite to eventually return
    Composite composite = new Composite(parent, SWT.NONE);
    // sets its layout
    FormLayout layout = new FormLayout();
    FormData data;
    layout.spacing = 5;
    composite.setLayout(layout);
    // Let's create some controls!
    // search button
    final Button fightButton = new Button(composite, SWT.PUSH);
    fightButton.setText("Fight!");
    try {
      fightButton.setImage(new Image(null, new FileInputStream("images/search.png")));
    } catch (Exception e) {

    }
    fightButton.setToolTipText("Click here to see how many articles contain each search term");

    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(50, -50);
    data.width = 100;
    data.height = 30;
    fightButton.setLayoutData(data);
    // search text
    searchText = new Text(composite, SWT.SINGLE | SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(fightButton, 0);
    data.width = 150;
    data.height = 24;
    searchText.setLayoutData(data);
    // second search text
    searchText2 = new Text(composite, SWT.SINGLE | SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(fightButton, 0);
    data.width = 150;
    data.height = 24;
    searchText2.setLayoutData(data);
    // label
    label = new Label(composite, SWT.CENTER);
    label.setText("Enter two terms and click 'Fight!'");
    label.setFont(new Font(Display.getCurrent(), "", 16, SWT.BOLD));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(fightButton, 5);
    label.setLayoutData(data);
    // browser
    browser = new Browser(composite, SWT.BORDER);
    data = new FormData();
    data.left = new FormAttachment(50, -275);
    data.right = new FormAttachment(50, 275);
    data.top = new FormAttachment(label, 5);
    // data.bottom = new FormAttachment(100,0);
    data.height = 520;
    data.width = 550;
    browser.setLayoutData(data);
    // sets browser home page
    browser.setUrl("http://www.rssoap.com");
    // adds click listener to start animation
    fightButton.addMouseListener(
        new MouseListener() {
          public void mouseUp(MouseEvent e) {}

          public void mouseDown(MouseEvent e) {
            fight();
          }

          public void mouseDoubleClick(MouseEvent e) {}
        });
    return composite;
  }
示例#23
0
  private void initGUI() {
    try {
      int w = 800;
      int h = 400;

      Font system = getDisplay().getSystemFont();
      FontData base = system.getFontData()[0];
      FontData normdat = new FontData(base.getName(), base.getHeight(), base.getStyle());
      Font normfont = new Font(getDisplay(), normdat);
      FormLayout thisLayout = new FormLayout();
      this.setSize(w, h);
      this.setLayout(thisLayout);

      {
        btn1 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn1LData = new FormData();
        btn1LData.top = new FormAttachment(this, 10);
        btn1LData.left = new FormAttachment(this, 10);
        btn1.setLayoutData(btn1LData);
        btn1.setText(Messages.KegverContent_btn1);
        btn1.setToolTipText(Messages.KegverContent_btn1_tt);
        btn1.setFont(normfont);
        btn1.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                nextStep();
              }
            });
      }

      {
        btn2 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn2LData = new FormData();
        btn2LData.top = new FormAttachment(btn1, 10);
        btn2LData.left = new FormAttachment(this, 10);
        btn2.setLayoutData(btn2LData);
        btn2.setText(Messages.KegverContent_btn2);
        btn2.setToolTipText(Messages.KegverContent_btn2_tt);
        btn2.setFont(normfont);
        btn2.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                editCA();
              }
            });
      }

      {
        btn3 = new Button(this, SWT.PUSH | SWT.CENTER);
        FormData btn3LData = new FormData();
        btn3LData.top = new FormAttachment(btn2, 10);
        btn3LData.left = new FormAttachment(this, 10);
        btn3.setLayoutData(btn3LData);
        btn3.setText(Messages.KegverContent_btn3);
        btn3.setToolTipText(Messages.KegverContent_btn3_tt);
        btn3.setFont(normfont);
        btn3.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent evt) {
                editUser();
              }
            });
      }

      {
        grp1 = new Group(this, SWT.BORDER);
        FormLayout grpstepsLayout = new FormLayout();
        grp1.setLayout(grpstepsLayout);
        FormData grp1LData = new FormData();
        grp1LData.left = new FormAttachment(btn1, 10);
        grp1LData.top = new FormAttachment(this, 10);
        grp1LData.width = w - 20;
        grp1LData.height = h - 20;
        grp1.setLayoutData(grp1LData);
        grp1.setText(Messages.KegverContent_grp1);
        grp1.setFont(normfont);
        {
          // FIXME: Why is SWT.H_SCROLL not working? : As long it is not working, SWT.WRAP
          grp1_t =
              new Text(grp1, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
          FormData grp1_tLData = new FormData();
          grp1_t.setEditable(false);
          grp1_t.setFont(normfont);
          grp1_tLData.left = new FormAttachment(grp1, 0);
          grp1_tLData.top = new FormAttachment(grp1, 0);
          grp1_tLData.width = w - 47;
          grp1_tLData.height = h - 20;
          grp1_t.setBackground(getBackground());
          grp1_t.setText(Messages.KegverContent_grp1_t);
          grp1_t.setLayoutData(grp1_tLData);
        }
      }

      getShell().setDefaultButton(btn1);

      this.layout();

    } catch (Exception ex) {
      LogUtil.logError(ex);
    }
  }
  public SeveritiesInExecutionTab(TabFolder tabFolder) {
    tabItem = new TabItem(tabFolder, SWT.None);
    tabItem.setText("Severities");

    ScrolledComposite scrolledComposite =
        new ScrolledComposite(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
    tabItem.setControl(scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite compositeInScrolledComposite = new Composite(scrolledComposite, SWT.NONE);
    compositeInScrolledComposite.setLayout(new FormLayout());

    // set contents of group grpInitialSeverityLevels
    Group grpInitialSeverityLevels = new Group(compositeInScrolledComposite, SWT.NONE);
    grpInitialSeverityLevels.setText("Initial Severity Levels");
    grpInitialSeverityLevels.setLayout(new FormLayout());
    FormData fd_grpInitialSeverityLevels = new FormData();
    fd_grpInitialSeverityLevels.left = new FormAttachment(0, 5);
    fd_grpInitialSeverityLevels.right = new FormAttachment(100, -5);
    grpInitialSeverityLevels.setLayoutData(fd_grpInitialSeverityLevels);

    Composite composite_left = new Composite(grpInitialSeverityLevels, SWT.NONE);
    composite_left.setLayout(new FormLayout());
    FormData fd_composite_left = new FormData();
    fd_composite_left.width = 250;
    fd_composite_left.bottom = new FormAttachment(100, -5);
    fd_composite_left.top = new FormAttachment(0, 35);
    fd_composite_left.left = new FormAttachment(0, 5);
    composite_left.setLayoutData(fd_composite_left);

    table_SeverityForUncaughtExceptionType =
        new Table(grpInitialSeverityLevels, SWT.BORDER | SWT.FULL_SELECTION);
    FormData fd_table_1 = new FormData();
    fd_table_1.right = new FormAttachment(composite_left, 311, SWT.RIGHT);
    fd_table_1.top = new FormAttachment(composite_left, 0, SWT.TOP);
    fd_table_1.right = new FormAttachment(100, -228);
    fd_table_1.left = new FormAttachment(composite_left, 6);
    fd_table_1.bottom = new FormAttachment(composite_left, 0, SWT.BOTTOM);
    table_SeverityForUncaughtExceptionType.setLayoutData(fd_table_1);
    table_SeverityForUncaughtExceptionType.setHeaderVisible(true);
    table_SeverityForUncaughtExceptionType.setLinesVisible(true);

    TableColumn tblclmnExceptionClassName =
        new TableColumn(table_SeverityForUncaughtExceptionType, SWT.NONE);
    tblclmnExceptionClassName.setWidth(173);
    tblclmnExceptionClassName.setText("Exception Class Name");

    TableColumn tblclmnInitialSeverity =
        new TableColumn(table_SeverityForUncaughtExceptionType, SWT.NONE);
    tblclmnInitialSeverity.setWidth(291);
    tblclmnInitialSeverity.setText("Initial Severity");

    Button btnAdd = new Button(grpInitialSeverityLevels, SWT.NONE);
    FormData fd_btnAdd = new FormData();
    fd_btnAdd.width = 60;
    fd_btnAdd.top = new FormAttachment(composite_left, 0, SWT.TOP);

    Label lblAssertionFailures = new Label(composite_left, SWT.NONE);
    FormData fd_lblAssertionFailures = new FormData();
    fd_lblAssertionFailures.left = new FormAttachment(0);
    lblAssertionFailures.setLayoutData(fd_lblAssertionFailures);
    lblAssertionFailures.setText("Assertion Failures:");

    Label lblProfileProblems = new Label(composite_left, SWT.NONE);
    FormData fd_lblProfileProblems = new FormData();
    fd_lblProfileProblems.left = new FormAttachment(0);
    lblProfileProblems.setLayoutData(fd_lblProfileProblems);
    lblProfileProblems.setText("Profile Problems:");

    Combo combo_AssertionFailures = new Combo(composite_left, SWT.NONE);
    fd_lblAssertionFailures.top = new FormAttachment(combo_AssertionFailures, 3, SWT.TOP);
    FormData fd_combo_AssertionFailures = new FormData();
    fd_combo_AssertionFailures.top = new FormAttachment(0, 7);
    fd_combo_AssertionFailures.right = new FormAttachment(100, -10);
    combo_AssertionFailures.setLayoutData(fd_combo_AssertionFailures);

    Combo combo_ProfileProblems = new Combo(composite_left, SWT.NONE);
    fd_lblProfileProblems.top = new FormAttachment(combo_ProfileProblems, 3, SWT.TOP);
    FormData fd_combo_ProfileProblems = new FormData();
    fd_combo_ProfileProblems.right = new FormAttachment(combo_AssertionFailures, 0, SWT.RIGHT);
    combo_ProfileProblems.setLayoutData(fd_combo_ProfileProblems);

    Combo combo_DbcViolations = new Combo(composite_left, SWT.NONE);
    fd_combo_ProfileProblems.bottom = new FormAttachment(combo_DbcViolations, -6);
    FormData fd_combo_DbcViolations = new FormData();
    fd_combo_DbcViolations.top = new FormAttachment(0, 69);
    fd_combo_DbcViolations.right = new FormAttachment(combo_AssertionFailures, 0, SWT.RIGHT);
    combo_DbcViolations.setLayoutData(fd_combo_DbcViolations);

    Combo combo_Outcomes = new Combo(composite_left, SWT.NONE);
    FormData fd_combo_Outcomes = new FormData();
    fd_combo_Outcomes.top = new FormAttachment(combo_DbcViolations, 6);
    fd_combo_Outcomes.right = new FormAttachment(combo_AssertionFailures, 0, SWT.RIGHT);
    combo_Outcomes.setLayoutData(fd_combo_Outcomes);

    Combo combo_UncaughtExceptions = new Combo(composite_left, SWT.NONE);
    FormData fd_combo_UncaughtExceptions = new FormData();
    fd_combo_UncaughtExceptions.top = new FormAttachment(combo_Outcomes, 6);
    fd_combo_UncaughtExceptions.right = new FormAttachment(combo_AssertionFailures, 0, SWT.RIGHT);
    combo_UncaughtExceptions.setLayoutData(fd_combo_UncaughtExceptions);

    Label lblDbcViolations = new Label(composite_left, SWT.NONE);
    FormData fd_lblDbcViolations = new FormData();
    fd_lblDbcViolations.left = new FormAttachment(0);
    fd_lblDbcViolations.top = new FormAttachment(combo_DbcViolations, 3, SWT.TOP);
    lblDbcViolations.setLayoutData(fd_lblDbcViolations);
    lblDbcViolations.setText("DbC Violations:");

    Label lblOutcomes = new Label(composite_left, SWT.NONE);
    FormData fd_lblOutcomes = new FormData();
    fd_lblOutcomes.top = new FormAttachment(combo_Outcomes, 3, SWT.TOP);
    fd_lblOutcomes.left = new FormAttachment(lblAssertionFailures, 0, SWT.LEFT);
    lblOutcomes.setLayoutData(fd_lblOutcomes);
    lblOutcomes.setText("Outcomes:");

    Label lblUncaughtExceptions = new Label(composite_left, SWT.NONE);
    FormData fd_lblUncaughtExceptions = new FormData();
    fd_lblUncaughtExceptions.bottom = new FormAttachment(100, -10);
    fd_lblUncaughtExceptions.left = new FormAttachment(lblAssertionFailures, 0, SWT.LEFT);
    lblUncaughtExceptions.setLayoutData(fd_lblUncaughtExceptions);
    lblUncaughtExceptions.setText("Uncaught Exceptions:");
    fd_btnAdd.left = new FormAttachment(table_SeverityForUncaughtExceptionType, 6);
    btnAdd.setLayoutData(fd_btnAdd);
    btnAdd.setText("Add");

    Button btnEdit_2 = new Button(grpInitialSeverityLevels, SWT.NONE);
    FormData fd_btnEdit_2 = new FormData();
    fd_btnEdit_2.width = 60;
    fd_btnEdit_2.top = new FormAttachment(btnAdd, 6);
    fd_btnEdit_2.left = new FormAttachment(table_SeverityForUncaughtExceptionType, 6);
    btnEdit_2.setLayoutData(fd_btnEdit_2);
    btnEdit_2.setText("Edit");

    Button btnRemove_1 = new Button(grpInitialSeverityLevels, SWT.NONE);
    FormData fd_btnRemove_1 = new FormData();
    fd_btnRemove_1.width = 60;
    fd_btnRemove_1.top = new FormAttachment(btnEdit_2, 6);
    fd_btnRemove_1.left = new FormAttachment(table_SeverityForUncaughtExceptionType, 6);
    btnRemove_1.setLayoutData(fd_btnRemove_1);
    btnRemove_1.setText("Remove");

    Label lblSeverityForSpecific = new Label(grpInitialSeverityLevels, SWT.NONE);
    FormData fd_lblSeverityForSpecific = new FormData();
    fd_lblSeverityForSpecific.bottom =
        new FormAttachment(table_SeverityForUncaughtExceptionType, -8);
    fd_lblSeverityForSpecific.left =
        new FormAttachment(table_SeverityForUncaughtExceptionType, 0, SWT.LEFT);
    lblSeverityForSpecific.setLayoutData(fd_lblSeverityForSpecific);
    lblSeverityForSpecific.setText("Severity for specific uncaught exception types:");

    // set contents of group grpInitialSeverityLevels
    Group grpSeverityModifiersincrease = new Group(compositeInScrolledComposite, SWT.NONE);
    grpSeverityModifiersincrease.setText(
        "Severity Modifiers (Increase or Decrease Severity Levels)");
    grpSeverityModifiersincrease.setLayout(new FormLayout());
    FormData fd_grpSeverityModifiersincrease = new FormData();
    fd_grpSeverityModifiersincrease.right = new FormAttachment(0, 475);
    fd_grpSeverityModifiersincrease.top =
        new FormAttachment(grpInitialSeverityLevels, 6, SWT.BOTTOM);
    fd_grpSeverityModifiersincrease.left = new FormAttachment(0, 5);
    fd_grpSeverityModifiersincrease.right = new FormAttachment(100, -5);
    grpSeverityModifiersincrease.setLayoutData(fd_grpSeverityModifiersincrease);

    Combo combo_RuntimeExceptions = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_RuntimeExceptions = new FormData();
    fd_combo_RuntimeExceptions.top = new FormAttachment(0, 10);
    fd_combo_RuntimeExceptions.right = new FormAttachment(0, 500);
    combo_RuntimeExceptions.setLayoutData(fd_combo_RuntimeExceptions);

    Combo combo_TasksForUserDefinedTests = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_TasksForUserDefinedTests = new FormData();
    fd_combo_TasksForUserDefinedTests.top = new FormAttachment(combo_RuntimeExceptions, 6);
    fd_combo_TasksForUserDefinedTests.right =
        new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_TasksForUserDefinedTests.setLayoutData(fd_combo_TasksForUserDefinedTests);

    Label lblRuntimeExceptionsValidated = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblRuntimeExceptionsValidated = new FormData();
    fd_lblRuntimeExceptionsValidated.top = new FormAttachment(combo_RuntimeExceptions, 0, SWT.TOP);
    fd_lblRuntimeExceptionsValidated.left = new FormAttachment(0, 10);
    lblRuntimeExceptionsValidated.setLayoutData(fd_lblRuntimeExceptionsValidated);
    lblRuntimeExceptionsValidated.setText("Runtime exceptions validated by BugDetective:");

    Combo combo_ExceptionDeclaredInThrows = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_ExceptionDeclaredInThrows = new FormData();
    fd_combo_ExceptionDeclaredInThrows.top = new FormAttachment(combo_TasksForUserDefinedTests, 6);
    fd_combo_ExceptionDeclaredInThrows.left =
        new FormAttachment(combo_RuntimeExceptions, 0, SWT.LEFT);
    combo_ExceptionDeclaredInThrows.setLayoutData(fd_combo_ExceptionDeclaredInThrows);

    Combo combo_DuplicateExceptions = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_DuplicateExceptions = new FormData();
    fd_combo_DuplicateExceptions.top = new FormAttachment(combo_ExceptionDeclaredInThrows, 6);
    fd_combo_DuplicateExceptions.left = new FormAttachment(combo_RuntimeExceptions, 0, SWT.LEFT);
    combo_DuplicateExceptions.setLayoutData(fd_combo_DuplicateExceptions);

    Combo combo_ExceptionsThrownByCode = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_ExceptionsThrownByCode = new FormData();
    fd_combo_ExceptionsThrownByCode.top = new FormAttachment(combo_DuplicateExceptions, 6);
    fd_combo_ExceptionsThrownByCode.left = new FormAttachment(combo_RuntimeExceptions, 0, SWT.LEFT);
    combo_ExceptionsThrownByCode.setLayoutData(fd_combo_ExceptionsThrownByCode);

    Combo combo_NullPointerORPreExceptionFromTestInput =
        new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_NullPointerORPreExceptionFromTestInput = new FormData();
    fd_combo_NullPointerORPreExceptionFromTestInput.top =
        new FormAttachment(combo_ExceptionsThrownByCode, 6);
    fd_combo_NullPointerORPreExceptionFromTestInput.right =
        new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_NullPointerORPreExceptionFromTestInput.setLayoutData(
        fd_combo_NullPointerORPreExceptionFromTestInput);

    Combo combo_TaskForPblicMethod = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_TaskForPblicMethod = new FormData();
    fd_combo_TaskForPblicMethod.top =
        new FormAttachment(combo_NullPointerORPreExceptionFromTestInput, 6);
    fd_combo_TaskForPblicMethod.right = new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_TaskForPblicMethod.setLayoutData(fd_combo_TaskForPblicMethod);

    Combo combo_TaskForMethodStub = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_TaskForMethodStub = new FormData();
    fd_combo_TaskForMethodStub.top = new FormAttachment(combo_TaskForPblicMethod, 6);
    fd_combo_TaskForMethodStub.right = new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_TaskForMethodStub.setLayoutData(fd_combo_TaskForMethodStub);

    Combo combo_TaskUnverified = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_TaskUnverified = new FormData();
    fd_combo_TaskUnverified.top = new FormAttachment(combo_TaskForMethodStub, 6);
    fd_combo_TaskUnverified.right = new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_TaskUnverified.setLayoutData(fd_combo_TaskUnverified);

    Combo combo_SensitiveMethodException = new Combo(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_combo_SensitiveMethodException = new FormData();
    fd_combo_SensitiveMethodException.top = new FormAttachment(combo_TaskUnverified, 6);
    fd_combo_SensitiveMethodException.right =
        new FormAttachment(combo_RuntimeExceptions, 0, SWT.RIGHT);
    combo_SensitiveMethodException.setLayoutData(fd_combo_SensitiveMethodException);

    Label lblExceptionsFromSensitive = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblExceptionsFromSensitive = new FormData();
    fd_lblExceptionsFromSensitive.top =
        new FormAttachment(combo_SensitiveMethodException, 0, SWT.TOP);
    fd_lblExceptionsFromSensitive.left =
        new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblExceptionsFromSensitive.setLayoutData(fd_lblExceptionsFromSensitive);
    lblExceptionsFromSensitive.setText("Exceptions from sensitive methods:");

    Label lblUnverifiedTasks = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblUnverifiedTasks = new FormData();
    fd_lblUnverifiedTasks.top = new FormAttachment(combo_TaskUnverified, 0, SWT.TOP);
    fd_lblUnverifiedTasks.left = new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblUnverifiedTasks.setLayoutData(fd_lblUnverifiedTasks);
    lblUnverifiedTasks.setText("Unverified Tasks:");

    Label lblTasksForMethods = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblTasksForMethods = new FormData();
    fd_lblTasksForMethods.top = new FormAttachment(combo_TaskForMethodStub, 0, SWT.TOP);
    fd_lblTasksForMethods.left = new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblTasksForMethods.setLayoutData(fd_lblTasksForMethods);
    lblTasksForMethods.setText("Tasks for methods with stubs:");

    Label lblTasksForPublic = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblTasksForPublic = new FormData();
    fd_lblTasksForPublic.top = new FormAttachment(combo_TaskForPblicMethod, 0, SWT.TOP);
    fd_lblTasksForPublic.left = new FormAttachment(0, 10);
    lblTasksForPublic.setLayoutData(fd_lblTasksForPublic);
    lblTasksForPublic.setText("Tasks for public methods:");

    Label lblDirectNullpointerexceptionsOr = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblDirectNullpointerexceptionsOr = new FormData();
    fd_lblDirectNullpointerexceptionsOr.top =
        new FormAttachment(combo_NullPointerORPreExceptionFromTestInput, 0, SWT.TOP);
    fd_lblDirectNullpointerexceptionsOr.left =
        new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblDirectNullpointerexceptionsOr.setLayoutData(fd_lblDirectNullpointerexceptionsOr);
    lblDirectNullpointerexceptionsOr.setText(
        "Direct NullPointerExceptions or PreExceptions from test input:");

    Label lblExceptionsExplicitlyThrown = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblExceptionsExplicitlyThrown = new FormData();
    fd_lblExceptionsExplicitlyThrown.top =
        new FormAttachment(combo_ExceptionsThrownByCode, 0, SWT.TOP);
    fd_lblExceptionsExplicitlyThrown.left = new FormAttachment(0, 10);
    lblExceptionsExplicitlyThrown.setLayoutData(fd_lblExceptionsExplicitlyThrown);
    lblExceptionsExplicitlyThrown.setText("Exceptions explicitly thrown by the tested code:");

    Label lblDuplicateExceptions = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblDuplicateExceptions = new FormData();
    fd_lblDuplicateExceptions.top = new FormAttachment(combo_DuplicateExceptions, 0, SWT.TOP);
    fd_lblDuplicateExceptions.left = new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblDuplicateExceptions.setLayoutData(fd_lblDuplicateExceptions);
    lblDuplicateExceptions.setText("Duplicate exceptions:");

    Label lblExceptionDeclaredIn = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblExceptionDeclaredIn = new FormData();
    fd_lblExceptionDeclaredIn.top = new FormAttachment(combo_ExceptionDeclaredInThrows, 0, SWT.TOP);
    fd_lblExceptionDeclaredIn.left = new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblExceptionDeclaredIn.setLayoutData(fd_lblExceptionDeclaredIn);
    lblExceptionDeclaredIn.setText("Exception declared in throws clause or @throws:");

    Label lblTasksForUser = new Label(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_lblTasksForUser = new FormData();
    fd_lblTasksForUser.top = new FormAttachment(combo_TasksForUserDefinedTests, 0, SWT.TOP);
    fd_lblTasksForUser.left = new FormAttachment(lblRuntimeExceptionsValidated, 0, SWT.LEFT);
    lblTasksForUser.setLayoutData(fd_lblTasksForUser);
    lblTasksForUser.setText("Tasks for user defined tests:");

    table_SensitiveMethods =
        new Table(grpSeverityModifiersincrease, SWT.BORDER | SWT.FULL_SELECTION);
    FormData fd_table_SensitiveMethods = new FormData();
    fd_table_SensitiveMethods.height = 200;
    fd_table_SensitiveMethods.top = new FormAttachment(lblExceptionsFromSensitive, 15);
    fd_table_SensitiveMethods.right = new FormAttachment(0, 430);
    fd_table_SensitiveMethods.left = new FormAttachment(0, 39);
    table_SensitiveMethods.setLayoutData(fd_table_SensitiveMethods);
    table_SensitiveMethods.setHeaderVisible(true);
    table_SensitiveMethods.setLinesVisible(true);

    TableColumn tblclmnNamesOfSensitive = new TableColumn(table_SensitiveMethods, SWT.NONE);
    tblclmnNamesOfSensitive.setWidth(183);
    tblclmnNamesOfSensitive.setText("Names of sensitive methods");

    Button btnAddSensitiveMethod = new Button(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_btnAddSensitiveMethod = new FormData();
    fd_btnAddSensitiveMethod.width = 60;
    fd_btnAddSensitiveMethod.top = new FormAttachment(table_SensitiveMethods, 0, SWT.TOP);
    fd_btnAddSensitiveMethod.left = new FormAttachment(table_SensitiveMethods, 6);
    btnAddSensitiveMethod.setLayoutData(fd_btnAddSensitiveMethod);
    btnAddSensitiveMethod.setText("Add");

    Button btnRemoveSensitiveMethod = new Button(grpSeverityModifiersincrease, SWT.NONE);
    FormData fd_btnRemoveSensitiveMethod = new FormData();
    fd_btnRemoveSensitiveMethod.width = 60;
    fd_btnRemoveSensitiveMethod.top = new FormAttachment(btnAddSensitiveMethod, 6, SWT.BOTTOM);
    fd_btnRemoveSensitiveMethod.left = new FormAttachment(btnAddSensitiveMethod, 0, SWT.LEFT);
    btnRemoveSensitiveMethod.setLayoutData(fd_btnRemoveSensitiveMethod);
    btnRemoveSensitiveMethod.setText("Remove");

    scrolledComposite.setContent(compositeInScrolledComposite);
    scrolledComposite.setMinSize(
        compositeInScrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
  @Override
  public void createPartControl(Composite parent) {
    // TODO Auto-generated method stub
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText("MetaData Editor:");

    toolkit.decorateFormHeading(form);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.minimumWidth = 200;
    //		FormLayout gridLayout = new FormLayout();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 5;
    form.getBody().setLayout(gridLayout);

    FormData formDate = new FormData();
    formDate.height = 250;
    formDate.width = 300;

    FormData formDate0 = new FormData();
    formDate0.height = 150;
    formDate0.width = 300;
    FormData formDate2 = new FormData();
    formDate2.height = 550;
    formDate2.width = 550;

    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Attribute Modifier");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new FormLayout());
    section.setClient(sectionClient);

    GridData gridData2 = new GridData();
    gridData2.verticalSpan = 2;
    section.setLayoutData(gridData2);

    Section section2 = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section2.setText("Collector");
    Composite sectionClient2 = toolkit.createComposite(section2);
    sectionClient2.setLayout(new FormLayout());
    section2.setClient(sectionClient2);

    Section section3 = toolkit.createSection(form.getBody(), Section.TITLE_BAR); // printStackTrace
    section3.setText("Collection Code");
    Composite sectionClient3 = toolkit.createComposite(section3);
    sectionClient3.setLayout(new FormLayout());
    section3.setClient(sectionClient3);

    final Table table2 =
        toolkit.createTable(
            sectionClient2, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table2.setHeaderVisible(true);

    final Button submitCollectionCode = toolkit.createButton(sectionClient2, "submit", SWT.None);

    TableColumn column01 = new TableColumn(table2, SWT.NONE);
    column01.setWidth(25);
    column01.setText("#");
    TableColumn column02 = new TableColumn(table2, SWT.NONE);
    column02.setWidth(100);
    column02.setText("Name");
    TableColumn column03 = new TableColumn(table2, SWT.NONE);
    column03.setWidth(100);
    column03.setText("Collection No");
    table2.setLayoutData(formDate);
    int index = 1;
    for (SpecCollectorMap map : spec.getSpecCollectorMaps()) {
      Collector c = map.getCollector();
      TableItem item = new TableItem(table2, SWT.FULL_SELECTION);
      item.setData("collector", c);
      item.setText(0, index + "");
      index++;
      item.setText(1, c.getCollectorFullName()); // c.exe
      if (spec.getRecordNumber() == null) {
        item.setText(2, "");
      } else item.setText(2, spec.getRecordNumber());

      table2.setSelection(index);
    }

    table2.addListener(
        SWT.MouseDoubleClick,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            int ret;
            for (final TableItem item : table2.getItems()) {

              for (int i = 0; i < table2.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Collector c = (Collector) item.getData("collector");
                  CollectorModDialog dialog =
                      new CollectorModDialog(Display.getDefault().getActiveShell(), c);
                  ret = dialog.open();
                }
              }
            }
          }
        });
    final Table table3 =
        toolkit.createTable(
            sectionClient3, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table3.setHeaderVisible(true);

    TableColumn column31 = new TableColumn(table3, SWT.NONE);
    column31.setWidth(25);
    column31.setText("#");
    TableColumn column32 = new TableColumn(table3, SWT.NONE);
    column32.setWidth(50);
    column32.setText("Collection Code");
    TableColumn column33 = new TableColumn(table3, SWT.NONE);
    column33.setWidth(150);
    column33.setText("Collection Info");
    table3.setLayoutData(formDate0);

    Collection ccc = this.spec.getCollection();

    TableItem item31 = new TableItem(table3, SWT.NONE);
    item31.setText(0, "1");
    if (ccc != null) {
      if (ccc.getCollectionCode() == null) ccc.setCollectionCode("");
      if (ccc.getCollectionInfo() == null) ccc.setCollectionInfo("");
      item31.setText(1, ccc.getCollectionCode());
      item31.setText(2, ccc.getCollectionInfo());
    }

    final TableEditor collectionEditor = new TableEditor(table3);
    collectionEditor.horizontalAlignment = SWT.LEFT;
    collectionEditor.grabHorizontal = true;
    collectionEditor.minimumWidth = 50;
    collectionSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = collectionEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    table3.addSelectionListener(collectionSelectionListener);
    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {}
            }
          }
        };

    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table3.getItems()) {

              for (int i = 0; i < table3.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Control oldEditor = collectionEditor.getEditor();
                  if (oldEditor != null) oldEditor.dispose();

                  final Combo newEditor = new Combo(table3, SWT.NONE);
                  DataUtilsService service = new DataUtilsService();
                  DataUtilsDelegate delegate = service.getDataUtilsPort();
                  final List<Collection> collections = delegate.getCollections();
                  for (Collection col : collections) {
                    newEditor.add(col.getCollectionCode());
                  }

                  newEditor.addDisposeListener(
                      new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e) {
                          // TODO Auto-generated method stub
                          Combo combo = (Combo) collectionEditor.getEditor();
                          Collection collection = collections.get(combo.getSelectionIndex());
                          collectionEditor.getItem().setText(1, collection.getCollectionCode());
                          collectionEditor.getItem().setText(2, collection.getCollectionInfo());
                          collectionEditor
                              .getItem()
                              .setBackground(new Color(Display.getCurrent(), 255, 250, 160));

                          String methodName = (String) item.getData();
                        }
                      });

                  newEditor.setFocus();
                  collectionEditor.setEditor(newEditor, item, 1);
                }
              }
            }
          }
        };
    table3.addListener(SWT.MouseDoubleClick, tableListener2);

    final Table table =
        toolkit.createTable(sectionClient, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLayoutData(formDate2);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Name");
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(250);
    column2.setText("Data");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(100);

    //		table.setLayoutData(gridData);
    /*
    		final TableItem itemName = new TableItem(table,SWT.NONE);
    		itemName.setText(0,"Scientific Name:");
    		final TableItem itemFamily = new TableItem(table, SWT.NONE);
    		itemFamily.setText(0, "Family:");
    		itemFamily.setData("setFamily");
    		final TableItem itemGenus = new TableItem(table, SWT.NONE);
    		itemGenus.setText(0, "Genus:");
    		itemGenus.setData("setGenus");
    		final TableItem itemSpecies = new TableItem(table, SWT.NONE);
    		itemSpecies.setText(0, "Species:");
    		itemSpecies.setData("setSpecies");
    		final TableItem itemCollectAt = new TableItem(table, SWT.NONE);
    		itemCollectAt.setText(0, "Collect At:");
    		itemCollectAt.setData("setCountry");
    		final TableItem itemCollectAtDarwin = new TableItem(table, SWT.NONE);
    		itemCollectAtDarwin.setText(0, "Name in Darwin's time:");
    		itemCollectAtDarwin.setData("setDcountry");
    		final TableItem itemSheetNote = new TableItem(table, SWT.NONE);
    		itemSheetNote.setText(0, "Sheet Notes:");
    		itemSheetNote.setData("setSheetNotes");
    		final TableItem itemState = new TableItem(table, SWT.NONE);
    		itemState.setText(0, "State:");
    		itemState.setData("setStateProvince");
    		final TableItem itemTown = new TableItem(table, SWT.NONE);
    		itemTown.setText(0, "Town:");
    		itemTown.setData("setTown");


    		itemName.setText(1,spec.getScientificName());
    		itemFamily.setText(1, spec.getFamily());
    		itemGenus.setText(1, spec.getGenus());
    		itemSpecies.setText(1, spec.getSpecificEpithet());
    		itemCollectAt.setText(1, spec.getCountry());
    		itemCollectAtDarwin.setText(1, spec.getDarwinCountry());
    		itemSheetNote.setText(1, spec.getSheetNotes());
    		itemState.setText(1, spec.getStateProvince());
    		itemTown.setText(1, spec.getTown());
    */

    try {
      Element root = this.configXml.selectElement("system/editor");
      for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        if (root.getChildNodes().item(i).getNodeType() == Element.ELEMENT_NODE) {
          Element child = (Element) root.getChildNodes().item(i);
          System.out.println("child name = " + child.getAttribute("field"));
          if (child.getAttribute("display").equals("true")) {
            final TableItem itemName = new TableItem(table, SWT.NONE);
            System.out.println(itemName);
            itemName.setData("set" + child.getAttribute("field"));
            itemName.setData("editable", child.getAttribute("editable"));
            itemName.setData("type", child.getAttribute("type"));
            itemName.setText(0, child.getAttribute("name"));
            if (child.getAttribute("field").equals("RecordNumber")) {
              System.out.println(child.getAttribute("editable"));
            }
            Method m;

            try {
              m = spec.getClass().getMethod("get" + child.getAttribute("field"));
              System.out.println("function name = " + m.getName());
              if (child.getAttribute("type").equals("date")) {
                XMLGregorianCalendar cal = (XMLGregorianCalendar) m.invoke(spec);

                String calstr = "";
                if (cal != null) {
                  calstr = cal.toString();
                  itemName.setText(1, calstr);
                  itemName.setData("date", cal);
                }
              } else if (child.getAttribute("type").equals("string")) {
                String str = (String) m.invoke(spec);
                if (str == null) {
                  str = "";
                }
                itemName.setText(1, str);
              } else if (child.getAttribute("type").equals("int")) {
                Integer inte = (Integer) m.invoke(spec);
                itemName.setText(1, inte + "");
              }
            } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              System.out.println("field==" + child.getAttribute("field"));
              //						e.printStackTrace();
            } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (XmlToolException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    final Button submitButton = toolkit.createButton(form.getBody(), "submit", SWT.None);
    submitButton.setEnabled(false);
    final Label label2 = new Label(form.getBody(), SWT.NONE);
    label2.setData("name", "label2");
    label2.setText("Modification Save Successfully");
    label2.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label2.setForeground(new Color(Display.getCurrent(), 0, 128, 64));
    label2.setVisible(false);

    final Label label3 = new Label(form.getBody(), SWT.NONE);
    label3.setData("name", "label2");
    label3.setText("Modification Save Error!");
    label3.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label3.setForeground(new Color(Display.getCurrent(), 128, 0, 0));
    label3.setVisible(false);

    final Label label4 = new Label(form.getBody(), SWT.NONE);
    label4.setData("name", "label4");
    label4.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label4.setForeground(new Color(Display.getCurrent(), 200, 0, 0));
    label4.setVisible(false);

    final TableEditor edit = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    edit.horizontalAlignment = SWT.LEFT;
    edit.grabHorizontal = true;
    edit.minimumWidth = 50;
    // editing the second column
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };
    table.addSelectionListener(tableSelectionListener);
    tableListener =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {
                for (int i = 0; i < table.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    Control oldEditor = editor.getEditor();
                    if (oldEditor != null) oldEditor.dispose();

                    if (item.getData("type").equals("int")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {Integer.parseInt(text.getText())});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    }

                    if (item.getData("type").equals("string")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {text.getText()});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    } else if (item.getData("type").equals("date")) {
                      CalendarCombo calendar = new CalendarCombo(table, SWT.CALENDAR);
                      XMLGregorianCalendar cal = (XMLGregorianCalendar) item.getData("date");
                      if (cal == null) {
                        calendar.setDate(new Date(System.currentTimeMillis()));
                      } else {
                        GregorianCalendar ca = cal.toGregorianCalendar();
                        calendar.setDate(ca.getTime());
                      }
                      //
                      calendar.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              CalendarCombo cc = (CalendarCombo) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, cc.getDateAsString());

                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(cc.getDate().getTime());
                                    XMLGregorianCalendar date2 =
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
                                    m.invoke(spec, new Object[] {date2});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (DatatypeConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });

                      calendar.setFocus();
                      editor.setEditor(calendar, item, EDITABLECOLUMN);
                      break;
                    }
                  }
                } // for
              }
            }
          }
        };
    table.addListener(SWT.MouseDoubleClick, tableListener);
    submitButton.setLayoutData(gridData);
    buttonSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              //					Specimen speca = null;
              //					for(IWorkbenchPage p : pages){
              //						IViewReference ivrs [] = p.getViewReferences();
              //						for(IViewReference ivr : ivrs){
              //							if(ivr.getId().equals("TestView.view")){
              //								View v = (View)ivr.getView(true);
              //								speca = v.getGallery().getSelection()[0].getData("spec", spec);
              //								if(spec.getMissingInfo()==0){
              //									v.getGallery().getSelection()[0].setBackground(new
              // Color(Display.getCurrent(), 255,255,255));
              //								}
              //								break;
              //							}
              //						}
              //					}
              DataUtilsService service = new DataUtilsService(); // Missing
              DataUtilsDelegate delegate = service.getDataUtilsPort();
              //					Specimen ss = delegate.getSpecimenById(spec.getSpecimenId());//getView

              List<SpecCollectorMap> scms = delegate.getScms(spec.getSpecimenId());
              //					System.out.println(ss.getSpecimenId()+"***"+scms.size());
              if (spec == null) {
                System.out.println("NULL ID!");
              }
              if (scms == null) {
                System.out.println("NULL SCMS!");
              }
              String scmIds = "";
              int index = 0;
              for (SpecCollectorMap scm : scms) {
                if (index == 0) {
                  scmIds += scm.getSpecCollectorMapId();
                } else {
                  scmIds += ("-" + scm.getSpecCollectorMapId());
                }
                index++;
              }
              System.out.println("scmIds = " + scmIds);
              System.out.println("specimen Id = " + spec.getSpecimenId());
              if (scmIds.equals("")) scmIds = "0";
              Specimen updatedSpecimen = delegate.updateSpecimen(spec, scmIds);
              for (TableItem item : table.getItems()) {
                item.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                submitButton.setEnabled(false);
              }
              IWorkbenchPage pages[] = getEditorSite().getWorkbenchWindow().getPages();
              for (IWorkbenchPage p : pages) {
                IViewReference ivrs[] = p.getViewReferences();
                for (IViewReference ivr : ivrs) {
                  if (ivr.getId().equals("TestView.view")) {
                    View v = (View) ivr.getView(true);
                    v.getGallery().getSelection()[0].setData(updatedSpecimen);
                    if (spec.getMissingInfo() == 0) {
                      v.getGallery()
                          .getSelection()[0]
                          .setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                    }
                    spec = updatedSpecimen;
                    break;
                  }
                }
              }
              label2.setVisible(true);
              label3.setVisible(false);
              label4.setVisible(false);
            } catch (Exception e) {
              label2.setVisible(false);
              label3.setVisible(true);
              //					label4.setText(e.getMessage());
              label4.setVisible(true);
              e.printStackTrace();
            }
          }
        }; // scientific name inserting
    submitButton.addSelectionListener(buttonSelectionListener);
    System.out.println(Platform.getInstallLocation().getURL().getPath());
    System.out.println(Platform.getInstanceLocation().getURL().getPath());
    Image image = ImageFactory.loadImage(Display.getCurrent(), ImageFactory.ACTION_SYNC);
    IStatusLineManager manager = this.getEditorSite().getActionBars().getStatusLineManager();
    Action toggleBotton =
        new SyncIDropAction("Sync with iDrop", ImageDescriptor.createFromImage(image), manager);
    if (spec.getIdropSync() == null || spec.getIdropSync() == 0) {
      toggleBotton.setEnabled(true);
    } else toggleBotton.setEnabled(true);
    form.getToolBarManager().add(toggleBotton);
    form.getToolBarManager().update(true);
  }
  /* very similar to the setupUI of the parent class GroupPanel, with only a few exceptions:
   * 	1. No close button. (Users cannot remove this time-anchoring group)
   *  2. Timing is restricted to "time-anchoring observations"
   *  3. No Timing widget
   *  4. Title is not Group 1
   */
  protected void setupUI() {
    this.setLayout(new FormLayout());

    Point singleCharSize = UIUtils.getDefaultCharSize(this);

    // set up title
    titleComp = new Composite(this, SWT.NONE);
    titleComp.setLayout(new FormLayout());
    FormData titleCompFD = FormDataMaker.makeFormData(0, (Integer) null, 0, 100);
    titleComp.setLayoutData(titleCompFD);

    titleLabel = new Label(titleComp, SWT.None);
    titleLabel.setText(ANCHOR_GROUP_NAME);
    Point titleSize = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    titleLabel.setLayoutData(
        FormDataMaker.makeFormData(
            50, -titleSize.y / 2, (Integer) null, 0, 0, 0, myNumberDisplay, 0));

    titleComp.setBackground(Colors.CONTROL_TITLE_BG);
    titleLabel.setBackground(Colors.CONTROL_TITLE_BG);
    titleLabel.setForeground(Colors.CONTROL_TITLE_FG);

    // adjust title height to the button height
    if (!QueryToolRuntime.getInstance().isTitleHeightSet()) {
      if (QueryToolRuntime.getInstance().isLaunchedFromWorkbench())
        QueryToolRuntime.getInstance()
            .setGroupTitleHeight(
                Math.max(
                    MINOR_TITLE_HEIGHT, this.myCloseLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y));
      else titleCompFD.height = Math.max(MINOR_TITLE_HEIGHT, DEFAULT_TITLE_HEIGHT);
    } else
      titleCompFD.height =
          UIUtils.computeButtonSizeOffScreen(
                  this,
                  null,
                  PlatformUI.getWorkbench()
                      .getSharedImages()
                      .getImage(ISharedImages.IMG_ETOOL_DELETE))
              .y;

    // set up date constraint Display and Number of Occurrence display
    myNumberDisplay = new NumberConstraintDisplay(titleComp, myGroup, SWT.None);
    FormData numberDisplayFD = FormDataMaker.makeFormData(0, 0, 100, 0, (Integer) null, 0, 100, 0);
    numberDisplayFD.width = NUM_CHARS_IN_NUMBER_DISPLAY * singleCharSize.x;
    myNumberDisplay.setLayoutData(numberDisplayFD);

    myDateDisplay = new SkinnyDateConstraintDisplay(titleComp, myGroup, SWT.None);
    FormData dateDisplayFD =
        FormDataMaker.makeFormData(0, 0, 100, 0, (Integer) null, 0, myNumberDisplay, 1);
    dateDisplayFD.width = NUM_CHARS_IN_DATE_DISPLAY * singleCharSize.x;
    myDateDisplay.setLayoutData(dateDisplayFD);
    myDateDisplay.setActive(true);

    /*
    myBindingDisplay = new GroupBindingDisplayForTemporalEventAnchor( titleComp, SWT.NONE, this.myGroup );
    	FormData bindingDisplayFD 		= FormDataMaker.makeFormData( 0, 0, 100, 0, (Integer)null, 0, myDateDisplay, 1);
    myBindingDisplay.setLayoutData( bindingDisplayFD );
    myBindingDisplay.setActive( true );
    */

    // add this as Displays' VisualActivationListener so that when a Display is clicked, it stays
    // 'activated'
    myNumberDisplay.addVisualActivationListener(this);
    myDateDisplay.addVisualActivationListener(this);
    // myBindingDisplay.addVisualActivationListener( this );

    myMainComposite = new Composite(this, SWT.NONE);
    myMainComposite.setLayout(new FormLayout());
    myMainComposite.setLayoutData(FormDataMaker.makeFormData(titleComp, 100, 0, 100));
    myMainComposite.setBackground(Colors.WHITE);

    // label and viewerComposite occupy the same space.
    // myPreTreeLabel = new Label( myMainComposite, SWT.CENTER | SWT.WRAP );
    // myPreTreeLabel.setText( DRAG_ONLOTOGY_TERMS_HERE );

    ArrayList<Object> contents = new ArrayList<Object>();
    contents.add(DRAG_ONLOTOGY_TERMS_HERE1);

    myPreTreeLabel =
        new MixedTextIconPanel(
            myMainComposite, SWT.CENTER | SWT.WRAP, contents, Colors.GRAY, Colors.WHITE);
    Point labelSize = myPreTreeLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // myPreTreeLabel.setLayoutData( FormDataMaker.makeFormData( (Integer)null, 0, 100, -4, 20, 0,
    // 80, 0));
    myPreTreeLabel.setLayoutData(
        FormDataMaker.makeFormData(
            50, -labelSize.y / 2, (Integer) null, 0, 50, -labelSize.x / 2, (Integer) null, 0));

    myViewerComposite = new Composite(myMainComposite, SWT.NONE);
    myViewerComposite.setLayout(new FormLayout());
    myViewerComposite.setLayoutData(FormDataMaker.makeFullFormData());

    myTreeViewer = new TreeViewer(myViewerComposite, SWT.VIRTUAL | SWT.H_SCROLL | SWT.V_SCROLL);
    myTreeViewer.getTree().setLayoutData(FormDataMaker.makeFullFormData());

    // initialize visibility of treeviewer and label
    myPreTreeLabel.setVisible(true);
    myViewerComposite.setVisible(false);

    myTreeViewer.setContentProvider(new GroupPanelConceptContentProvider());
    myTreeViewer.setLabelProvider(new GroupPanelConceptLabelProvider());
    myTreeViewer.setInput(myGroup.getTreeData());

    ColumnViewerToolTipSupport.enableFor(myTreeViewer);
  }
  private void drawWindow() {
    shell =
        new Shell(SWT.ON_TOP | SWT.APPLICATION_MODAL | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);

    // Setup Title
    shell.setText("Artifact Information");

    // Setup Icon
    Image image = ArtifactImageManager.getImage(CoreArtifactTypes.Artifact);
    shell.setImage(image);

    // Setup Form Layout
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    shell.setLayout(layout);

    SashForm sashForm = new SashForm(shell, SWT.VERTICAL);

    // Create valid artifact fields
    FormLayout validLayout = new FormLayout();
    validLayout.spacing = 5;

    Composite validComposite = new Composite(sashForm, SWT.NONE);
    validComposite.setLayout(validLayout);

    Label validLabel = new Label(validComposite, SWT.LEFT);
    validLabel.setText("Valid artifacts - will be added");

    Table validTable =
        new Table(
            validComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    validTable.setLinesVisible(true);
    validTable.setHeaderVisible(true);

    // Create invalid artifacts fields
    FormLayout invalidLayout = new FormLayout();
    invalidLayout.spacing = 5;

    Composite invalidComposite = new Composite(sashForm, SWT.NONE);
    invalidComposite.setLayout(invalidLayout);

    Label invalidLabel = new Label(invalidComposite, SWT.LEFT);
    invalidLabel.setText("Invalid artifacts - will not be added");

    Table invalidTable =
        new Table(
            invalidComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    invalidTable.setLinesVisible(true);
    invalidTable.setHeaderVisible(true);

    // Create the Buttons
    Button okButton = new Button(invalidComposite, SWT.PUSH);
    okButton.setText("OK");

    Button cancelButton = new Button(invalidComposite, SWT.PUSH);
    cancelButton.setText("Cancel");

    // Attach validLabel to top-left corner
    FormData data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    validLabel.setLayoutData(data);

    // Attach validTable to bottom of validLabel
    data = new FormData();
    data.top = new FormAttachment(validLabel);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    validTable.setLayoutData(data);

    // Attach invalidLabel to top-left corner
    data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    invalidLabel.setLayoutData(data);

    // Attach invalidTable to bottom of invalidLabel
    data = new FormData();
    data.top = new FormAttachment(invalidLabel);
    data.bottom = new FormAttachment(okButton);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    invalidTable.setLayoutData(data);

    // Attach sashForm to top-left corner of shell
    data = new FormData();
    data.top = new FormAttachment(0);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    sashForm.setLayoutData(data);

    // Attach buttons to bottom of sashForm
    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(100);
    cancelButton.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(cancelButton);
    okButton.setLayoutData(data);

    // Populate Tables
    relationTableViewer = new RelationTableViewer(validTable, invalidTable, branch);
    for (int i = 0; i < validArtifacts.size(); i++) {
      relationTableViewer.addValidItem(validArtifacts.get(i));
    }
    for (int i = 0; i < invalidName.size(); i++) {
      relationTableViewer.addInvalidItem(invalidName.get(i), invalidReason.get(i));
    }

    // Add Listeners to buttons
    okButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            okSelected();
          }
        });

    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            cancelSelected();
          }
        });

    // Add shell resize listener
    shell.addControlListener(
        new ControlListener() {

          @Override
          public void controlMoved(ControlEvent e) {
            // do nothing
          }

          @Override
          public void controlResized(ControlEvent e) {
            relationTableViewer.resizeTable(((Shell) e.widget).getClientArea().width);
            shell.layout();
          }
        });

    if (needWindow) {
      shell.pack();
      shell.open();
    } else {
      okSelected();
    }
  }
示例#28
0
  /** Set the layout of widgets depending on whether the details are being shown or not. */
  protected void setLayout() {
    // error icon
    FormData data = new FormData();
    data.top = new FormAttachment(0, Settings.MARGIN_TOP);
    data.left = new FormAttachment(0, Settings.MARGIN_LEFT);
    data.height = 32;
    data.width = 32;
    errorIcon.setLayoutData(data);

    if (showDetails) {
      Point curSL;

      // error message label
      curSL = errorMessage.getSize();
      data = new FormData();
      data.top = new FormAttachment(0, Settings.MARGIN_TOP);
      data.left = new FormAttachment(0, Settings.MARGIN_LEFT + 32 + Settings.ITEM_SPACING_H);
      data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
      data.height = curSL.y;
      errorMessage.setLayoutData(data);
      // the OK button
      data = new FormData();
      curSL = okButton.getLocation();
      data.top = new FormAttachment(0, curSL.y);
      data.right =
          new FormAttachment(
              100, -Settings.MARGIN_RIGHT - Settings.BUTTON_WIDTH - Settings.ITEM_SPACING_H);
      data.height = Settings.BUTTON_HEIGHT;
      data.width = Settings.BUTTON_WIDTH;
      okButton.setLayoutData(data);
      // the Details button
      data = new FormData();
      curSL = okButton.getLocation();
      data.top = new FormAttachment(0, curSL.y);
      data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
      data.height = Settings.BUTTON_HEIGHT;
      data.width = Settings.BUTTON_WIDTH;
      detailsButton.setLayoutData(data);

      // stack trace
      data = new FormData();
      curSL = okButton.getLocation();
      data.top = new FormAttachment(0, curSL.y + Settings.BUTTON_HEIGHT + Settings.ITEM_SPACING_V);
      data.left = new FormAttachment(0, Settings.MARGIN_LEFT);
      data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
      data.bottom = new FormAttachment(100, -Settings.MARGIN_BOTTOM);
      stackTrace.setLayoutData(data);

      // if details have been switched on increase the window height
      if (detailsSwitched) {
        curSL = shell.getSize();
        shell.setSize(curSL.x, curSL.y + detailsHeight + Settings.ITEM_SPACING_V);
      }
    } else {
      // if details have been switched off, decrease the window height
      if (detailsSwitched) {
        // remember last stack trace window height
        detailsHeight = stackTrace.getSize().y;

        Point curSL = shell.getSize();
        shell.setSize(curSL.x, curSL.y - detailsHeight - Settings.ITEM_SPACING_V);
      }

      // error message label
      data = new FormData();
      data.top = new FormAttachment(0, Settings.MARGIN_TOP);
      data.left = new FormAttachment(0, Settings.MARGIN_LEFT + 32 + Settings.ITEM_SPACING_H);
      data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
      data.bottom =
          new FormAttachment(
              100 - Settings.MARGIN_BOTTOM - Settings.BUTTON_HEIGHT - Settings.ITEM_SPACING_V);
      errorMessage.setLayoutData(data);
      // the OK button
      data = new FormData();
      data.bottom = new FormAttachment(100, -Settings.MARGIN_BOTTOM);
      data.right =
          new FormAttachment(
              100, -Settings.MARGIN_RIGHT - Settings.BUTTON_WIDTH - Settings.ITEM_SPACING_H);
      data.height = Settings.BUTTON_HEIGHT;
      data.width = Settings.BUTTON_WIDTH;
      okButton.setLayoutData(data);
      // the Details button
      data = new FormData();
      data.bottom = new FormAttachment(100, -Settings.MARGIN_BOTTOM);
      data.right = new FormAttachment(100, -Settings.MARGIN_RIGHT);
      data.height = Settings.BUTTON_HEIGHT;
      data.width = Settings.BUTTON_WIDTH;
      detailsButton.setLayoutData(data);
      // stack trace (hidden)
      data = new FormData();
      data.top = new FormAttachment(100, 1);
      data.height = detailsHeight;
      stackTrace.setLayoutData(data);
    }
  }
  private Button createPerspectiveButton(final IPerspectiveDescriptor desc) {

    Button result = (Button) perspectiveButtonMap.get(desc);
    if (result == null && desc != null && desc.getLabel() != null) {
      Composite buttonBg = new Composite(background, SWT.NONE);
      buttonBg.setBackground(Graphics.getColor(247, 247, 247));
      buttonBg.setLayout(new FormLayout());

      Label leftBg = new Label(buttonBg, SWT.NONE);
      leftBg.setImage(left);
      FormData fdLeftBg = new FormData();
      leftBg.setLayoutData(fdLeftBg);
      fdLeftBg.top = new FormAttachment(0);
      fdLeftBg.left = new FormAttachment(0);
      fdLeftBg.height = left.getBounds().height;
      fdLeftBg.width = left.getBounds().width;

      Label rightBg = new Label(buttonBg, SWT.NONE);
      rightBg.setImage(right);
      FormData fdRightBg = new FormData();
      rightBg.setLayoutData(fdRightBg);
      fdRightBg.top = new FormAttachment(0);
      fdRightBg.height = right.getBounds().height;
      fdRightBg.width = right.getBounds().width;

      final Button perspButton = new Button(buttonBg, SWT.PUSH | SWT.FLAT);
      perspButton.setData(RWT.CUSTOM_VARIANT, "perspective"); // $NON-NLS-1$
      FormData fdButton = new FormData();
      perspButton.setLayoutData(fdButton);
      fdButton.left = new FormAttachment(leftBg);
      FormData buttonPos = getLayoutSet().getPosition(ILayoutSetConstants.PERSP_BUTTON_POS);
      fdButton.top = buttonPos.top;
      fdRightBg.left = new FormAttachment(perspButton);

      perspButton.setText(desc.getLabel());

      perspectiveButtonMap.put(desc, perspButton);
      buttonPerspectiveMap.put(perspButton, desc);
      buttonList.add(perspButton);

      perspButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              cleanButtons(perspButton);
              switchPerspective(desc.getId());
            }
          });

      Menu menu = new Menu(perspButton);
      MenuItem item = new MenuItem(menu, SWT.PUSH);
      item.setText(Messages.get().PerspectiveSwitcherBuilder_Close);
      item.setImage(getImage(ILayoutSetConstants.PERSP_CLOSE));
      item.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              removeIdFromStore(desc.getId());
              Button button = (Button) perspectiveButtonMap.get(desc);
              if (button != null) {
                cleanUpButton(desc, button);
              }
              closePerspective(desc);
              background.layout();
            }
          });
      perspButton.setMenu(menu);
      if (otherButton != null) {
        otherButton.getParent().moveBelow(perspButton.getParent());
      }
      result = perspButton;
    }

    return result;
  }
  /** Open. */
  public void open() {
    try {
      attribute2Value = new HashMap<EAttribute, String>();
      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      dialogShell.setLayout(new FormLayout());
      {
        button2 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button2LData = new FormData();
        button2LData.left = new FormAttachment(0, 1000, 330);
        button2LData.top = new FormAttachment(0, 1000, 310);
        button2LData.width = 99;
        button2LData.height = 25;
        button2.setLayoutData(button2LData);
        button2.setText("Cancel");
        button2.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = true;
                dialogShell.close();
              }
            });
      }

      {
        button1 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button1LData = new FormData();
        button1LData.left = new FormAttachment(0, 1000, 229);
        button1LData.top = new FormAttachment(0, 1000, 310);
        button1LData.width = 95;
        button1LData.height = 25;
        button1.setLayoutData(button1LData);
        button1.setText("Ok");
        button1.setEnabled(true);
        button1.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = false;
                for (int i = 0, n = table1.getItemCount(); i < n; i++) {
                  TableItem item = table1.getItem(i);
                  if (item.getChecked()) {
                    EAttribute attribut = attributeTypen.get(i);
                    attribute2Value.put(attribut, item.getText(2));
                  }
                }
                dialogShell.close();
              }
            });
      }
      {
        FormData table1LData = new FormData();
        table1LData.left = new FormAttachment(0, 1000, 12);
        table1LData.top = new FormAttachment(0, 1000, 12);
        table1LData.width = 400;
        table1LData.height = 269;
        table1 =
            new Table(
                dialogShell,
                SWT.CHECK
                    | SWT.SINGLE
                    | SWT.FULL_SELECTION
                    | SWT.V_SCROLL
                    | SWT.H_SCROLL
                    | SWT.VIRTUAL);
        table1.setLayoutData(table1LData);
        table1.setHeaderVisible(true);
        table1.setLinesVisible(true);
        {
          tableColumn1 = new TableColumn(table1, SWT.CENTER);
          tableColumn1.setText("Create");
          tableColumn1.setWidth(60);
        }
        {
          tableColumn2 = new TableColumn(table1, SWT.LEFT);
          tableColumn2.setText("Attribute");
          tableColumn2.setWidth(200);
        }
        {
          tableColumn3 = new TableColumn(table1, SWT.LEFT);
          tableColumn3.setText("Value");
          tableColumn3.setWidth(140);
        }

        vavueCorect = new HashMap<TypeEditorValidator, Boolean>();
        typeEditorValidators = new ArrayList<TypeEditorValidator>();

        for (EAttribute attr : attributeTypen) {
          TableItem tableItem = new TableItem(table1, SWT.NONE);
          TypeEditorValidator typeEditorValidator = new TypeEditorValidator(node, attr);

          tableItem.setText(1, attr.getName());
          tableItem.setText(2, typeEditorValidator.getDefaultValue());
          table1.addListener(
              SWT.Selection,
              new Listener() {

                @Override
                public void handleEvent(Event event) {
                  if (event.detail == SWT.CHECK) {
                    TableItem tItem = (TableItem) event.item;
                    corectValueTest(tItem, tItem.getText(2));
                    refreshOkButton();
                  }
                }
              });
          typeEditorValidators.add(typeEditorValidator);
          /*
           * if (typeEditorValidator.isValid(typeEditorValidator
           * .getDefaultValue()) == null) {
           * vavueCorect.put(typeEditorValidator, corect); } else {
           * vavueCorect.put(typeEditorValidator, incorect);
           * button1.setEnabled(false); }
           */
        }
        final TableEditor editor = new TableEditor(table1);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;

        table1.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDown(MouseEvent event) {
                // Dispose any existing editor
                Control old = editor.getEditor();
                if (old != null) old.dispose();

                // Determine where the mouse was clicked
                Point pt = new Point(event.x, event.y);

                // Determine which row was selected
                final TableItem item = table1.getItem(pt);
                if (item != null) {
                  // Determine which column was selected
                  int column = -1;
                  for (int i = 0, n = table1.getColumnCount(); i < n; i++) {
                    Rectangle rect = item.getBounds(i);
                    if (rect.contains(pt)) {
                      // This is the selected column
                      column = i;
                      break;
                    }
                  }
                  // Column 2 holds dropdowns
                  if (column == 2) {
                    // Create the Text object for our editor
                    final Text text = new Text(table1, SWT.NONE);
                    text.setForeground(item.getForeground());

                    // Transfer any text from the cell to the Text
                    // control,
                    // set the color to match this row, select the
                    // text,
                    // and set focus to the control
                    text.setText(item.getText(column));
                    text.setForeground(item.getForeground());
                    text.selectAll();
                    text.setFocus();

                    // Recalculate the minimum width for the editor
                    editor.minimumWidth = text.getBounds().width;

                    // Set the control into the editor
                    editor.setEditor(text, item, column);

                    // Add a handler to transfer the text back to
                    // the cell
                    // any time it's modified
                    final int col = column;
                    text.addModifyListener(
                        new ModifyListener() {

                          @Override
                          public void modifyText(ModifyEvent e) {
                            item.setChecked(true);
                            corectValueTest(item, text.getText());
                            item.setText(col, text.getText());
                          }
                        });
                  }
                }
              }
            });
      }
      dialogShell.layout();
      dialogShell.setSize(450, 380);
      Rectangle shellBounds = getParent().getBounds();
      Point dialogSize = dialogShell.getSize();
      dialogShell.setLocation(
          shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
          shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }