Ejemplo n.º 1
0
  public void addDescriptionRow(String sectionName) {
    RowData rowdata = (RowData) descriptionGroup.getLayoutData();
    rowdata.height += 60;
    descriptionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = descriptionGroup.getBounds();
    rect.height += 60;
    descriptionGroup.setBounds(rect);

    /*Add the row*/
    Text prevText = sections.get(new Integer(secCount - 1)).getEndTokens();
    rect = prevText.getBounds();
    Text newText_1 = new Text(descriptionGroup, SWT.BORDER);
    newText_1.setBounds(10, rect.y + 40, 75, 20);
    newText_1.setFocus();

    Label lblNew = new Label(descriptionGroup, SWT.NONE);
    lblNew.setBounds(120, rect.y + 40, 145, 20);
    lblNew.setText(sectionName);

    Text newText_2 = new Text(descriptionGroup, SWT.BORDER);
    newText_2.setBounds(270, rect.y + 40, 115, 20);

    Text newText_3 = new Text(descriptionGroup, SWT.BORDER);
    newText_3.setBounds(420, rect.y + 40, 115, 20);

    Text newText_4 = new Text(descriptionGroup, SWT.BORDER);
    newText_4.setBounds(570, rect.y + 40, 115, 20);
    sections.put(
        new Integer(secCount), new SectionBean(newText_1, lblNew, newText_2, newText_3, newText_4));
    secCount++;

    descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
Ejemplo n.º 2
0
 void layout() {
   Rectangle rect = shell.getClientArea();
   // String[] strings = new String[objects.length];
   int width = 0;
   String[] items = list.getItems();
   GC gc = new GC(list);
   for (int i = 0; i < objects.length; i++) {
     width = Math.max(width, gc.stringExtent(items[i]).x);
   }
   gc.dispose();
   Point size1 = start.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Point size2 = stop.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Point size3 = check.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Point size4 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   width = Math.max(size1.x, Math.max(size2.x, Math.max(size3.x, width)));
   width = Math.max(64, Math.max(size4.x, list.computeSize(width, SWT.DEFAULT).x));
   start.setBounds(0, 0, width, size1.y);
   stop.setBounds(0, size1.y, width, size2.y);
   check.setBounds(0, size1.y + size2.y, width, size3.y);
   label.setBounds(0, rect.height - size4.y, width, size4.y);
   int height = size1.y + size2.y + size3.y;
   list.setBounds(0, height, width, rect.height - height - size4.y);
   text.setBounds(width, 0, rect.width - width, rect.height);
   canvas.setBounds(width, 0, rect.width - width, rect.height);
 }
Ejemplo n.º 3
0
  @Override
  public void createPartControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    {
      textField = new Text(container, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
      textField.addMouseListener(
          new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
              TextEditor editor =
                  (TextEditor)
                      Perspective.getView(
                          PlatformUI.getWorkbench().getActiveWorkbenchWindow(), TextEditor.ID);

              String selectedText = ((Text) e.widget).getSelectionText();
              String textOfTextEditor = editor.getTextField().getText().toLowerCase();
              if (textOfTextEditor.contains(selectedText)) {
                // TODO change this selection with MyItemTree.getPosition
                int start = textOfTextEditor.indexOf(selectedText);
                int end = start + selectedText.length();
                editor.getTextField().setSelection(start, end);
              }
            }
          });
      textField.setEditable(true);
      textField.setBounds(10, 10, 370, 225);
    }
  }
Ejemplo n.º 4
0
  @Test
  public void testInsertWithModifyListener() {
    final java.util.List<ModifyEvent> log = new ArrayList<ModifyEvent>();
    Text text = new Text(shell, SWT.SINGLE);
    text.setBounds(0, 0, 100, 20);
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent event) {
            log.add(event);
          }
        });

    // Test that event is fired when correctly using insert
    log.clear();
    text.insert("abc");
    assertEquals(1, log.size());

    // Test that event is *not* fired when passing illegal argument to insert
    log.clear();
    text = new Text(shell, SWT.SINGLE);
    try {
      text.insert(null);
      fail("No exception thrown on string == null");
    } catch (IllegalArgumentException e) {
    }
    assertEquals(0, log.size());
  }
Ejemplo n.º 5
0
  public static void main(String[] args) {
    Display d = new Display();
    final Shell shell = new Shell(d);
    shell.setText("Hello world");
    shell.setSize(600, 400);
    shell.setLayout(new FillLayout());

    Text text = new Text(shell, SWT.BORDER);
    text.setBounds(40, 40, 100, 20);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Click me!");
    b.setLocation(200, 200);
    b.setSize(50, 50);
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Button b = new Button(shell, SWT.PUSH);
            b.setText("New button");
            Random r = new Random();

            b.setBounds(r.nextInt(600), r.nextInt(400), 100, 100);
            shell.layout(true);
          }
        });

    shell.open();

    while (!shell.isDisposed()) {
      if (!d.readAndDispatch()) d.sleep();
    }
  }
Ejemplo n.º 6
0
  public void addExpressionRow(String expressionName) {
    RowData rowdata = (RowData) expressionGroup.getLayoutData();
    rowdata.height += 120;
    expressionGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = expressionGroup.getBounds();
    rect.height += 120;
    expressionGroup.setBounds(rect);
    /*Create a row*/
    ExpressionBean expBean = expressions.get(new Integer(expCount - 1));
    Label previousLabel = expBean.getLabel();
    rect = previousLabel.getBounds();
    Label lblNew = new Label(expressionGroup, SWT.NONE);
    lblNew.setBounds(10, rect.y + 90, 120, 15);
    lblNew.setText(expressionName);
    lblNew.setFocus();

    Text previousText = expBean.getText();
    rect = previousText.getBounds();

    Text newText = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    newText.setBounds(135, rect.y + 90, 550, 70);
    expressions.put(new Integer(expCount), new ExpressionBean(lblNew, newText));
    expCount++;
    expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);

    table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION);
    table.setBounds(10, 58, 520, 110);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableColumn tblclmnClass = new TableColumn(table, SWT.NONE);
    tblclmnClass.setWidth(180);
    tblclmnClass.setText("Class has similar feature with");

    TableColumn tblclmnClasses = new TableColumn(table, SWT.NONE);
    tblclmnClasses.setWidth(199);
    tblclmnClasses.setText("Class");

    TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
    tblclmnNewColumn.setWidth(140);
    tblclmnNewColumn.setText("Attributes");

    Label lblSimilarFeaturesAmong = new Label(container, SWT.NONE);
    lblSimilarFeaturesAmong.setBounds(10, 38, 285, 14);
    lblSimilarFeaturesAmong.setText("Similar Features among the selected classes:");

    Label lblClassName = new Label(container, SWT.NONE);
    lblClassName.setBounds(10, 10, 78, 14);
    lblClassName.setText("Class name:");

    text = new Text(container, SWT.BORDER);
    text.setBounds(82, 5, 438, 19);

    fillTable(table);
  }
Ejemplo n.º 8
0
 void internalLayout(boolean changed) {
   if (isDropped()) dropDown(false);
   Rectangle rect = getClientArea();
   int width = rect.width;
   int height = rect.height;
   Point arrowSize = arrow.computeSize(SWT.DEFAULT, height, changed);
   if (icon != null) {
     Point iconSize = icon.computeSize(SWT.DEFAULT, height, changed);
     text.setBounds(0, 0, width - arrowSize.x - iconSize.x, height);
     icon.setBounds(width - arrowSize.x - iconSize.x, 0, iconSize.x, height);
     arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
   } else {
     text.setBounds(0, 0, width - arrowSize.x, height);
     arrow.setBounds(width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
   }
 }
Ejemplo n.º 9
0
  public InputViewer(Shell parent, Properties properties, String resources) {
    sShell = new org.eclipse.swt.widgets.Shell(parent);
    sShell.setLocation(parent.getLocation().x + 200, parent.getLocation().y + 150);
    sShell.setSize(new org.eclipse.swt.graphics.Point(471, 146));
    sShell.setLayout(null);

    listeners = new Vector<DialogInputListener>();

    ApplicationFactory factory = new ApplicationFactory(sShell, resources, getClass().getName());

    factory.createLabel("lbl").setBounds(15, 15, 100, 20);

    txtName = factory.createText();
    txtName.setBounds(120, 15, 280, 20);
    txtName.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.keyCode != 13) return;
            enter();
          }
        });
    factory
        .createButton(
            "but",
            new SelectionAdapter() {
              @SuppressWarnings("unused")
              public void widgetSelected(SelectionEvent e) {
                enter();
              }
            })
        .setBounds(180, 50, 90, 20);

    sShell.setSize(420, 120);
    sShell.open();
  }
Ejemplo n.º 10
0
  protected Control createContents(Composite parent) {
    ViewForm form = new ViewForm(parent, SWT.NONE);
    form.setSize(400, 290);
    final Composite shell = new Composite(form.getShell(), SWT.NONE);
    Label lbApp1 = new Label(shell, SWT.NONE);
    lbApp1.setText("Version:");
    lbApp1.setBounds(10, 10, 50, 20);
    controls.add(lbApp1);
    Label lbApp2 = new Label(shell, SWT.NONE);
    lbApp2.setText("noti-J 1.0");
    lbApp2.setBounds(UIUtils.getBoundsH(lbApp1, 10, 100));
    controls.add(lbApp2);

    Label lbStatus1 = new Label(shell, SWT.NONE);
    lbStatus1.setText("State:");
    lbStatus1.setBounds(UIUtils.getBoundsV(lbApp1, 10));
    controls.add(lbStatus1);
    Label lbStatus2 = new Label(shell, SWT.NONE);
    lbStatus2.setText(connected ? "connected" : "disconnect");
    lbStatus2.setForeground(
        Display.getDefault().getSystemColor(connected ? SWT.COLOR_BLUE : SWT.COLOR_RED));
    lbStatus2.setBounds(UIUtils.getBoundsV(lbApp2, 10));
    controls.add(lbStatus2);

    Label lbUser1 = new Label(shell, SWT.NONE);
    lbUser1.setText("Account:");
    lbUser1.setBounds(UIUtils.getBoundsV(lbStatus1, 10));
    controls.add(lbUser1);
    Label lbUser2 = new Label(shell, SWT.NONE);
    lbUser2.setText(userid + "(" + userName + ")");
    lbUser2.setBounds(UIUtils.getBoundsV(lbStatus2, 10));
    controls.add(lbUser2);

    Label lbLic1 = new Label(shell, SWT.NONE);
    lbLic1.setText("License:");
    lbLic1.setBounds(UIUtils.getBoundsV(lbUser1, 10));
    controls.add(lbLic1);
    Label lbLic2 = new Label(shell, SWT.NONE);
    lbLic2.setText("GPL 3.0");
    lbLic2.setBounds(UIUtils.getBoundsV(lbUser2, 10));
    controls.add(lbLic2);

    Label lbDev1 = new Label(shell, SWT.NONE);
    lbDev1.setText("Author:");
    lbDev1.setBounds(UIUtils.getBoundsV(lbLic1, 10));
    controls.add(lbDev1);
    Label lbDev2 = new Label(shell, SWT.NONE);
    lbDev2.setText("Jong-Bok,Park([email protected])");
    lbDev2.setBounds(UIUtils.getBoundsV(lbLic2, 10, 300));
    controls.add(lbDev2);

    Text txError = new Text(shell, SWT.NONE | SWT.WRAP);
    txError.setText(errorMsg == null ? "" : errorMsg);
    txError.setBounds(UIUtils.getBoundsV(lbDev1, 10, 300, 100));
    txError.setEditable(false);
    controls.add(txError);
    controls.add(form);
    return form;
  }
 @Override
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Point prefSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   Rectangle rectangle = label.getTextBounds().getCopy();
   label.translateToAbsolute(rectangle);
   text.setBounds(rectangle.x - 1, rectangle.y - 1, prefSize.x + 1, prefSize.y + 1);
 }
Ejemplo n.º 12
0
 /** @generated */
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Rectangle rect = getLabel().getTextBounds().getCopy();
   getLabel().translateToAbsolute(rect);
   int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
   rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
   if (!rect.equals(new Rectangle(text.getBounds()))) {
     text.setBounds(rect.x, rect.y, rect.width, rect.height);
   }
 }
Ejemplo n.º 13
0
  @Override
  public void createControl(Composite parent) {

    composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Text pageText = new Text(composite, SWT.CENTER);
    pageText.setBounds(composite.getBounds());
    pageText.setText("Toolchain F Wizard Page");
    pageText.setVisible(true);
  }
Ejemplo n.º 14
0
 /** @generated */
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Rectangle rect = getMultilineEditableFigure().getBounds().getCopy();
   rect.x = getMultilineEditableFigure().getEditionLocation().x;
   rect.y = getMultilineEditableFigure().getEditionLocation().y;
   getMultilineEditableFigure().translateToAbsolute(rect);
   if (getMultilineEditableFigure().getText().length() > 0) {
     rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
   }
   if (!rect.equals(new Rectangle(text.getBounds()))) {
     text.setBounds(rect.x, rect.y, rect.width, rect.height);
   }
 }
Ejemplo n.º 15
0
 /** Create contents of the shell. */
 protected void createContents() {
   setText("Working");
   setSize(300, 150);
   setCursor(waitingIndicator);
   setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
   ProgressBar progressBar = new ProgressBar(this, SWT.SMOOTH | SWT.INDETERMINATE);
   progressBar.setBounds(10, 71, 274, 25);
   progressBar.setEnabled(true);
   progressBar.setVisible(true);
   txtPleaseWaitUntil = new Text(this, SWT.WRAP | SWT.MULTI);
   txtPleaseWaitUntil.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
   txtPleaseWaitUntil.setText("Please wait until the application closes all open files.");
   txtPleaseWaitUntil.setBounds(12, 24, 272, 41);
 }
Ejemplo n.º 16
0
  /** Create contents of the window. */
  protected void createContents() {
    shell = new Shell();
    shell.setSize(340, 286);
    shell.setText("New customer");
    Utils.centerDialogOnScreen(shell);

    Label lblGuestId = new Label(shell, SWT.NONE);
    lblGuestId.setBounds(33, 42, 61, 17);
    lblGuestId.setText("Guest ID");

    text = new Text(shell, SWT.BORDER);
    text.setBounds(167, 42, 100, 23);
    text.setText(UUID.randomUUID().toString().substring(0, 3));

    Label lblGuestAmount = new Label(shell, SWT.NONE);
    lblGuestAmount.setBounds(33, 71, 94, 17);
    lblGuestAmount.setText("Guest amount");

    text_1 = new Text(shell, SWT.BORDER);
    text_1.setBounds(167, 71, 100, 23);

    Button btnCommit = new Button(shell, SWT.NONE);
    btnCommit.setBounds(103, 211, 80, 27);
    btnCommit.setText("Commit");

    btnAllowSeatTogether = new Button(shell, SWT.CHECK);
    btnAllowSeatTogether.setBounds(69, 108, 219, 17);
    btnAllowSeatTogether.setText("Allow to seat with other customer.");

    lblNewLabel = new Label(shell, SWT.NONE);
    lblNewLabel.setBounds(33, 131, 61, 17);
    lblNewLabel.setText("Additional infomation");
    btnCommit.addSelectionListener(new btnCommitForNewCustomerListener());

    text_2 = new Text(shell, SWT.BORDER);
    text_2.setBounds(33, 154, 255, 23);
  }
  public void relocate(CellEditor celleditor) {
    if (celleditor == null) return;
    Text text = (Text) celleditor.getControl();

    Rectangle rect = fig.getClientArea(Rectangle.SINGLETON);
    if (fig instanceof Label) rect = ((Label) fig).getTextBounds().intersect(rect);
    fig.translateToAbsolute(rect);

    org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
    rect.translate(trim.x, trim.y);
    rect.width += trim.width;
    rect.height += trim.height;

    text.setBounds(rect.x, rect.y, rect.width, rect.height);
  }
Ejemplo n.º 18
0
  protected void createContents() {
    setText("DateTime");
    setSize(471, 140);
    text = new Text(this, SWT.BORDER);
    text.setEditable(false);
    text.setBackground(new Color(display, 255, 255, 255));
    text.setBounds(122, 41, 228, 25);

    text.addMouseListener(
        new MouseAdapter() {
          public void mouseUp(MouseEvent e) {
            DTDialog dialog = DTDialog.getInstance(DateTimeDemo.this);
            dialog.open();
          }
        });
  }
Ejemplo n.º 19
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   Text text = new Text(shell, SWT.BORDER | SWT.V_SCROLL);
   text.setBounds(10, 10, 100, 100);
   for (int i = 0; i < 16; i++) {
     text.append("Line " + i + "\n");
   }
   shell.open();
   text.setSelection(30, 38);
   System.out.println(text.getCaretLocation());
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Ejemplo n.º 20
0
  // TODO [bm] extend testcase with newline chars and getLineCount
  @Test
  public void testInsert() {
    // Test insert on multi-line Text
    Text text = new Text(shell, SWT.MULTI);
    text.setBounds(0, 0, 500, 500);
    // Ensure initial state
    assertEquals("", text.getText());
    // Test with allowed arguments
    text.insert("");
    assertEquals("", text.getText());
    text.insert("fred");
    assertEquals("fred", text.getText());
    text.setSelection(2);
    text.insert("helmut");
    assertEquals("frhelmuted", text.getText());
    // Test with illegal argument
    try {
      text.setText("oldText");
      text.insert(null);
      fail("No exception thrown on string == null");
    } catch (IllegalArgumentException e) {
      assertEquals("oldText", text.getText());
    }

    // Test insert on single-line Text
    text = new Text(shell, SWT.SINGLE);
    assertEquals("", text.getText());
    text.insert("");
    assertEquals("", text.getText());
    text.insert("fred");
    assertEquals("fred", text.getText());
    text.setSelection(2);
    text.insert("helmut");
    assertEquals("frhelmuted", text.getText());
    // Test with illegal arguments
    text = new Text(shell, SWT.SINGLE);
    try {
      text.setText("oldText");
      text.insert(null);
      fail("No exception thrown on string == null");
    } catch (IllegalArgumentException e) {
      assertEquals("oldText", text.getText());
    }
  }
  /** Create contents of the window. */
  protected void createContents() {

    shell = new Shell();
    shell.setImage(SWTResourceManager.getImage(PrintedLumpWindow.class, "/icon/App.ico"));
    shell.setSize(457, 244);
    shell.setText(loader.getValue(LabelConstants.LAYOUT_PRINTED_LUMPS_NEW_PRINTED_LUMPS));
    Label lblNameOfTheLump = new Label(shell, SWT.NONE);
    lblNameOfTheLump.setBounds(24, 38, 249, 15);
    lblNameOfTheLump.setText(loader.getValue(LabelConstants.LAYOUT_PRINTED_LUMPS_NAME_OF_THE_LUMP));

    txtNameOfTheLump = new Text(shell, SWT.BORDER);
    txtNameOfTheLump.setBounds(20, 77, 397, 25);

    Button btnPrintedLumpCancel = new Button(shell, SWT.NONE);
    btnPrintedLumpCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            shell.setVisible(false);
            shell.dispose();
          }
        });
    btnPrintedLumpCancel.setBounds(20, 149, 105, 32);
    btnPrintedLumpCancel.setText(loader.getValue(LabelConstants.LAYOUT_CANCEL));

    btnPrintedLumpSave = new Button(shell, SWT.NONE);
    btnPrintedLumpSave.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            lumpsInterface.addPrintedLump(txtNameOfTheLump.getText());
            shell.setVisible(false);
            shell.dispose();
          }
        });
    btnPrintedLumpSave.setBounds(312, 149, 105, 32);
    btnPrintedLumpSave.setText(loader.getValue(LabelConstants.LAYOUT_SAVE));
  }
  /** Create contents of the window. */
  protected void createContents() {
    shlMcScheduler = new Shell();
    shlMcScheduler.setSize(803, 401);
    shlMcScheduler.setText("MC3 Scheduler");

    // MENU BAR
    Menu MenuBar = new Menu(shlMcScheduler, SWT.BAR);
    shlMcScheduler.setMenuBar(MenuBar);

    // FILE
    MenuItem FileMenu = new MenuItem(MenuBar, SWT.CASCADE);
    FileMenu.setText("File");

    Menu FileCascade = new Menu(FileMenu);
    FileMenu.setMenu(FileCascade);

    MenuItem mntmSave = new MenuItem(FileCascade, SWT.NONE);
    mntmSave.setText("Save");

    MenuItem mntmOpen = new MenuItem(FileCascade, SWT.NONE);
    mntmOpen.setText("Open");

    MenuItem mntmExit = new MenuItem(FileCascade, SWT.NONE);
    mntmExit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shlMcScheduler.close();
          }
        });
    mntmExit.setText("Exit");

    // EDIT
    MenuItem EditMenu = new MenuItem(MenuBar, SWT.CASCADE);
    EditMenu.setText("Edit");

    Menu EditCascade = new Menu(EditMenu);
    EditMenu.setMenu(EditCascade);

    // INSERT
    MenuItem InsertMenu = new MenuItem(MenuBar, SWT.CASCADE);
    InsertMenu.setText("Insert");

    Menu InsertCascade = new Menu(InsertMenu);
    InsertMenu.setMenu(InsertCascade);

    MenuItem InsertTranscript = new MenuItem(InsertCascade, SWT.NONE);
    InsertTranscript.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final InsertDialog dial = new InsertDialog(shlMcScheduler, 1, txtXscript);
            dial.open();
          }
        });
    InsertTranscript.setText("Insert Transcript");

    MenuItem InsertCoursePlan = new MenuItem(InsertCascade, SWT.NONE);
    InsertCoursePlan.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final InsertDialog dial = new InsertDialog(shlMcScheduler, 1, txtCoursePlan);
            dial.open();
          }
        });
    InsertCoursePlan.setText("Insert Course Plan");

    MenuItem InsertCourseList = new MenuItem(InsertCascade, SWT.NONE);
    InsertCourseList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {}
        });
    InsertCourseList.setText("Insert a Course List");

    // WINDOW TABS
    TabFolder WindowTab = new TabFolder(shlMcScheduler, SWT.NONE);
    WindowTab.setBounds(0, 0, 565, 343);

    // TRANSCRIPT TAB
    TabItem TranscriptTab = new TabItem(WindowTab, SWT.NONE);
    TranscriptTab.setText("Transcript");

    Composite TranscriptWindow = new Composite(WindowTab, SWT.NONE);
    TranscriptTab.setControl(TranscriptWindow);

    txtXscript =
        new Text(
            TranscriptWindow,
            SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
    txtXscript.setEditable(false);
    txtXscript.setText("Insert your Transcript!");
    txtXscript.setBounds(0, 0, 557, 315);

    // COURSE PLAN TAB
    TabItem CoursePlanTab = new TabItem(WindowTab, SWT.NONE);
    CoursePlanTab.setText("Course Plan");

    Composite CoursePlanWindow = new Composite(WindowTab, SWT.NONE);
    CoursePlanTab.setControl(CoursePlanWindow);

    txtCoursePlan =
        new Text(
            CoursePlanWindow,
            SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
    txtCoursePlan.setText("Insert your Course Plan");
    txtCoursePlan.setEditable(false);
    txtCoursePlan.setBounds(0, 0, 557, 315);

    // COURSE LIST TAB
    TabItem CourseListTab = new TabItem(WindowTab, SWT.NONE);
    CourseListTab.setText("Course List");

    Composite CourseListWindow = new Composite(WindowTab, SWT.NONE);
    CourseListTab.setControl(CourseListWindow);

    final List cList = new List(CourseListWindow, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    cList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            currentCourseSelected = cList.getSelection()[0];
          }
        });
    cList.setBounds(0, 0, 557, 315);
    cList.add("MATH TEST");
    cList.add("SCIENCE TEST");

    TabItem CalendarTab = new TabItem(WindowTab, SWT.NONE);
    CalendarTab.setText("Calendar");

    Composite CalenderWindow = new Composite(WindowTab, SWT.NONE);
    CalenderWindow.setEnabled(false);
    CalendarTab.setControl(CalenderWindow);

    table = new Table(CalenderWindow, SWT.BORDER | SWT.FULL_SELECTION);
    table.setBounds(0, 0, 557, 315);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableColumn SunColumn = new TableColumn(table, SWT.NONE);
    SunColumn.setWidth(79);
    SunColumn.setText("Sunday");

    TableColumn MonColumn = new TableColumn(table, SWT.NONE);
    MonColumn.setWidth(79);
    MonColumn.setText("Monday");

    TableColumn TueColumn = new TableColumn(table, SWT.NONE);
    TueColumn.setWidth(79);
    TueColumn.setText("Tuesday");

    TableColumn WedsColumn = new TableColumn(table, SWT.NONE);
    WedsColumn.setWidth(79);
    WedsColumn.setText("Wednesday");

    TableColumn ThuColumn = new TableColumn(table, SWT.NONE);
    ThuColumn.setWidth(79);
    ThuColumn.setText("Thursday");

    TableColumn FriColumn = new TableColumn(table, SWT.NONE);
    FriColumn.setWidth(79);
    FriColumn.setText("Friday");

    TableColumn SatColumn = new TableColumn(table, SWT.NONE);
    SatColumn.setWidth(79);
    SatColumn.setText("Saturday");

    //
    Label LabelSelectedCourses = new Label(shlMcScheduler, SWT.NONE);
    LabelSelectedCourses.setLocation(621, 2);
    LabelSelectedCourses.setSize(112, 15);
    LabelSelectedCourses.setText("Selected Courses");

    Composite SelectedCoursesWindow = new Composite(shlMcScheduler, SWT.NONE);
    SelectedCoursesWindow.setBounds(571, 23, 206, 310);

    final List selectedList = new List(SelectedCoursesWindow, SWT.BORDER);
    selectedList.setBounds(0, 0, 206, 269);
    selectedList.add("No Courses Selected");

    Button btnRemoveCourse = new Button(SelectedCoursesWindow, SWT.NONE);
    btnRemoveCourse.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              removeCurrentCourse(selectedList, selectedList.getSelection()[0]);
            } catch (ArrayIndexOutOfBoundsException error) {
              final ErrorDialog err = new ErrorDialog(shlMcScheduler, 1);
              err.open();
            }
          }
        });
    btnRemoveCourse.setBounds(111, 275, 95, 25);
    btnRemoveCourse.setText("Remove Course");

    Button btnAddCourse = new Button(SelectedCoursesWindow, SWT.NONE);
    btnAddCourse.setBounds(0, 275, 95, 25);
    btnAddCourse.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              addCurrentCourse(selectedList, cList.getSelection()[0]);
            } catch (ArrayIndexOutOfBoundsException error) {
              final ErrorDialog err = new ErrorDialog(shlMcScheduler, 1);
              err.open();
            }
          }
        });
    btnAddCourse.setText("Add Course");
  }
Ejemplo n.º 23
0
  /**
   * Create the SMSTextPage
   *
   * @author Ralph Plawetzki
   * @param parent parent shell
   * @param style SWT style
   * @param app App - main application
   */
  public SMSTextPage(Composite parent, int style, App app) {
    super(parent, style);

    this.app = app;

    lblNewLabel = new Label(this, SWT.NONE);
    lblNewLabel.setBounds(17, 21, 106, 22);
    lblNewLabel.setText("Empfänger");

    lblcommaSeperated = new Label(this, SWT.NONE);
    lblcommaSeperated.setBounds(17, 46, 139, 21);
    lblcommaSeperated.setText("(Trennung mit Komma)");

    combo = new Combo(this, SWT.NONE);
    combo.setItems(app.getAddressComboContent());
    combo.setText(app.getPullDownText());
    combo.setBounds(156, 21, 238, 23);

    int length = 0;
    if (app.getMessage() != null) length = app.getMessage().length();
    smsCount = new Label(this, SWT.NONE);
    smsCount.setBounds(149, 66, 15, 16);
    smsCount.setText(new Integer(calculateSMSCount(length)).toString());

    lblNewLabel_4 = new Label(this, SWT.CENTER);
    lblNewLabel_4.setBounds(170, 66, 34, 16);
    lblNewLabel_4.setText("SMS");

    numberCharsLeft = new Label(this, SWT.RIGHT);
    numberCharsLeft.setBounds(222, 66, 34, 15);
    numberCharsLeft.setText(
        new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible()) - length).toString());

    lblNewLabel_5 = new Label(this, SWT.CENTER);
    lblNewLabel_5.setBounds(262, 66, 15, 15);
    lblNewLabel_5.setText("/");

    numberSMSLength = new Label(this, SWT.NONE);
    numberSMSLength.setBounds(283, 66, 34, 15);
    numberSMSLength.setText(
        new Integer(getMaxSMSLengthPossible(app.getMaxSMSpossible())).toString());

    lblNewLabel_7 = new Label(this, SWT.NONE);
    lblNewLabel_7.setBounds(321, 66, 94, 21);
    lblNewLabel_7.setText("Zeichen übrig");

    lblSmsText = new Label(this, SWT.NONE);
    lblSmsText.setBounds(72, 66, 68, 15);
    lblSmsText.setText("SMS text");

    message = new Text(this, SWT.MULTI | SWT.WRAP | SWT.BORDER);
    message.setBounds(72, 87, 324, 91);
    if (app.getMessage() != null) message.setText(app.getMessage());
    message.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent evt) {
            messageKeyReleased(evt);
          }
        });
    message.setFocus();

    lblNewLabel_1 = new Label(this, SWT.NONE);
    lblNewLabel_1.setBounds(102, 185, 87, 28);
    lblNewLabel_1.setText("gesendet von");

    sender = new Label(this, SWT.NONE);
    sender.setBounds(195, 184, 184, 22);
    sender.setText(app.geteMail());

    smsLeft = new Label(this, SWT.RIGHT);
    smsLeft.setBounds(36, 226, 26, 15);
    smsLeft.setText(app.getSmsLeft());

    lblNewLabel_9 = new Label(this, SWT.CENTER);
    lblNewLabel_9.setBounds(65, 226, 15, 15);
    lblNewLabel_9.setText("/");

    smsTotal = new Label(this, SWT.NONE);
    smsTotal.setBounds(82, 226, 26, 15);
    smsTotal.setText(app.getSmsTotal());

    lblNewLabel_2 = new Label(this, SWT.CENTER);
    lblNewLabel_2.setBounds(110, 225, 15, 15);
    lblNewLabel_2.setText("+");

    smsBought = new Label(this, SWT.NONE);
    smsBought.setBounds(125, 226, 23, 15);
    smsBought.setText(app.getSmsBought());

    lblNewLabel_11 = new Label(this, SWT.NONE);
    lblNewLabel_11.setBounds(155, 226, 86, 23);
    lblNewLabel_11.setText("SMS übrig");

    btnSendSms = new Button(this, SWT.NONE);
    btnSendSms.setBounds(310, 216, 84, 28);
    btnSendSms.setText("Sende SMS");
  }
Ejemplo n.º 24
0
  public void addNomenclatureRow(String name) {

    RowData rowdata = (RowData) nomenclatureGroup.getLayoutData();
    rowdata.height += 30;
    nomenclatureGroup.setLayoutData(new RowData(rowdata.width, rowdata.height));
    Rectangle rect = nomenclatureGroup.getBounds();
    rect.height += 30;
    nomenclatureGroup.setBounds(rect);

    /*Create a row*/

    NomenclatureBean nbean = nomenclatures.get(new Integer(nomenCount - 1));
    Label previousLabel = nbean.getLabel();
    rect = previousLabel.getBounds();
    rect.y += 45;

    Label lblNew = new Label(nomenclatureGroup, SWT.NONE);
    lblNew.setBounds(rect);
    lblNew.setText(name);
    lblNew.setFocus();

    /* Create the first group*/
    Group prevGroup = nbean.getParent();
    rect = prevGroup.getBounds();
    Group group_1 = new Group(nomenclatureGroup, SWT.NONE);
    group_1.setBounds(100, rect.y + 45, 182, 40);

    Button buttonYes_1 = new Button(group_1, SWT.RADIO);
    buttonYes_1.setText("Yes");
    buttonYes_1.setBounds(10, 13, 39, 16);

    Button buttonNo_1 = new Button(group_1, SWT.RADIO);
    buttonNo_1.setText("No");
    buttonNo_1.setBounds(55, 13, 39, 16);

    Text text1 = new Text(group_1, SWT.BORDER);
    text1.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_1, buttonYes_1, buttonNo_1, text1, lblNew));
    nomenCount++;
    ///////////////////////////////////

    /*Create the second group */
    Group group_2 = new Group(nomenclatureGroup, SWT.NONE);
    group_2.setBounds(300, rect.y + 45, 182, 40);

    Button buttonYes_2 = new Button(group_2, SWT.RADIO);
    buttonYes_2.setText("Yes");
    buttonYes_2.setBounds(10, 13, 39, 16);

    Button buttonNo_2 = new Button(group_2, SWT.RADIO);
    buttonNo_2.setText("No");
    buttonNo_2.setBounds(55, 13, 39, 16);

    Text text2 = new Text(group_2, SWT.BORDER);
    text2.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_2, buttonYes_2, buttonNo_2, text2, lblNew));
    nomenCount++;

    /* Create the third group */
    Group group_3 = new Group(nomenclatureGroup, SWT.NONE);
    group_3.setBounds(500, rect.y + 45, 182, 40);

    Button buttonYes_3 = new Button(group_3, SWT.RADIO);
    buttonYes_3.setText("Yes");
    buttonYes_3.setBounds(10, 13, 39, 16);

    Button buttonNo_3 = new Button(group_3, SWT.RADIO);
    buttonNo_3.setText("No");
    buttonNo_3.setBounds(55, 13, 39, 16);

    Text text3 = new Text(group_3, SWT.BORDER);
    text3.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_3, buttonYes_3, buttonNo_3, text3, lblNew));
    nomenCount++;
    nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  }
Ejemplo n.º 25
0
  /** @wbp.parser.entryPoint */
  public void showType2Document() {
    final Display display = Display.getDefault();

    shlTypeDocument = new Shell(display);
    shlTypeDocument.setText("Type 2 Document");
    shlTypeDocument.setSize(780, 634);
    shlTypeDocument.setLocation(display.getBounds().x + 200, display.getBounds().y + 100);

    Composite composite = new Composite(shlTypeDocument, SWT.NONE);
    composite.setBounds(0, 0, 759, 557);

    TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setBounds(10, 10, 742, 545);

    TabItem tbtmText = new TabItem(tabFolder, SWT.NONE);
    tbtmText.setText("Text");

    Group grpText = new Group(tabFolder, SWT.NONE);
    grpText.setText("Text");
    tbtmText.setControl(grpText);
    // The first tab!  --> Text
    Label lblLeadingIndentionOf = new Label(grpText, SWT.NONE);
    lblLeadingIndentionOf.setBounds(10, 82, 374, 15);
    lblLeadingIndentionOf.setText("Leading indention of other paragraph:");

    text = new Text(grpText, SWT.BORDER);
    text.setBounds(422, 79, 76, 21);

    Label lblCharacters = new Label(grpText, SWT.NONE);
    lblCharacters.setBounds(504, 82, 85, 15);
    lblCharacters.setText("characters");

    Label lblSpacingBetweenCharacters = new Label(grpText, SWT.NONE);
    lblSpacingBetweenCharacters.setBounds(10, 116, 374, 15);
    lblSpacingBetweenCharacters.setText("Spacing between paragraphs:");

    text_1 = new Text(grpText, SWT.BORDER);
    text_1.setBounds(422, 113, 76, 21);

    Label lblLines = new Label(grpText, SWT.NONE);
    lblLines.setBounds(504, 116, 85, 15);
    lblLines.setText("lines");

    Label lblstParagraph = new Label(grpText, SWT.NONE);
    lblstParagraph.setBounds(10, 47, 374, 15);
    lblstParagraph.setText("1st Paragraph:");

    text_2 = new Text(grpText, SWT.BORDER);
    text_2.setBounds(422, 47, 76, 21);

    Label label_2 = new Label(grpText, SWT.NONE);
    label_2.setBounds(504, 47, 85, 15);
    label_2.setText("characters");

    Label lblEstimatedAverageLengths = new Label(grpText, SWT.NONE);
    lblEstimatedAverageLengths.setBounds(10, 154, 374, 15);
    lblEstimatedAverageLengths.setText("Estimated average length(s) of a line:");

    text_3 = new Text(grpText, SWT.BORDER);
    text_3.setBounds(422, 148, 76, 21);

    Label label_3 = new Label(grpText, SWT.NONE);
    label_3.setBounds(504, 154, 85, 15);
    label_3.setText("characters");

    Label lblPageNumberForms = new Label(grpText, SWT.NONE);
    lblPageNumberForms.setBounds(10, 194, 141, 15);
    lblPageNumberForms.setText("Page number forms:");

    text_4 = new Text(grpText, SWT.BORDER);
    text_4.setBounds(161, 191, 477, 21);

    Label lblSectionHeadings = new Label(grpText, SWT.NONE);
    lblSectionHeadings.setBounds(10, 237, 141, 15);
    lblSectionHeadings.setText("Section headings:");

    Button btnCapitalized = new Button(grpText, SWT.RADIO);
    btnCapitalized.setBounds(169, 236, 90, 16);
    btnCapitalized.setText("Capitalized");

    Button btnAllCapital = new Button(grpText, SWT.RADIO);
    btnAllCapital.setBounds(263, 237, 90, 16);
    btnAllCapital.setText("ALL CAPITAL");

    text_5 = new Text(grpText, SWT.BORDER);
    text_5.setBounds(366, 231, 272, 21);

    Label lblFooterTokens = new Label(grpText, SWT.NONE);
    lblFooterTokens.setBounds(10, 283, 85, 15);
    lblFooterTokens.setText("Footer tokens:");

    Button btnHasFooters = new Button(grpText, SWT.CHECK);
    btnHasFooters.setBounds(123, 282, 93, 16);
    btnHasFooters.setText("Has footers");

    text_6 = new Text(grpText, SWT.BORDER);
    text_6.setBounds(222, 280, 98, 21);

    Label lblHeaderTokens = new Label(grpText, SWT.NONE);
    lblHeaderTokens.setBounds(337, 283, 85, 15);
    lblHeaderTokens.setText("Header tokens:");

    Button btnHasHeaders = new Button(grpText, SWT.CHECK);
    btnHasHeaders.setBounds(428, 282, 93, 16);
    btnHasHeaders.setText("Has headers");

    text_7 = new Text(grpText, SWT.BORDER);
    text_7.setBounds(523, 277, 98, 21);

    textBean =
        new TextBean(
            text_2,
            text,
            text_1,
            text_3,
            text_4,
            btnCapitalized,
            btnAllCapital,
            text_5,
            new SpecialBean(btnHasFooters, btnHasHeaders, text_6, text_7));

    TabItem tbtmNomenclature = new TabItem(tabFolder, SWT.NONE);
    tbtmNomenclature.setText("Nomenclature");

    Group grpNomenclature = new Group(tabFolder, SWT.NONE);
    grpNomenclature.setText("Nomenclature");
    tbtmNomenclature.setControl(grpNomenclature);

    Label lblWhatIsIn = new Label(grpNomenclature, SWT.NONE);
    lblWhatIsIn.setBounds(10, 28, 111, 15);
    lblWhatIsIn.setText("What is in a name?");

    Label lblFamily = new Label(grpNomenclature, SWT.NONE);
    lblFamily.setBounds(233, 28, 55, 15);
    lblFamily.setText("Family");

    Label lblGenus = new Label(grpNomenclature, SWT.NONE);
    lblGenus.setBounds(399, 28, 55, 15);
    lblGenus.setText("Genus");

    Label lblSpecies = new Label(grpNomenclature, SWT.NONE);
    lblSpecies.setBounds(569, 28, 55, 15);
    lblSpecies.setText("Species");

    nomenScrolledComposite =
        new ScrolledComposite(grpNomenclature, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    nomenScrolledComposite.setBounds(10, 53, 714, 278);
    nomenScrolledComposite.setExpandHorizontal(true);
    nomenScrolledComposite.setExpandVertical(true);

    nomenclatureGroup = new Group(nomenScrolledComposite, SWT.NONE);
    nomenclatureGroup.setLayoutData(new RowData());

    Label lblName = new Label(nomenclatureGroup, SWT.NONE);
    lblName.setBounds(10, 20, 75, 15);
    lblName.setText("Name");

    Group group_2 = new Group(nomenclatureGroup, SWT.NONE);
    group_2.setBounds(100, 10, 182, 40);

    Button button = new Button(group_2, SWT.RADIO);
    button.setText("Yes");
    button.setBounds(10, 13, 39, 16);

    Button button_1 = new Button(group_2, SWT.RADIO);
    button_1.setText("No");
    button_1.setBounds(55, 13, 39, 16);

    text_14 = new Text(group_2, SWT.BORDER);
    text_14.setBounds(100, 11, 76, 21);
    nomenclatures.put(
        new Integer(nomenCount), new NomenclatureBean(group_2, button, button_1, text_14, lblName));
    nomenCount++;

    Group group_1 = new Group(nomenclatureGroup, SWT.NONE);
    group_1.setBounds(300, 10, 182, 40);

    Button button_2 = new Button(group_1, SWT.RADIO);
    button_2.setText("Yes");
    button_2.setBounds(10, 13, 39, 16);

    Button button_3 = new Button(group_1, SWT.RADIO);
    button_3.setText("No");
    button_3.setBounds(55, 13, 39, 16);

    text_15 = new Text(group_1, SWT.BORDER);
    text_15.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_1, button_2, button_3, text_15, lblName));
    nomenCount++;

    ///////////////
    Group group_4 = new Group(nomenclatureGroup, SWT.NONE);
    group_4.setBounds(500, 10, 182, 40);

    Button button_4 = new Button(group_4, SWT.RADIO);
    button_4.setText("Yes");
    button_4.setBounds(10, 13, 39, 16);

    Button button_5 = new Button(group_4, SWT.RADIO);
    button_5.setText("No");
    button_5.setBounds(55, 13, 39, 16);

    text_16 = new Text(group_4, SWT.BORDER);
    text_16.setBounds(100, 11, 76, 21);

    nomenclatures.put(
        new Integer(nomenCount),
        new NomenclatureBean(group_4, button_4, button_5, text_16, lblName));
    nomenCount++;

    String[] nomenclatureArray = {"Authors", "Date", "Publication", "Taxon Rank"};
    for (String name : nomenclatureArray) {
      addNomenclatureRow(name);
    }

    nomenScrolledComposite.setContent(nomenclatureGroup);
    // When you add a row, reset the size of scrolledComposite
    nomenScrolledComposite.setMinSize(nomenclatureGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow = new Button(grpNomenclature, SWT.NONE);
    btnAddARow.setBounds(10, 337, 75, 25);
    btnAddARow.setText("Add a Row");
    btnAddARow.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addNomenclatureRow(identifier);
            }
          }
        });

    TabItem tbtmExpressions = new TabItem(tabFolder, SWT.NONE);
    tbtmExpressions.setText("Expressions");

    Group grpExpressionsUsedIn = new Group(tabFolder, SWT.NONE);
    grpExpressionsUsedIn.setText("Expressions used in Nomenclature");
    tbtmExpressions.setControl(grpExpressionsUsedIn);

    Label lblUseCapLetters = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblUseCapLetters.setBounds(10, 22, 426, 15);
    lblUseCapLetters.setText("Use CAP words for fixed tokens; use small letters for variables");

    Label lblHononyms = new Label(grpExpressionsUsedIn, SWT.NONE);
    lblHononyms.setBounds(348, 22, 99, 15);
    lblHononyms.setText("Hononyms:");

    expScrolledComposite =
        new ScrolledComposite(grpExpressionsUsedIn, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    expScrolledComposite.setBounds(10, 43, 714, 440);
    expScrolledComposite.setExpandHorizontal(true);
    expScrolledComposite.setExpandVertical(true);

    expressionGroup = new Group(expScrolledComposite, SWT.NONE);
    expressionGroup.setLayoutData(new RowData());

    // count of number of rows
    expCount = 0;
    Label lblSpecialTokensUsed = new Label(expressionGroup, SWT.NONE);
    lblSpecialTokensUsed.setBounds(10, 20, 120, 15);
    lblSpecialTokensUsed.setText("Special tokens used:");

    text_29 = new Text(expressionGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_29.setBounds(135, 20, 550, 70);

    expressions.put(new Integer(expCount), new ExpressionBean(lblSpecialTokensUsed, text_29));
    expCount++;

    String[] expressionArray = {"Minor Amendment:", "Past name:", "Name origin:", "Homonyms:"};
    for (String name : expressionArray) {
      addExpressionRow(name);
    }

    expScrolledComposite.setContent(expressionGroup);
    expScrolledComposite.setMinSize(expressionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_2 = new Button(grpExpressionsUsedIn, SWT.NONE);
    btnAddARow_2.setBounds(10, 489, 75, 25);
    btnAddARow_2.setText("Add a row");
    btnAddARow_2.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addExpressionRow(identifier);
            }
          }
        });

    TabItem tbtmDescription = new TabItem(tabFolder, SWT.NONE);
    tbtmDescription.setText("Description");

    Group grpMorphologicalDescriptions = new Group(tabFolder, SWT.NONE);
    tbtmDescription.setControl(grpMorphologicalDescriptions);

    Label lblAllInOne = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblAllInOne.setBounds(10, 53, 160, 15);
    lblAllInOne.setText("All in one paragraph");

    Button btnYes = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnYes.setBounds(241, 52, 90, 16);
    btnYes.setText("Yes");

    Button btnNo = new Button(grpMorphologicalDescriptions, SWT.RADIO);
    btnNo.setBounds(378, 52, 90, 16);
    btnNo.setText("No");

    Label lblOtherInformationMay = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOtherInformationMay.setBounds(10, 85, 438, 15);
    lblOtherInformationMay.setText(
        "Other information may also be included in a description paragraph:");

    Combo combo = new Combo(grpMorphologicalDescriptions, SWT.NONE);
    combo.setItems(new String[] {"Nomenclature", "Habitat", "Distribution", "Discussion", "Other"});
    combo.setBounds(496, 82, 177, 23);

    descriptionBean = new DescriptionBean(btnYes, btnNo, combo, sections);

    Label lblMorphological = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblMorphological.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblMorphological.setBounds(10, 25, 242, 15);
    lblMorphological.setText("Morphological Descriptions: ");

    Label lblOrder = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblOrder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblOrder.setBounds(22, 142, 55, 15);
    lblOrder.setText("Order");

    Label lblSection = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSection.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSection.setBounds(140, 142, 55, 15);
    lblSection.setText("Section");

    Label lblStartTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblStartTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblStartTokens.setBounds(285, 142, 90, 15);
    lblStartTokens.setText("Start tokens");

    Label lblEndTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEndTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEndTokens.setBounds(443, 142, 68, 15);
    lblEndTokens.setText("End tokens");

    Label lblEmbeddedTokens = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblEmbeddedTokens.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblEmbeddedTokens.setBounds(592, 142, 132, 15);
    lblEmbeddedTokens.setText("Embedded tokens");

    descScrolledComposite =
        new ScrolledComposite(
            grpMorphologicalDescriptions, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descScrolledComposite.setBounds(10, 169, 714, 310);
    descScrolledComposite.setExpandHorizontal(true);
    descScrolledComposite.setExpandVertical(true);

    descriptionGroup = new Group(descScrolledComposite, SWT.NONE);
    descriptionGroup.setLayoutData(new RowData());

    text_33 = new Text(descriptionGroup, SWT.BORDER);
    text_33.setBounds(10, 20, 75, 20);

    Label lblNomenclature = new Label(descriptionGroup, SWT.NONE);
    lblNomenclature.setBounds(120, 20, 145, 20);
    lblNomenclature.setText("Nomenclature");

    text_40 = new Text(descriptionGroup, SWT.BORDER);
    text_40.setBounds(270, 20, 115, 20);

    text_41 = new Text(descriptionGroup, SWT.BORDER);
    text_41.setBounds(420, 20, 115, 20);

    text_42 = new Text(descriptionGroup, SWT.BORDER);
    text_42.setBounds(570, 20, 115, 20);

    sections.put(
        new Integer(secCount),
        new SectionBean(text_33, lblNomenclature, text_40, text_41, text_42));
    secCount++;

    String[] sectionArray = {
      "Morph. description", "Habitat", "Distribution", "Discussion", "Keys", "References"
    };
    for (String name : sectionArray) {
      addDescriptionRow(name);
    }

    descScrolledComposite.setContent(descriptionGroup);
    descScrolledComposite.setMinSize(descriptionGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Button btnAddARow_1 = new Button(grpMorphologicalDescriptions, SWT.NONE);
    btnAddARow_1.setBounds(10, 482, 75, 25);
    btnAddARow_1.setText("Add a row");
    btnAddARow_1.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = null;
            showInputBox();
            if (identifier != null && !identifier.equals("")) {
              addDescriptionRow(identifier);
            }
          }
        });

    Label lblSectionIndicationsAnd = new Label(grpMorphologicalDescriptions, SWT.NONE);
    lblSectionIndicationsAnd.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    lblSectionIndicationsAnd.setBounds(10, 116, 222, 15);
    lblSectionIndicationsAnd.setText("Section indications and order:");

    TabItem tbtmSpecial = new TabItem(tabFolder, SWT.NONE);
    tbtmSpecial.setText("Special");

    Group grpSpecialSections = new Group(tabFolder, SWT.NONE);
    grpSpecialSections.setText("Special Sections");
    tbtmSpecial.setControl(grpSpecialSections);

    Label lblGlossaries = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaries.setBounds(10, 51, 55, 15);
    lblGlossaries.setText("Glossaries:");

    Button btnHasGlossaries = new Button(grpSpecialSections, SWT.CHECK);
    btnHasGlossaries.setBounds(96, 51, 93, 16);
    btnHasGlossaries.setText("has glossaries");

    Label lblGlossaryHeading = new Label(grpSpecialSections, SWT.NONE);
    lblGlossaryHeading.setBounds(257, 51, 93, 15);
    lblGlossaryHeading.setText("Glossary heading");

    text_9 = new Text(grpSpecialSections, SWT.BORDER);
    text_9.setBounds(377, 48, 76, 21);

    Label lblReferences = new Label(grpSpecialSections, SWT.NONE);
    lblReferences.setBounds(10, 102, 69, 15);
    lblReferences.setText("References :");

    Button btnHasReferences = new Button(grpSpecialSections, SWT.CHECK);
    btnHasReferences.setBounds(96, 102, 93, 16);
    btnHasReferences.setText("has references");

    Label lblReferencesHeading = new Label(grpSpecialSections, SWT.NONE);
    lblReferencesHeading.setBounds(257, 102, 114, 15);
    lblReferencesHeading.setText("References heading:");

    text_10 = new Text(grpSpecialSections, SWT.BORDER);
    text_10.setBounds(377, 99, 76, 21);
    special = new SpecialBean(btnHasGlossaries, btnHasReferences, text_9, text_10);

    TabItem tbtmAbbreviations = new TabItem(tabFolder, SWT.NONE);
    tbtmAbbreviations.setText("Abbreviations");

    Group grpAbbreviationsUsedIn = new Group(tabFolder, SWT.NONE);
    tbtmAbbreviations.setControl(grpAbbreviationsUsedIn);

    text_11 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    text_11.setBounds(10, 52, 691, 69);
    abbreviations.put("Text", text_11);

    Label lblAbbreviationsUsedIn = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn.setBounds(10, 31, 272, 15);
    lblAbbreviationsUsedIn.setText("Abbreviations used in text:");

    Label lblAbbreviationsUsedIn_1 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_1.setBounds(10, 150, 272, 15);
    lblAbbreviationsUsedIn_1.setText("Abbreviations used in bibliographical citations:");

    text_12 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_12.setBounds(10, 175, 691, 69);
    abbreviations.put("Bibliographical Citations", text_12);

    Label lblAbbreviationsUsedIn_2 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_2.setBounds(10, 275, 272, 15);
    lblAbbreviationsUsedIn_2.setText("Abbreviations used in authorities:");

    text_13 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_13.setBounds(10, 296, 691, 69);
    abbreviations.put("Authorities", text_13);

    Label lblAbbreviationsUsedIn_3 = new Label(grpAbbreviationsUsedIn, SWT.NONE);
    lblAbbreviationsUsedIn_3.setBounds(10, 395, 204, 15);
    lblAbbreviationsUsedIn_3.setText("Abbreviations used in others:");

    text_8 = new Text(grpAbbreviationsUsedIn, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    text_8.setBounds(10, 416, 691, 69);
    abbreviations.put("Others", text_8);
    final Type2Bean bean =
        new Type2Bean(
            textBean, nomenclatures, expressions, descriptionBean, special, abbreviations);
    Button btnSave = new Button(shlTypeDocument, SWT.NONE);
    btnSave.setBounds(670, 563, 75, 25);
    btnSave.setText("Save");
    btnSave.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            try {
              if (configDb.saveType2Details(bean)) {
                ApplicationUtilities.showPopUpWindow(
                    ApplicationUtilities.getProperty("popup.info.savetype3"),
                    ApplicationUtilities.getProperty("popup.header.info"),
                    SWT.ICON_INFORMATION);
                shlTypeDocument.dispose();
              }
            } catch (SQLException exe) {

            }
          }
        });

    /* Load previously saved details here */
    try {
      configDb.retrieveType2Details(bean, this);
    } catch (SQLException exe) {
      exe.printStackTrace();
    }

    shlTypeDocument.open();
    shlTypeDocument.layout();
    while (!shlTypeDocument.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Ejemplo n.º 26
0
  public ConfigPanel(final Shell shell, final Composite parent, final int style) {
    super(parent, style);
    this.setBounds(0, 0, 970, 663);
    setLayout(null);
    config = new Config();
    this.shell = shell;

    Group group_2 = new Group(this, SWT.NONE);
    group_2.setText("地点配置");
    group_2.setBounds(10, 79, 937, 320);

    // Group group = new Group(group_2, SWT.NONE);
    // group.setText("裁判长");
    // group.setBounds(59, 34, 861, 93);
    //
    // Label label = new Label(group, SWT.NONE);
    // label.setBounds(25, 48, 55, 15);
    // label.setText("仲裁主任");
    //
    // intercessorText = new Text(group, SWT.BORDER);
    // intercessorText.setBounds(86, 48, 73, 21);
    //
    // Label label_1 = new Label(group, SWT.NONE);
    // label_1.setBounds(191, 48, 55, 15);
    // label_1.setText("副裁判长");
    //
    // viceRefereeText = new Text(group, SWT.BORDER);
    // viceRefereeText.setBounds(252, 48, 73, 21);
    //
    // Label label_2 = new Label(group, SWT.NONE);
    // label_2.setBounds(377, 48, 55, 15);
    // label_2.setText("总裁判长");
    //
    // refreeText = new Text(group, SWT.BORDER);
    // refreeText.setBounds(438, 48, 73, 21);

    Group group_1 = new Group(group_2, SWT.NONE);
    group_1.setText("比赛地点配置");
    group_1.setBounds(36, 69, 861, 93);

    Label label_3 = new Label(group_1, SWT.NONE);
    label_3.setBounds(40, 52, 55, 15);
    label_3.setText("参赛地点");

    locationText = new Text(group_1, SWT.BORDER);
    locationText.setBounds(113, 46, 73, 21);

    Button submit = new Button(group_2, SWT.NONE);
    submit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            String mention = "";
            // String intercessor=intercessorText.getText();
            boolean mark = false;
            // if(intercessor==null||intercessor.equals("")){
            // mention+="未填写仲裁主任的名字\n";
            // }
            // String viceReferee=viceRefereeText.getText();
            // if(viceReferee==null||viceReferee.equals("")){
            // mention+="未填写副裁判长的名字\n";
            // }
            // String refree=refreeText.getText();
            // if(refree==null||refree.equals("")){
            // mention+="未填写总裁判长的名字\n";
            // }
            String location = locationText.getText();
            if (location == null || location.equals("")) {
              mention += "未填写比赛地点的名字\n";
            }
            if (mention.equals("")) {
              mark = true;
            } else {
              MessageBox box = new MessageBox(shell, SWT.OK | SWT.CANCEL);
              box.setText("提示");
              box.setMessage("存在以下问题是否继续??\n" + mention);
              if (box.open() == SWT.OK) {
                mark = true;
              }
            }
            if (mark) {
              // if(intercessor==null||intercessor.equals("")){
              // data.get(0).put("name", "");
              // }else{
              // data.get(0).put("name", intercessor);
              // }
              // if(viceReferee==null||viceReferee.equals("")){
              // data.get(1).put("name", "");
              // }else{
              // data.get(1).put("name", viceReferee);
              // }
              // if(refree==null||refree.equals("")){
              // data.get(2).put("name", "");
              // }else{
              // data.get(2).put("name", refree);
              // }
              if (location == null || location.equals("")) {
                data.get(0).put("location", "");
                data.get(1).put("location", "");
                data.get(2).put("location", "");
              } else {
                data.get(0).put("location", location);
                data.get(1).put("location", location);
                data.get(2).put("location", location);
              }
              MessageBox box = new MessageBox(shell, SWT.OK);
              box.setText("提示");
              if (config.updateParams(data) > -1) {
                box.setMessage("修改成功");
              } else {
                box.setMessage("修改失败");
              }
              box.open();
            }
          }
        });
    submit.setBounds(823, 275, 75, 25);
    submit.setText("确定");

    // 初始化数据
    if (config.isCollected()) {
      data = config.getParams();
      // if(data.get(0).get("name")!=null){
      // intercessorText.setText(data.get(0).get("name").toString());
      // }
      // if(data.get(1).get("name")!=null){
      // viceRefereeText.setText(data.get(1).get("name").toString());
      // }
      // if(data.get(2).get("name")!=null){
      // refreeText.setText(data.get(2).get("name").toString());
      // }
      if (data.get(2).get("location") != null) {
        locationText.setText(data.get(2).get("location").toString());
      }
    } else {
      MessageBox box = new MessageBox(this.shell, SWT.OK);
      box.setText("提示");
      box.setMessage("数据库连接失败");
      box.open();
    }
  }
Ejemplo n.º 27
0
  /**
   * This method creates the SWT elements for an explorer
   *
   * @param parent Parent is the base composite
   */
  protected Control createContents(Composite parent) {

    parent.setBounds(0, 0, 550, 500);

    // upper sash
    SashForm sash = new SashForm(parent, SWT.VERTICAL | SWT.NULL);
    sash.setBounds(0, 0, 550, 480);
    // lower sash
    SashForm sash_form = new SashForm(sash, SWT.VERTICAL | SWT.NULL);
    sash_form.setBounds(0, 0, 200, 200);

    Composite composite = new Composite(sash, SWT.NONE);
    composite.setBounds(0, 0, 345, 220);

    final Label label = new Label(composite, SWT.NONE);
    label.setBounds(15, 15, 60, 20);
    label.setText("Root:");

    final Combo combo = new Combo(composite, SWT.NONE);
    combo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            tv.setInput(new File(combo.getText()));
          }
        });
    combo.setBounds(80, 10, 100, 20);
    File[] roots = File.listRoots();
    for (int i = 0; i < roots.length; i++) {
      combo.add(roots[i].toString());
    }
    combo.select(0);

    // explorer
    tv = new TreeViewer(sash_form);
    tv.setContentProvider(new FileTreeContentProvider());
    tv.setLabelProvider(new FileTreeLabelProvider());
    tv.setInput(new File(combo.getText()));

    final Label labelFile = new Label(composite, SWT.NONE);
    labelFile.setBounds(15, 45, 30, 25);
    if (buttonString.startsWith(saveString)) {
      labelFile.setText("Konfig:");
    } else {
      labelFile.setText("File:");
    }

    final Text fileName = new Text(composite, SWT.BORDER);
    fileName.setBounds(80, 40, 350, 25);

    final Label labelPath = new Label(composite, SWT.NONE);
    labelPath.setBounds(15, 75, 45, 25);
    labelPath.setText("Path:");

    final Label pathName = new Label(composite, SWT.NONE);
    pathName.setBounds(80, 75, 300, 25);

    if (buttonString.equals(loadString)) {
      final Label labedTemp = new Label(composite, SWT.NONE);
      labedTemp.setBounds(15, 230, 100, 25);
      labedTemp.setText("Temp:");

      textTemp = new Text(composite, SWT.BORDER);
      textTemp.setBounds(130, 230, 300, 25);
      textTemp.setText(Controller.loadTemp());

      final Label labelXargs = new Label(composite, SWT.NONE);
      labelXargs.setBounds(15, 195, 100, 25);
      labelXargs.setText("xargs template:");

      textXargs = new Text(composite, SWT.BORDER);
      textXargs.setBounds(130, 195, 300, 25);
      textXargs.setText(Controller.loadXarg());

      final Label labelLocal = new Label(composite, SWT.NONE);
      labelLocal.setBounds(15, 160, 100, 25);
      labelLocal.setText("Local deploy path:");

      textLocal = new Text(composite, SWT.BORDER);
      textLocal.setBounds(130, 160, 300, 25);
      textLocal.setText(Controller.loadLocal());
    }

    final Button exitButton = new Button(composite, SWT.NONE);
    exitButton.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            closeExplorer();
          }
        });
    exitButton.setBounds(50, 110, 100, 25);
    exitButton.setText("Cancel");

    if (buttonString == loadString) {
      final Button deployButton = new Button(composite, SWT.NONE);
      deployButton.addMouseListener(
          new MouseAdapter() {
            public void mouseDown(MouseEvent e) {

              String fullPath = "";

              char lastChar = pathName.getText().charAt(pathName.getText().length() - 1);
              if (lastChar != File.separatorChar) {
                pathName.setText(pathName.getText() + File.separatorChar);
              }

              if (fileName.getText().length() <= 0) {
                Controller.activateErrorView("choose a filename !");
                System.out.println("choose a filename !");
                return;
              }

              AmonemUI.amonemManager.setFolders(
                  textTemp.getText(), textLocal.getText(), textXargs.getText(), textTemp.getText());

              AmonemUI.amonemManager.importDAG(pathName.getText() + fileName.getText(), true);

              Controller.closeExplorer();
            }
          });
      deployButton.setBounds(270, 110, 100, 25);
      deployButton.setText("Deploy");
    }

    Button button = new Button(composite, 0);
    button.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {

            //				if(pathName.getText().length()<=0 || fileName.getText().length()<=0){
            //					System.out.println("path directory error");
            //					return;
            //				}

            String fullPath = "";
            //				if(pathName.getText().endsWith(String.valueOf(Path.SEPARATOR)) ||
            // pathName.getText().endsWith("\\")){
            //					fullPath = pathName.getText()+fileName.getText();
            //				}else{
            //					fullPath = pathName.getText()+String.valueOf(Path.SEPARATOR)+fileName.getText();
            //				}
            //				if(pathName.getText().lastIndexOf("/") != pathName.getText().firstIndexOf("/")){
            //
            //				}
            //				System.out.println(pathName.getText());
            //				System.out.println(fileName.getText());
            //				System.out.println(pathName.getText()+fileName.getText());
            //
            char lastChar = pathName.getText().charAt(pathName.getText().length() - 1);
            //				if(!(lastChar == Path.SEPARATOR || lastChar == '\\')){
            //					pathName.setText(pathName.getText()+Path.SEPARATOR);
            //				}

            if (lastChar != File.separatorChar) {
              pathName.setText(pathName.getText() + File.separatorChar);
            }

            // System.out.println(pathName.getText());

            if (buttonString == okString) {
              if (mode == DIRECTORY) {
                text.setText(pathName.getText());
              } else if (mode == FILE) {
                text.setText(pathName.getText() + fileName.getText());
              }
            } else {
              // fileName not needed
              if (buttonString == savePeerString) {
                AmonemUI.amonemManager.exportPeer(pathName.getText(), fieldName);
              }
              // fileName needed
              else {
                if (fileName.getText().length() <= 0) {
                  Controller.activateErrorView("choose a filename !");
                  System.out.println("choose a filename !");
                  return;
                }
                // System.out.println(pathName.getText()+Path.SEPARATOR+fileName.getText());
                if (buttonString == loadString) {
                  AmonemUI.amonemManager.importDAG(pathName.getText() + fileName.getText(), false);
                } else if (buttonString == saveString) {
                  AmonemUI.amonemManager.exportDAG(pathName.getText(), fileName.getText());
                }
              }
            }
            Controller.closeExplorer();
          }
        });
    button.setBounds(160, 110, 100, 25);
    button.setText(buttonString);

    tv.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            File selected_file = (File) selection.getFirstElement();
            if (selected_file.isDirectory()) {
              pathName.setText(selected_file.toString());
              fileName.setText("");
            }
            if (selected_file.isFile()) {
              fileName.setText(selected_file.getName());
              pathName.setText(
                  selected_file
                      .toString()
                      .substring(
                          0, selected_file.toString().length() - selected_file.getName().length()));
            }
          }
        });

    parent.pack();
    parent.update();

    return sash;
  }
 public void relocate(CellEditor celleditor) {
   Text text = (Text) celleditor.getControl();
   Point origin = getViewportOrigin().getNegated();
   Rectangle rect = label.getTextBounds().getCopy().expand(5, 0).translate(origin);
   text.setBounds(rect.x, rect.y, rect.width, rect.height);
 }
Ejemplo n.º 29
0
  /** *************************************************************** */
  private void creaContenidos() {
    display = new Display();
    shell = new Shell();

    // EN CASO DE NO RECUPERAR BIEN TOD0 EL CODIGO CNO browser.getText(); lo hacemos con el DOM
    // mediante JAVASCRIPT
    // System.out.println( (String)brw.evaluate("return document.forms[0].innerHTML;") );
    //
    // if ((Boolean)brw.evaluate("return raise('SelectFare', new SelectFareEventArgs(1, 1, 'G'));"))
    // System.out.println("raise() EJEC CORRECMT");;

    final String html =
        "<html><title>Snippet</title><body><p id='myid'>Best Friends</p><p id='myid2'>Cat and Dog</p></body></html>";
    // final String jsSelecValladolid = "var i=0; while(Stations[i]!=null){; i++;}";

    // Ej de jQuery que funciona: Devuelve el valor del listbox de "Origen Vuelo" selecionado
    final String jQueryRyan = "var orig=$(\"select[@id*='Origin1']\").val(); alert(orig);";
    // "$(\"select[@id*='Origin1']\")[posicion].attr('selected', 'true');";

    /** *** VARIABLES !!!VENTANA¡¡¡ **** */

    // SYSTEM TRAY
    Image image = null;
    try {
      // image = new Image(display, /*rutaActual*/"C:\\"+"fr.ico");
      image = new Image(display, rutaActual + "fr.ico");
    } catch (Exception e) {
      e.getMessage();
    }
    final Tray tray = display.getSystemTray();
    if (tray == null) {
      System.out.println("El system tray no está disponible");
    } else {
      final TrayItem item = new TrayItem(tray, SWT.NONE);
      item.setToolTipText("Ryanair Inspector v2");
      item.setImage(image);
      // Click simple en en icono
      item.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {
              // System.out.println("selection");
            }
          });
      // Doble click en en icono
      item.addListener(
          SWT.DefaultSelection,
          new Listener() {
            public void handleEvent(Event event) {
              // System.out.println("default selection");
              // mio
              if (shell.getVisible()) shell.setVisible(false);
              else shell.setVisible(true);
              // shell.setMinimized(false);
              // shell.setMinimized(true);
            }
          });
    }

    // SHELL
    shell.setSize(1054, 727);
    // shell.setLayout(new FillLayout());
    shell.setText("Ryanair checker");
    shell.setImage(image);
    // Con esto al agrandar y empequeñecer se reorganizan los componentes
    // shell.setLayout(new FillLayout());

    // CREAMOS CONTENEDOR
    /** ************************************************************************ */
    compIzq = new Composite(shell, SWT.NONE);
    compIzq.setBounds(0, 0, 765, 691);
    final FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    fillLayout.marginWidth = 200;
    fillLayout.marginHeight = 200;
    // comp.setLayout(fillLayout);
    // comp.setSize(200, 200);

    compDer = new Composite(shell, SWT.NONE);
    compDer.setBounds(771, 0, 267, 691);

    // CREAMOS CAJA TEXTO Y BOTON PARA HTML OBTENIDO
    /** ************************************************************************ */
    final Text txtGetHTML = new Text(compDer, SWT.MULTI);
    txtGetHTML.setBounds(0, 0, 251, 198);

    // RyanairInspector2.class.getResource("RyanairInspector2.class").getPath();
    // System.getProperty("user.dir")+"\\bin\\calculadora\\";
    txtGetHTML.setText(
        RyanairInspector2.class.getResource("RyanairInspector2.class").getPath()
            + "\n"
            + System.getProperty("user.dir"));

    final Button button = new Button(compDer, SWT.NONE);
    button.setText("button");

    // TABS
    /** ************************************************************************ */
    tabFolder = new TabFolder(compIzq, SWT.BORDER);
    itemT1 = new TabItem(tabFolder, SWT.NONE);
    itemT2 = new TabItem(tabFolder, SWT.NONE);
    itemT3 = new TabItem(tabFolder, SWT.NONE);
    itemT1.setText("Resultado");
    itemT2.setText("Debugger");
    itemT3.setText("Hilos");

    // TABLE CON DOS COLUMNAS
    /** ************************************************************************ */
    table = new Table(tabFolder, SWT.VIRTUAL);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText("Origen");
    column1.setWidth(200);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText("Destino");
    column2.setWidth(200);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText("Fecha");
    column3.setWidth(200);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setText("Precio");
    column4.setWidth(150);

    /* Metemos elementos en la tabla
    TableItem fila = new TableItem(table, SWT.NONE);
    fila.setText(new String[] { "a", "b", "c", "d" });
    */

    // METEMOS EL TABLE EN LA TAB2
    itemT1.setControl(table);
    tabFolder.setBounds(0, 0, 700, 691);
    tabFolder.pack();

    // CREAMOS BROWSER
    /** ************************************************************************ */
    try {
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      return;
    }
    // CREAMOS BROWSER (2)
    /** ************************************************************************ */
    // FUNCIONA BIEN SIN TABS: browser = new Browser(compIzq, SWT.BORDER);

    // El Normal
    navegadores.add(new Navegador(tabFolder, SWT.BORDER));
    // El Mozilla (hay q ejecutar el xulrunner.exe --register-global)
    // browser = new Browser(tabFolder, SWT.MOZILLA);
    // browser.setSize(1000, 800);
    navegadores.get(0).setBounds(0, 0, 787, 691);
    // browser.setLocation(500, 900);
    /*final FillLayout fillLayoutB = new FillLayout(SWT.VERTICAL);
    fillLayoutB.marginWidth = 200;
    fillLayoutB.marginHeight = 200;
    browser.setLayout(fillLayoutB);
     */

    // METEMOS EL BROWSER EN LA TAB1
    itemT2.setControl(navegadores.get(0)); // prueba18-6-09
    // browser.setVisible(false);

    tabFolder.setBounds(0, 0, 766, 691);
    tabFolder.pack();

    navegadores.add(new Navegador(tabFolder, SWT.BORDER));
    navegadores.get(1).setBounds(0, 0, 787, 691);
    itemT3.setControl(navegadores.get(1));

    // CADA VEZ!!! QUE TERMINE DE CARGAR
    navegadores
        .get(0)
        .addProgressListener(
            new ProgressAdapter() {
              public void completed(ProgressEvent event) {
                if (!postSubmit(navegadores.get(0), table)) {
                  System.out.println(
                      "ERROR: Problema al ejecutar la gestion de los datos, finalizar la carga de la pagina.");
                }
              }
            });

    // CADA VEZ!!! QUE TERMINE DE CARGAR
    navegadores
        .get(1)
        .addProgressListener(
            new ProgressAdapter() {
              public void completed(ProgressEvent event) {
                if (!postSubmit(navegadores.get(1), table)) {
                  System.out.println(
                      "ERROR: Problema al ejecutar la gestion de los datos, finalizar la carga de la pagina.");
                }
              }
            });

    // BOTON OBTENER HTML
    /** ************************************************************************ */
    final Button btnGetHTML = new Button(compDer, SWT.PUSH);
    btnGetHTML.setBounds(0, 204, 151, 30);
    btnGetHTML.setText("Obtener codigo html");
    btnGetHTML.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {

            addBrowser();

            String result = navegadores.get(0).getText();
            txtGetHTML.setText(result);
          }
        });

    // CREAMOS CAJA TEXTO PARA EJECUTAR JS
    /** ************************************************************************ */
    /*final Text txtJS = new Text(compDer, SWT.MULTI);
    txtJS.setText("var newNode = document.createElement('P'); \r\n"+
    		"var text = document.createTextNode('At least when I am around');\r\n"+
    		"newNode.appendChild(text);\r\n"+
    		"document.getElementById('myid').appendChild(newNode);\r\n"+
    		"document.bgColor='yellow';\r\n"+
    		"\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_OneWay').checked = true;\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_ButtonSubmit').click();\r\n"+
    		"document.getElementById('AvailabilitySearchInputFRSearchView_DropDownListMarketOrigin1')[2].selected=true;\r\n"+
    		"Destination1");
    */

    // BOTON LANZAMOS RYANAIR
    /** ************************************************************************ */
    /*final Button btnCargarRyan = new Button(compDer, SWT.PUSH);
    btnCargarRyan.setText("Cargar RYANAIR");
    btnCargarRyan.addListener(SWT.Selection, new Listener() {
    	public void handleEvent(Event event) {
    		//boolean result = browser.execute(text.getText());
    		boolean result = browser.setUrl("http://www.bookryanair.com/SkySales/FRSearch.aspx?culture=ES-ES&pos=HEAD");
    		if (!result) {
    			// Script may fail or may not be supported on certain platforms.
    			System.out.println("Script was not executed.");
    		}
    	}
    });
    */

    // BOTON EJECUTAMOS JAVASCRIPT
    /** ************************************************************************ */
    final Button btnEjeJS = new Button(compDer, SWT.PUSH);
    btnEjeJS.setBounds(0, 266, 151, 30);
    btnEjeJS.setText("Ejecutar JAVASCRIPT");
    btnEjeJS.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {}
        });

    // image.dispose(); //con esto no funciona el shell.setImage(image)

  }
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public ComputingInfrastructureServiceComposite(Composite parent, int style) {
    super(parent, style);
    setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    setLayout(new FormLayout());

    Label lblTitle = new Label(this, SWT.NONE);
    lblTitle.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblTitle.setFont(SWTResourceManager.getFont("Ubuntu", 13, SWT.NORMAL));
    FormData fd_lblTitle = new FormData();
    fd_lblTitle.bottom = new FormAttachment(0, 21);
    fd_lblTitle.top = new FormAttachment(0);
    fd_lblTitle.left = new FormAttachment(0);
    lblTitle.setLayoutData(fd_lblTitle);
    lblTitle.setText("Instance name:");

    Composite composite = new Composite(this, SWT.BORDER);
    FormData fd_composite = new FormData();
    fd_composite.bottom = new FormAttachment(lblTitle, 210, SWT.BOTTOM);
    fd_composite.top = new FormAttachment(lblTitle, 6);
    fd_composite.left = new FormAttachment(lblTitle, 10, SWT.LEFT);
    fd_composite.right = new FormAttachment(100, -11);
    composite.setLayoutData(fd_composite);

    CLabel label_1 = new CLabel(composite, SWT.NONE);
    label_1.setText("Instance");
    label_1.setBounds(10, 36, 115, 23);

    CLabel label_2 = new CLabel(composite, SWT.NONE);
    label_2.setText("CPU (MHz)");
    label_2.setLeftMargin(10);
    label_2.setBounds(10, 71, 115, 23);

    CLabel label_3 = new CLabel(composite, SWT.NONE);
    label_3.setText("CPU (Units)");
    label_3.setLeftMargin(10);
    label_3.setBounds(10, 100, 89, 23);

    CLabel label_4 = new CLabel(composite, SWT.NONE);
    label_4.setText("Memory (MB)");
    label_4.setLeftMargin(10);
    label_4.setBounds(10, 129, 104, 23);

    txtCpu = new Text(composite, SWT.BORDER);
    txtCpu.setText("0");
    // txtCpu.setEnabled(false);
    txtCpu.setBounds(141, 73, 70, 21);

    txtCpuUnits = new Text(composite, SWT.BORDER);
    txtCpuUnits.setText("0");
    // txtCpuUnits.setEnabled(false);
    txtCpuUnits.setBounds(141, 102, 70, 21);

    txtMemory = new Text(composite, SWT.BORDER);
    txtMemory.setText("0");
    // txtMemory.setEnabled(false);
    txtMemory.setBounds(141, 131, 70, 21);

    CLabel label_5 = new CLabel(composite, SWT.NONE);
    label_5.setText("Storage (GB)");
    label_5.setLeftMargin(10);
    label_5.setBounds(10, 158, 97, 23);

    txtStorage = new Text(composite, SWT.BORDER);
    txtStorage.setText("0");
    // txtStorage.setEnabled(false);
    txtStorage.setBounds(141, 160, 70, 21);

    Label lblHardware = new Label(composite, SWT.NONE);
    lblHardware.setBounds(10, 10, 311, 17);
    lblHardware.setText("Hardware specification");

    Composite composite_1 = new Composite(this, SWT.BORDER);
    composite_1.setLayout(new FormLayout());
    FormData fd_composite_1 = new FormData();
    fd_composite_1.bottom = new FormAttachment(100, -10);
    fd_composite_1.top = new FormAttachment(composite, 6);
    fd_composite_1.right = new FormAttachment(100, -11);
    fd_composite_1.left = new FormAttachment(0, 10);

    comboViewer = new ComboViewer(composite, SWT.NONE);
    Combo combo = comboViewer.getCombo();
    combo.setBounds(141, 36, 180, 29);
    composite_1.setLayoutData(fd_composite_1);

    Label lblComponents = new Label(composite_1, SWT.NONE);
    FormData fd_lblComponents = new FormData();
    fd_lblComponents.right = new FormAttachment(0, 88);
    fd_lblComponents.top = new FormAttachment(0, 10);
    fd_lblComponents.left = new FormAttachment(0, 10);
    lblComponents.setLayoutData(fd_lblComponents);
    lblComponents.setText("Software");

    CLabel label = new CLabel(composite_1, SWT.NONE);
    FormData fd_label = new FormData();
    fd_label.top = new FormAttachment(0, 45);
    fd_label.left = new FormAttachment(0, 10);
    label.setLayoutData(fd_label);
    label.setText("Operating system");

    textOs = new Text(composite_1, SWT.BORDER);
    FormData fd_textOs = new FormData();
    fd_textOs.bottom = new FormAttachment(0, 72);
    fd_textOs.right = new FormAttachment(0, 321);
    fd_textOs.top = new FormAttachment(0, 45);
    fd_textOs.left = new FormAttachment(0, 141);
    textOs.setLayoutData(fd_textOs);
    textOs.setText("Debian 7.1 Linux");
    textOs.setEditable(false);

    CLabel lblComponents_1 = new CLabel(composite_1, SWT.NONE);
    FormData fd_lblComponents_1 = new FormData();
    fd_lblComponents_1.left = new FormAttachment(0, 10);
    fd_lblComponents_1.right = new FormAttachment(100, -106);
    fd_lblComponents_1.top = new FormAttachment(0, 91);
    lblComponents_1.setLayoutData(fd_lblComponents_1);
    lblComponents_1.setText("Deployed platform services");

    tableViewer = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION);
    tableViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
              IStructuredSelection selection = (IStructuredSelection) event.getSelection();
              PlatformService platformService = (PlatformService) selection.getFirstElement();
              Util.openEditor(
                  new PlatformServiceEditorInput(platformService), PlatformServiceEditor.ID);
            }
          }
        });
    table = tableViewer.getTable();
    FormData fd_table = new FormData();
    fd_table.bottom = new FormAttachment(100, -10);
    fd_table.top = new FormAttachment(lblComponents_1, 6);
    fd_table.left = new FormAttachment(0, 10);
    fd_table.right = new FormAttachment(100, -10);
    table.setLayoutData(fd_table);

    txtName = new Text(this, SWT.BORDER);
    txtName.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    FormData fd_txtName = new FormData();
    fd_txtName.top = new FormAttachment(lblTitle, 0, SWT.TOP);
    fd_txtName.bottom = new FormAttachment(composite, -6);
    fd_txtName.right = new FormAttachment(100, -11);
    fd_txtName.left = new FormAttachment(lblTitle, 6);
    txtName.setLayoutData(fd_txtName);

    // Should not be called -- the call is auto-generated
    if (computingInfrastructureService != null) m_bindingContext = initDataBindings();
  }