Esempio n. 1
0
 void drawRectangles(Rectangle[] rects, boolean stippled) {
   int xDisplay = display.xDisplay;
   int color = OS.XWhitePixel(xDisplay, 0);
   int xWindow = OS.XDefaultRootWindow(xDisplay);
   if (parent != null) {
     xWindow = OS.XtWindow(parent.handle);
     if (xWindow == 0) return;
     int foreground = parent.getForegroundPixel();
     Control control = parent.findBackgroundControl();
     if (control == null) control = parent;
     int background = control.getBackgroundPixel();
     color = foreground ^ background;
   }
   int gc = OS.XCreateGC(xDisplay, xWindow, 0, null);
   OS.XSetForeground(xDisplay, gc, color);
   OS.XSetSubwindowMode(xDisplay, gc, OS.IncludeInferiors);
   OS.XSetFunction(xDisplay, gc, OS.GXxor);
   int stipplePixmap = 0;
   if (stippled) {
     byte[] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
     stipplePixmap = OS.XCreateBitmapFromData(xDisplay, xWindow, bits, 8, 8);
     OS.XSetStipple(xDisplay, gc, stipplePixmap);
     OS.XSetFillStyle(xDisplay, gc, OS.FillStippled);
     OS.XSetLineAttributes(xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter);
   }
   for (int i = 0; i < rects.length; i++) {
     Rectangle rect = rects[i];
     OS.XDrawRectangle(xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height);
   }
   if (stippled) {
     OS.XFreePixmap(xDisplay, stipplePixmap);
   }
   OS.XFreeGC(xDisplay, gc);
 }
  /**
   * Creates an instance of a ControlExample embedded inside the supplied parent Composite.
   *
   * @param parent the container of the example
   */
  public ControlExample(Composite parent) {
    initResources();
    tabFolder = new TabFolder(parent, SWT.NONE);
    tabs = createTabs();
    for (Tab tab : tabs) {
      TabItem item = new TabItem(tabFolder, SWT.NONE);
      item.setText(tab.getTabText());
      item.setControl(tab.createTabFolderPage(tabFolder));
      item.setData(tab);
    }

    /* Workaround: if the tab folder is wider than the screen,
     * Mac platforms clip instead of somehow scrolling the tab items.
     * We try to recover some width by using shorter tab names. */
    Point size = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = parent.getMonitor().getClientArea();
    boolean isMac = SWT.getPlatform().equals("cocoa");
    if (size.x > monitorArea.width && isMac) {
      TabItem[] tabItems = tabFolder.getItems();
      for (int i = 0; i < tabItems.length; i++) {
        tabItems[i].setText(tabs[i].getShortTabText());
      }
    }
    startup = false;
  }
  protected Composite createMaxOccurComp(Composite parent, FormToolkit toolkit) {
    fMaxLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_maxOccurLabel);
    fMaxLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    Composite comp = toolkit.createComposite(parent);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    comp.setLayoutData(gd);

    fMaxOccurSpinner = new Spinner(comp, SWT.BORDER);
    fMaxOccurSpinner.setMinimum(1);
    fMaxOccurSpinner.setMaximum(999);
    fMaxOccurSpinner.setIncrement(1);

    fUnboundSelect =
        toolkit.createButton(comp, PDEUIMessages.AbstractSchemaDetails_unboundedButton, SWT.CHECK);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fUnboundSelect.setLayoutData(gd);
    fUnboundSelect.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (blockListeners()) return;
            fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && isEditableElement());
          }
        });

    return comp;
  }
Esempio n. 4
0
 @Test
 public void testItemComposition() {
   Display display = new Display();
   Composite shell = new Shell(display, SWT.NONE);
   new Item(shell, SWT.NONE) {};
   assertEquals(0, shell.getChildren().length);
 }
  @Override
  protected Control createContents(Composite parent) {
    project = (IProject) getElement().getAdapter(IProject.class);
    settings = TeaVMEclipsePlugin.getDefault().getSettings(project);

    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.verticalSpacing = 10;
    layout.marginWidth = 10;
    container.setLayout(layout);

    natureButton = new Button(container, SWT.CHECK);
    natureButton.setText("Enable TeaVM");
    natureButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    Control profilesContainer = createProfilesContainer(container);
    profilesContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    try {
      natureButton.setSelection(project.hasNature(TeaVMEclipsePlugin.NATURE_ID));
    } catch (CoreException e) {
      reportStatus(e.getStatus());
    }
    loadProfiles();

    return container;
  }
  public void createButtonPanel(Shell dialog) {
    Composite buttonPanel = new Composite(dialog, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    buttonPanel.setLayoutData(gridData);
    buttonPanel.setLayout(new GridLayout(4, false));

    String buttonAlign =
        System.getProperty("org.pentaho.di.buttonPosition", "right")
            .toLowerCase(); //$NON-NLS-1$ //$NON-NLS-2$

    if (!"left".equals(buttonAlign)) { // $NON-NLS-1$
      Label emptyLabel = new Label(buttonPanel, SWT.NONE);
      gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
      emptyLabel.setLayoutData(gridData);
    }
    okButton = new Button(buttonPanel, SWT.PUSH);
    okButton.setText(Messages.getString("VfsFileChooserDialog.ok")); // $NON-NLS-1$
    gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
    gridData.widthHint = 90;
    okButton.setLayoutData(gridData);
    okButton.addSelectionListener(this);
    cancelButton = new Button(buttonPanel, SWT.PUSH);
    cancelButton.setText(Messages.getString("VfsFileChooserDialog.cancel")); // $NON-NLS-1$
    cancelButton.addSelectionListener(this);
    gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
    gridData.widthHint = 90;
    cancelButton.setLayoutData(gridData);
    if ("center".equals(buttonAlign)) { // $NON-NLS-1$
      Label emptyLabel = new Label(buttonPanel, SWT.NONE);
      gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
      emptyLabel.setLayoutData(gridData);
    }
  }
Esempio n. 7
0
  /** Creates content Composite. */
  Composite eswtConstructContent(int style) {
    Composite comp = super.eswtConstructContent(SWT.VERTICAL);

    FormLayout layout = new FormLayout();
    layout.marginBottom = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTBOTTOMMARGIN);
    layout.marginTop = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTTOPMARGIN);
    layout.marginLeft = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTLEFTMARGIN);
    layout.marginRight = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTRIGHTMARGIN);
    layout.spacing = Style.pixelMetric(Style.QSTYLE_PM_LAYOUTVERTICALSPACING);
    comp.setLayout(layout);

    eswtScrolledText = new ScrolledTextComposite(comp, comp.getVerticalBar());
    eswtImgLabel = new LabelExtension(comp, SWT.NONE);

    FormData imageLD = new FormData();
    imageLD.right = new FormAttachment(100);
    imageLD.top = new FormAttachment(0);
    eswtImgLabel.setLayoutData(imageLD);

    FormData scrolledTextLD = new FormData();
    scrolledTextLD.left = new FormAttachment(0);
    scrolledTextLD.top = new FormAttachment(0);
    scrolledTextLD.right = new FormAttachment(eswtImgLabel);
    eswtScrolledText.setLayoutData(scrolledTextLD);

    eswtProgbarLD = new FormData();
    eswtProgbarLD.left = new FormAttachment(0);
    eswtProgbarLD.right = new FormAttachment(100);
    eswtProgbarLD.bottom = new FormAttachment(100);

    eswtUpdateProgressbar(comp, false, false);

    return comp;
  }
  private Composite createAvailableList(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    container.setLayout(layout);
    container.setLayoutData(new GridData());

    Label label = new Label(container, SWT.NONE);
    label.setText(PDEUIMessages.ImportWizard_DetailedPage_availableList);

    Table table = new Table(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    gd.widthHint = 225;
    table.setLayoutData(gd);

    fAvailableListViewer = new TableViewer(table);
    fAvailableListViewer.setLabelProvider(new PluginImportLabelProvider());
    fAvailableListViewer.setContentProvider(new ContentProvider());
    fAvailableListViewer.setInput(PDECore.getDefault().getModelManager());
    fAvailableListViewer.setComparator(ListUtil.PLUGIN_COMPARATOR);

    return container;
  }
Esempio n. 9
0
  private void createTable(Division main) throws WingException {
    // Get all our parameters
    String id = parameters.getParameter("versionID", null);

    Table table = main.addTable("version", 1, 1);

    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCellContent(T_column1);
    header.addCellContent(T_column2);
    header.addCellContent(T_column3);
    header.addCellContent(T_column4);

    VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
    Version version = versioningService.getVersion(context, Integer.parseInt(id));

    Row row = table.addRow();
    row.addCell().addContent(version.getVersionNumber());
    row.addCell().addContent(version.getEperson().getEmail());
    row.addCell().addContent(new DCDate(version.getVersionDate()).toString());
    row.addCell().addContent(version.getSummary());

    List fields = main.addList("fields", List.TYPE_FORM);
    Composite addComposite = fields.addItem().addComposite("summary");
    addComposite.setLabel(T_column4);
    addComposite.addTextArea("summary");
  }
  public void createControl(Composite parent) {

    Composite pageContent = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    pageContent.setLayout(layout);
    pageContent.setLayoutData(new GridData(GridData.FILL_BOTH));

    // variable never used ... is pageContent.getLayoutData() needed?
    // GridData outerFrameGridData = (GridData)
    pageContent.getLayoutData();

    //		outerFrameGridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
    //		outerFrameGridData.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;

    //    WorkbenchHelp.setHelp(
    //        pageContent,
    //        B2BGUIContextIds.BTBG_SELECT_MULTI_FILE_PAGE);

    createLabels(pageContent);
    createSourceViewer(pageContent);
    createButtonPanel(pageContent);
    createSelectedListBox(pageContent);
    createImportButton(pageContent);

    setControl(pageContent);
    if (isFileMandatory) setPageComplete(false);
  }
Esempio n. 11
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /**
   * Creates and returns the contents of the upper part of the dialog (above the button bar).
   *
   * <p>Subclasses should override.
   *
   * @param ancestor the parent composite to contain the dialog area
   * @return the dialog area control
   */
  protected Control createDialogArea(Composite ancestor) {
    Composite composite = (Composite) super.createDialogArea(ancestor);

    Label comment = new Label(composite, SWT.NONE);
    comment.setText(XMLCompareMessages.XMLCompareEditCopyIdMapDialog_comment);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    comment.setLayoutData(data);

    Composite inner = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    inner.setLayout(layout);
    inner.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label label = new Label(inner, SWT.NULL);
    label.setText(XMLCompareMessages.XMLCompareEditCopyIdMapDialog_label);
    label.setLayoutData(new GridData());

    fIdMapText = new Text(inner, SWT.BORDER);
    fIdMapText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fIdMapText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            doValidation();
          }
        });

    fIdMapText.setFocus();

    return composite;
  }
 private Composite createUIContainer(Composite parent) {
   Composite container = new Composite(parent, SWT.NONE);
   GridLayout layout = new GridLayout();
   layout.numColumns = 3;
   container.setLayout(layout);
   return container;
 }
  public void createControl(Composite parent) {
    Composite maincomposite = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 1;
    maincomposite.setLayout(layout);

    GridData data = new GridData(GridData.FILL_BOTH);
    maincomposite.setLayoutData(data);

    showAttributes(maincomposite);

    IModelPropertyEditorAdapter a = support.getPropertyEditorAdapterByName("value");
    if (a instanceof JSFKnowledgeBaseAdapter) {
      ISelection s =
          getSpecificWizard().getWizardModel().getDropData().getSelectionProvider().getSelection();
      if (s instanceof TextSelection) {
        int offset = ((TextSelection) s).getOffset();
        context.put("offset", new Integer(offset));
      }
      ((JSFKnowledgeBaseAdapter) a).setContext(context);
    }

    setControl(maincomposite);
    getSpecificWizard()
        .getWizardModel()
        .addPropertyChangeListener(IDropWizardModel.TAG_PROPOSAL, this);
    updateTitle();
    runValidation();
  }
  public Composite create(Composite parentComp) {

    Composite comp = new Composite(parentComp, SWT.EMBEDDED);
    comp.setLayout(new MigLayout());
    createGroup(comp, "车站信息浏览", "pos 0.5al 0.2al", null);
    return comp;
  }
Esempio n. 16
0
 public void setEnabled(boolean isEnabled) {
   if (this.isEnabled != isEnabled) {
     this.isEnabled = isEnabled;
     avatarsPanel.setEnabled(isEnabled);
     avatarsPanel.layout(true);
   }
 }
Esempio n. 17
0
  /**
   * Adds the platform to the folder on the given level. This method is recursive. If agent name is
   * not fitting the level, it will be added to the given composite. If it fitting for the level,
   * proper search will be done for sub-composite to insert the platform.
   *
   * @param folder Top composite.
   * @param level Wanted level.
   * @param platformIdent {@link PlatformIdent}.
   * @param agentStatusData {@link AgentStatusData}.
   * @param cmrRepositoryDefinition Repository agent is belonging to.
   */
  private static void addToFolder(
      Composite folder,
      int level,
      PlatformIdent platformIdent,
      AgentStatusData agentStatusData,
      CmrRepositoryDefinition cmrRepositoryDefinition) {
    if (!accessibleForLevel(platformIdent.getAgentName(), level)) {
      // if name is not matching the level just add th leaf
      AgentLeaf agentLeaf =
          new AgentLeaf(platformIdent, agentStatusData, cmrRepositoryDefinition, level != 0);
      folder.addChild(agentLeaf);
    } else {
      // search for proper folder
      boolean folderExisting = false;
      String agentLevelName = getFolderNameFromAgent(platformIdent.getAgentName(), level);
      for (Component child : folder.getChildren()) {
        if (child instanceof Composite && ObjectUtils.equals(child.getName(), agentLevelName)) {
          addToFolder(
              (Composite) child,
              level + 1,
              platformIdent,
              agentStatusData,
              cmrRepositoryDefinition);
          folderExisting = true;
        }
      }

      // if not found create new one
      if (!folderExisting) {
        Composite newFolder = createFolder(agentLevelName);
        addToFolder(newFolder, level + 1, platformIdent, agentStatusData, cmrRepositoryDefinition);
        folder.addChild(newFolder);
      }
    }
  }
Esempio n. 18
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Esempio n. 19
0
  static void create(final List actions, final Composite actionBar) {
    Control[] children = actionBar.getChildren();
    for (int i = 0; i < children.length; i++) {
      children[i].dispose();
    }

    actionBar.setLayout(new RowLayout());
    Iterator iterator = actions.iterator();
    while (iterator.hasNext()) {
      Object next = iterator.next();
      if (next instanceof Action) {
        final Action action = (Action) next;
        new ActionBarButton(action, actionBar);
        Label separator = new Label(actionBar, SWT.NONE);
        separator.setText(" ");
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      } else {
        Label separator = new Label(actionBar, SWT.SEPARATOR | SWT.VERTICAL);
        separator.setForeground(Graphics.getColor(255, 255, 255));
        Label separator2 = new Label(actionBar, SWT.NONE);
        separator2.setText(" ");
        Label separator3 = new Label(actionBar, SWT.NONE);
        separator3.setText(" ");
      }
    }
    actionBar.layout();
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 8;
    layout.numColumns = 1;

    layout.makeColumnsEqualWidth = false;
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(gd);
    Label libraryLabel = new Label(container, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    libraryLabel.setLayoutData(gd);
    libraryLabel.setText(PDEUIMessages.ManifestEditor_RuntimeLibraryDialog_label);

    libraryText = new Text(container, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    libraryText.setLayoutData(gd);
    libraryText.setText(PDEUIMessages.ManifestEditor_RuntimeLibraryDialog_default);
    libraryText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateStatus(validator.validate(libraryText.getText()));
          }
        });
    applyDialogFont(container);
    return container;
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    layout.horizontalSpacing = 5;
    layout.verticalSpacing = 10;
    container.setLayout(layout);

    createScrollArea(container);
    createAvailableList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    createButtonArea(container);
    createImportList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    updateCount();

    // create container for buttons
    Composite optionComp =
        SWTFactory.createComposite(container, 1, 3, GridData.FILL_HORIZONTAL, 5, 0);
    createComputationsOption(optionComp);
    createFilterOptions(optionComp);

    addViewerListeners();
    initialize();
    addFilters();
    setControl(container);
    Dialog.applyDialogFont(container);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(container, IHelpContextIds.PLUGIN_IMPORT_SECOND_PAGE);
  }
  public void createFileNamePanel(Shell dialog, String fileName) {
    Composite fileNamePanel = new Composite(dialog, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    fileNamePanel.setLayoutData(gridData);
    fileNamePanel.setLayout(new GridLayout(2, false));
    Label fileNameLabel = new Label(fileNamePanel, SWT.NONE);
    fileNameLabel.setText(Messages.getString("VfsFileChooserDialog.fileName")); // $NON-NLS-1$
    gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    fileNameLabel.setLayoutData(gridData);
    fileNameText = new Text(fileNamePanel, SWT.BORDER);
    if (fileName != null) {
      fileNameText.setText(fileName);
    }
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    fileNameText.setLayoutData(gridData);
    fileNameText.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent arg0) {}

          public void keyReleased(KeyEvent event) {
            if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
              okPressed();
            }
          }
        });
  }
Esempio n. 23
0
 private void createRight(final Composite parent) {
   parent.setLayout(new FillLayout());
   Group styleGroup = new Group(parent, SWT.NONE);
   styleGroup.setText("Styles and Parameters");
   styleGroup.setLayout(new FillLayout());
   styleComp = new Composite(styleGroup, SWT.NONE);
   styleComp.setLayout(new RowLayout(SWT.VERTICAL));
 }
Esempio n. 24
0
 void update() {
   if (parent != null) {
     if (parent.isDisposed()) return;
     parent.getShell().update();
   } else {
     display.update();
   }
 }
Esempio n. 25
0
 @Test
 public void testDisplay() {
   Display display = new Display();
   Composite shell = new Shell(display, SWT.NONE);
   Button button = new Button(shell, SWT.PUSH);
   assertSame(display, shell.getDisplay());
   assertSame(display, button.getDisplay());
 }
Esempio n. 26
0
  public Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(3, false));
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fButton = new Button(comp, SWT.CHECK);
    fButton.setText(PDEUIMessages.AdvancedPluginExportPage_signButton);
    GridData gd = new GridData();
    gd.horizontalSpan = 3;
    fButton.setLayoutData(gd);
    fButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updateGroup(fButton.getSelection());
            fPage.pageChanged();
          }
        });

    fKeystoreLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_keystore);
    fKeystoreText = createText(comp, 1);

    fBrowseButton = new Button(comp, SWT.PUSH);
    fBrowseButton.setText(PDEUIMessages.ExportWizard_browse);
    fBrowseButton.setLayoutData(new GridData());
    SWTUtil.setButtonDimensionHint(fBrowseButton);
    fBrowseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(fPage.getShell(), SWT.OPEN);
            String path = fKeystoreText.getText();
            if (path.trim().length() == 0)
              path = PDEPlugin.getWorkspace().getRoot().getLocation().toString();
            dialog.setFileName(path);
            String res = dialog.open();
            if (res != null) {
              fKeystoreText.setText(res);
            }
          }
        });

    fKeypassLabel = createLabel(comp, PDEUIMessages.JARSigningTab_keypass);
    fKeypassText = createText(comp, 2);
    fKeypassText.setEchoChar('*');

    fAliasLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_alias);
    fAliasText = createText(comp, 2);

    fPasswordLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_password);
    fPasswordText = createText(comp, 2);
    fPasswordText.setEchoChar('*');

    Dialog.applyDialogFont(comp);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.ADVANCED_PLUGIN_EXPORT);
    return comp;
  }
Esempio n. 27
0
 @Override
 protected void createButtonsForButtonBar(Composite parent) {
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalAlignment = GridData.CENTER;
   parent.setLayoutData(gd);
   parent.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
   Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
   button.setFocus();
 }
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    section.setLayoutData(data);

    section.setText(PDEUIMessages.IntroSection_sectionText);
    section.setDescription(PDEUIMessages.IntroSection_sectionDescription);

    boolean canCreateNew = TargetPlatformHelper.getTargetVersion() >= NEW_INTRO_SUPPORT_VERSION;

    Composite client = toolkit.createComposite(section);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, canCreateNew ? 3 : 2));
    client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = toolkit.createLabel(client, PDEUIMessages.IntroSection_introLabel, SWT.WRAP);
    GridData td = new GridData();
    td.horizontalSpan = canCreateNew ? 3 : 2;
    label.setLayoutData(td);

    Label introLabel = toolkit.createLabel(client, PDEUIMessages.IntroSection_introInput);
    introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fIntroCombo = new ComboPart();
    fIntroCombo.createControl(client, toolkit, SWT.READ_ONLY);
    td = new GridData(GridData.FILL_HORIZONTAL);
    fIntroCombo.getControl().setLayoutData(td);
    loadManifestAndIntroIds(false);
    if (fAvailableIntroIds != null) fIntroCombo.setItems(fAvailableIntroIds);
    fIntroCombo.add(""); // $NON-NLS-1$
    fIntroCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleSelection();
          }
        });

    if (canCreateNew) {
      Button button = toolkit.createButton(client, PDEUIMessages.IntroSection_new, SWT.PUSH);
      button.setEnabled(isEditable());
      button.setLayoutData(new GridData(GridData.FILL));
      button.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleNewIntro();
            }
          });
    }

    fIntroCombo.getControl().setEnabled(isEditable());

    toolkit.paintBordersFor(client);
    section.setClient(client);
    // Register to be notified when the model changes
    getModel().addModelChangedListener(this);
  }
Esempio n. 29
0
  public void init(Shell parentShell) {
    shell = ShellFactory.createShell(parentShell, SWT.BORDER | SWT.TITLE | SWT.CLOSE | SWT.RESIZE);
    Utils.setShellIcon(shell);
    if (Constants.isOSX) monospace = new Font(shell.getDisplay(), "Courier", 12, SWT.NORMAL);
    else monospace = new Font(shell.getDisplay(), "Courier New", 8, SWT.NORMAL);

    shell.setText(
        MessageText.getString("window.welcome.title", new String[] {Constants.AZUREUS_VERSION}));

    display = shell.getDisplay();

    GridLayout layout = new GridLayout();
    shell.setLayout(layout);

    GridData data;

    cWhatsNew = new Composite(shell, SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    cWhatsNew.setLayoutData(data);
    cWhatsNew.setLayout(new FillLayout());

    Button bClose = new Button(shell, SWT.PUSH);
    bClose.setText(MessageText.getString("Button.close"));
    data = new GridData();
    data.widthHint = 70;
    data.horizontalAlignment = Constants.isOSX ? SWT.CENTER : SWT.RIGHT;
    bClose.setLayoutData(data);

    Listener closeListener =
        new Listener() {
          public void handleEvent(Event event) {
            close();
          }
        };

    bClose.addListener(SWT.Selection, closeListener);
    shell.addListener(SWT.Close, closeListener);

    shell.setDefaultButton(bClose);

    shell.addListener(
        SWT.Traverse,
        new Listener() {
          public void handleEvent(Event e) {
            if (e.character == SWT.ESC) {
              close();
            }
          }
        });

    shell.setSize(750, 500);
    Utils.centreWindow(shell);
    shell.layout();
    shell.open();
    pullWhatsNew(cWhatsNew);
  }
Esempio n. 30
0
 public static Composite createPlaceholder(Composite parent, int columns, int spacing) {
   Composite ph = new Composite(parent, SWT.NONE);
   GridLayout gl = new GridLayout(columns, false);
   gl.verticalSpacing = spacing;
   gl.horizontalSpacing = spacing;
   gl.marginHeight = 0;
   gl.marginWidth = 0;
   ph.setLayout(gl);
   return ph;
 }