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;
  }
Beispiel #2
0
  /** Create contents of the window. */
  protected void createContents() {
    shlUCEditor = new Shell();
    shlUCEditor.setSize(722, 530);
    shlUCEditor.setText("µC Editor");
    shlUCEditor.setLayout(new GridLayout(1, false));

    Label lblAddElements = new Label(shlUCEditor, SWT.CENTER);
    lblAddElements.setFont(SWTResourceManager.getFont("Lucida Grande", 20, SWT.NORMAL));
    lblAddElements.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
    lblAddElements.setText("Microcontroller Editor");

    table = new Table(shlUCEditor, SWT.BORDER | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableColumn tblclmnType = new TableColumn(table, SWT.CENTER);
    tblclmnType.setWidth(123);
    tblclmnType.setText("Type");
    // Set not editable
    //		tblclmnType.setData(new UCEditorColumnData(false));

    TableColumn tblclmnName = new TableColumn(table, SWT.CENTER);
    tblclmnName.setWidth(193);
    tblclmnName.setText("Name");

    TableColumn tblclmnId = new TableColumn(table, SWT.CENTER);
    tblclmnId.setWidth(184);
    tblclmnId.setText("Port");

    // Allow the table to be edited
    //		table.addListener(SWT.MouseDoubleClick, new ElementsDoubleClickListener(this, table));

    Label label = new Label(shlUCEditor, SWT.SEPARATOR | SWT.HORIZONTAL);
    label.setAlignment(SWT.CENTER);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));

    Label lblDoubleClickTo = new Label(shlUCEditor, SWT.NONE);
    lblDoubleClickTo.setText("Double click a microcontroller to make changes. ");

    Composite composite = new Composite(shlUCEditor, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    Button btnNewButton = new Button(composite, SWT.NONE);
    btnNewButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            addController();
          }
        });
    btnNewButton.setBounds(0, 0, 94, 28);
    btnNewButton.setText("Add Local Arduino");
  }
  public void buildWUIDTab(String wuid) {
    CTabItem tab2 = new CTabItem(folder, SWT.NONE);
    tab2.setText(wuid);

    Table table = new Table(folder, SWT.VIRTUAL | SWT.BORDER);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.clearAll();
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 200;
    table.setLayoutData(data);

    // openFile(fileName,table);

    tab2.setControl(table);
  }
  public void buildTab(String filename, String resType, CTabFolder subfolder) {
    System.out.println("buildTab");
    CTabItem tab2 = new CTabItem(subfolder, SWT.NONE);
    tab2.setText(resType);

    Table table = new Table(subfolder, SWT.VIRTUAL | SWT.BORDER);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.clearAll();
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 200;
    table.setLayoutData(data);

    openFile(filename, table);

    tab2.setControl(table);
    System.out.println("BUILDSUBTAB--------" + subfolder.indexOf(tab2));
    subfolder.setSelection(subfolder.indexOf(tab2));
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    parent.setLayout(new GridLayout());

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    composite.setLayout(new GridLayout());

    viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);

    Table table = viewer.getTable();
    table.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    table.setHeaderVisible(true);
    table.setLinesVisible(false);

    TableColumn tc;

    tc = new TableColumn(table, SWT.LEFT);
    tc.setText(""); // $NON-NLS-1$
    tc.setWidth(40);

    tc = new TableColumn(table, SWT.LEFT);
    tc.setText(Messages.ExterneDokumente_file_date);
    tc.setWidth(120);
    tc.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            // TODO sort by Datum
            // http://www.vogella.de/articles/EclipseJFaceTable/article.html#sortcolumns
          }
        });

    tc = new TableColumn(table, SWT.LEFT);
    tc.setText(Messages.VerifierDialog_name);
    tc.setWidth(200);
    tc.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            // TODO sort by Nummer
          }
        });

    viewer.setContentProvider(new VerifierContentProvider());
    viewer.setLabelProvider(new VerifierLabelProvider());
    viewer.setComparator(new TimestampComparator());
    viewer.setInput(this);

    // edit file properties at if double clicked

    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            StructuredSelection selection = (StructuredSelection) viewer.getSelection();
            if (selection != null) {
              Object element = selection.getFirstElement();
              if (element instanceof File) {
                openFileEditorDialog((File) element);
              }
            }
          }
        });

    return composite;
  }
  void createFileTransfer(Composite copyParent, Composite pasteParent) {
    // File Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("FileTransfer:"); // $NON-NLS-1$

    Composite c = new Composite(copyParent, SWT.NONE);
    c.setLayout(new GridLayout(2, false));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    c.setLayoutData(data);

    copyFileTable = new Table(c, SWT.MULTI | SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    data.horizontalSpan = 2;
    copyFileTable.setLayoutData(data);

    Button b = new Button(c, SWT.PUSH);
    b.setText("Select file(s)");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
            String result = dialog.open();
            if (result != null && result.length() > 0) {
              // copyFileTable.removeAll();
              String separator = System.getProperty("file.separator");
              String path = dialog.getFilterPath();
              String[] names = dialog.getFileNames();
              for (int i = 0; i < names.length; i++) {
                TableItem item = new TableItem(copyFileTable, SWT.NONE);
                item.setText(path + separator + names[i]);
              }
            }
          }
        });
    b = new Button(c, SWT.PUSH);
    b.setText("Select directory");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
            String result = dialog.open();
            if (result != null && result.length() > 0) {
              // copyFileTable.removeAll();
              TableItem item = new TableItem(copyFileTable, SWT.NONE);
              item.setText(result);
            }
          }
        });

    b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TableItem[] items = copyFileTable.getItems();
            if (items.length > 0) {
              status.setText("");
              String[] data = new String[items.length];
              for (int i = 0; i < data.length; i++) {
                data[i] = items[i].getText();
              }
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {FileTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("FileTransfer:"); // $NON-NLS-1$
    pasteFileTable = new Table(pasteParent, SWT.MULTI | SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteFileTable.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(FileTransfer.getInstance());
            if (data != null && data.length > 0) {
              status.setText("");
              pasteFileTable.removeAll();
              for (int i = 0; i < data.length; i++) {
                TableItem item = new TableItem(pasteFileTable, SWT.NONE);
                item.setText(data[i]);
              }
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
  private Control createProfilesContainer(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.numColumns = 2;
    layout.verticalSpacing = 3;
    layout.horizontalSpacing = 3;
    container.setLayout(layout);

    Label caption = new Label(container, SWT.NONE);
    caption.setText("Profiles");
    caption.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    profilesTable = new Table(container, SWT.BORDER | SWT.V_SCROLL | SWT.CHECK);
    profilesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
    profilesTable.setHeaderVisible(true);
    profilesTable.setLinesVisible(true);
    TableColumn nameColumn = new TableColumn(profilesTable, SWT.LEFT);
    nameColumn.setText("Name");
    nameColumn.setWidth(150);
    TableColumn pathColumn = new TableColumn(profilesTable, SWT.LEFT);
    pathColumn.setText("Target directory");
    pathColumn.setWidth(300);
    TableColumn fileColumn = new TableColumn(profilesTable, SWT.LEFT);
    fileColumn.setText("Target file");
    fileColumn.setWidth(150);
    profilesTable.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updateTableSelection();
          }
        });

    addProfileButton = new Button(container, SWT.PUSH);
    addProfileButton.setText("Add...");
    addProfileButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    addProfileButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            addProfile();
          }
        });

    editProfileButton = new Button(container, SWT.PUSH);
    editProfileButton.setText("Edit...");
    editProfileButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    editProfileButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            editProfile();
          }
        });

    removeProfileButton = new Button(container, SWT.PUSH);
    removeProfileButton.setText("Remove");
    removeProfileButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    removeProfileButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            deleteProfile();
          }
        });

    return container;
  }
  /** @see PreferencePage#createContents(Composite) */
  protected Control createContents(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);

    // layout the top table & its buttons
    Label label = new Label(parent, SWT.LEFT);
    label.setText(XMLCompareMessages.XMLComparePreference_topTableLabel);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    fIdMapsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    fIdMapsTable.setHeaderVisible(true);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = fIdMapsTable.getItemHeight() * 4;
    fIdMapsTable.setLayoutData(data);
    fIdMapsTable.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            selectionChanged();
          }
        });

    String column2Text = XMLCompareMessages.XMLComparePreference_topTableColumn2;
    String column3Text = XMLCompareMessages.XMLComparePreference_topTableColumn3;
    ColumnLayoutData columnLayouts[] = {
      new ColumnWeightData(1),
      new ColumnPixelData(convertWidthInCharsToPixels(column2Text.length() + 2), true),
      new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 5), true)
    };
    TableLayout tablelayout = new TableLayout();
    fIdMapsTable.setLayout(tablelayout);
    for (int i = 0; i < 3; i++) tablelayout.addColumnData(columnLayouts[i]);
    TableColumn column = new TableColumn(fIdMapsTable, SWT.NONE);
    column.setText(XMLCompareMessages.XMLComparePreference_topTableColumn1);
    column = new TableColumn(fIdMapsTable, SWT.NONE);
    column.setText(column2Text);
    column = new TableColumn(fIdMapsTable, SWT.NONE);
    column.setText(column3Text);

    fillIdMapsTable();

    Composite buttons = new Composite(parent, SWT.NULL);
    buttons.setLayout(new GridLayout());
    data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    buttons.setLayoutData(data);

    fAddIdMapButton = new Button(buttons, SWT.PUSH);
    fAddIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topAdd);
    fAddIdMapButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            addIdMap(fAddIdMapButton.getShell());
          }
        });
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint =
        Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fAddIdMapButton.setLayoutData(data);

    fRenameIdMapButton = new Button(buttons, SWT.PUSH);
    fRenameIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRename);
    fRenameIdMapButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            renameIdMap(fRenameIdMapButton.getShell());
          }
        });
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint =
        Math.max(widthHint, fAddIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fRenameIdMapButton.setLayoutData(data);

    fRemoveIdMapButton = new Button(buttons, SWT.PUSH);
    fRemoveIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topRemove);
    fRemoveIdMapButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            removeIdMap(fRemoveIdMapButton.getShell());
          }
        });
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint =
        Math.max(widthHint, fRemoveIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fRemoveIdMapButton.setLayoutData(data);

    createSpacer(buttons);

    fEditIdMapButton = new Button(buttons, SWT.PUSH);
    fEditIdMapButton.setText(XMLCompareMessages.XMLComparePreference_topEdit);
    fEditIdMapButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            editIdMap(fEditIdMapButton.getShell());
          }
        });
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    // data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
    widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    data.widthHint =
        Math.max(widthHint, fEditIdMapButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    fEditIdMapButton.setLayoutData(data);

    // Spacer
    label = new Label(parent, SWT.LEFT);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    // layout the middle table & its buttons
    label = new Label(parent, SWT.LEFT);
    label.setText(XMLCompareMessages.XMLComparePreference_middleTableLabel);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    fMappingsTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    fMappingsTable.setHeaderVisible(true);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = fMappingsTable.getItemHeight() * 4;
    data.widthHint = convertWidthInCharsToPixels(70);
    fMappingsTable.setLayoutData(data);

    column3Text = XMLCompareMessages.XMLComparePreference_middleTableColumn3;
    String column4Text = XMLCompareMessages.XMLComparePreference_middleTableColumn4;
    columnLayouts =
        new ColumnLayoutData[] {
          new ColumnWeightData(10),
          new ColumnWeightData(18),
          new ColumnPixelData(convertWidthInCharsToPixels(column3Text.length() + 1), true),
          new ColumnPixelData(convertWidthInCharsToPixels(column4Text.length() + 3), true)
        };
    tablelayout = new TableLayout();
    fMappingsTable.setLayout(tablelayout);
    for (int i = 0; i < 4; i++) tablelayout.addColumnData(columnLayouts[i]);
    column = new TableColumn(fMappingsTable, SWT.NONE);
    column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn1);
    column = new TableColumn(fMappingsTable, SWT.NONE);
    column.setText(XMLCompareMessages.XMLComparePreference_middleTableColumn2);
    column = new TableColumn(fMappingsTable, SWT.NONE);
    column.setText(column3Text);
    column = new TableColumn(fMappingsTable, SWT.NONE);
    column.setText(column4Text);

    buttons = new Composite(parent, SWT.NULL);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);

    fNewMappingsButton = new Button(buttons, SWT.PUSH);
    fNewMappingsButton.setLayoutData(getButtonGridData(fNewMappingsButton));
    fNewMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleNew);
    fNewMappingsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            addMapping(fAddIdMapButton.getShell());
          }
        });

    fEditMappingsButton = new Button(buttons, SWT.PUSH);
    fEditMappingsButton.setLayoutData(getButtonGridData(fEditMappingsButton));
    fEditMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleEdit);
    fEditMappingsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            editMapping(fEditMappingsButton.getShell());
          }
        });

    fRemoveMappingsButton = new Button(buttons, SWT.PUSH);
    fRemoveMappingsButton.setLayoutData(getButtonGridData(fRemoveMappingsButton));
    fRemoveMappingsButton.setText(XMLCompareMessages.XMLComparePreference_middleRemove);
    fRemoveMappingsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            removeMapping(fRemoveMappingsButton.getShell());
          }
        });

    createSpacer(buttons);

    // layout the botton table & its buttons
    label = new Label(parent, SWT.LEFT);
    label.setText(XMLCompareMessages.XMLComparePreference_bottomTableLabel);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    fOrderedTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    fOrderedTable.setHeaderVisible(true);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = fOrderedTable.getItemHeight() * 2;
    data.widthHint = convertWidthInCharsToPixels(70);
    fOrderedTable.setLayoutData(data);

    columnLayouts = new ColumnLayoutData[] {new ColumnWeightData(1), new ColumnWeightData(1)};
    tablelayout = new TableLayout();
    fOrderedTable.setLayout(tablelayout);
    for (int i = 0; i < 2; i++) tablelayout.addColumnData(columnLayouts[i]);
    column = new TableColumn(fOrderedTable, SWT.NONE);
    column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn1);
    column = new TableColumn(fOrderedTable, SWT.NONE);
    column.setText(XMLCompareMessages.XMLComparePreference_bottomTableColumn2);

    buttons = new Composite(parent, SWT.NULL);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);

    fNewOrderedButton = new Button(buttons, SWT.PUSH);
    fNewOrderedButton.setLayoutData(getButtonGridData(fNewOrderedButton));
    fNewOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomNew);
    fNewOrderedButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            addOrdered(fNewOrderedButton.getShell());
          }
        });

    fEditOrderedButton = new Button(buttons, SWT.PUSH);
    fEditOrderedButton.setLayoutData(getButtonGridData(fEditOrderedButton));
    fEditOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomEdit);
    fEditOrderedButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            editOrdered(fEditOrderedButton.getShell());
          }
        });

    fRemoveOrderedButton = new Button(buttons, SWT.PUSH);
    fRemoveOrderedButton.setLayoutData(getButtonGridData(fRemoveOrderedButton));
    fRemoveOrderedButton.setText(XMLCompareMessages.XMLComparePreference_bottomRemove);
    fRemoveOrderedButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            removeOrdered(fRemoveOrderedButton.getShell());
          }
        });

    createSpacer(buttons);

    fIdMapsTable.setSelection(0);
    fIdMapsTable.setFocus();
    selectionChanged();

    return parent;
  }
  @Override
  protected Control createContents(final Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1, 5);

    {
      typeTable = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
      typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
      UIUtils.createTableColumn(typeTable, SWT.LEFT, "Name");
      UIUtils.createTableColumn(typeTable, SWT.LEFT, "Description");
      typeTable.setHeaderVisible(true);
      typeTable.setLayoutData(new GridData(GridData.FILL_BOTH));
      typeTable.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              showSelectedType(getSelectedType());
            }
          });

      Composite tableGroup = UIUtils.createPlaceholder(composite, 2, 5);
      tableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Button newButton = new Button(tableGroup, SWT.PUSH);
      newButton.setText("New");
      newButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              String name;
              for (int i = 1; ; i++) {
                name = "Type" + i;
                boolean hasName = false;
                for (DBPConnectionType type : changedInfo.keySet()) {
                  if (type.getName().equals(name)) {
                    hasName = true;
                    break;
                  }
                }
                if (!hasName) {
                  break;
                }
              }
              DBPConnectionType newType =
                  new DBPConnectionType(
                      SecurityUtils.generateUniqueId(),
                      name,
                      "255,255,255",
                      "New type",
                      true,
                      false);
              addTypeToTable(newType, newType);
              typeTable.select(typeTable.getItemCount() - 1);
              typeTable.showSelection();
              showSelectedType(newType);
            }
          });

      deleteButton = new Button(tableGroup, SWT.PUSH);
      deleteButton.setText("Delete");
      deleteButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              DBPConnectionType connectionType = getSelectedType();
              if (!UIUtils.confirmAction(
                  deleteButton.getShell(),
                  "Delete connection type",
                  "Are you sure you want to delete connection type '"
                      + connectionType.getName()
                      + "'?\n"
                      + "All connections of this type will be reset to default type ("
                      + DBPConnectionType.DEFAULT_TYPE.getName()
                      + ")")) {
                return;
              }
              changedInfo.remove(connectionType);
              int index = typeTable.getSelectionIndex();
              typeTable.remove(index);
              if (index > 0) index--;
              typeTable.select(index);
              showSelectedType(getSelectedType());
            }
          });
    }

    {
      Group groupSettings =
          UIUtils.createControlGroup(
              composite, "Settings", 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
      groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH));

      typeName = UIUtils.createLabelText(groupSettings, "Name", null);
      typeName.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              getSelectedType().setName(typeName.getText());
              updateTableInfo();
            }
          });
      typeDescription = UIUtils.createLabelText(groupSettings, "Description", null);
      typeDescription.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              getSelectedType().setDescription(typeDescription.getText());
              updateTableInfo();
            }
          });

      {
        UIUtils.createControlLabel(groupSettings, "Color");
        Composite colorGroup = UIUtils.createPlaceholder(groupSettings, 2, 5);
        colorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        colorPicker = new CImageCombo(colorGroup, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
        colorPicker.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        colorPicker.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                getSelectedType()
                    .setColor(
                        StringConverter.asString(
                            colorPicker
                                .getItem(colorPicker.getSelectionIndex())
                                .getBackground()
                                .getRGB()));
                updateTableInfo();
              }
            });
        Button pickerButton = new Button(colorGroup, SWT.PUSH);
        pickerButton.setText("...");
        pickerButton.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                DBPConnectionType connectionType = getSelectedType();
                ColorDialog colorDialog = new ColorDialog(parent.getShell());
                colorDialog.setRGB(StringConverter.asRGB(connectionType.getColor()));
                RGB rgb = colorDialog.open();
                if (rgb != null) {
                  Color color = null;
                  int count = colorPicker.getItemCount();
                  for (int i = 0; i < count; i++) {
                    TableItem item = colorPicker.getItem(i);
                    if (item.getBackground() != null && item.getBackground().getRGB().equals(rgb)) {
                      color = item.getBackground();
                      break;
                    }
                  }
                  if (color == null) {
                    color = new Color(colorPicker.getDisplay(), rgb);
                    colorPicker.add(null, COLOR_TEXT, color, color);
                  }
                  colorPicker.select(color);
                  getSelectedType().setColor(StringConverter.asString(color.getRGB()));
                  updateTableInfo();
                }
              }
            });
      }

      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;

      autocommitCheck = UIUtils.createCheckbox(groupSettings, "Auto-commit by default", false);
      autocommitCheck.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              getSelectedType().setAutocommit(autocommitCheck.getSelection());
            }
          });
      autocommitCheck.setLayoutData(gd);
      confirmCheck = UIUtils.createCheckbox(groupSettings, "Confirm SQL execution", false);
      confirmCheck.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              getSelectedType().setConfirmExecute(confirmCheck.getSelection());
            }
          });
      confirmCheck.setLayoutData(gd);
    }

    performDefaults();

    return composite;
  }
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    FormLayout mainLayout = new FormLayout();
    mainLayout.marginHeight = 5;
    mainLayout.marginWidth = 5;
    container.setLayout(mainLayout);

    inlineUserRolesText = new Text(container, SWT.SINGLE | SWT.BORDER);
    {
      FormData inlineUserRolesTextLayoutData = new FormData(100, SWT.DEFAULT);
      inlineUserRolesTextLayoutData.top = new FormAttachment(0, 20);
      inlineUserRolesTextLayoutData.left = new FormAttachment(30);
      inlineUserRolesTextLayoutData.right = new FormAttachment(100, -5);
      inlineUserRolesText.setLayoutData(inlineUserRolesTextLayoutData);
      inlineUserRolesText.setText(getUserRolesInLine(selectedRoles));
    }

    Label inlineUserRolesLabel = new Label(container, SWT.NONE);
    {
      inlineUserRolesLabel.setText("User Roles: ");
      FormData inlineUserRolesLabelLayoutData = new FormData(20, SWT.DEFAULT);
      inlineUserRolesLabelLayoutData.top = new FormAttachment(inlineUserRolesText, 0, SWT.CENTER);
      inlineUserRolesLabelLayoutData.right = new FormAttachment(inlineUserRolesText, -5);
      inlineUserRolesLabelLayoutData.left = new FormAttachment(0);
      inlineUserRolesLabel.setLayoutData(inlineUserRolesLabelLayoutData);
    }

    getRolesFromServerEnableButton = new Button(container, SWT.CHECK);
    {
      getRolesFromServerEnableButton.setText("Get Roles from Server");
      FormData inlineRadioButtonLayoutData = new FormData();
      inlineRadioButtonLayoutData.top = new FormAttachment(inlineUserRolesLabel, 10);
      inlineRadioButtonLayoutData.left = new FormAttachment(0);
      getRolesFromServerEnableButton.setLayoutData(inlineRadioButtonLayoutData);

      getRolesFromServerEnableButton.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {
              updateServerRolesUI(getRolesFromServerEnableButton.getSelection());
            }
          });
    }

    serverUrlText = new Text(container, SWT.SINGLE | SWT.BORDER);
    {
      FormData serverUrlTextLayoutData = new FormData(100, SWT.DEFAULT);
      serverUrlTextLayoutData.top = new FormAttachment(inlineUserRolesText, 35);
      serverUrlTextLayoutData.left = new FormAttachment(inlineUserRolesText, 0, SWT.LEFT);
      serverUrlTextLayoutData.right = new FormAttachment(100, -5);
      serverUrlText.setLayoutData(serverUrlTextLayoutData);

      serverUrlText.addListener(
          SWT.KeyUp,
          new Listener() {
            public void handleEvent(Event event) {
              validateServerInfo();
            }
          });
    }

    Label serverUrlLabel = new Label(container, SWT.NONE);
    {
      serverUrlLabel.setText("URL: ");
      FormData serverUrlLabelLayoutData = new FormData(20, SWT.DEFAULT);
      serverUrlLabelLayoutData.top = new FormAttachment(serverUrlText, 0, SWT.CENTER);
      serverUrlLabelLayoutData.right = new FormAttachment(serverUrlText, -5);
      serverUrlLabelLayoutData.left = new FormAttachment(0);
      serverUrlLabel.setLayoutData(serverUrlLabelLayoutData);
    }

    userNameText = new Text(container, SWT.SINGLE | SWT.BORDER);
    {
      FormData userNameTextLayoutData = new FormData(100, SWT.DEFAULT);
      userNameTextLayoutData.top = new FormAttachment(serverUrlText, 5);
      userNameTextLayoutData.left = new FormAttachment(serverUrlText, 0, SWT.LEFT);
      userNameTextLayoutData.right = new FormAttachment(100, -5);
      userNameText.setLayoutData(userNameTextLayoutData);

      userNameText.addListener(
          SWT.KeyUp,
          new Listener() {
            public void handleEvent(Event event) {
              validateServerInfo();
            }
          });
    }

    Label userNameLabel = new Label(container, SWT.NONE);
    {
      userNameLabel.setText("Username: "******"Password: "******"Role name pattern (* for all):");
      FormData roleNamePatternLabelLayoutData = new FormData(25, SWT.DEFAULT);
      roleNamePatternLabelLayoutData.top = new FormAttachment(roleNamePatternText, 0, SWT.CENTER);
      roleNamePatternLabelLayoutData.right = new FormAttachment(roleNamePatternText, -5);
      roleNamePatternLabelLayoutData.left = new FormAttachment(0);
      roleNamePatternLabel.setLayoutData(roleNamePatternLabelLayoutData);
    }

    Label rolesLabel = new Label(container, SWT.NONE);
    {
      rolesLabel.setText("Roles:");
      FormData rolesLabelLayoutData = new FormData(25, SWT.DEFAULT);
      rolesLabelLayoutData.top = new FormAttachment(roleNamePatternText, 10);
      rolesLabelLayoutData.left = new FormAttachment(0);
      rolesLabelLayoutData.right = new FormAttachment(100, -5);
      rolesLabel.setLayoutData(rolesLabelLayoutData);
    }

    getRolesButton = new Button(container, SWT.NONE);
    {
      getRolesButton.setText("Get Roles");
      FormData getRolesButtonLayoutData = new FormData(80, SWT.DEFAULT);
      getRolesButtonLayoutData.top = new FormAttachment(rolesLabel, 10);
      getRolesButtonLayoutData.right = new FormAttachment(100, -5);
      getRolesButton.setLayoutData(getRolesButtonLayoutData);

      getRolesButton.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {
              listRoles();
            }
          });
    }

    userRolesTable =
        new Table(container, SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.CHECK);
    {
      TableColumn nameColumn = new TableColumn(userRolesTable, SWT.LEFT);

      nameColumn.setText("Name");
      nameColumn.setWidth(495);

      userRolesTable.setHeaderVisible(true);
      userRolesTable.setLinesVisible(true);

      FormData userRolesTableLayoutData = new FormData(500, 150);
      userRolesTableLayoutData.top = new FormAttachment(getRolesButton, 0, SWT.TOP);
      userRolesTableLayoutData.left = new FormAttachment(0);
      userRolesTableLayoutData.right = new FormAttachment(getRolesButton, -5);
      userRolesTableLayoutData.bottom = new FormAttachment(100);
      userRolesTable.setLayoutData(userRolesTableLayoutData);
    }

    {
      // Set default values.
      serverUrlText.setText("https://localhost:9443/");
      userNameText.setText("admin");
      passwordText.setText("admin");
      roleNamePatternText.setText("*");

      updateServerRolesUI(false);
    }

    return container;
  }
Beispiel #11
0
  /** build the view */
  private void buildView() {
    GridLayout gridLayout = new GridLayout(2, false);
    final Composite comp = new Composite(shell, SWT.NONE);

    shell.setLayout(new FillLayout());

    comp.setLayout(gridLayout);

    GridData gridData = new GridData();

    dataList = new List(comp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    gridData = new GridData();
    gridData.widthHint = 200;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalSpan = 2;
    dataList.setLayoutData(gridData);
    dataList.addListener(SWT.Selection, new ListListener());

    dataTable = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    dataTable.setLinesVisible(true);
    dataTable.setHeaderVisible(true);

    gridData = new GridData();
    gridData.verticalAlignment = SWT.FILL;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    dataTable.setLayoutData(gridData);

    final TableColumn column1 = new TableColumn(dataTable, SWT.NONE);
    final TableColumn column2 = new TableColumn(dataTable, SWT.NONE);

    column1.setText("Time");
    column2.setText("Value");
    column1.setWidth(180);
    column2.setWidth(270);

    Composite buttonsComp = new Composite(comp, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 40;
    buttonsComp.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.HORIZONTAL;

    rowLayout.justify = true;
    rowLayout.pack = true;
    buttonsComp.setLayout(rowLayout);

    ButtonListener bl = new ButtonListener();

    Button refreshButton = new Button(buttonsComp, SWT.NONE);
    refreshButton.setText("Refresh");
    refreshButton.addSelectionListener(bl);

    Button exportButton = new Button(buttonsComp, SWT.NONE);
    exportButton.setText("Export");
    exportButton.addSelectionListener(bl);

    Button deleteButton = new Button(buttonsComp, SWT.NONE);
    deleteButton.setText("Delete Selection");
    deleteButton.addSelectionListener(bl);

    Button deleteallButton = new Button(buttonsComp, SWT.NONE);
    deleteallButton.setText("Delete all");
    deleteallButton.addSelectionListener(bl);
  }