public void testFlatSectionAroundNestedSectionLayoutDecorator() {

    SwtMetawidget metawidget =
        new SwtMetawidget(new Shell(SwtMetawidgetTests.TEST_DISPLAY, SWT.NONE), SWT.NONE);
    metawidget.setMetawidgetLayout(
        new SeparatorLayoutDecorator(
            new SeparatorLayoutDecoratorConfig()
                .setLayout(
                    new TabFolderLayoutDecorator(
                        new TabFolderLayoutDecoratorConfig().setLayout(new GridLayout())))));
    metawidget.setToInspect(new Baz());

    Composite composite = (Composite) metawidget.getChildren()[0];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Foo", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    TabFolder innerTabFolder = (TabFolder) metawidget.getChildren()[1];
    assertEquals("Bar", innerTabFolder.getItem(0).getText());
    Composite innerPanel = (Composite) innerTabFolder.getChildren()[0];
    assertEquals("Abc:", ((Label) innerPanel.getChildren()[0]).getText());
    assertTrue(innerPanel.getChildren()[1] instanceof Text);
    assertEquals(2, innerPanel.getChildren().length);

    composite = (Composite) metawidget.getChildren()[2];
    assertEquals(((org.eclipse.swt.layout.GridLayout) composite.getLayout()).marginWidth, 0);
    assertEquals("Baz", ((Label) composite.getChildren()[0]).getText());
    assertEquals((composite.getChildren()[1].getStyle() & SWT.SEPARATOR), SWT.SEPARATOR);

    assertEquals("Def:", ((Label) metawidget.getChildren()[3]).getText());
    assertTrue(metawidget.getChildren()[4] instanceof Button);
    assertEquals((metawidget.getChildren()[4].getStyle() & SWT.CHECK), SWT.CHECK);
    assertEquals(5, metawidget.getChildren().length);
  }
 /**
  * Creates a vertical spacer for separating components. If applied to a <code>GridLayout</code>,
  * this method will automatically span all of the columns of the parent to make vertical space
  *
  * @param parent the parent composite to add this spacer to
  * @param numlines the number of vertical lines to make as space
  * @since 3.3
  */
 public static void createVerticalSpacer(Composite parent, int numlines) {
   Label lbl = new Label(parent, SWT.NONE);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   Layout layout = parent.getLayout();
   if (layout instanceof GridLayout) {
     gd.horizontalSpan = ((GridLayout) parent.getLayout()).numColumns;
   }
   gd.heightHint = numlines;
   lbl.setLayoutData(gd);
 }
Exemple #3
0
  protected Control createDialogArea(Composite parent) {
    getShell().setText(editRule == null ? "Add New Rule" : "Edit Rule");

    Composite mainComposite = (Composite) super.createDialogArea(parent);
    ((GridLayout) mainComposite.getLayout()).numColumns = 2;
    initializeDialogUnits(mainComposite);

    GridData fieldData = new GridData(GridData.FILL_HORIZONTAL);
    fieldData.widthHint = convertWidthInCharsToPixels(50);

    new Label(mainComposite, SWT.NONE).setText("Package Pattern:");
    packagePatternText = new Text(mainComposite, SWT.BORDER);
    packagePatternText.setLayoutData(fieldData);
    if (editRule != null) {
      packagePatternText.setText(editRule.getPackagePattern().pattern());
    }

    new Label(mainComposite, SWT.NONE).setText("Target URL:");
    targetUrlText = new Text(mainComposite, SWT.BORDER);
    targetUrlText.setLayoutData(fieldData);
    if (editRule != null) {
      targetUrlText.setText(editRule.getTargetUrl());
    }

    checkState();

    packagePatternText.addListener(SWT.Modify, modifyListener);
    targetUrlText.addListener(SWT.Modify, modifyListener);

    return mainComposite;
  }
  /*
   * Creates a button with a help image. This is only used if there
   * is an image available.
   */
  private ToolBar createLocalizationImageButton(Composite parent, Image image) {
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    ((GridLayout) parent.getLayout()).numColumns++;
    toolBar.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, false));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);
    toolBar.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
          }
        });

    final ToolItem item = new ToolItem(toolBar, SWT.NONE);
    item.setImage(image);

    languageSet.associate(
        "localizationToolTip", //$NON-NLS-1$
        new TranslatableTextInput(
            Activator.getLocalizableText(
                "LocalizableTrayDialog.localizationToolTip")) { //$NON-NLS-1$
          @Override
          public void updateControl(String text) {
            item.setToolTipText(text);
          }
        });

    item.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            localizationPressed();
          }
        });
    return toolBar;
  }
  @Override
  protected void contributeButtons(Composite parent) {
    ((GridLayout) parent.getLayout()).numColumns++;
    generateButton = new Button(parent, SWT.NONE);
    generateButton.setFont(parent.getFont());
    generateButton.setText(LibHoverMessages.getString(GENERATE));
    generateButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            regenerate();
          }
        });
    generateButton.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent event) {
            generateButton = null;
          }
        });
    GridData gd = new GridData();

    gd.horizontalAlignment = GridData.FILL;
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    gd.widthHint =
        Math.max(widthHint, generateButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    generateButton.setLayoutData(gd);
  }
  /**
   * Add buttons to the dialog's button bar.
   *
   * <p>Subclasses should override.
   *
   * @param parent the button bar composite
   */
  protected void createButtonsForButtonBar(Composite parent) {
    parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    if (!field.getPreferencesLevel().equals(IPreferencesService.DEFAULT_LEVEL)) {
      copyButton = createButton(parent, COPY_ID, PreferenceDialogConstants.COPY_LABEL, false);
      copyButton.setEnabled(
          field.getPreferencesLevel() != null
              && field.isInherited()
              && field.getComboBoxControl().isEnabled());
    }

    //	        emptyButton = createButton(parent, EMPTY_ID, PreferenceDialogConstants.EMPTY_LABEL,
    // false);
    //	        emptyButton.setEnabled(field.getPreferencesLevel() != null &&
    //		        	field.isEmptyStringAllowed() && field.getComboBoxControl(parent).isEnabled());

    removeButton = createButton(parent, REMOVE_ID, PreferenceDialogConstants.REMOVE_LABEL, false);
    removeButton.setEnabled(
        (field.getPreferencesLevel() != null)
            && !field.isInherited()
            && field.isRemovable()
            && field.getComboBoxControl().isEnabled());

    Label l = new Label(parent, SWT.NONE);
    l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns++;
    layout.makeColumnsEqualWidth = false;

    Button b = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    b.setFocus();
  }
 /**
  * Sets the visibility of the ascii text.
  *
  * @param visible the visibility of the ascii text
  * @see #getAsciiVisible()
  */
 public void setAsciiVisible(boolean visible) {
   ((GridData) asciiText.getLayoutData()).exclude = !visible;
   asciiText.setVisible(visible);
   ((GridLayout) composite.getLayout()).makeColumnsEqualWidth =
       visible && brailleText.getVisible();
   composite.layout();
 }
  void showActionComposite() throws CoreException {
    // Find the selected extension
    int selectedTypeIndex = combo.getSelectionIndex();
    lastSelectedActionTypeIndex = selectedTypeIndex;
    tracepointAction = tracepointActions.get(selectedTypeIndex);

    actionPage = actionPages[selectedTypeIndex];
    if (actionPage == null) {
      actionPages[selectedTypeIndex] = getActionPage(tracepointActions.get(selectedTypeIndex));
      actionPage = actionPages[selectedTypeIndex];
      if (actionPage instanceof WhileSteppingActionPage) {
        ((WhileSteppingActionPage) actionPage).setParentGlobalList(parentGlobalList);
      }
    }
    if (actionComposites[selectedTypeIndex] == null) {
      Composite actionComposite =
          actionPages[selectedTypeIndex].createComposite(tracepointAction, actionArea, SWT.NONE);
      actionComposites[selectedTypeIndex] = actionComposite;
    }
    actionName = tracepointAction.getName();

    actionNameTextWidget.setText(actionName);
    StackLayout stacklayout = (StackLayout) actionArea.getLayout();
    stacklayout.topControl = actionComposites[selectedTypeIndex];
    actionArea.layout();
  }
  @Override
  protected Control createDialogArea(Composite ancestor) {
    Composite parent = (Composite) super.createDialogArea(ancestor);

    final int nOfColumns = 4;

    initializeDialogUnits(ancestor);

    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns = nOfColumns;
    parent.setLayout(layout);

    createAccessorPart(parent, nOfColumns, convertWidthInCharsToPixels(40));

    Separator s = new Separator(SWT.SEPARATOR | SWT.HORIZONTAL);
    s.doFillIntoGrid(parent, nOfColumns);

    createPropertyPart(parent, nOfColumns, convertWidthInCharsToPixels(40));

    Dialog.applyDialogFont(parent);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(parent, IJavaHelpContextIds.EXTERNALIZE_WIZARD_PROPERTIES_FILE_PAGE);
    validateAll();
    return parent;
  }
  /**
   * Creates a new button with the given id.
   *
   * <p>The <code>Dialog</code> implementation of this framework method creates a standard push
   * button, registers for selection events including button presses and registers default buttons
   * with its shell. The button id is stored as the buttons client data. Note that the parent's
   * layout is assumed to be a GridLayout and the number of columns in this layout is incremented.
   * Subclasses may override.
   *
   * @param parent the parent composite
   * @param id the id of the button (see <code>IDialogConstants.*_ID</code> constants for standard
   *     dialog button ids)
   * @param label the label from the button
   * @param defaultButton <code>true</code> if the button is to be the default button, and <code>
   *     false</code> otherwise
   */
  private Button createButton(
      final Composite parent, final int id, final String label, final boolean defaultButton) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;

    final Button button = new Button(parent, SWT.PUSH);
    button.setFont(parent.getFont());

    final GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
    button.setLayoutData(buttonData);

    button.setData(Integer.valueOf(id));
    button.setText(label);
    button.setFont(parent.getFont());

    if (defaultButton) {
      final Shell shell = parent.getShell();
      if (shell != null) {
        shell.setDefaultButton(button);
      }
      button.setFocus();
    }
    button.setFont(parent.getFont());
    setButtonLayoutData(button);
    return button;
  }
  /*
   * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createButtonBar(Composite parent) {
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);

    Composite buttonBar = new Composite(parent, SWT.NONE);
    buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    buttonBar.setLayout(layout);

    /* Info Container */
    Composite infoContainer = new Composite(buttonBar, SWT.None);
    infoContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    infoContainer.setLayout(LayoutUtils.createGridLayout(2, 0, 0));
    ((GridLayout) infoContainer.getLayout()).marginRight = 10;

    Label infoImg = new Label(infoContainer, SWT.NONE);
    infoImg.setImage(OwlUI.getImage(fResources, "icons/obj16/info.gif")); // $NON-NLS-1$
    infoImg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    Label infoText = new Label(infoContainer, SWT.WRAP);
    infoText.setText(Messages.CustomizeToolbarDialog_USE_MOUSE_INFO);
    infoText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    applyDialogFont(infoContainer);

    /* Create Ok / Cancel Buttons */
    createButtonsForButtonBar(buttonBar);

    return buttonBar;
  }
 /* (non-Javadoc)
  * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
  */
 public void createControl(Composite parent) {
   Font font = parent.getFont();
   Group group = createGroup(parent, "Working directory:", 2, 1, GridData.FILL_HORIZONTAL);
   setControl(group);
   // PlatformUI.getWorkbench().getHelpSystem().setHelp(group,
   // IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK);
   // default choice
   Composite comp = createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0);
   fUseDefaultDirButton = createRadioButton(comp, "Default:");
   fUseDefaultDirButton.addSelectionListener(fListener);
   fWorkingDirText = createSingleText(comp, 1);
   fWorkingDirText.addModifyListener(fListener);
   fWorkingDirText.setEnabled(false);
   // user enter choice
   fUseOtherDirButton = createRadioButton(comp, "Other:");
   fUseOtherDirButton.addSelectionListener(fListener);
   fOtherWorkingText = createSingleText(comp, 1);
   fOtherWorkingText.addModifyListener(fListener);
   // buttons
   Composite buttonComp = createComposite(comp, font, 3, 2, GridData.HORIZONTAL_ALIGN_END);
   GridLayout ld = (GridLayout) buttonComp.getLayout();
   ld.marginHeight = 1;
   ld.marginWidth = 0;
   fWorkspaceButton = createPushButton(buttonComp, "Workspace...", null);
   fWorkspaceButton.addSelectionListener(fListener);
   fFileSystemButton = createPushButton(buttonComp, "File System...", null);
   fFileSystemButton.addSelectionListener(fListener);
   fVariablesButton = createPushButton(buttonComp, "Variables...", null);
   fVariablesButton.addSelectionListener(fListener);
 }
  @Override
  protected Control createDialogArea(Composite parent) {
    getShell().setText("Sign Log Entries");
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) container.getLayout();
    gridLayout.marginWidth = 2;
    gridLayout.marginHeight = 2;
    errorBar = new ErrorBar(container, SWT.NONE);
    errorBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    container.setLayout(new GridLayout(2, false));
    lblUsername = new Label(container, SWT.NONE);
    lblUsername.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblUsername.setText("User Name:");

    username = new Text(container, SWT.BORDER);
    username.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    lblPassword = new Label(container, SWT.NONE);
    lblPassword.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPassword.setText("Password:");

    password = new Text(container, SWT.BORDER | SWT.PASSWORD);
    password.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    return container;
  }
  @Override
  public void createUI(FormToolkit formToolkit) {
    super.createUI(formToolkit);
    GridBuilder widgetBuilder = new GridBuilder(formToolkit, getClientComposite(), 3);
    picker.setState(EControlState.MANDATORY, true);
    Composite composite = getClientComposite();
    GridLayout gl = (GridLayout) composite.getLayout();
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    gl.marginTop = 0;
    gl.marginBottom = 0;
    composite.setLayout(gl);

    GridData gd = (GridData) composite.getLayoutData();
    if (gd == null) gd = GridLayoutFactory.createDefaultLayoutData();
    // calculate horizontal indent for the first widget. take care of the margin width of the grid
    // layout
    // if margin width is greater than indent -> set indent to 0
    //        gd.horizontalIndent = GridLayoutFactory.INDENT_FOR_DECORATORS < gl.marginWidth ? 0 :
    // GridLayoutFactory.INDENT_FOR_DECORATORS - gl.marginWidth;
    gd.horizontalIndent = 0;
    composite.setLayoutData(gd);
    widgetBuilder.add(picker);
    picker.getText().getRCPHyperlink().setVisible(false);
  }
  private ToolBar createHelpImageButton(Composite parent, Image image) {
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    ((GridLayout) parent.getLayout()).numColumns++;
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);
    toolBar.addDisposeListener(
        new DisposeListener() {

          @Override
          public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
          }
        });
    ToolItem item = new ToolItem(toolBar, SWT.NONE);
    item.setImage(image);
    item.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$
    item.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            helpPressed();
          }
        });
    return toolBar;
  }
Exemple #16
0
  protected Control createDialogArea(Composite parent) {

    Composite comp = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) comp.getLayout();
    layout.numColumns = 2;

    // below copied from IconandMessageDialog or something like that
    Image image = getSWTImage(SWT.ICON_ERROR);

    if (image != null) {
      imageLabel = new Label(comp, SWT.NULL);
      image.setBackground(imageLabel.getBackground());
      imageLabel.setImage(image);
      // addAccessibleListeners(imageLabel, image);
      imageLabel.setLayoutData(new GridData(GridData.GRAB_VERTICAL));
      GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }

    GridData data = new GridData();
    data.horizontalIndent = 4;
    Label text = new Label(comp, SWT.NULL);
    text.setLayoutData(data);
    text.setText(message);
    return comp;
  }
 /** 添加帮助按钮 robert 2012-09-06 */
 @Override
 protected Control createHelpControl(Composite parent) {
   // ROBERTHELP 项目设置
   String language = CommonFunction.getSystemLanguage();
   final String helpUrl =
       MessageFormat.format(
           "/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html#project-setting", language);
   Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
   ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
   ((GridLayout) parent.getLayout()).numColumns++;
   toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
   final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
   toolBar.setCursor(cursor);
   toolBar.addDisposeListener(
       new DisposeListener() {
         public void widgetDisposed(DisposeEvent e) {
           cursor.dispose();
         }
       });
   ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
   helpItem.setImage(helpImage);
   helpItem.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$
   helpItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
         }
       });
   return toolBar;
 }
 private Composite createRadioContainer(Composite parent) {
   Composite composite = ControlFactory.createComposite(parent, 1);
   GridLayout layout = (GridLayout) composite.getLayout();
   layout.marginHeight = 0;
   layout.marginWidth = 0;
   return composite;
 }
  @Override
  protected final void contributeButtons(final Composite parent) {
    this.statusButton = new Button(parent, SWT.PUSH);

    this.statusButton.setText("Status");

    Dialog.applyDialogFont(this.statusButton);

    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);

    int hint = this.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    int size = this.statusButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x;

    data.widthHint = Math.max(hint, size);

    this.statusButton.setLayoutData(data);

    this.statusButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          @SuppressWarnings("synthetic-access")
          public final void widgetSelected(final SelectionEvent e) {
            ElasticsearchPreferencePage.super.performOk();
            ElasticsearchPreferencePage.this.requestClusterState(true);
          }
        });

    ((GridLayout) parent.getLayout()).numColumns++;
  }
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) container.getLayout();
    gridLayout.verticalSpacing = 2;
    gridLayout.horizontalSpacing = 2;
    gridLayout.marginHeight = 2;
    gridLayout.marginWidth = 2;

    Composite compositeBody = new Composite(container, SWT.NONE);
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    compositeBody.setLayout(new GridLayout(1, false));

    tadpoleEditor =
        new TadpoleEditorWidget(
            compositeBody, SWT.BORDER, EditorDefine.EXT_JSON, JSONUtil.getPretty(content), "");
    tadpoleEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    initUI();

    // google analytic
    AnalyticCaller.track(this.getClass().getName());

    return container;
  }
Exemple #21
0
 private void configureButtonCompositeLayout(Composite composite) {
   GridLayout layout = (GridLayout) composite.getLayout();
   layout.marginLeft = 20;
   layout.marginRight = 20;
   layout.marginTop = 0;
   layout.horizontalSpacing = 10;
   layout.verticalSpacing = 10;
 }
 /** Adjust the layout of the field editors so that they are properly aligned. */
 protected void adjustGridLayout() {
   int numColumns = calcNumberOfColumns();
   ((GridLayout) fieldEditorParent.getLayout()).numColumns = numColumns;
   if (fields != null) {
     for (int i = 0; i < fields.size(); i++) {
       FieldEditor fieldEditor = fields.get(i);
       fieldEditor.adjustForNumColumns(numColumns);
     }
   }
 }
Exemple #23
0
 private void configureDialogLayout(Composite composite) {
   GridLayout layout = (GridLayout) composite.getLayout();
   layout.numColumns = 2;
   layout.marginLeft = 10;
   layout.marginRight = 10;
   layout.marginTop = 30;
   layout.marginBottom = 0;
   layout.horizontalSpacing = 20;
   layout.verticalSpacing = 10;
 }
 private void addLayoutDataWithExclude(Composite facade) {
   Layout layout = composite.getLayout();
   if (layout instanceof RowLayout) {
     addExcludedRowData(facade);
   } else if (layout instanceof GridLayout) {
     addExcludedGridData(facade);
   } else {
     throw new IllegalStateException("Composite needs to be layouted using Grid- or RowLayout");
   }
 }
  private Composite createPreviousAndNextButtons(Composite parent) {
    // Copied from Wizard Dialog.

    // increment the number of columns in the button bar
    GridLayout barLayout = (GridLayout) parent.getLayout();
    barLayout.numColumns +=
        2; // parent is assumed to have a GridLayout (see javadoc of Dialog#createButton(..))
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size.
    GridLayout layout = new GridLayout();
    layout.numColumns = 0; // will be incremented by createButton
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    composite.setLayout(layout);
    composite.setFont(parent.getFont());
    Button backButton =
        createButton(composite, IDialogConstants.BACK_ID, IDialogConstants.BACK_LABEL, false);
    backButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            backPressed();
          }
        });

    // CODINGSPECTATOR: Pass the "next" button object to the event handler "nextOrPreviewPressed" so
    // that CodingSpectator can tell that the user has pressed "next" and not "preview".
    final Button nextButton =
        createButton(composite, IDialogConstants.NEXT_ID, IDialogConstants.NEXT_LABEL, false);
    nextButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            nextOrPreviewPressed(nextButton);
          }
        });

    GridData data = new GridData();
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    Point minSize1 = backButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    Point minSize2 = nextButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    int minSize = Math.max(minSize1.x, minSize2.x);
    ((GridData) backButton.getLayoutData()).widthHint = minSize;
    ((GridData) nextButton.getLayoutData()).widthHint = minSize;
    data.widthHint = 2 * Math.max(widthHint, minSize) + barLayout.horizontalSpacing;
    data.horizontalAlignment = SWT.FILL;
    data.grabExcessHorizontalSpace = true;
    data.horizontalSpan = 2;
    composite.setLayoutData(data);

    return composite;
  }
  /** {@inheritDoc} */
  @Override
  public void createPartControl(Composite parent, FormToolkit toolkit) {
    main = toolkit.createComposite(parent, SWT.BORDER);
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    GridLayout gl = new GridLayout(8, false);
    main.setLayout(gl);

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_DATABASE));

    totalSql = toolkit.createFormText(main, false);
    totalSql.setToolTipText("Total amount of SQL Statements executed in the invocation");
    totalSql.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_TIME));

    totalDuration = toolkit.createFormText(main, false);
    totalDuration.setToolTipText("Duration sum of all SQL Statements executed in the invocation");
    totalDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_INVOCATION));

    percentageOfDuration = toolkit.createFormText(main, false);
    percentageOfDuration.setToolTipText(
        "Percentage of the time spent in the invocation on SQL Statements execution");
    percentageOfDuration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    toolkit
        .createLabel(main, null)
        .setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_HELP));

    slowestCount = toolkit.createFormText(main, false);
    slowestCount.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    slowestCount.setToolTipText(
        "Amount of slowest SQL Statements that take 80%/20% time of total SQL execution duration");

    // remove left and right margins from the parent
    Layout parentLayout = parent.getLayout();
    if (parentLayout instanceof GridLayout) {
      ((GridLayout) parentLayout).marginWidth = 0;
      ((GridLayout) parentLayout).marginHeight = 0;
    }

    setDefaultText();

    slowestHyperlinkSettings = new HyperlinkSettings(parent.getDisplay());
    slowestHyperlinkSettings.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
    slowestCount.setHyperlinkSettings(slowestHyperlinkSettings);
    slowestCount.addHyperlinkListener(getHyperlinkAdapter());
  }
 private void createSpacer(Composite top) {
   Layout layout = top.getLayout();
   if (layout instanceof GridLayout) {
     int columns = ((GridLayout) layout).numColumns;
     Label spacer = new Label(top, SWT.NONE);
     GridData gd = new GridData();
     gd.heightHint = 5;
     gd.horizontalSpan = columns;
     spacer.setLayoutData(gd);
   }
 }
Exemple #28
0
  protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));

    setButtonLayoutData(button);
    return button;
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.window.Window#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite mainPanel = (Composite) super.createDialogArea(parent);
    ((GridLayout) mainPanel.getLayout()).marginHeight = 10;
    ((GridLayout) mainPanel.getLayout()).marginWidth = 10;
    this.setTitle(TITLE);
    this.setMessage(Messages.createRelationalViewInitialMessage);

    new ViewTableEditorPanel(parent, (RelationalViewTable) relationalObject, modelFile, this);

    return mainPanel;
  }
  /**
   * Creates the Install button for this wizard dialog. Creates a standard (<code>SWT.PUSH</code>)
   * button and registers for its selection events. Note that the number of columns in the button
   * bar composite is incremented.
   *
   * @param parent the parent button bar
   * @return the new Install button
   */
  private Button createInstallButton(Composite parent) {
    // increment the number of columns in the button bar
    ((GridLayout) parent.getLayout()).numColumns++;
    Button button = new Button(parent, SWT.PUSH);
    button.setText(
        Messages.getString("ExternalModulesInstallDialog_InstallAll")
            + "  "); //$NON-NLS-1$ //$NON-NLS-2$//a space is added cause the last letter is missing
    // on my MAC
    setButtonLayoutData(button);
    button.setFont(parent.getFont());

    return button;
  }