Esempio n. 1
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;
  }
Esempio n. 2
0
  public static Label createImageLabel(Composite parent, DBPImage image) {
    Label imageLabel = new Label(parent, SWT.NONE);
    imageLabel.setImage(DBeaverIcons.getImage(image));

    return imageLabel;
  }