예제 #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");
  }
  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));
  }
예제 #4
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Widget");

    final Table table = new Table(shell, SWT.MULTI);
    table.setLinesVisible(true);
    table.setBounds(10, 10, 100, 100);
    for (int i = 0; i < 9; i++) {
      new TableItem(table, SWT.NONE).setText("item" + i);
    }

    Button button = new Button(shell, SWT.PUSH);
    button.setText("Capture");
    button.pack();
    button.setLocation(10, 140);
    button.addListener(
        SWT.Selection,
        event -> {
          Point tableSize = table.getSize();
          GC gc = new GC(table);
          final Image image = new Image(display, tableSize.x, tableSize.y);
          gc.copyArea(image, 0, 0);
          gc.dispose();

          Shell popup = new Shell(shell);
          popup.setText("Image");
          popup.addListener(SWT.Close, e -> image.dispose());

          Canvas canvas = new Canvas(popup, SWT.NONE);
          canvas.setBounds(10, 10, tableSize.x + 10, tableSize.y + 10);
          canvas.addPaintListener(e -> e.gc.drawImage(image, 0, 0));
          popup.pack();
          popup.open();
        });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
예제 #5
0
  @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;
  }
예제 #6
0
  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;
  }
  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;
  }
예제 #8
0
파일: ViewData.java 프로젝트: schugabe/FWS
  /** 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);
  }