Esempio n. 1
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");
  }
Esempio n. 2
0
  public Shell open(Display display) {
    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.addShellListener(
        new ShellAdapter() {
          @Override
          public void shellClosed(ShellEvent e) {
            e.doit = closeAddressBook();
          }
        });

    createMenuBar();

    searchDialog = new SearchDialog(shell);
    searchDialog.setSearchAreaNames(columnNames);
    searchDialog.setSearchAreaLabel(resAddressBook.getString("Column"));
    searchDialog.addFindListener(
        new FindListener() {
          public boolean find() {
            return findEntry();
          }
        });

    table = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setMenu(createPopUpMenu());
    table.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            TableItem[] items = table.getSelection();
            if (items.length > 0) editEntry(items[0]);
          }
        });
    for (int i = 0; i < columnNames.length; i++) {
      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setText(columnNames[i]);
      column.setWidth(150);
      final int columnIndex = i;
      column.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              sort(columnIndex);
            }
          });
    }

    newAddressBook();

    shell.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
    shell.open();
    return shell;
  }
Esempio n. 3
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final Table table = new Table(shell, SWT.BORDER);
   table.setHeaderVisible(true);
   final TableColumn column1 = new TableColumn(table, SWT.NONE);
   column1.setText("Column 1");
   final TableColumn column2 = new TableColumn(table, SWT.NONE);
   column2.setText("Column 2");
   TableItem item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"a", "3"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"b", "2"});
   item = new TableItem(table, SWT.NONE);
   item.setText(new String[] {"c", "1"});
   column1.setWidth(100);
   column2.setWidth(100);
   Listener sortListener =
       e -> {
         TableItem[] items = table.getItems();
         Collator collator = Collator.getInstance(Locale.getDefault());
         TableColumn column = (TableColumn) e.widget;
         int index = column == column1 ? 0 : 1;
         for (int i = 1; i < items.length; i++) {
           String value1 = items[i].getText(index);
           for (int j = 0; j < i; j++) {
             String value2 = items[j].getText(index);
             if (collator.compare(value1, value2) < 0) {
               String[] values = {items[i].getText(0), items[i].getText(1)};
               items[i].dispose();
               TableItem item1 = new TableItem(table, SWT.NONE, j);
               item1.setText(values);
               items = table.getItems();
               break;
             }
           }
         }
         table.setSortColumn(column);
       };
   column1.addListener(SWT.Selection, sortListener);
   column2.addListener(SWT.Selection, sortListener);
   table.setSortColumn(column1);
   table.setSortDirection(SWT.UP);
   shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  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;
  }
Esempio n. 7
0
  @Override
  public void createPartControl(Composite parent) {
    final IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbar = actionBars.getToolBarManager();
    mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$
    toolbar.add(mSymbolEntryText);
    toolbar.add(new AddSymbolAction(mSymbolEntryText, this));

    final Table table =
        new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER);
    table.setHeaderVisible(true);
    mViewer = new TableViewer(table);
    GridDataFactory.defaultsFor(table).applyTo(table);

    final MarketDataItemComparator comparator = new MarketDataItemComparator();
    mViewer.setComparator(comparator);

    SelectionListener listener =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // determine new sort column and direction
            TableColumn sortColumn = table.getSortColumn();
            TableColumn currentColumn = (TableColumn) e.widget;
            final int index = table.indexOf(currentColumn);
            int dir = table.getSortDirection();
            if (sortColumn == currentColumn) {
              dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {
              table.setSortColumn(currentColumn);
              dir = SWT.UP;
            }
            table.setSortDirection(dir);
            comparator.setSort(dir == SWT.UP ? 1 : -1);
            comparator.setIndex(index);
            mViewer.refresh();
          }
        };

    // create columns, using FIXFieldLocalizer to preserve backwards
    // compatibility
    TableViewerColumn symbolColumn =
        new TableViewerColumn(
            mViewer,
            createColumn(
                table,
                FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()),
                SWT.LEFT,
                listener));
    symbolColumn.setEditingSupport(new SymbolEditingSupport());
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()),
        SWT.RIGHT,
        listener);
    createColumn(
        table,
        FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()),
        SWT.RIGHT,
        listener);

    // restore table state if it exists
    if (mViewState != null) {
      ColumnState.restore(table, mViewState);
      for (TableColumn column : table.getColumns()) {
        if (column.getWidth() == 0) {
          column.setResizable(false);
        }
      }
    }

    registerContextMenu();
    getSite().setSelectionProvider(mViewer);

    ObservableListContentProvider content = new ObservableListContentProvider();
    mViewer.setContentProvider(content);
    IObservableSet domain = content.getKnownElements();
    IObservableMap[] maps =
        new IObservableMap[] {
          BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$
          createCompositeMap(
              domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$
        };
    mViewer.setLabelProvider(new ObservableMapLabelProvider(maps));
    mViewer.setUseHashlookup(true);
    mItems = WritableList.withElementType(MarketDataViewItem.class);
    mViewer.setInput(mItems);
  }
  public Shell open(Display display) {

    // Window dressing - the icon
    windowIcon =
        new Image(display, getClass().getClassLoader().getResourceAsStream("icons/joanju.gif"));

    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            e.doit = closeAddressBook();
          }
        });

    shell.setImage(windowIcon);

    createMenuBar();

    searchDialog = new SearchDialog(shell);
    searchDialog.setSearchAreaNames(columnNames);
    searchDialog.setSearchAreaLabel(resMessages.getString("Column"));
    searchDialog.addFindListener(
        new FindListener() {
          public boolean find() {
            return findEntry();
          }
        });

    table = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setMenu(createPopUpMenu());
    table.addSelectionListener(
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            TableItem[] items = table.getSelection();
            if (items.length > 0) launchEditor(items[0]);
          }
        });
    int[] widths = {150, 50, 200, 200};
    for (int i = 0; i < columnNames.length; i++) {
      TableColumn column = new TableColumn(table, SWT.NONE);
      column.setText(columnNames[i]);
      column.setWidth(widths[i]);
      final int columnIndex = i;
      column.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              sort(columnIndex);
            }
          });
    }

    newAddressBook();

    shell.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            windowIcon.dispose();
          }
        });

    shell.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);
    shell.open();
    return shell;
  }
  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;
  }
Esempio n. 13
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);
  }