protected void enableMinMax(boolean enable) {
   fMinOccurSpinner.setEnabled(enable);
   fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && enable);
   fUnboundSelect.setEnabled(enable);
   fMinLabel.setEnabled(enable);
   fMaxLabel.setEnabled(enable);
 }
Exemplo n.º 2
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
   String modifier = SWT.MOD1 == SWT.CTRL ? "Ctrl" : "Command";
   text.setText("Hit " + modifier + "+Return\nto see\nthe default button\nrun");
   text.addTraverseListener(
       e -> {
         switch (e.detail) {
           case SWT.TRAVERSE_RETURN:
             if ((e.stateMask & SWT.MOD1) != 0) e.doit = true;
         }
       });
   Button button = new Button(shell, SWT.PUSH);
   button.pack();
   button.setText("OK");
   button.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           System.out.println("OK selected");
         }
       });
   shell.setDefaultButton(button);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  private void createImpButtons(Composite container) {
    Composite buttonContainer =
        SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0);

    fAddButton = SWTFactory.createPushButton(buttonContainer, PDEUIMessages.SourceBlock_add, null);
    fAddButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleAdd();
          }
        });

    fRemoveButton =
        SWTFactory.createPushButton(buttonContainer, PDEUIMessages.SourceBlock_remove, null);
    fRemoveButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleRemove();
          }
        });

    fRemoveAllButton =
        SWTFactory.createPushButton(
            buttonContainer, PDEUIMessages.TargetImplicitPluginsTab_removeAll3, null);
    fRemoveAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleRemoveAll();
          }
        });

    updateImpButtons();
  }
 private Button createButton(Composite parent, FormToolkit toolkit, String label) {
   Button button = toolkit.createButton(parent, label, SWT.CHECK);
   GridData gd = new GridData();
   gd.horizontalSpan = F_NUM_COLUMNS;
   button.setLayoutData(gd);
   return button;
 }
 private void createOptionalDependenciesButton(Composite container) {
   if (isEditable()) {
     fIncludeOptionalButton = new Button(container, SWT.CHECK);
     fIncludeOptionalButton.setText(PDEUIMessages.PluginSection_includeOptional);
     // initialize value
     IEditorInput input = getPage().getEditorInput();
     if (input instanceof IFileEditorInput) {
       IFile file = ((IFileEditorInput) input).getFile();
       try {
         fIncludeOptionalButton.setSelection(
             "true".equals(file.getPersistentProperty(OPTIONAL_PROPERTY))); // $NON-NLS-1$
       } catch (CoreException e) {
       }
     }
     // create listener to save value when the checkbox is changed
     fIncludeOptionalButton.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent e) {
             IEditorInput input = getPage().getEditorInput();
             if (input instanceof IFileEditorInput) {
               IFile file = ((IFileEditorInput) input).getFile();
               try {
                 file.setPersistentProperty(
                     OPTIONAL_PROPERTY,
                     fIncludeOptionalButton.getSelection() ? "true" : null); // $NON-NLS-1$
               } catch (CoreException e1) {
               }
             }
           }
         });
   }
 }
Exemplo n.º 6
0
  @NotNull
  public static Button createLabelCheckbox(
      @NotNull Composite parent,
      @NotNull String label,
      @Nullable String tooltip,
      boolean checked,
      int style) {
    Label labelControl = createControlLabel(parent, label);
    // labelControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final Button button = new Button(parent, SWT.CHECK | style);
    if (checked) {
      button.setSelection(true);
    }
    labelControl.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            if (!button.isDisposed() && button.isVisible() && button.isEnabled()) {
              button.setSelection(!button.getSelection());
              button.notifyListeners(SWT.Selection, new Event());
            }
          }
        });

    if (tooltip != null) {
      labelControl.setToolTipText(tooltip);
      button.setToolTipText(tooltip);
    }
    return button;
  }
  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;
  }
Exemplo n.º 8
0
  public static Button createCheckbox(Composite parent, String label, boolean checked) {
    final Button button = new Button(parent, SWT.CHECK);
    button.setText(label);
    if (checked) {
      button.setSelection(true);
    }

    return button;
  }
Exemplo n.º 9
0
 /** Sets the state of the "Example" widgets. */
 void setExampleWidgetState() {
   super.setExampleWidgetState();
   Control[] controls = getExampleWidgets();
   if (controls.length != 0) {
     leftButton.setSelection((controls[0].getStyle() & SWT.LEFT) != 0);
     centerButton.setSelection((controls[0].getStyle() & SWT.CENTER) != 0);
     rightButton.setSelection((controls[0].getStyle() & SWT.RIGHT) != 0);
   }
 }
  private void showSelectedType(DBPConnectionType connectionType) {
    colorPicker.select(UIUtils.getConnectionTypeColor(connectionType));
    typeName.setText(connectionType.getName());
    typeDescription.setText(connectionType.getDescription());
    autocommitCheck.setSelection(connectionType.isAutocommit());
    confirmCheck.setSelection(connectionType.isConfirmExecute());

    deleteButton.setEnabled(!connectionType.isPredefined());
  }
 private void setButtonEnabled(String configKey, Button b, boolean enabled) {
   Boolean previousValue = oldBulkAPIDependencies.put(b, b.getSelection());
   b.setSelection(
       enabled
           ? (previousValue != null
               ? previousValue
               : this.controller.getConfig().getBoolean(configKey))
           : false);
   b.setEnabled(enabled);
 }
Exemplo n.º 12
0
 public static Button createToolButton(
     Composite parent, String text, SelectionListener selectionListener) {
   Button button = new Button(parent, SWT.PUSH);
   button.setText(text);
   button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   if (selectionListener != null) {
     button.addSelectionListener(selectionListener);
   }
   return button;
 }
  private void createProgressMessageConfig(Composite parent) {
    fAddMessageButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressMessage);
    fAddMessageButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean enable = fAddMessageButton.getSelection();
            getSplashInfo().addProgressMessage(enable, false);
            updateFieldEnablement();
          }
        });
    fAddMessageButton.setEnabled(false);

    Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);

    fMessageControls[0] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageX);
    fMessageControls[1] = fMessageSpinners[0] = createSpinner(parent, fToolkit);
    fMessageControls[2] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageY);
    fMessageControls[3] = fMessageSpinners[1] = createSpinner(parent, fToolkit);

    fMessageControls[4] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageWidth);
    fMessageControls[5] = fMessageSpinners[2] = createSpinner(parent, fToolkit);
    fMessageControls[6] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageHeight);
    fMessageControls[7] = fMessageSpinners[3] = createSpinner(parent, fToolkit);

    fMessageControls[8] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageColor);
    fColorSelector = new ColorSelector(parent);
    fColorSelector.addListener(
        new IPropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent event) {
            if (!event.getNewValue().equals(event.getOldValue())) applyColor();
          }
        });
    fToolkit.adapt(fColorSelector.getButton(), true, true);
    fMessageControls[9] = fColorSelector.getButton();
    // Add tooltips to coordinate controls
    addOffsetTooltips(fMessageControls);

    for (Spinner spinner : fMessageSpinners) {
      spinner.setEnabled(isEditable());
      spinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              applySpinners(false);
            }
          });
    }
  }
Exemplo n.º 14
0
 @NotNull
 public static Button createPushButton(
     @NotNull Composite parent, @Nullable String label, @Nullable Image image) {
   Button button = new Button(parent, SWT.PUSH);
   if (label != null) {
     button.setText(label);
   }
   if (image != null) {
     button.setImage(image);
   }
   return button;
 }
  private void updateButtonEnablement(boolean doAddEnablement, boolean doRemoveEnablement) {
    updateCount();
    int availableCount = fAvailableListViewer.getTable().getItemCount();
    int importCount = fImportListViewer.getTable().getItemCount();

    if (doAddEnablement) updateSelectionBasedEnablement(fAvailableListViewer.getSelection(), true);
    if (doRemoveEnablement) updateSelectionBasedEnablement(fImportListViewer.getSelection(), false);

    fAddAllButton.setEnabled(availableCount > 0);
    fRemoveAllButton.setEnabled(importCount > 0);
    fAddRequiredButton.setEnabled(importCount > 0);
  }
  private void createProgressBarConfig(Composite parent) {
    fAddBarButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressBar);
    fAddBarButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean enable = fAddBarButton.getSelection();
            getSplashInfo().addProgressBar(enable, false);
            updateFieldEnablement();
          }
        });
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.verticalIndent = 5;
    data.horizontalSpan = F_NUM_COLUMNS;
    fAddBarButton.setLayoutData(data);
    fAddBarButton.setEnabled(isEditable());

    Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);

    fBarControls[0] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressX);
    fBarControls[1] = fBarSpinners[0] = createSpinner(parent, fToolkit);
    fBarControls[2] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressY);
    fBarControls[3] = fBarSpinners[1] = createSpinner(parent, fToolkit);
    fBarControls[4] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressWidth);
    fBarControls[5] = fBarSpinners[2] = createSpinner(parent, fToolkit);
    fBarControls[6] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressHeight);
    fBarControls[7] = fBarSpinners[3] = createSpinner(parent, fToolkit);
    // Add tooltips to coordinate controls
    addOffsetTooltips(fBarControls);

    for (Spinner spinner : fBarSpinners) {
      spinner.setEnabled(isEditable());
      spinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              applySpinners(true);
            }
          });
    }

    Composite filler = fToolkit.createComposite(parent);
    filler.setLayout(new GridLayout());
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    filler.setLayoutData(gd);
  }
Exemplo n.º 17
0
  @NotNull
  public static Text createOutputFolderChooser(
      final Composite parent, @Nullable String label, @Nullable ModifyListener changeListener) {
    UIUtils.createControlLabel(
        parent, label != null ? label : CoreMessages.data_transfer_wizard_output_label_directory);
    Composite chooserPlaceholder = UIUtils.createPlaceholder(parent, 2);
    chooserPlaceholder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    final Text directoryText = new Text(chooserPlaceholder, SWT.BORDER);
    directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (changeListener != null) {
      directoryText.addModifyListener(changeListener);
    }

    final Runnable folderChooser =
        new Runnable() {
          @Override
          public void run() {
            DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.NONE);
            dialog.setMessage(CoreMessages.data_transfer_wizard_output_dialog_directory_message);
            dialog.setText(CoreMessages.data_transfer_wizard_output_dialog_directory_text);
            String directory = directoryText.getText();
            if (!CommonUtils.isEmpty(directory)) {
              dialog.setFilterPath(directory);
            }
            directory = dialog.open();
            if (directory != null) {
              directoryText.setText(directory);
            }
          }
        };
    directoryText.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            folderChooser.run();
          }
        });

    Button openFolder = new Button(chooserPlaceholder, SWT.PUSH | SWT.FLAT);
    openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
    openFolder.setLayoutData(
        new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_CENTER));
    openFolder.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            folderChooser.run();
          }
        });
    return directoryText;
  }
  private void createControls(Composite parent) {
    Group container = new Group(parent, SWT.SHADOW_ETCHED_OUT);
    container.setText("General interpreter properties");
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    container.setLayoutData(data);
    container.setLayout(new GridLayout(1, false));

    final Button saveButton = new Button(container, SWT.CHECK);
    saveButton.setText("Save file before loading in interpreter");
    saveButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            mSaveBeforeLoad = saveButton.getSelection();
          }
        });
    saveButton.setSelection(mSaveBeforeLoad);

    final Button surroundButton = new Button(container, SWT.CHECK);
    surroundButton.setText("Surround expressions with (begin ...  )");
    surroundButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            mSurroundWithBegin = surroundButton.getSelection();
          }
        });
    surroundButton.setSelection(mSurroundWithBegin);
  }
Exemplo n.º 19
0
 private void radioChanged() {
   if (exampleModelButton.getSelection()) {
     descriptionText.setText("This model displays an awesome simulation of something ...");
     titleText.setText("example");
     fileText.setText("example.gaml");
     updateStatus(null);
   }
   if (emptyModelButton.getSelection() || skeletonModelButton.getSelection()) {
     descriptionText.setText("");
     titleText.setText("new");
     fileText.setText("new.gaml");
     updateStatus(null);
   }
   dialogChanged();
 }
Exemplo n.º 20
0
  void createRTFTransfer(Composite copyParent, Composite pasteParent) {
    //	RTF Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    copyRtfText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyRtfText.setText("some\nrtf\ntext");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyRtfText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyRtfText.getText();
            if (data.length() > 0) {
              status.setText("");
              data = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i " + data + "}";
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {RTFTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    pasteRtfText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteRtfText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(RTFTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteRtfText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
Exemplo n.º 21
0
  protected void saveSettings(IDialogSettings settings) {
    ISecurePreferences preferences = getPreferences(settings.getName());
    if (preferences == null) {
      // only in case it is not possible to create secured storage in
      // default location -> in that case do not persist settings
      return;
    }

    try {
      preferences.putBoolean(S_SIGN_JARS, fButton.getSelection(), true);
      preferences.put(S_KEYSTORE, fKeystoreText.getText().trim(), true);
      preferences.put(S_ALIAS, fAliasText.getText().trim(), true);
      preferences.put(S_PASSWORD, fPasswordText.getText().trim(), true);
      preferences.put(S_KEYPASS, fKeypassText.getText().trim(), true);

      // bug387565 - for keys which are starting with this bugfix to be
      // stored
      // in secured storage, replace value in settings with empty string
      // to avoid keeping sensitive info in plain text
      String[] obsoleted = new String[] {S_KEYSTORE, S_ALIAS, S_PASSWORD, S_KEYPASS};
      for (String key : obsoleted) {
        if (settings.get(key) != null) {
          settings.put(key, ""); // $NON-NLS-1$
        }
      }
    } catch (StorageException e) {
      PDEPlugin.log(
          "Failed to store JarSigning settings in secured preferences store"); //$NON-NLS-1$
    }
  }
Exemplo n.º 22
0
  public void addSelectedFilesToTargetList() {
    ISelection selection = sourceFileViewer.getSelection();

    if (isValidSourceFileViewerSelection(selection)) {
      java.util.List list = null;
      if (selection instanceof IStructuredSelection) {
        list = ((IStructuredSelection) selection).toList();

        if (list != null) {
          list = ((IStructuredSelection) selection).toList();
          for (Iterator i = list.iterator(); i.hasNext(); ) {
            IResource resource = (IResource) i.next();
            if (resource instanceof IFile) {
              // Check if its in the list. Don't add it if it is.
              String resourceName = resource.getFullPath().toString();
              if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName);
            }
          }
          setFiles(selectedListBox.getItems());
        }

        setAddButtonEnabled(false);

        if (selectedListBox.getItemCount() > 0) {
          removeAllButton.setEnabled(true);
          if (isFileMandatory) setPageComplete(true);
          if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
          else setRemoveButtonEnabled(false);
        }
      }
    }
  }
 public void promptForNewFolder() {
   boolean done = false;
   String defaultText = "New Folder";
   String text = defaultText;
   while (!done) {
     if (text == null) {
       text = defaultText;
     }
     TextInputDialog textDialog =
         new TextInputDialog(
             Messages.getString("VfsBrowser.enterNewFolderName"), text, 500, 160); // $NON-NLS-1$
     text = textDialog.open();
     if (text != null && !"".equals(text)) { // $NON-NLS-1$
       try {
         vfsBrowser.createFolder(text); // $NON-NLS-1$
         done = true;
       } catch (FileSystemException e) {
         MessageBox errorDialog = new MessageBox(newFolderButton.getShell(), SWT.OK);
         errorDialog.setText(Messages.getString("VfsBrowser.error")); // $NON-NLS-1$
         if (e.getCause() != null) {
           errorDialog.setMessage(e.getCause().getMessage());
         } else {
           errorDialog.setMessage(e.getMessage());
         }
         errorDialog.open();
       }
     } else {
       done = true;
     }
   }
 }
 protected Button[] createTrueFalseButtons(Composite parent, FormToolkit toolkit, int colSpan) {
   Composite comp = toolkit.createComposite(parent, SWT.NONE);
   GridLayout gl = new GridLayout(2, false);
   gl.marginHeight = gl.marginWidth = 0;
   comp.setLayout(gl);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = colSpan;
   gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
   comp.setLayoutData(gd);
   Button tButton = toolkit.createButton(comp, BOOLS[0], SWT.RADIO);
   Button fButton = toolkit.createButton(comp, BOOLS[1], SWT.RADIO);
   gd = new GridData();
   gd.horizontalIndent = 20;
   fButton.setLayoutData(gd);
   return new Button[] {tButton, fButton};
 }
 protected void updateMaxOccur(int max) {
   if (fMaxOccurSpinner == null) return;
   boolean isMax = max == Integer.MAX_VALUE;
   fUnboundSelect.setSelection(isMax);
   fMaxOccurSpinner.setEnabled(!isMax);
   if (!isMax) fMaxOccurSpinner.setSelection(max);
 }
Exemplo n.º 26
0
  void createHTMLTransfer(Composite copyParent, Composite pasteParent) {
    //	HTML Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    copyHtmlText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyHtmlText.setText("<b>Hello World</b>");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyHtmlText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyHtmlText.getText();
            if (data.length() > 0) {
              status.setText("");
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {HTMLTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    pasteHtmlText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteHtmlText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(HTMLTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteHtmlText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
 public static void directoryDialogTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Directory Dialog");
   tab.setToolTipText("Select a directory");
   final Button b = new Button(folder, SWT.PUSH);
   b.setText("Select a Directory");
   b.addListener(
       SWT.MouseDown,
       new Listener() {
         public void handleEvent(Event e) {
           DirectoryDialog dd = new DirectoryDialog(shell);
           String path = dd.open();
           if (path != null) b.setText(path);
         }
       });
   tab.setControl(b);
 }
 public static void buttonTab() {
   TabItem tab = new TabItem(folder, SWT.CLOSE);
   tab.setText("Buttons");
   tab.setToolTipText("Different kinds of Buttons");
   Composite composite = new Composite(folder, SWT.NONE);
   composite.setLayout(new GridLayout(4, true));
   for (int dir : new int[] {SWT.UP, SWT.RIGHT, SWT.LEFT, SWT.DOWN}) {
     Button b = new Button(composite, SWT.ARROW | dir);
     b.addListener(SWT.MouseDown, listener);
   }
   newButton(composite, SWT.CHECK, "Check button");
   newButton(composite, SWT.PUSH, "Push button");
   newButton(composite, SWT.RADIO, "Radio button");
   newButton(composite, SWT.TOGGLE, "Toggle button");
   newButton(composite, SWT.FLAT, "Flat button");
   tab.setControl(composite);
 }
Exemplo n.º 29
0
  /** Creates the "Other" group. */
  void createOtherGroup() {
    super.createOtherGroup();

    /* Create display controls specific to this example */
    caretButton = new Button(otherGroup, SWT.CHECK);
    caretButton.setText(ControlExample.getResourceString("Caret"));
    fillDamageButton = new Button(otherGroup, SWT.CHECK);
    fillDamageButton.setText(ControlExample.getResourceString("FillDamage"));

    /* Add the listeners */
    caretButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            setCaret();
          }
        });
  }
Exemplo n.º 30
0
 void createAvailableTypes(Composite parent) {
   final List list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
   GridData data = new GridData(GridData.FILL_BOTH);
   data.heightHint = 100;
   list.setLayoutData(data);
   Button b = new Button(parent, SWT.PUSH);
   b.setText("Get Available Types");
   b.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           list.removeAll();
           String[] names = clipboard.getAvailableTypeNames();
           for (int i = 0; i < names.length; i++) {
             list.add(names[i]);
           }
         }
       });
 }