Beispiel #1
0
 public static CellEditor createPropertyEditor(
     final IServiceLocator serviceLocator,
     Composite parent,
     DBPPropertySource source,
     DBPPropertyDescriptor property) {
   if (source == null) {
     return null;
   }
   final Object object = source.getEditableValue();
   if (!property.isEditable(object)) {
     return null;
   }
   CellEditor cellEditor = UIUtils.createCellEditor(parent, object, property);
   if (cellEditor != null) {
     final Control editorControl = cellEditor.getControl();
     UIUtils.addFocusTracker(serviceLocator, UIUtils.INLINE_WIDGET_EDITOR_ID, editorControl);
     editorControl.addDisposeListener(
         new DisposeListener() {
           @Override
           public void widgetDisposed(DisposeEvent e) {
             UIUtils.removeFocusTracker(serviceLocator, editorControl);
           }
         });
   }
   return cellEditor;
 }
Beispiel #2
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;
  }