Exemplo n.º 1
0
 /**
  * Sets the size of the shell to it's "packed" size, unless that makes it bigger than the display,
  * in which case set it to 9/10 of display size.
  */
 private static void setShellSize(Display display, Shell shell) {
   Rectangle bounds = display.getBounds();
   Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) size.x = bounds.width * 9 / 10;
   if (size.y > bounds.height) size.y = bounds.height * 9 / 10;
   shell.setSize(size);
 }
Exemplo n.º 2
0
 /** Center the supplied Shell */
 public static void centerShell(Shell shell) {
   Display d = shell.getDisplay();
   Rectangle db = d.getBounds();
   Rectangle sb = shell.getBounds();
   int xoffset = (db.width - sb.width) / 2;
   int yoffset = (db.height - sb.height) / 2;
   shell.setLocation(xoffset, yoffset);
 }
Exemplo n.º 3
0
 private DisplayClass getDisplayClass(Display paramDisplay) {
   int i = paramDisplay.getBounds().height;
   if (i <= 768) return DisplayClass.DisplayClass_768;
   if (i <= 800) return DisplayClass.DisplayClass_800;
   if (i <= 900) return DisplayClass.DisplayClass_900;
   if (i <= 1050) return DisplayClass.DisplayClass_1050;
   return DisplayClass.DisplayClass_1280;
 }
Exemplo n.º 4
0
 /**
  * Gets the bounds.
  *
  * @return the bounds
  */
 public static Rectangle getBounds() {
   Display display = Display.getDefault();
   Rectangle bounds = display.getBounds();
   Rectangle result =
       new Rectangle(
           bounds.x + bounds.width / 4,
           bounds.y + bounds.height / 4,
           bounds.width / 2,
           bounds.height / 2);
   return result;
 }
Exemplo n.º 5
0
 private static void setShellSize(
     org.eclipse.swt.widgets.Display display, org.eclipse.swt.widgets.Shell shell) {
   org.eclipse.swt.graphics.Rectangle bounds = display.getBounds();
   org.eclipse.swt.graphics.Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) {
     size.x = bounds.width * 9 / 10;
   }
   if (size.y > bounds.height) {
     size.y = bounds.height * 9 / 10;
   }
   shell.setSize(size);
 }
  /**
   * Get the size hints for the receiver. These are used for layout data.
   *
   * @return Point - the preferred x and y coordinates
   */
  public Point getSizeHints() {

    Display display = canvas.getDisplay();

    GC gc = new GC(canvas);
    FontMetrics fm = gc.getFontMetrics();
    int charWidth = fm.getAverageCharWidth();
    int charHeight = fm.getHeight();
    gc.dispose();

    int maxWidth = display.getBounds().width / 2;
    int maxHeight = display.getBounds().height / 6;
    int fontWidth = charWidth * maxCharacterWidth;
    int fontHeight = charHeight * numShowItems;
    if (maxWidth < fontWidth) {
      fontWidth = maxWidth;
    }
    if (maxHeight < fontHeight) {
      fontHeight = maxHeight;
    }
    return new Point(fontWidth, fontHeight);
  }
Exemplo n.º 7
0
 protected Shell createSplash(Display display) {
   final Shell splash = new Shell(display, SWT.ON_TOP);
   splash.setLayout(new GridLayout(1, true));
   Label l = new Label(splash, SWT.NONE);
   l.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
   l.setText("Caleydo Sandbox");
   splash.setSize(200, 100);
   Rectangle splashRect = splash.getBounds();
   Rectangle displayRect = display.getBounds();
   int x = (displayRect.width - splashRect.width) / 2;
   int y = (displayRect.height - splashRect.height) / 2;
   splash.setLocation(x, y);
   return splash;
 }
Exemplo n.º 8
0
  /** Show the window and return when it's closed. */
  public void show() {
    Rectangle dispSize = display.getBounds();
    shell.setLocation(
        (dispSize.width - shell.getSize().x) / 2, (dispSize.height - shell.getSize().y) / 2);
    shell.open();

    // This is to force redraw -- at some point SWT stopped drawing
    // window contents correctly on start, but after resizing everything
    // looks fine.
    shell.setSize(shell.getSize().x + 1, shell.getSize().y + 1);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
  public boolean checkPassword(String[] savedUserInfos) {
    // center the dialog screen to the monitor
    Rectangle bounds = display.getBounds();
    Rectangle rect = shlObaLogin.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shlObaLogin.setLocation(x, y);
    shlObaLogin.open();
    for (int i = 0; i < 100; i++) {
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      bar.setSelection(i);
    }

    controller = OBAController.getInstance();
    boolean result = controller.loginWithSavePasswd(savedUserInfos);
    display.dispose();
    return result;
  }
Exemplo n.º 10
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();
    }
  }
Exemplo n.º 11
0
  public static void logIn(Display display, final AssemblyUsersModel assemblyUsersModel) {
    // Set layout for shell
    final Shell shell = new Shell(display);
    shell.setText("Monitoring montaze - Prihlasenie");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);
    Composite composite = new Composite(shell, SWT.BORDER);
    composite.setLayout(new GridLayout(2, false));
    new Label(composite, SWT.None);
    new Label(composite, SWT.None);
    Label label = new Label(composite, SWT.None);
    label.setText("Zadajte prihlasovacie udaje:");
    GridData gdLabel = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gdLabel.horizontalSpan = 2;
    label.setLayoutData(gdLabel);
    new Label(composite, SWT.None);
    new Label(composite, SWT.None);
    label = new Label(composite, SWT.None);
    label.setText("ID uzivatela:");
    final Text txUserId = new Text(composite, SWT.BORDER);
    GridData gdText = new GridData();
    gdText.widthHint = 250;
    txUserId.setLayoutData(gdText);
    label = new Label(composite, SWT.None);
    label.setText("Heslo:");
    final Text txPassword = new Text(composite, SWT.PASSWORD | SWT.BORDER);
    txPassword.setLayoutData(gdText);
    new Label(composite, SWT.None);
    new Label(composite, SWT.None);
    Composite btnComposite = new Composite(composite, SWT.None);
    btnComposite.setLayout(new GridLayout(2, true));
    GridData gdBtnComposite = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gdBtnComposite.horizontalSpan = 2;
    btnComposite.setLayoutData(gdBtnComposite);
    Button btnLogIn = new Button(btnComposite, SWT.BORDER | SWT.FLAT);
    btnLogIn.setText("Prihlas");
    GridData gdLoginButton = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gdLoginButton.widthHint = 160;
    btnLogIn.setLayoutData(gdLoginButton);
    Button btnCancel = new Button(btnComposite, SWT.BORDER | SWT.FLAT);
    btnCancel.setText("Zrus");
    GridData gdCancelButton = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gdCancelButton.widthHint = 160;
    btnCancel.setLayoutData(gdCancelButton);
    btnCancel.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            shell.dispose();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {}
        });
    btnLogIn.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            if (assemblyUsersModel.checkAndSetLoggedUser(
                txUserId.getText(), txPassword.getText())) {
              shell.dispose();
            } else {
              MessageBox.displayMessageBox(
                  shell,
                  SWT.ERROR,
                  "Monitoring montaze - chyba prihlasenia",
                  "Zadane prihlasovacie udaje su nespravne.\nZadajte znovu prosim.");
              txPassword.setText("");
              txPassword.setFocus();
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {}
        });
    // Ask the shell to display its content
    shell.pack();
    Point shellSize = shell.getSize();
    shell.setLocation(
        (display.getBounds().width - shellSize.x) / 2,
        (display.getBounds().height - shellSize.y) / 2);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Exemplo n.º 12
0
 public static void main(String[] args) {
   final Display display = new Display();
   final int[] count = new int[] {4};
   final Image image = new Image(display, 300, 300);
   GC gc = new GC(image);
   gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
   gc.fillRectangle(image.getBounds());
   gc.drawText("Splash Screen", 10, 10);
   gc.dispose();
   final Shell splash = new Shell(SWT.ON_TOP);
   final ProgressBar bar = new ProgressBar(splash, SWT.NONE);
   bar.setMaximum(count[0]);
   Label label = new Label(splash, SWT.NONE);
   label.setImage(SWTResourceManager.getImage(SplashScreen.class, "/resources/splashep.png"));
   FormLayout layout = new FormLayout();
   splash.setLayout(layout);
   FormData labelData = new FormData();
   labelData.right = new FormAttachment(100, 0);
   labelData.bottom = new FormAttachment(100, 0);
   label.setLayoutData(labelData);
   FormData progressData = new FormData();
   progressData.left = new FormAttachment(0, 5);
   progressData.right = new FormAttachment(100, -5);
   progressData.bottom = new FormAttachment(100, -5);
   bar.setLayoutData(progressData);
   splash.pack();
   Rectangle splashRect = splash.getBounds();
   Rectangle displayRect = display.getBounds();
   int x = (displayRect.width - splashRect.width) / 2;
   int y = (displayRect.height - splashRect.height) / 2;
   splash.setLocation(x, y);
   splash.open();
   display.asyncExec(
       new Runnable() {
         @Override
         public void run() {
           Shell[] shells = new Shell[count[0]];
           for (int i = 0; i < count[0]; i++) {
             shells[i] = new Shell(display);
             shells[i].setSize(300, 300);
             shells[i].addListener(
                 SWT.Close,
                 new Listener() {
                   @Override
                   public void handleEvent(Event e) {
                     --count[0];
                   }
                 });
             bar.setSelection(i + 1);
             try {
               Thread.sleep(1000);
             } catch (Throwable e) {
             }
           }
           splash.close();
           image.dispose();
           // Start Main Window
           MainWindow.main(null);
         }
       });
   while (count[0] != 0) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }