private Composite createStyleTabContent(Composite folder) {
    int nColumns = 3;
    final ScrolledPageContent sc1 = new ScrolledPageContent(folder);

    Composite composite = sc1.getBody();
    GridLayout layout = new GridLayout(nColumns, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);

    Label description = new Label(composite, SWT.LEFT | SWT.WRAP);
    description.setFont(description.getFont());
    description.setText(
        "Select the severity level for the following optional "
            + lastSegment(languageName)
            + " compiler problems:");
    description.setLayoutData(
        new GridData(GridData.BEGINNING, GridData.CENTER, true, false, nColumns - 1, 1));

    int indentStep = fPixelConverter.convertWidthInCharsToPixels(1);

    int defaultIndent = indentStep * 0;

    fillSettingsPage(composite, nColumns, defaultIndent);

    new Label(composite, SWT.NONE); // TODO what's this?
    restoreSectionExpansionStates(section);
    return sc1;
  }
  private void createLabel(Composite c, int span, String content, Image image, LabelAttributes la) {
    if (content == null && image == null) return;

    Label l = new Label(c, la.getFontStyle());
    GridData gd = new GridData();
    gd.verticalSpan = span;
    gd.horizontalIndent = 5;
    if (content != null) l.setText(content);

    if (image != null) l.setImage(image);
    if (la.getForegroundColor() != null)
      l.setForeground(new Color(DisplayManager.getDefaultDisplay(), la.getForegroundColor()));

    Font initialFont = l.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(la.getFontSize());
      fontData[i].setStyle(la.getFontStyle());
    }
    Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
    l.setFont(newFont);
    l.pack();

    l.setBackground(c.getBackground());
    l.setLayoutData(gd);
  }
Пример #3
0
 /**
  * Update the width of the label to take into account the error font. Only works for labels in a
  * grid layout
  *
  * @param label
  * @param errorFont
  */
 public static void updateErrorLabelWidth(Label label, Font errorFont) {
   Object layoutData = label.getLayoutData();
   if (layoutData instanceof GridData) {
     Font currentFont = label.getFont();
     label.setFont(errorFont);
     ((GridData) layoutData).widthHint = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
     label.setFont(currentFont);
   }
 }
Пример #4
0
 private static void setBoldFont(Label name) {
   if (boldFont == null) {
     Font initialFont = name.getFont();
     FontData[] fontData = initialFont.getFontData();
     for (int i = 0; i < fontData.length; i++) fontData[i].setStyle(SWT.BOLD);
     boldFont = new Font(Display.getCurrent(), fontData);
   }
   name.setFont(boldFont);
 }
Пример #5
0
  protected void applyFonts(final Composite composite) {
    Dialog.applyDialogFont(composite);

    if (info != null) {
      final Font font = info.getFont();
      final FontData[] fontDatas = font.getFontData();
      for (int i = 0; i < fontDatas.length; i++) {
        fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
      }
      infoFont = new Font(info.getDisplay(), fontDatas);
      info.setFont(infoFont);
    }
  }
  private void addTitle(Composite parent, String text) {
    Label label = new Label(parent, SWT.LEFT);
    label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1));
    label.setText(text);

    FontData[] fontDatas = label.getFont().getFontData();
    if (fontDatas.length > 0) {
      int fHeight = (fontDatas[0].getHeight() + 2);
      int fStyle = (fontDatas[0].getStyle() | SWT.BOLD);
      final Font font = new Font(label.getDisplay(), fontDatas[0].getName(), fHeight, fStyle);
      label.setFont(font);
      label.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
              font.dispose();
            }
          });
    }
  }
Пример #7
0
 private void refontLabel(boolean dye) {
   FontData fontData = label.getFont().getFontData()[0];
   Font font;
   int color;
   if (dye) {
     font =
         new Font(
             label.getParent().getDisplay(),
             new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
     color = SWT.COLOR_RED;
   } else {
     font =
         new Font(
             label.getParent().getDisplay(),
             new FontData(fontData.getName(), fontData.getHeight(), SWT.NONE));
     color = SWT.COLOR_WIDGET_FOREGROUND;
   }
   label.setForeground(label.getParent().getDisplay().getSystemColor(color));
   label.setFont(font);
 }
  /**
   * Clients are expected to override this method if they require a custom layout with various
   * composites
   *
   * @param parent
   * @param top
   */
  protected void addDeploymentLocationControls(Composite parent, Control top) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Label l1 = toolkit.createLabel(parent, Messages.EditorDeploymentPageWarning);
    FontData fontData = l1.getFont().getFontData()[0];
    Font font =
        new Font(
            parent.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    l1.setFont(font);

    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 5);
    fd.top = top == null ? new FormAttachment(0, 5) : new FormAttachment(top, 5);
    fd.right = new FormAttachment(100, -5);
    l1.setLayoutData(fd);

    errorImage = toolkit.createLabel(parent, "");
    fd = new FormData();
    fd.top = new FormAttachment(l1, 5);
    fd.left = new FormAttachment(0, 0);
    errorImage.setLayoutData(fd);

    errorLabel = toolkit.createLabel(parent, "", SWT.WRAP);
    fd = new FormData();
    fd.top = new FormAttachment(l1, 5);
    fd.left = new FormAttachment(0, 20);
    fd.right = new FormAttachment(0, 600);
    errorLabel.setLayoutData(fd);

    // First section is deployment mode (server / custom / metadata) etc.
    standardOptions = createServerDeploymentOptions(parent);
    standardOptions.setLayoutData(UIUtil.createFormData2(errorLabel, 5, null, 0, 0, 5, 100, -5));

    // Simply create a composite to show the per-module customizations
    perModuleOptions = createModuleDeploymentOptions(parent);
    fd = new FormData();
    fd.left = new FormAttachment(0, 5);
    fd.top = new FormAttachment(standardOptions, 5);
    fd.right = new FormAttachment(100, -5);
    fd.bottom = new FormAttachment(100, -5);
    perModuleOptions.setLayoutData(fd);
  }
Пример #9
0
  public ConfigMaker(File configFile) {
    builder = new Builder(configFile);

    display = new Display();
    shell = new Shell(display);
    shell.setText("Negura Server");
    shell.setSize(760, 620);
    stackLayout = new StackLayout();
    shell.setLayout(stackLayout);

    // Page one positioning. ///////////////////////////////////////////////
    p1 = new Composite(shell, SWT.NONE);
    p1.setLayout(new MigLayout("insets 10", "[right][200!][max][100::, fill]"));
    Label newConfigL = Swt.newLabel(p1, "span, align left, wrap 30px", "New configuration");

    Swt.newLabel(p1, null, "Server name:");
    serverNameT = Swt.newText(p1, "w max, wrap", "Negura Server Name");

    Swt.newLabel(p1, null, "Block size:");
    blockSizeC = Swt.newCombo(p1, "w max, wrap 25px", optionsStr, 2);

    Swt.newLabel(p1, null, "Virtual disk blocks:");
    diskBlocksT = Swt.newText(p1, "w max", null);
    Scale diskBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64);

    Swt.newLabel(p1, null, "Virtual disk space:");
    Label diskSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null);

    Swt.newLabel(p1, null, "Minimum user blocks:");
    minBlocksT = Swt.newText(p1, "w max", null);
    Scale minBlocksS = Swt.newHScale(p1, "span, w max, wrap", 128, 1024, 64);

    Swt.newLabel(p1, null, "Minimum user space:");
    Label minSpaceL = Swt.newLabel(p1, "w max, wrap 25px", null);

    Swt.newLabel(p1, null, "Port:");
    portT = Swt.newText(p1, "w max, wrap", "5000");

    Swt.newLabel(p1, null, "Check-in time:");
    checkInTimeT = Swt.newText(p1, "w max", "300");
    Swt.newLabel(p1, "wrap", "seconds");

    Swt.newLabel(p1, null, "Thread pool options:");
    threadPoolT =
        Swt.newText(p1, "span, w max, wrap 25px", new ThreadPoolOptions(2, 20, 30000).toString());

    Swt.newLabel(p1, null, "Database URL:");
    databaseUrlT = Swt.newText(p1, "span, w max", "jdbc:postgresql://127.0.0.1:5432/neguradb");

    Swt.newLabel(p1, null, "Database user:"******"w max, wrap", "p");

    Swt.newLabel(p1, null, "Database password:"******"w max, wrap push", "password");

    Button continueB = Swt.newButton(p1, "skip 3", "Continue");

    // Page one options. ///////////////////////////////////////////////////
    titleFont = Swt.getFontWithDifferentHeight(display, newConfigL.getFont(), 16);
    Swt.connectDisposal(shell, titleFont);
    newConfigL.setFont(titleFont);

    Swt.Mod tripleConnector =
        new Swt.Mod() {
          public void modify(Widget to, Widget... from) {
            Label label = (Label) to;
            Combo combo = (Combo) from[0];
            Text text = (Text) from[1];
            int blockSize = optionsInt[combo.getSelectionIndex()];
            long numberOfBlocks = Util.parseLongOrZero(text.getText());
            label.setText(Util.bytesWithUnit(numberOfBlocks * blockSize, 2));
          }
        };

    diskBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER);
    Swt.connectTo(Swt.TEXT_FROM_SCALE, diskBlocksT, diskBlocksS);
    Swt.connectTo(Swt.SCALE_FROM_TEXT, diskBlocksS, diskBlocksT);
    Swt.connectTo(tripleConnector, diskSpaceL, blockSizeC, diskBlocksT);
    diskBlocksT.setText("768");

    minBlocksT.addVerifyListener(Swt.INTEGER_VERIFIER);
    Swt.connectTo(Swt.TEXT_FROM_SCALE, minBlocksT, minBlocksS);
    Swt.connectTo(Swt.SCALE_FROM_TEXT, minBlocksS, minBlocksT);
    Swt.connectTo(tripleConnector, minSpaceL, blockSizeC, minBlocksT);
    minBlocksT.setText("350");

    portT.addVerifyListener(Swt.INTEGER_VERIFIER);
    checkInTimeT.addVerifyListener(Swt.INTEGER_VERIFIER);

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

    // Page two positioning. ///////////////////////////////////////////////
    p2 = new Composite(shell, SWT.NONE);
    p2.setLayout(new MigLayout("insets 10", "[right][grow][100::, fill]"));
    Label newConfig2L = Swt.newLabel(p2, "span, align left, wrap 30px", "New configuration");

    Swt.newLabel(p2, null, "Server key pair:");
    final Text key1T = Swt.newText(p2, "w max", null);
    Button load1B = Swt.newButton(p2, "wrap", "Load");

    Swt.newLabel(p2, null, "Admin key pair:");
    final Text key2T = Swt.newText(p2, "w max", null);
    Button load2B = Swt.newButton(p2, "wrap push", "Load");

    Button genB = Swt.newButton(p2, "align left", "Key pair generator");

    doneB = Swt.newButton(p2, "skip 1", "Done");

    // Page two options. ///////////////////////////////////////////////////
    newConfig2L.setFont(titleFont);
    key1T.setEditable(false);
    key2T.setEditable(false);

    load1B.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            loadKeyPair(key1T, 0);
          }
        });
    load2B.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            loadKeyPair(key2T, 1);
          }
        });
    genB.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            openKeyGeneratorWindow();
          }
        });
    doneB.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            step3();
          }
        });

    stackLayout.topControl = p1;
    shell.layout();
    shell.setDefaultButton(continueB);

    Swt.centerShell(shell);
    shell.open();
  }
Пример #10
0
  @Override
  public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().spacing(1, 3).applyTo(composite);

    Group group = new Group(composite, SWT.NONE);
    group.setText("Launch target");
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(group);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group);

    Label label = new Label(group, SWT.NONE);
    label.setText("HTML file:");
    htmlText = new Text(group, SWT.BORDER | SWT.SINGLE);
    htmlText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(ModifyEvent e) {
            notifyPanelChanged();
          }
        });
    GridDataFactory.swtDefaults()
        .align(SWT.FILL, SWT.CENTER)
        .hint(400, SWT.DEFAULT)
        .grab(true, false)
        .applyTo(htmlText);

    htmlBrowseButton = new Button(group, SWT.PUSH);
    htmlBrowseButton.setText("Select...");
    PixelConverter converter = new PixelConverter(htmlBrowseButton);
    int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    GridDataFactory.swtDefaults()
        .align(SWT.FILL, SWT.BEGINNING)
        .hint(widthHint, -1)
        .applyTo(htmlBrowseButton);
    htmlBrowseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleApplicationBrowseButton();
          }
        });

    // Dartium settings group
    group = new Group(composite, SWT.NONE);
    group.setText("Dartium settings");
    GridDataFactory.fillDefaults().grab(true, false).applyTo(group);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group);
    ((GridLayout) group.getLayout()).marginBottom = 5;

    // additional browser arguments
    Label argsLabel = new Label(group, SWT.NONE);
    argsLabel.setText("Browser arguments:");

    argumentText = new Text(group, SWT.BORDER | SWT.SINGLE);
    GridDataFactory.swtDefaults()
        .align(SWT.FILL, SWT.CENTER)
        .grab(true, false)
        .span(2, 1)
        .applyTo(argumentText);

    Label messageLabel = new Label(composite, SWT.NONE);
    messageLabel.setText("Note: Does not support debugging of applications in Dartium");
    messageLabel.setFont(getItalicFont(label.getFont()));

    setControl(composite);
  }
  /**
   * Creates a source viewer information control with the given shell as parent. The given shell
   * styles are applied to the created shell. The given styles are applied to the created styled
   * text widget. The text widget will be initialized with the given font. The status field will
   * contain the given text or be hidden.
   *
   * @param parent the parent shell
   * @param isResizable <code>true</code> if resizable
   * @param symbolicFontName the symbolic font name
   * @param statusFieldText the text to be used in the optional status field or <code>null</code> if
   *     the status field should be hidden
   */
  public SourceViewerInformationControl(
      Shell parent, boolean isResizable, String symbolicFontName, String statusFieldText) {
    GridLayout layout;
    GridData gd;

    int shellStyle = SWT.TOOL | SWT.ON_TOP | (isResizable ? SWT.RESIZE : 0);
    int textStyle = isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;

    fShell = new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
    Display display = fShell.getDisplay();

    Composite composite = fShell;
    layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    composite.setLayoutData(gd);

    if (statusFieldText != null) {
      composite = new Composite(composite, SWT.NONE);
      layout = new GridLayout(1, false);
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      composite.setLayout(layout);
      gd = new GridData(GridData.FILL_BOTH);
      composite.setLayoutData(gd);
      composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
      composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    // Source viewer
    fViewer = new SourceViewer(composite, null, textStyle);
    fViewer.configure(new SourceViewerConfiguration());
    fViewer.setEditable(false);

    fText = fViewer.getTextWidget();
    gd = new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
    fText.setLayoutData(gd);
    fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    fSymbolicFontName = symbolicFontName;
    fTextFont = JFaceResources.getFont(symbolicFontName);
    fText.setFont(fTextFont);

    fText.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent e) {
            if (e.character == 0x1B) // ESC
            fShell.dispose();
          }

          public void keyReleased(KeyEvent e) {}
        });

    // Status field
    if (statusFieldText != null) {

      // Horizontal separator line
      fSeparator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
      fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // Status field label
      fStatusField = new Label(composite, SWT.RIGHT);
      fStatusField.setText(statusFieldText);
      Font font = fStatusField.getFont();
      FontData[] fontDatas = font.getFontData();
      for (int i = 0; i < fontDatas.length; i++)
        fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
      fStatusTextFont = new Font(fStatusField.getDisplay(), fontDatas);
      fStatusField.setFont(fStatusTextFont);
      GridData gd2 =
          new GridData(
              GridData.FILL_VERTICAL
                  | GridData.FILL_HORIZONTAL
                  | GridData.HORIZONTAL_ALIGN_BEGINNING
                  | GridData.VERTICAL_ALIGN_BEGINNING);
      fStatusField.setLayoutData(gd2);

      fStatusTextForegroundColor =
          new Color(
              fStatusField.getDisplay(),
              blend(
                  display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(),
                  display.getSystemColor(SWT.COLOR_INFO_FOREGROUND).getRGB(),
                  0.56f));
      fStatusField.setForeground(fStatusTextForegroundColor);

      fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    addDisposeListener(this);
  }
Пример #12
0
  public TitleBar(final Window parent, final int size, int flags) {
    this.flags = flags;

    composite = new Composite(parent.getContentPanel(), SWT.NONE);

    composite.setSize(parent.getSize().x, size);

    buttonListener =
        new Listener() {
          public void handleEvent(Event event) {
            if (event.type == SWT.MouseUp) {
              // If the click is still on the button.
              if (event.x >= 0 && event.x < size && event.y >= 0 && event.y < size) {
                if (event.widget == closeButton) {
                  parent.close();
                } else if (event.widget == restoreButton) {
                  dontSetX = true;
                  parent.setMaximized(!parent.isMaximized());
                } else if (event.widget == minimizeButton) {
                  parent.setMinimized(true);
                }
              }
            } else if (event.type == SWT.MouseEnter) {
              Label button = (Label) event.widget;

              button.setBackground(hoverColor);
            } else if (event.type == SWT.MouseExit) {
              Label button = (Label) event.widget;

              button.setBackground(normalColor);
            }
          }
        };

    addButtons();

    titleLabel = new Label(composite, SWT.NONE);
    FontData fd = titleLabel.getFont().getFontData()[0];
    fd.setHeight(14);
    titleLabel.setFont(new Font(Display.getDefault(), fd));

    titleGC = new GC(titleLabel);
    setTitle(parent.getTitle());

    iconLabel = new Label(composite, SWT.NONE);
    setIcon(parent.getIcon());

    dontSetX = true;
    wasRestored = true;
    wasMaximized = parent.isMaximized();

    ControlListener resizeListener =
        new ControlListener() {
          public void controlResized(ControlEvent e) {
            composite.setSize(parent.getClientArea().width, size);

            setTitleLocation();

            layoutButtons();

            if (parent.isMaximized()) {
              if (restoreButton != null) {
                restoreButton.setImage(restoreImage);
              }
            } else {
              if (wasMaximized && !dontSetX) {
                parent.setLocation(mouseX - parent.getSize().x / 2, parent.getLocation().y);
              }

              if (restoreButton != null) {
                restoreButton.setImage(maximizeImage);
              }
            }

            dontSetX = false;

            wasRestored = false;

            wasMaximized = false;

            if (parent.isFullscreen()) {
              if (minimizeButton != null) {
                minimizeButton.setEnabled(false); // .setVisible(false);
              }
              if (restoreButton != null) {
                restoreButton.setEnabled(false); // .setVisible(false);
              }
            } else {
              if (minimizeButton != null) {
                minimizeButton.setEnabled(true); // .setVisible(true);
              }
              if (restoreButton != null) {
                restoreButton.setEnabled(true); // .setVisible(true);
              }
            }
          }

          public void controlMoved(ControlEvent e) {}
        };

    parent.addControlListener(resizeListener);

    final Tracker tracker = new Tracker(parent.getShell(), SWT.NONE);

    tracker.addControlListener(
        new ControlListener() {
          public void controlResized(ControlEvent e) {}

          public void controlMoved(ControlEvent e) {
            if (parent.isMaximized()) {
              parent.setMaximized(false);
            }

            Point loc =
                new Point(
                    tracker.getRectangles()[0].x + 99999, tracker.getRectangles()[0].y + 99999);

            int dx = loc.x - startX;
            int dy = loc.y - startY;

            parent.setLocation(parent.getLocation().x + dx, parent.getLocation().y + dy);

            startX = loc.x;
            startY = loc.y;
          }
        });

    Listener moveListener =
        new Listener() {
          public void handleEvent(Event event) {
            if (!parent.isFullscreen()) {
              if (event.type == SWT.MouseDown) {
                dragging = true;

                Control control = (Control) event.widget;

                mouseX = event.x + parent.getBorderSize() + control.getLocation().x;
                mouseY = event.y + parent.getBorderSize() + control.getLocation().y;

                wasMaximized = parent.isMaximized();

                startX = 0;
                startY = 0;

                tracker.setRectangles(new Rectangle[] {new Rectangle(-99999, -99999, 0, 0)});
                tracker.open();

                tracker.close();
                dragging = false;

                if (parent.getLocation().y + mouseY <= 0) {
                  wasRestored = true;
                  parent.setMaximized(true);
                }
              } else if (event.type == SWT.MouseDoubleClick) {
                dontSetX = true;
                wasRestored = true;
                parent.setMaximized(!parent.isMaximized());
              }
            }
          }
        };

    titleLabel.addListener(SWT.MouseDown, moveListener);
    titleLabel.addListener(SWT.MouseDoubleClick, moveListener);
    composite.addListener(SWT.MouseDown, moveListener);
    composite.addListener(SWT.MouseDoubleClick, moveListener);

    parent.addWindowListener(
        new WindowListener() {
          public boolean titleChanged(String newTitle) {
            setTitle(newTitle);

            return true;
          }

          public boolean iconChanged(Image newIcon) {
            setIcon(newIcon);

            return true;
          }
        });

    composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
  }
Пример #13
0
  /** @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */
  @Override
  public final void createControl(final Composite parent) {
    GridData pageCompositeLayoutData = new GridData();
    GridLayout pageCompositeLayout = new GridLayout();
    pageCompositeLayoutData.grabExcessHorizontalSpace = true;
    pageCompositeLayoutData.grabExcessVerticalSpace = false;
    pageCompositeLayoutData.horizontalAlignment = SWT.FILL;
    pageCompositeLayoutData.verticalAlignment = SWT.FILL;
    pageComposite = new Composite(parent, SWT.NULL);
    pageComposite.setLayout(pageCompositeLayout);
    pageComposite.setLayoutData(pageCompositeLayoutData);

    {
      grpText = new Group(pageComposite, SWT.NONE);
      grpText.setText(Messages.TranspTextWizardPage_grpText_text);
      grpText.setLayout(new GridLayout(2, false));
      grpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
      {
        compTextInputMode = new Composite(grpText, SWT.NONE);
        compTextInputMode.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        compTextInputMode.setLayout(new GridLayout(1, false));

        Label lblLadenDesTextes = new Label(compTextInputMode, SWT.NONE);
        lblLadenDesTextes.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1));
        lblLadenDesTextes.setBounds(0, 0, 55, 15);
        lblLadenDesTextes.setText(Messages.TranspTextWizardPage_lblLadenDesTextes_text);
        {
          composite = new Composite(compTextInputMode, SWT.NONE);
          composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
          composite.setLayout(new GridLayout(1, false));
          {
            btnJcteditor = new Button(composite, SWT.RADIO);
            btnJcteditor.setText(Messages.TranspTextWizardPage_btnJcteditor_text);
          }
          {
            comboEditorInputSelector =
                new Combo(composite, SWT.NONE) {
                  @Override
                  protected void checkSubclass() {};

                  @Override
                  public org.eclipse.swt.graphics.Point computeSize(
                      int wHint, int hHint, boolean changed) {
                    Point result = super.computeSize(wHint, hHint, changed);
                    return new Point(getAppropriateXValue(result.x, 160), result.y);
                  };

                  private int getAppropriateXValue(int superXCalc, int maxSize) {
                    return Math.min(superXCalc, maxSize);
                  }
                };
            GridData gd_comboEditorInputSelector =
                new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
            gd_comboEditorInputSelector.horizontalIndent = 15;
            comboEditorInputSelector.setLayoutData(gd_comboEditorInputSelector);
          }
          {
            btnDatei = new Button(composite, SWT.RADIO);
            btnDatei.setText(Messages.TranspTextWizardPage_btnDatei_text);
          }
          {
            compFileInputDetails = new Composite(composite, SWT.NONE);
            GridData gd_compFileInputDetails =
                new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
            gd_compFileInputDetails.horizontalIndent = 15;
            compFileInputDetails.setLayoutData(gd_compFileInputDetails);
            GridLayout gl_compFileInputDetails = new GridLayout(2, false);
            gl_compFileInputDetails.marginWidth = 0;
            gl_compFileInputDetails.marginHeight = 0;
            compFileInputDetails.setLayout(gl_compFileInputDetails);

            lblFilenametxt = new Label(compFileInputDetails, SWT.NONE);
            lblFilenametxt.setBounds(0, 0, 55, 15);
            lblFilenametxt.setText(Messages.TranspTextWizardPage_lblFilenametxt_text);

            linkChangeFile = new Link(compFileInputDetails, SWT.NONE);
            linkChangeFile.setText(Messages.TranspTextWizardPage_link_text);
          }
          {
            btnZwischenablageeigeneEingabe = new Button(composite, SWT.RADIO);
            btnZwischenablageeigeneEingabe.setText(
                Messages.TranspTextWizardPage_btnZwischenablageeigeneEingabe_text);
            btnZwischenablageeigeneEingabe.addSelectionListener(
                new SelectionAdapter() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    if (btnZwischenablageeigeneEingabe.getSelection()) {
                      doTxfieldActionPreservingVisibleLines(
                          new Runnable() {
                            @Override
                            public void run() {
                              txtInputText.setSelection(txtInputText.getText().length(), 0);
                              txtInputText.forceFocus();
                            }
                          },
                          txtInputText);
                    }
                  }
                });
          }
        }
      }
      {
        grpTextinputCtrls = new Group(grpText, SWT.NONE);
        GridLayout group2Layout = new GridLayout();
        grpTextinputCtrls.setLayout(group2Layout);
        GridData group2LData = new GridData();
        group2LData.verticalAlignment = SWT.FILL;
        group2LData.grabExcessHorizontalSpace = true;
        group2LData.horizontalAlignment = GridData.FILL;
        grpTextinputCtrls.setLayoutData(group2LData);
        grpTextinputCtrls.setText(Messages.TranspTextWizardPage_text);
        {
          textfieldComp = new Composite(grpTextinputCtrls, SWT.NONE);
          GridLayout composite2Layout = new GridLayout();
          composite2Layout.makeColumnsEqualWidth = true;
          composite2Layout.marginHeight = 0;
          composite2Layout.marginWidth = 0;
          GridData composite2LData = new GridData();
          composite2LData.grabExcessHorizontalSpace = true;
          composite2LData.horizontalAlignment = GridData.FILL;
          composite2LData.grabExcessVerticalSpace = true;
          composite2LData.verticalAlignment = GridData.FILL;
          textfieldComp.setLayoutData(composite2LData);
          textfieldComp.setLayout(composite2Layout);
          {
            txtInputText =
                new Text(textfieldComp, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
            GridData text1LData = new GridData();
            text1LData.grabExcessVerticalSpace = true;
            text1LData.verticalAlignment = SWT.FILL;
            text1LData.grabExcessHorizontalSpace = true;
            text1LData.horizontalAlignment = GridData.FILL;

            GC temp = new GC(txtInputText);
            int lines = 4;
            int charHeight =
                temp.getFontMetrics().getAscent() + 2 * temp.getFontMetrics().getLeading();
            int height = lines * charHeight;
            temp.dispose();
            text1LData.widthHint = 200;
            text1LData.heightHint = height;

            txtInputText.setLayoutData(text1LData);
          }
        }
      }
      Label nextPageInfo = new Label(grpText, SWT.WRAP);
      GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
      layoutData.widthHint = 300;
      nextPageInfo.setLayoutData(layoutData);
      nextPageInfo.setText(Messages.TranspTextWizardPage_zzz);
    }
    {
      parttextGroup = new Group(pageComposite, SWT.NONE);
      GridLayout composite4Layout = new GridLayout(3, false);
      composite4Layout.horizontalSpacing = 0;
      composite4Layout.verticalSpacing = 0;
      GridData parttextGroupLData = new GridData();
      parttextGroupLData.grabExcessHorizontalSpace = true;
      parttextGroupLData.horizontalAlignment = GridData.FILL;
      parttextGroupLData.verticalIndent = 5;
      parttextGroup.setLayoutData(parttextGroupLData);
      parttextGroup.setLayout(composite4Layout);
      parttextGroup.setText(Messages.TranspTextWizardPage_shortenthetext);
      {
        {
          parttextCheck = new Button(parttextGroup, SWT.CHECK | SWT.LEFT);
          parttextCheck.setText(Messages.TranspTextWizardPage_takeonlyapartofthetext);
          parttextCheck.setSelection(init_croptext);

          parttextCheck.addSelectionListener(
              new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent evt) {
                  parttextCheckWidgetSelected(evt);
                }
              });
        }
        {
          parttextCount = new Spinner(parttextGroup, SWT.NONE);
          parttextCount.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
          parttextCount.setSelection(init_croplength);

          parttextCount.setEnabled(parttextCheck.getSelection());
          parttextCount.setMinimum(1);
          parttextCount.setMaximum(200);
          parttextCount.addSelectionListener(
              new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent evt) {
                  parttextCountWidgetSelected(evt);
                }
              });

          parttextCount.setSelection(init_croplength);
        }
        {
          lblCharacters = new Label(parttextGroup, SWT.NONE);
          lblCharacters.setText(Messages.TranspTextWizardPage_lblCharacters_text);
        }
        {
          lblIfTheText = new Label(parttextGroup, SWT.WRAP);
          lblIfTheText.setText(Messages.TranspTextWizardPage_lblIfTheText_text);
          GridData lblIfthetextLData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
          lblIfthetextLData.horizontalIndent = 20;
          lblIfthetextLData.verticalIndent = 4;
          lblIfthetextLData.widthHint = 200;
          lblIfTheText.setLayoutData(lblIfthetextLData);
          FontData fontdata = lblIfTheText.getFont().getFontData()[0];
          fontdata.height = ((float) 0.9) * (fontdata.height);
          lblIfTheText.setFont(new Font(Display.getCurrent(), fontdata));
        }
      }
      {
        // parttextLabel1 = new Label(parttextGroup, SWT.NONE);
        // parttextLabel1.setText("(This option is activated by default, if you chose not to arrange
        // the text into columns)");
      }
    }
    {
      group1 = new Group(pageComposite, SWT.NONE);
      GridLayout group1Layout = new GridLayout(3, false);
      group1.setLayout(group1Layout);
      GridData group1LData = new GridData();
      group1LData.grabExcessHorizontalSpace = true;
      group1LData.horizontalAlignment = GridData.FILL;
      group1.setLayoutData(group1LData);
      group1.setText(Messages.TranspTextWizardPage_columns);
      {
        label1 = new Label(group1, SWT.NONE);
        label1.setText(Messages.TranspTextWizardPage_setnumberofcolumns);
        GridData label1LData = new GridData();
        label1LData.horizontalAlignment = GridData.FILL;
        label1.setLayoutData(label1LData);
      }
      {
        blocklengthSpinner = new Spinner(group1, SWT.NONE);
        {
          GridData gd_blocklengthSpinner = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
          gd_blocklengthSpinner.heightHint = 18;
          blocklengthSpinner.setLayoutData(gd_blocklengthSpinner);
        }
        blocklengthSpinner.setMinimum(1);
        blocklengthSpinner.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent evt) {
                blocklengthSpinnerWidgetSelected(evt);
              }
            });

        blocklengthSpinner.setSelection(init_blocklength);
      }
      {
        lblyouCanChange = new Label(group1, SWT.WRAP);
        lblyouCanChange.setText(Messages.TranspTextWizardPage_lblyouCanChange_text);
        GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
        layoutData.widthHint = 200;
        lblyouCanChange.setLayoutData(layoutData);
      }
    }
    {
      groupReadInDirection = new Group(pageComposite, SWT.NONE);
      GridLayout groupReadInDirectionLayout = new GridLayout();
      groupReadInDirectionLayout.numColumns = 2;
      groupReadInDirection.setLayout(groupReadInDirectionLayout);
      GridData groupReadInDirectionLData = new GridData();
      groupReadInDirectionLData.grabExcessHorizontalSpace = true;
      groupReadInDirectionLData.horizontalAlignment = GridData.FILL;
      groupReadInDirection.setLayoutData(groupReadInDirectionLData);
      groupReadInDirection.setText(Messages.TranspTextWizardPage_readinmode);
      {
        labelReadIn = new Label(groupReadInDirection, SWT.NONE);
        labelReadIn.setText(Messages.TranspTextWizardPage_readinmode_description);
      }
      {
        directionChooserIn = new ReadDirectionChooser(groupReadInDirection, false);
        directionChooserIn.setDirection(iniDirection);

        directionChooserIn
            .getInput()
            .addObserver(
                new Observer() {
                  @Override
                  public void update(Observable o, Object arg) {
                    if (arg == null) preview();
                  }
                });
      }
    }

    {
      previewGroup = new Group(pageComposite, SWT.NONE);
      GridLayout previewGroupLayout = new GridLayout();
      previewGroupLayout.makeColumnsEqualWidth = true;
      previewGroup.setLayout(previewGroupLayout);
      GridData previewGroupLData = new GridData();
      previewGroupLData.verticalIndent = 10;
      previewGroupLData.horizontalAlignment = GridData.FILL;
      previewGroupLData.grabExcessHorizontalSpace = true;
      previewGroupLData.verticalAlignment = GridData.FILL;
      previewGroupLData.grabExcessVerticalSpace = true;
      previewGroup.setLayoutData(previewGroupLData);
      previewGroup.setText(Messages.TranspTextWizardPage_preview);
      {
        GridLayout transpTableLayout = new GridLayout();
        transpTableLayout.makeColumnsEqualWidth = true;
        GridData transpositionTable1LData = new GridData();
        transpositionTable1LData.heightHint = 120;
        transpositionTable1LData.widthHint = 250;
        transpositionTable1LData.grabExcessHorizontalSpace = true;
        transpositionTable1LData.horizontalAlignment = GridData.FILL;
        transpositionTable1LData.grabExcessVerticalSpace = true;
        transpositionTable1LData.verticalAlignment = GridData.FILL;
        transpositionTable1 = new TranspositionTableComposite(previewGroup, SWT.NONE);
        transpositionTable1.setLayout(transpTableLayout);
        transpositionTable1.setLayoutData(transpositionTable1LData);
      }
    }

    setControl(pageComposite);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(getControl(), TranspositionAnalysisPlugin.PLUGIN_ID + ".wizard"); // $NON-NLS-1$

    initializeTextInput();

    setPageComplete(true);

    preview();
    isPageBuilt = true;
  }
  /**
   * Creates the dialog's contents
   *
   * @param shell the dialog window
   */
  private void createContents(final Shell shell) {

    final Config config = controller.getConfig();

    // Create the ScrolledComposite to scroll horizontally and vertically
    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    // Create the parent Composite container for the three child containers
    Composite container = new Composite(sc, SWT.NONE);
    GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    shell.setLayout(new FillLayout());

    GridData data;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 50;
    data.widthHint = 400;

    // START TOP COMPONENT

    Composite topComp = new Composite(container, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    topComp.setLayout(layout);
    topComp.setLayoutData(data);

    Label blank = new Label(topComp, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 10;
    blank.setLayoutData(data);
    blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    // Show the message
    Label label = new Label(topComp, SWT.NONE);
    label.setText(message);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 30;
    data.widthHint = 370;

    Font f = label.getFont();
    FontData[] farr = f.getFontData();
    FontData fd = farr[0];
    fd.setStyle(SWT.BOLD);
    label.setFont(new Font(Display.getCurrent(), fd));

    label.setLayoutData(data);
    label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    labelSeparator.setLayoutData(data);

    // END TOP COMPONENT

    // START MIDDLE COMPONENT

    Composite restComp = new Composite(container, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    restComp.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    restComp.setLayout(layout);

    // Hide welecome screen
    Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT);
    labelHideWelcomeScreen.setText(
        Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$
    labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK);
    buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN));

    // batch size
    Label labelBatch = new Label(restComp, SWT.RIGHT);
    labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelBatch.setLayoutData(data);

    textBatch = new Text(restComp, SWT.BORDER);
    textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE));
    textBatch.setTextLimit(8);
    textBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 50;
    textBatch.setLayoutData(data);

    // insert Nulls
    Label labelNulls = new Label(restComp, SWT.RIGHT);
    labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelNulls.setLayoutData(data);
    buttonNulls = new Button(restComp, SWT.CHECK);
    buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS));

    // assignment rules
    Label labelRule = new Label(restComp, SWT.RIGHT);
    labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRule.setLayoutData(data);

    textRule = new Text(restComp, SWT.BORDER);
    textRule.setTextLimit(18);
    data = new GridData();
    data.widthHint = 115;
    textRule.setLayoutData(data);
    textRule.setText(config.getString(Config.ASSIGNMENT_RULE));

    // endpoint
    Label labelEndpoint = new Label(restComp, SWT.RIGHT);
    labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEndpoint.setLayoutData(data);

    textEndpoint = new Text(restComp, SWT.BORDER);
    data = new GridData();
    data.widthHint = 250;
    textEndpoint.setLayoutData(data);
    String endpoint = config.getString(Config.ENDPOINT);
    if ("".equals(endpoint)) { // $NON-NLS-1$
      endpoint = defaultServer;
    }

    textEndpoint.setText(endpoint);

    // reset url on login
    Label labelResetUrl = new Label(restComp, SWT.RIGHT);
    labelResetUrl.setText(
        Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelResetUrl.setLayoutData(data);
    buttonResetUrl = new Button(restComp, SWT.CHECK);
    buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN));

    // insert compression
    Label labelCompression = new Label(restComp, SWT.RIGHT);
    labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCompression.setLayoutData(data);
    buttonCompression = new Button(restComp, SWT.CHECK);
    buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION));

    // timeout size
    Label labelTimeout = new Label(restComp, SWT.RIGHT);
    labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTimeout.setLayoutData(data);

    textTimeout = new Text(restComp, SWT.BORDER);
    textTimeout.setTextLimit(4);
    textTimeout.setText(config.getString(Config.TIMEOUT_SECS));
    textTimeout.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textTimeout.setLayoutData(data);

    // extraction batch size
    Label labelQueryBatch = new Label(restComp, SWT.RIGHT);
    labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelQueryBatch.setLayoutData(data);

    textQueryBatch = new Text(restComp, SWT.BORDER);
    textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE));
    textQueryBatch.setTextLimit(4);
    textQueryBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textQueryBatch.setLayoutData(data);

    // enable/disable output of success file for extracts
    Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT);
    labelOutputExtractStatus.setText(
        Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOutputExtractStatus.setLayoutData(data);

    buttonOutputExtractStatus = new Button(restComp, SWT.CHECK);
    buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT));

    // utf-8 for loading
    Label labelReadUTF8 = new Label(restComp, SWT.RIGHT);
    labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelReadUTF8.setLayoutData(data);

    buttonReadUtf8 = new Button(restComp, SWT.CHECK);
    buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8));

    // utf-8 for extraction
    Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT);
    labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelWriteUTF8.setLayoutData(data);

    buttonWriteUtf8 = new Button(restComp, SWT.CHECK);
    buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8));

    // European Dates
    Label labelEuropeanDates = new Label(restComp, SWT.RIGHT);
    labelEuropeanDates.setText(
        Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEuropeanDates.setLayoutData(data);

    buttonEuroDates = new Button(restComp, SWT.CHECK);
    buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES));

    // Field truncation
    Label labelTruncateFields = new Label(restComp, SWT.RIGHT);
    labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTruncateFields.setLayoutData(data);

    buttonTruncateFields = new Button(restComp, SWT.CHECK);
    buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS));

    Label labelCsvCommand = new Label(restComp, SWT.RIGHT);
    labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCsvCommand.setLayoutData(data);
    buttonCsvComma = new Button(restComp, SWT.CHECK);
    buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA));

    Label labelTabCommand = new Label(restComp, SWT.RIGHT);
    labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTabCommand.setLayoutData(data);
    buttonCsvTab = new Button(restComp, SWT.CHECK);
    buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB));

    Label labelOtherCommand = new Label(restComp, SWT.RIGHT);
    labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherCommand.setLayoutData(data);
    buttonCsvOther = new Button(restComp, SWT.CHECK);
    buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER));

    Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT);
    labelOtherDelimiterValue.setText(
        Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherDelimiterValue.setLayoutData(data);
    textSplitterValue = new Text(restComp, SWT.BORDER);
    textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE));
    data = new GridData();
    data.widthHint = 25;
    textSplitterValue.setLayoutData(data);

    // Enable Bulk API Setting
    Label labelUseBulkApi = new Label(restComp, SWT.RIGHT);
    labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelUseBulkApi.setLayoutData(data);

    boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED);
    buttonUseBulkApi = new Button(restComp, SWT.CHECK);
    buttonUseBulkApi.setSelection(useBulkAPI);
    buttonUseBulkApi.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            boolean enabled = buttonUseBulkApi.getSelection();
            // update batch size when this setting changes
            int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled);
            logger.info("Setting batch size to " + newDefaultBatchSize);
            textBatch.setText(String.valueOf(newDefaultBatchSize));
            // make sure the appropriate check boxes are enabled or disabled
            initBulkApiSetting(enabled);
          }
        });

    // Bulk API serial concurrency mode setting
    Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT);
    labelBulkApiSerialMode.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$
    labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK);
    buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiSerialMode.setEnabled(useBulkAPI);

    // Bulk API serial concurrency mode setting
    Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT);
    labelBulkApiZipContent.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$
    labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiZipContent = new Button(restComp, SWT.CHECK);
    buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiZipContent.setEnabled(useBulkAPI);
    // timezone
    textTimezone =
        createTextInput(
            restComp,
            "AdvancedSettingsDialog.timezone",
            Config.TIMEZONE,
            TimeZone.getDefault().getID(),
            200);

    // proxy Host
    Label labelProxyHost = new Label(restComp, SWT.RIGHT);
    labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyHost.setLayoutData(data);

    textProxyHost = new Text(restComp, SWT.BORDER);
    textProxyHost.setText(config.getString(Config.PROXY_HOST));
    data = new GridData();
    data.widthHint = 250;
    textProxyHost.setLayoutData(data);

    // Proxy Port
    Label labelProxyPort = new Label(restComp, SWT.RIGHT);
    labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPort.setLayoutData(data);

    textProxyPort = new Text(restComp, SWT.BORDER);
    textProxyPort.setText(config.getString(Config.PROXY_PORT));
    textProxyPort.setTextLimit(4);
    textProxyPort.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 25;
    textProxyPort.setLayoutData(data);

    // Proxy Username
    Label labelProxyUsername = new Label(restComp, SWT.RIGHT);
    labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyUsername.setLayoutData(data);

    textProxyUsername = new Text(restComp, SWT.BORDER);
    textProxyUsername.setText(config.getString(Config.PROXY_USERNAME));
    data = new GridData();
    data.widthHint = 120;
    textProxyUsername.setLayoutData(data);

    // Proxy Password
    Label labelProxyPassword = new Label(restComp, SWT.RIGHT);
    labelProxyPassword.setText(
        Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPassword.setLayoutData(data);

    textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD);
    textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD));
    data = new GridData();
    data.widthHint = 120;
    textProxyPassword.setLayoutData(data);

    // proxy NTLM domain
    Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT);
    labelProxyNtlmDomain.setText(
        Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyNtlmDomain.setLayoutData(data);

    textProxyNtlmDomain = new Text(restComp, SWT.BORDER);
    textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN));
    data = new GridData();
    data.widthHint = 250;
    textProxyNtlmDomain.setLayoutData(data);

    //////////////////////////////////////////////////
    // Row to start At

    Label blankAgain = new Label(restComp, SWT.NONE);
    data = new GridData();
    data.horizontalSpan = 2;
    blankAgain.setLayoutData(data);

    // Row to start AT
    Label labelLastRow = new Label(restComp, SWT.NONE);

    String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW);
    if (lastBatch.equals("")) { // $NON-NLS-1$
      lastBatch = "0"; // $NON-NLS-1$
    }

    labelLastRow.setText(
        Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$
    data = new GridData();
    data.horizontalSpan = 2;
    labelLastRow.setLayoutData(data);

    Label labelRowToStart = new Label(restComp, SWT.RIGHT);
    labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRowToStart.setLayoutData(data);

    textRowToStart = new Text(restComp, SWT.BORDER);
    textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT));
    data = new GridData();
    data.widthHint = 75;
    textRowToStart.setLayoutData(data);
    textRowToStart.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });

    // now that we've created all the buttons, make sure that buttons dependent on the bulk api
    // setting are enabled or disabled appropriately
    initBulkApiSetting(useBulkAPI);

    // the bottow separator
    Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    labelSeparatorBottom.setLayoutData(data);

    // ok cancel buttons
    new Label(restComp, SWT.NONE);

    // END MIDDLE COMPONENT

    // START BOTTOM COMPONENT

    Composite buttonComp = new Composite(restComp, SWT.NONE);
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    buttonComp.setLayoutData(data);
    buttonComp.setLayout(new GridLayout(2, false));

    // Create the OK button and add a handler
    // so that pressing it will set input
    // to the entered value
    Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$
    ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            Config config = controller.getConfig();

            // set the configValues
            config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection());
            config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection());
            config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText());
            if (!buttonCsvComma.getSelection()
                && !buttonCsvTab.getSelection()
                && (!buttonCsvOther.getSelection()
                    || textSplitterValue.getText() == null
                    || textSplitterValue.getText().length() == 0)) {
              return;
            }
            config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText());
            config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection());
            config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection());
            config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection());

            config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText());
            config.setValue(Config.ENDPOINT, textEndpoint.getText());
            config.setValue(Config.ASSIGNMENT_RULE, textRule.getText());
            config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText());
            config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection());
            config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection());
            config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection());
            config.setValue(Config.TIMEOUT_SECS, textTimeout.getText());
            config.setValue(
                Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection());
            config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection());
            config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection());
            config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection());
            config.setValue(Config.TIMEZONE, textTimezone.getText());
            config.setValue(Config.PROXY_HOST, textProxyHost.getText());
            config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText());
            config.setValue(Config.PROXY_PORT, textProxyPort.getText());
            config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText());
            config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText());
            config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection());
            config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection());
            config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection());

            controller.saveConfig();
            controller.logout();

            input = Labels.getString("UI.ok"); // $NON-NLS-1$
            shell.close();
          }
        });
    data = new GridData();
    data.widthHint = 75;
    ok.setLayoutData(data);

    // Create the cancel button and add a handler
    // so that pressing it will set input to null
    Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            input = null;
            shell.close();
          }
        });

    // END BOTTOM COMPONENT

    data = new GridData();
    data.widthHint = 75;
    cancel.setLayoutData(data);

    // Set the OK button as the default, so
    // user can type input and press Enter
    // to dismiss
    shell.setDefaultButton(ok);

    // Set the child as the scrolled content of the ScrolledComposite
    sc.setContent(container);

    // Set the minimum size
    sc.setMinSize(768, 1024);

    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
  }
Пример #15
0
  public SensorWidget(
      final Composite parent,
      final int style,
      final Measurements<T> totals,
      final Measurements<T>... parts) {
    super(parent, style);

    this.totals = totals;

    setLayout(new GridLayout(1, false));
    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    TimeTableXYDataset dataset = new TimeTableXYDataset();
    XYBarRenderer renderer = new StackedXYBarRenderer(0.0);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);

    if (parts == null || parts.length == 0) {
      renderer.setSeriesPaint(0, Color.green);
    }

    XYPlot plot = new XYPlot(dataset, new DateAxis("Time"), new NumberAxis("Count"), renderer);

    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.getRangeAxis().setLabel(null);
    plot.getDomainAxis().setLabel(null);

    JFreeChart realChart = new JFreeChart(plot);
    realChart.setTitle((String) null);

    chart = new ChartComposite(this, SWT.NONE, realChart, true);
    chart.setLayoutData(new GridData(300, 180));

    final Composite labels = new Composite(this, SWT.NONE);
    labels.setLayout(new GridLayout(5, false));

    final Label totalLabel = new Label(labels, SWT.NONE);
    totalLabel.setText(totals.getName());

    total = new Label(labels, SWT.BOLD);
    final FontData[] fd = total.getFont().getFontData();
    fd[0].setStyle(SWT.BOLD);
    total.setFont(new Font(getDisplay(), fd));
    totalMin = new Label(labels, SWT.NONE);
    totalMax = new Label(labels, SWT.NONE);
    totalAvg = new Label(labels, SWT.NONE);

    if (parts != null && parts.length > 0) {
      for (Measurements<T> part : parts) {
        final Label label = new Label(labels, SWT.NONE);
        label.setText(part.getName());
        final Label valueLabel = new Label(labels, SWT.BOLD);
        valueLabel.setFont(new Font(getDisplay(), fd));
        this.parts.put(
            part.getName(),
            new MeasurementsDisplay<T>(
                part,
                valueLabel,
                new Label(labels, SWT.NONE),
                new Label(labels, SWT.NONE),
                new Label(labels, SWT.NONE)));
      }
    }
  }