コード例 #1
0
ファイル: ArchlightNoticeView.java プロジェクト: zheng3/AS
  @Override
  public void createPartControl(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ViewContentProvider());
    viewer.setLabelProvider(new ViewLabelProvider());
    viewer.setInput(getViewSite());

    Table table = viewer.getTable();

    TableColumn column = new TableColumn(table, SWT.CENTER);
    column.setText(COLUMN_NAMES[0]);

    TableColumn column2 = new TableColumn(table, SWT.LEFT);
    column2.setText(COLUMN_NAMES[1]);

    TableColumn column3 = new TableColumn(table, SWT.LEFT);
    column3.setText(COLUMN_NAMES[2]);

    TableLayout tableLayout = new AutoResizeTableLayout(table);
    tableLayout.addColumnData(new ColumnWeightData(5, false));
    tableLayout.addColumnData(new ColumnWeightData(80, true));
    tableLayout.addColumnData(new ColumnWeightData(15, true));
    table.setLayout(tableLayout);

    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    // table.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));

    viewer.setColumnProperties(COLUMN_NAMES);
    // CellEditor tce = new TextCellEditor(table);
    // tv.setCellEditors(new CellEditor[]{null, tce});
    // tv.setCellModifier(new ViewCellModifier(selectedRefs[i]));

    viewer.refresh();
  }
コード例 #2
0
  /** Create the Table */
  private void createTable(Composite parent) {
    int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;

    table = new Table(parent, style);
    TableLayout layout = new TableLayout();
    table.setLayout(layout);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 2;
    table.setLayoutData(gridData);

    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    // 1st column with attribute
    TableColumn column1 = new TableColumn(table, SWT.LEFT, 0);
    column1.setText(BINDINGS_TABLE_ATTR_COL_TEXT);
    ColumnWeightData weight = new ColumnWeightData(1);
    layout.addColumnData(weight);

    // 2nd column with sql
    TableColumn column2 = new TableColumn(table, SWT.LEFT, 1);
    column2.setText(BINDINGS_TABLE_SQL_COL_TEXT);
    weight = new ColumnWeightData(1);
    layout.addColumnData(weight);

    // add a listener to keep the table sized to it's container
    new TableSizeAdapter(table, 10);
  }
コード例 #3
0
ファイル: ViewTestCase.java プロジェクト: Haegin/YetiPlugin
  private Table createTableWithColumns(Composite parent) {
    Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);

    TableLayout layout = new TableLayout();
    table.setLayout(layout);

    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    String[] STD_HEADINGS = {"TestCase Id ", "Test Case Description", "Test Module"};

    layout.addColumnData(new ColumnWeightData(10, 80, true));
    TableColumn tc0 = new TableColumn(table, SWT.NONE);
    tc0.setText(STD_HEADINGS[0]);
    tc0.setAlignment(SWT.LEFT);
    tc0.setResizable(true);

    layout.addColumnData(new ColumnWeightData(20, 800, true));
    TableColumn tc1 = new TableColumn(table, SWT.NONE);
    tc1.setText(STD_HEADINGS[1]);
    tc1.setAlignment(SWT.LEFT);
    tc1.setResizable(true);

    layout.addColumnData(new ColumnWeightData(30, 400, true));
    TableColumn tc2 = new TableColumn(table, SWT.NONE);
    tc2.setText(STD_HEADINGS[2]);
    tc2.setAlignment(SWT.LEFT);
    tc2.setResizable(true);

    return table;
  }
  /**
   * Creates the SWT controls for this workbench part.
   *
   * @param parent the parent control
   */
  public void createSection(Composite parent) {
    super.createSection(parent);
    FormToolkit toolkit = getFormToolkit(parent.getDisplay());

    Section section =
        toolkit.createSection(
            parent,
            ExpandableComposite.TWISTIE
                | ExpandableComposite.EXPANDED
                | ExpandableComposite.TITLE_BAR
                | Section.DESCRIPTION
                | ExpandableComposite.FOCUS_TITLE);
    section.setText("Ports");
    section.setDescription("Modify the server ports.");
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

    // ports
    Composite composite = toolkit.createComposite(section);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 8;
    layout.marginWidth = 8;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL));
    // IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
    // whs.setHelp(composite, ContextIds.CONFIGURATION_EDITOR_PORTS);
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    ports = toolkit.createTable(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    ports.setHeaderVisible(true);
    ports.setLinesVisible(true);
    // whs.setHelp(ports, ContextIds.CONFIGURATION_EDITOR_PORTS_LIST);

    TableLayout tableLayout = new TableLayout();

    TableColumn col = new TableColumn(ports, SWT.NONE);
    col.setText("Port Name");
    ColumnWeightData colData = new ColumnWeightData(15, 150, true);
    tableLayout.addColumnData(colData);

    col = new TableColumn(ports, SWT.NONE);
    col.setText("Value");
    colData = new ColumnWeightData(8, 80, true);
    tableLayout.addColumnData(colData);

    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    data.widthHint = 230;
    data.heightHint = 100;
    ports.setLayoutData(data);
    ports.setLayout(tableLayout);

    viewer = new TableViewer(ports);
    viewer.setColumnProperties(new String[] {"name", "port"});

    initialize();
  }
コード例 #5
0
  @Override
  public void create() {
    super.create();

    Label descriptionLabel = new Label(getDialogArea(), SWT.WRAP);
    descriptionLabel.setText(
        "Some local profiles have changed. Select the ones you want to re-apply");

    TreeViewer viewer = new TreeViewer(getDialogArea());
    viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Tree tree = viewer.getTree();

    TableLayout layout = new TableLayout();

    TreeColumn propertyColumn = new TreeColumn(tree, SWT.CENTER);
    propertyColumn.setText("Package");
    layout.addColumnData(new ColumnWeightData(30, 300, true));

    TreeColumn propertyVersionColumn = new TreeColumn(tree, SWT.CENTER);
    propertyVersionColumn.setText("Version");
    layout.addColumnData(new ColumnWeightData(30, 100, true));

    TreeColumn ownerColumn = new TreeColumn(tree, SWT.CENTER);
    ownerColumn.setText("Profile");
    layout.addColumnData(new ColumnWeightData(60, 150, true));

    TreeColumn ownerVersionColumn = new TreeColumn(tree, SWT.CENTER);
    ownerVersionColumn.setText("Version");
    layout.addColumnData(new ColumnWeightData(30, 100, true));

    TreeColumn checkColumn = new TreeColumn(tree, SWT.CENTER);
    checkColumn.setText("Reapply");
    layout.addColumnData(new ColumnWeightData(10, 70, true));

    tree.setLayout(layout);
    tree.setHeaderVisible(true);

    viewer.setContentProvider(new ProfileApplicationContentProvider(rootPackage));
    viewer.setLabelProvider(new ProfileApplicationLabelProvider());

    viewer.setInput(new Object());

    installEditors(viewer);

    getDialogArea().layout();

    getShell().pack();
  }
コード例 #6
0
ファイル: AoWizardPage.java プロジェクト: belaban/IronJacamar
  private TableViewer createTableViewer(Composite parent) {
    String fTableColumnHeaders[] = {"Name", "Type", "Value"};
    final ColumnLayoutData[] fTableColumnLayouts = {
      new ColumnWeightData(30), new ColumnWeightData(20), new ColumnWeightData(50)
    };

    Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);

    data.widthHint = 600;
    table.setLayoutData(data);
    table.setFont(parent.getFont());

    TableViewer tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new PropsContentProvider(tableViewer));
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.addSelectionChangedListener(tableListener);

    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    for (int i = 0; i < fTableColumnHeaders.length; i++) {
      tableLayout.addColumnData(fTableColumnLayouts[i]);
      TableColumn column = new TableColumn(table, SWT.NONE, i);
      column.setResizable(fTableColumnLayouts[i].resizable);
      column.setText(fTableColumnHeaders[i]);
    }

    return tableViewer;
  }
コード例 #7
0
  /**
   * @param parent
   * @return
   */
  public Control createContents(Composite parent) {
    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    ScrolledForm sf = toolkit.createScrolledForm(parent);
    Composite comp = sf.getForm().getBody();
    comp.setLayout(new GridLayout(1, true));
    comp.setBackground(parent.getBackground());

    Section brandSection = toolkit.createSection(comp, Section.TITLE_BAR);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    brandSection.setLayoutData(gridData);
    brandSection.setText("Supported Interaction Types");

    Table table = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK | SWT.SINGLE);
    table.setHeaderVisible(true);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1));
    table.setLayout(layout);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText("Interaction Type");
    column.setWidth(100);
    column.setResizable(true);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 200;
    table.setLayoutData(gd);

    viewer = new CheckboxTableViewer(table);
    viewer.setContentProvider(new InteractionTypeContentProvider());
    InteractionTypeLabelProvider labelProvider = new InteractionTypeLabelProvider();
    viewer.setLabelProvider(labelProvider);
    viewer.setCheckStateProvider(labelProvider);
    viewer.addCheckStateListener(this);
    viewer.setInput(this);

    return comp;
  }
コード例 #8
0
  private void createTableViewer(final Composite parent) {
    mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    gridLayout = new GridLayout(1, false);
    mainComposite.setLayout(gridLayout);
    viewer =
        new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100, false));
    viewer.getTable().setLayout(layout);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn column = columnViewer.getColumn();
    column.setText(Messages.name);

    final TableColumnSorter sorter = new TableColumnSorter(viewer);
    sorter.setColumn(column);

    viewer.getTable().setHeaderVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ParameterNameLabelProvider());

    viewer.addPostSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(final SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
              ParameterEditor.this.fireSelectionChanged();
            }
          }
        });
  }
コード例 #9
0
 private TableColumn createColumn(int weight, String name, ViewerSorter asc, ViewerSorter desc) {
   Table table = tv.getTable();
   TableLayout layout = (TableLayout) table.getLayout();
   layout.addColumnData(new ColumnWeightData(weight));
   TableColumn col = new TableColumn(table, SWT.NONE);
   col.setText(name);
   if (asc != null && desc != null)
     col.addSelectionListener(new ViewerSortSelectionListener(tv, asc, desc));
   return col;
 }
コード例 #10
0
ファイル: TargetListViewerPart.java プロジェクト: zhaog/cdt
  @Override
  protected StructuredViewer createStructuredViewer(Composite parent, int style) {
    tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
    Table table = (Table) tableViewer.getControl();
    TableLayout layout = new TableLayout();

    layout.addColumnData(new ColumnWeightData(50));
    TableColumn tc = new TableColumn(table, SWT.NONE, 0);
    tc.setText(MakeUIPlugin.getResourceString("TargetListViewer.lable.target")); // $NON-NLS-1$

    layout.addColumnData(new ColumnWeightData(50));
    tc = new TableColumn(table, SWT.NONE, 1);
    tc.setText(MakeUIPlugin.getResourceString("TargetListViewer.lable.location")); // $NON-NLS-1$

    table.setLayout(layout);
    table.setHeaderVisible(true);

    tableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent e) {
            TargetListViewerPart.this.selectionChanged((IStructuredSelection) e.getSelection());
          }
        });
    tableViewer.setContentProvider(new MakeContentProvider(recursive));
    tableViewer.addFilter(
        new ViewerFilter() {

          @Override
          public boolean select(Viewer viewer, Object parentElement, Object element) {
            return (element instanceof IMakeTarget);
          }
        });
    tableViewer.setLabelProvider(new MakeLabelProvider(fContainer.getProjectRelativePath()));
    tableViewer.setInput(fContainer);

    return tableViewer;
  }
コード例 #11
0
ファイル: RedDeerJUnitTab.java プロジェクト: rawagner/reddeer
  private void setLayout(Table table) {
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 90;
    table.setLayoutData(gd);

    ColumnLayoutData[] layouts = {new ColumnWeightData(150, 150), new ColumnWeightData(120, 120)};

    TableLayout layout = new TableLayout();
    for (int i = 0; i < layouts.length; i++) {
      layout.addColumnData(layouts[i]);
    }
    table.setLayout(layout);
  }
コード例 #12
0
  /** create table columns with checkbox */
  public void createTableColumns() {
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    tableLayout.addColumnData(new ColumnWeightData(10, 150, true));
    TableColumn column = new TableColumn(table, SWT.NONE | SWT.DM_FILL_NONE);

    column.setText(titles[0]);
    column.setAlignment(SWT.LEFT);
    for (int i = 1; i < titles.length; i++) {
      tableLayout.addColumnData(new ColumnWeightData(10, 80, false));
      column = new TableColumn(table, SWT.NONE);
      column.setText(titles[i]);
      column.setAlignment(SWT.CENTER);
    }

    column.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent event) {}

          public void widgetDefaultSelected(SelectionEvent event) {}
        });
  }
コード例 #13
0
  private void createColumns(TreeColumn[] currentColumns, int[] widths) {
    Tree tree = this.viewer.getTree();
    TableLayout layout = new TableLayout();

    TreeViewerColumn column = null;
    layout.addColumnData(new ColumnPixelData(440, true, true));
    column = new TreeViewerColumn(this.viewer, 0);
    column.setLabelProvider(new MarkerColumnLabelProvider());
    column.getColumn().setText("breakpoints");

    this.viewer.getTree().setLayout(layout);
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.layout(true);
  }
コード例 #14
0
  /**
   * DOC klliu Comment method "buildAndLayoutTable".figure 13429 2010-08-03.
   *
   * @param table
   * @return
   */
  private TableViewer buildAndLayoutTable(final Table table) {
    TableViewer tableViewer = new TableViewer(table);

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(50, 75, true));
    layout.addColumnData(new ColumnWeightData(50, 75, true));
    table.setLayout(layout);

    TableColumn nameColumn = new TableColumn(table, SWT.CENTER);
    nameColumn.setText("Parameter Key"); // $NON-NLS-1$
    TableColumn valColumn = new TableColumn(table, SWT.CENTER);
    valColumn.setText("Parameter Value"); // $NON-NLS-1$
    table.setHeaderVisible(true);
    return tableViewer;
  }
コード例 #15
0
  /**
   * Creates the table viewer for a set of constraints. The resulting table viewer will support
   * single selection only.
   *
   * @param parent the parent composite
   * @param columnTitle display the column title
   * @return the table viewer
   */
  static TableViewer createTableViewer(Composite parent, boolean columnTitle) {
    TableViewer tableViewer =
        new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = tableViewer.getTable();
    TableLayout layout = new TableLayout();
    table.setLayout(layout);
    table.setHeaderVisible(columnTitle);
    table.setLinesVisible(true);

    TableColumn objectColumn = new TableColumn(table, SWT.NONE);
    layout.addColumnData(new ColumnWeightData(3, 500, true));
    if (!columnTitle) {
      objectColumn.setText("constraint");
    }
    objectColumn.setResizable(true);
    return tableViewer;
  }
コード例 #16
0
  private void buildTable(Composite composite) {
    table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.V_SCROLL);
    table.setHeaderVisible(true);

    tableViewer = new TableViewer(table);
    tableViewer.setContentProvider(new ListContentProvider());
    tableViewer.setLabelProvider(new TPropertyLabelProvider());

    attachCellEditors(tableViewer, table);

    setColumnToolTip();

    TableColumn[] column = new TableColumn[2];
    column[0] = new TableColumn(table, SWT.NONE);
    column[0].setText(Messages.common_name);

    column[1] = new TableColumn(table, SWT.NONE);
    column[1].setText(Messages.JRPropertyPage_value);

    fillTable(table);
    for (int i = 0, n = column.length; i < n; i++) {
      column[i].pack();
    }

    TableLayout tlayout = new TableLayout();
    tlayout.addColumnData(new ColumnWeightData(50, true));
    tlayout.addColumnData(new ColumnWeightData(50, true));
    table.setLayout(tlayout);
    // Set the help for the elements
    TableHelpListener.setTableHelp(table);

    table.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            if (e.item instanceof TableItem) {
              setMessage(getDescription(((TableItem) e.item)));
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
  }
  private void createDependencyViewer(Composite parent) {
    dependencyViewer =
        new TableViewer(
            parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 80;
    dependencyViewer.getTable().setLayoutData(gd);
    // viewer.setLabelProvider(new TableLabelProvider());
    dependencyViewer.setContentProvider(new TableContentProvider());
    Table table = dependencyViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setFont(parent.getFont());

    String[] columnHeaders = {
      Messages.MavenUserLibraryProviderInstallPanel_GroupId,
      Messages.MavenUserLibraryProviderInstallPanel_ArtifactId,
      Messages.MavenUserLibraryProviderInstallPanel_Version,
      Messages.MavenUserLibraryProviderInstallPanel_Scope,
      Messages.MavenUserLibraryProviderInstallPanel_Type
    };

    for (int i = 0; i < columnHeaders.length; i++) {
      TableViewerColumn column = new TableViewerColumn(dependencyViewer, SWT.NONE);
      column.setLabelProvider(new DependencyColumnLabelProvider(i));
      column.getColumn().setText(columnHeaders[i]);
      column.getColumn().setResizable(true);
      column.getColumn().setMoveable(true);
      column.setEditingSupport(new DependencyEditingSupport(dependencyViewer, i));
    }

    TableLayout layout = new AutoResizeTableLayout(table);
    for (int i = 0; i < dependencyTableColumnLayouts.length; i++) {
      layout.addColumnData(dependencyTableColumnLayouts[i]);
    }

    dependencyViewer.getTable().setLayout(layout);
    dependencyViewer.setInput(dependencies);
    createDependencyButtons(parent);
  }
コード例 #18
0
  public SynchronizedTreeViewer(
      Composite parent,
      int style,
      ModelContentMergeViewer mergeViewer,
      boolean editable,
      boolean isAncestor) {
    super(parent, style);
    this.mergeViewer = mergeViewer;
    this.editable = editable;
    createActions();
    createMenus();
    hookListeners();
    getTree().setHeaderVisible(true);
    getTree().setLinesVisible(true);
    getTree()
        .getVerticalBar()
        .addSelectionListener(
            new SelectionListener() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                if (SWT.getPlatform().equals("gtk")) { // $NON-NLS-1$
                  // for the linux platform do not use setTopItem, simply
                  // set the scroll bar position, this does not work on
                  // windows platoforms
                  for (SynchronizedTreeViewer viewer : synchronizedViewers) {
                    viewer
                        .getTree()
                        .getVerticalBar()
                        .setSelection(((ScrollBar) e.widget).getSelection());
                  }
                  getMergeViewer().refreshCenter();
                  return;
                }
                TreeItem item = getTree().getTopItem();
                for (SynchronizedTreeViewer viewer : synchronizedViewers) {
                  TreeItem matchingItem = getMatchingItem(item.getData(), viewer);
                  if (matchingItem != null) {
                    viewer.getTree().setTopItem(matchingItem);
                  }
                }
                getMergeViewer().refreshCenter();
              }

              @Override
              public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
              }
            });

    // create a root column, and a value column
    final TreeColumn rootColumn = new TreeColumn(getTree(), SWT.LEAD);
    rootColumn.setText("Elements");
    rootColumn.addControlListener(
        new ControlListener() {

          @Override
          public void controlResized(ControlEvent e) {
            if (inSynchronization) {
              return;
            }
            if (e.getSource() instanceof TreeColumn) {
              if (SynchronizedTreeViewer.this
                  != SynchronizedTreeViewer.this.mergeViewer.getLeftViewer()) {
                SynchronizedTreeViewer.this
                    .mergeViewer
                    .getLeftViewer()
                    .synchronizeColumnSize((TreeColumn) e.getSource());
                return;
              }
              SynchronizedTreeViewer.this.synchronizeColumnSize((TreeColumn) e.getSource());
            }
          }

          @Override
          public void controlMoved(ControlEvent e) {
            // do nothing
          }
        });
    TreeViewerColumn viewerColumn = new TreeViewerColumn(this, SWT.LEAD);
    viewerColumn.getColumn().setText("Values");
    initializeEditingSupport(viewerColumn);
    TableLayout layout = new TableLayout();
    if (isAncestor) {
      layout.addColumnData(new ColumnWeightData(24));
      layout.addColumnData(new ColumnWeightData(76));
    } else {
      layout.addColumnData(new ColumnWeightData(50));
      layout.addColumnData(new ColumnWeightData(50));
    }
    getTree().setLayout(layout);
  }
コード例 #19
0
  void createContextPage() {
    contextValues = new Properties();
    Composite composite = new Composite(getContainer(), SWT.NULL);
    composite.setLayout(new FillLayout());
    contextValuesTable = new Table(composite, SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    contextValuesTable.setVisible(true);
    contextValuesTable.setLinesVisible(false);
    contextValuesTable.setHeaderVisible(true);
    contextValuesTable.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            editContextValueButton.setEnabled(true);
            deleteContextValueButton.setEnabled(true);
          }

          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    contextValuesTable.addKeyListener(new ContextValueDeleteKeyListener());
    contextValuesTable.addMouseListener(new EditContextValueButtonListener());

    // create the columns
    TableColumn keyColumn = new TableColumn(contextValuesTable, SWT.LEFT);
    TableColumn valueColumn = new TableColumn(contextValuesTable, SWT.LEFT);
    keyColumn.setText("Name");
    valueColumn.setText("Type");
    ColumnLayoutData keyColumnLayout = new ColumnWeightData(30, false);
    ColumnLayoutData valueColumnLayout = new ColumnWeightData(70, false);

    // set columns in Table layout
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(keyColumnLayout);
    tableLayout.addColumnData(valueColumnLayout);
    contextValuesTable.setLayout(tableLayout);

    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 50;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    contextValuesTable.setLayoutData(data);

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.BEGINNING;
    data.verticalAlignment = GridData.BEGINNING;
    buttonComposite.setLayoutData(data);
    GridLayout gl = new GridLayout(1, true);
    buttonComposite.setLayout(gl);
    buttonComposite.setVisible(true);
    addContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    addContextValueButton.setText("New");
    addContextValueButton.setVisible(true);
    addContextValueButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
    addContextValueButton.addSelectionListener(new AddContextValueButtonListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    addContextValueButton.setLayoutData(data);
    editContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    editContextValueButton.setText("Edit");
    editContextValueButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
    editContextValueButton.addSelectionListener(new EditContextValueButtonListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    editContextValueButton.setLayoutData(data);
    deleteContextValueButton = new Button(buttonComposite, SWT.NATIVE);
    deleteContextValueButton.setText("Delete");
    deleteContextValueButton.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
    deleteContextValueButton.addSelectionListener(new ContextValueDeleteKeyListener());
    data = new GridData();
    data.widthHint = 45;
    data.grabExcessHorizontalSpace = true;
    deleteContextValueButton.setLayoutData(data);

    reloadContextValues();
    int index = addPage(composite);
    setPageText(index, "Context");
  }
コード例 #20
0
  /**
   * This is the method used by the framework to install your own controls.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void createPages() {
    // Creates the model from the editor input
    //
    createModel();

    // Create a page for the selection tree view.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              Tree tree = new Tree(composite, SWT.MULTI);
              TreeViewer newTreeViewer = new TreeViewer(tree);
              return newTreeViewer;
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      selectionViewer = (TreeViewer) viewerPane.getViewer();
      selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));

      selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
      selectionViewer.setInput(editingDomain.getResourceSet());
      viewerPane.setTitle(editingDomain.getResourceSet());

      new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);

      createContextMenuFor(selectionViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_SelectionPage_label"));
    }

    // Create a page for the parent tree view.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              Tree tree = new Tree(composite, SWT.MULTI);
              TreeViewer newTreeViewer = new TreeViewer(tree);
              return newTreeViewer;
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      parentViewer = (TreeViewer) viewerPane.getViewer();
      parentViewer.setAutoExpandLevel(30);
      parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
      parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(parentViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_ParentPage_label"));
    }

    // This is the page for the list viewer
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new ListViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      listViewer = (ListViewer) viewerPane.getViewer();
      listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(listViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_ListPage_label"));
    }

    // This is the page for the tree viewer
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TreeViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      treeViewer = (TreeViewer) viewerPane.getViewer();
      treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);

      createContextMenuFor(treeViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TreePage_label"));
    }

    // This is the page for the table viewer.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TableViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());
      tableViewer = (TableViewer) viewerPane.getViewer();

      Table table = tableViewer.getTable();
      TableLayout layout = new TableLayout();
      table.setLayout(layout);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);

      TableColumn objectColumn = new TableColumn(table, SWT.NONE);
      layout.addColumnData(new ColumnWeightData(3, 100, true));
      objectColumn.setText(getString("_UI_ObjectColumn_label"));
      objectColumn.setResizable(true);

      TableColumn selfColumn = new TableColumn(table, SWT.NONE);
      layout.addColumnData(new ColumnWeightData(2, 100, true));
      selfColumn.setText(getString("_UI_SelfColumn_label"));
      selfColumn.setResizable(true);

      tableViewer.setColumnProperties(new String[] {"a", "b"});
      tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(tableViewer);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TablePage_label"));
    }

    // This is the page for the table tree viewer.
    //
    {
      ViewerPane viewerPane =
          new ViewerPane(getSite().getPage(), ProvervisualEditor.this) {
            public Viewer createViewer(Composite composite) {
              return new TreeViewer(composite);
            }

            public void requestActivation() {
              super.requestActivation();
              setCurrentViewerPane(this);
            }
          };
      viewerPane.createControl(getContainer());

      treeViewerWithColumns = (TreeViewer) viewerPane.getViewer();

      Tree tree = treeViewerWithColumns.getTree();
      tree.setLayoutData(new FillLayout());
      tree.setHeaderVisible(true);
      tree.setLinesVisible(true);

      TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
      objectColumn.setText(getString("_UI_ObjectColumn_label"));
      objectColumn.setResizable(true);
      objectColumn.setWidth(250);

      TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
      selfColumn.setText(getString("_UI_SelfColumn_label"));
      selfColumn.setResizable(true);
      selfColumn.setWidth(200);

      treeViewerWithColumns.setColumnProperties(new String[] {"a", "b"});
      treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
      treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

      createContextMenuFor(treeViewerWithColumns);
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
    }

    setActivePage(0);

    getContainer()
        .addControlListener(
            new ControlAdapter() {
              boolean guard = false;

              public void controlResized(ControlEvent event) {
                if (!guard) {
                  guard = true;
                  hideTabs();
                  guard = false;
                }
              }
            });
  }
コード例 #21
0
ファイル: ResourceEditDialog.java プロジェクト: lukehan/birt
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
   * .Composite)
   */
  protected Control createDialogArea(Composite parent) {
    UIUtil.bindHelp(parent, IHelpContextIds.RESOURCE_EDIT_DIALOG_ID);
    loadMessage();

    final Composite innerParent = (Composite) super.createDialogArea(parent);

    final Table table = new Table(innerParent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 450;
    data.heightHint = 200;
    table.setLayoutData(data);

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.getString("ResourceEditDialog.text.Key.TableColumn")); // $NON-NLS-1$
    column1.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            table.setSortColumn(column1);
            viewer.setSorter(new ResourceSorter(table.getSortDirection() == SWT.UP, false));
            table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP);
          }
        });

    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.getString("ResourceEditDialog.text.Value.TableColumn")); // $NON-NLS-1$
    column2.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            table.setSortColumn(column2);
            viewer.setSorter(new ResourceSorter(table.getSortDirection() == SWT.UP, true));
            table.setSortDirection(table.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP);
          }
        });

    viewer = new TableViewer(table);
    viewer.setContentProvider(
        new IStructuredContentProvider() {

          public Object[] getElements(Object inputElement) {
            if (inputElement instanceof List) {
              List list = (List) inputElement;
              List availableList = new ArrayList();
              for (int i = 0; i < list.size(); i++) {
                GlobalProperty property = (GlobalProperty) list.get(i);
                if (!property.isDeleted) availableList.add(property);
              }
              return availableList.toArray();
            }

            return new Object[0];
          }

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          public void dispose() {}
        });
    viewer.setLabelProvider(new PropertyLabelProvider());

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {
            updateSelection();
          }
        });

    TableLayout layout = new AutoResizeTableLayout(viewer.getTable());
    layout.addColumnData(new ColumnWeightData(50, true));
    layout.addColumnData(new ColumnWeightData(50, true));
    viewer.getTable().setLayout(layout);

    // table.setSortColumn( column1 );
    // table.setSortDirection( SWT.UP );
    // viewer.setSorter( new ResourceSorter( false, false ) );

    Group gp = new Group(innerParent, SWT.NONE);
    gp.setText(Messages.getString("ResourceEditDialog.text.QuickAdd")); // $NON-NLS-1$
    gp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    gp.setLayout(new GridLayout(6, false));

    Label lb = new Label(gp, 0);
    lb.setText(Messages.getString("ResourceEditDialog.text.Key")); // $NON-NLS-1$

    keyText = new Text(gp, SWT.BORDER | SWT.SINGLE);
    keyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    lb = new Label(gp, 0);
    lb.setText(Messages.getString("ResourceEditDialog.text.Value")); // $NON-NLS-1$

    // lb = new Label( gp, 0 );
    // lb = new Label( gp, 0 );
    valueText = new Text(gp, SWT.BORDER | SWT.SINGLE);
    valueText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    btnAdd = new Button(gp, SWT.PUSH);
    btnAdd.setText(Messages.getString("ResourceEditDialog.text.Add")); // $NON-NLS-1$
    btnAdd.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            addSelection();
          }
        });
    btnAdd.setEnabled(isFileSystemFile());

    btnDelete = new Button(gp, SWT.PUSH);
    btnDelete.setText(Messages.getString("ResourceEditDialog.text.Delete")); // $NON-NLS-1$
    btnDelete.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            deleteSelection();
          }
        });

    lb = new Label(innerParent, 0);
    lb.setText(Messages.getString("ResourceEditDialog.message.AddNote")); // $NON-NLS-1$
    lb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    viewer.setInput(globalLinkedProperties);

    return innerParent;
  }
コード例 #22
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    context = new EMFDataBindingContext();

    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(
        GridLayoutFactory.fillDefaults().numColumns(1).margins(15, 15).create());

    final Text searchText =
        new Text(mainComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchText.setMessage(Messages.search);
    searchText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final CheckboxTableViewer languageViewer =
        CheckboxTableViewer.newCheckList(
            mainComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL);
    languageViewer
        .getTable()
        .setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 190).create());
    languageViewer.getTable().setLinesVisible(true);
    languageViewer.getTable().setHeaderVisible(true);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(65));
    layout.addColumnData(new ColumnWeightData(35));
    languageViewer.getTable().setLayout(layout);
    languageViewer.setContentProvider(new ArrayContentProvider());
    languageViewer.setLabelProvider(new LocaleLabelProvider());

    searchFilter =
        new ViewerFilter() {

          @Override
          public boolean select(Viewer arg0, Object arg1, Object element) {
            if (!searchText.getText().isEmpty()) {
              String searchQuery = searchText.getText().toLowerCase();
              Locale locale = (Locale) element;
              return locale.toString().toLowerCase().contains(searchQuery)
                  || locale.getDisplayName().toLowerCase().contains(searchQuery);
            }
            return true;
          }
        };
    languageViewer.addFilter(searchFilter);
    languageViewer.setInput(Locale.getAvailableLocales());
    languageViewer.getTable().setFocus();

    TableViewerColumn countryNameColumn = new TableViewerColumn(languageViewer, SWT.FILL);
    countryNameColumn.setLabelProvider(new LocaleLabelProvider());
    countryNameColumn.getColumn().setText(Messages.countryName);

    TableViewerColumn localeCodeNameColumn = new TableViewerColumn(languageViewer, SWT.FILL);
    localeCodeNameColumn.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((Locale) element).toString();
          }
        });

    localeCodeNameColumn.getColumn().setText(Messages.locale);

    new TableColumnSorter(languageViewer).setColumn(countryNameColumn.getColumn());

    context.bindSet(
        ViewersObservables.observeCheckedElements(languageViewer, Locale.class),
        PojoObservables.observeSet(this, "selectedLocales"));

    searchText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(ModifyEvent e) {
            languageViewer.refresh();
          }
        });

    pageSupport = WizardPageSupport.create(this, context);
    setControl(mainComposite);
  }
コード例 #23
0
  /** @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;
  }
コード例 #24
0
  /** @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */
  @Override
  protected Control createDialogArea(Composite parent) {

    Composite composite = (Composite) super.createDialogArea(parent);

    composite.getShell().setText(UMLMessage.LABEL_ADD_COVERED_LIFELINE);

    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 1;

    Table table =
        new Table(
            composite, SWT.BORDER | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL | SWT.HIDE_SELECTION);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setMoveable(false);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnWeightData(100));
    table.setLayout(tableLayout);
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.widthHint = 300;
    gd.heightHint = 200;
    table.setLayoutData(gd);

    lifelineTableViwer = new CheckboxTableViewer(table);
    lifelineTableViwer.setContentProvider(new CoveredLifelineContentProvider());
    lifelineTableViwer.setLabelProvider(new CoveredLifelineLabelProvider());

    lifelineTableViwer.setInput(lifelineList);
    lifelineTableViwer.setAllChecked(isSelectAll);

    Composite buttonComposit = new Composite(composite, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    buttonComposit.setLayout(gridLayout);
    buttonComposit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    checkAllButton = new Button(buttonComposit, SWT.NONE);
    checkAllButton.setText(UMLMessage.LABEL_SELECT_ALL);
    checkAllButton.addSelectionListener(
        new SelectionListener() {
          /**
           * @see
           *     org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            lifelineTableViwer.setAllChecked(true);
          }

          /**
           * @see
           *     org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    unCheckAllButton = new Button(buttonComposit, SWT.NONE);
    unCheckAllButton.setText(UMLMessage.LABEL_UNSELECT_ALL);
    unCheckAllButton.addSelectionListener(
        new SelectionListener() {
          /**
           * @see
           *     org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetSelected(SelectionEvent e) {
            lifelineTableViwer.setAllChecked(false);
          }

          /**
           * @see
           *     org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
           */
          public void widgetDefaultSelected(SelectionEvent e) {}
        });

    return composite;
  }
コード例 #25
0
  public Control createContent(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    UIUtil.createLabel(composite, "Service Class");

    srvName = new Text(composite, SWT.BORDER);
    srvName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    if (res.isSupported(Feature.DATASOURCENAME)) {
      UIUtil.createLabel(composite, "Data Source Name");

      final Text dsName = new Text(composite, SWT.BORDER);
      dsName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    Composite cmp = new Composite(composite, SWT.NONE);
    cmp.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    cmp.setLayoutData(gd);

    Table wtable = new Table(cmp, SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 100;
    wtable.setLayoutData(gd);
    wtable.setHeaderVisible(true);
    wtable.setLinesVisible(true);

    TableColumn[] col = new TableColumn[2];
    col[0] = new TableColumn(wtable, SWT.NONE);
    col[0].setText(com.jaspersoft.studio.messages.Messages.common_name);

    col[1] = new TableColumn(wtable, SWT.NONE);
    col[1].setText(
        com.jaspersoft.studio.messages.Messages.DefaultDataAdapterEditorComposite_valueLabel);

    for (TableColumn tc : col) tc.pack();

    TableLayout tlayout = new TableLayout();
    tlayout.addColumnData(new ColumnWeightData(50, false));
    tlayout.addColumnData(new ColumnWeightData(50, false));
    wtable.setLayout(tlayout);

    tviewer = new TableViewer(wtable);
    tviewer.setContentProvider(new ListContentProvider());
    tviewer.setLabelProvider(new TLabelProvider());
    attachCellEditors(tviewer, wtable);
    UIUtil.setViewerCellEditingOnDblClick(tviewer);

    Composite bGroup = new Composite(cmp, SWT.NONE);
    bGroup.setLayout(new GridLayout(1, false));
    bGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    final ResourceDescriptor rd = res.getValue();
    new NewButton() {
      @Override
      protected void afterElementAdded(Object selement) {
        rd.setResourceProperty((ResourceProperty) selement);
      }
    }.createNewButtons(
        bGroup,
        tviewer,
        new INewElement() {

          public Object newElement(List<?> input, int pos) {
            return new ResourceProperty("name", "value");
          }
        });
    final DeleteButton delb =
        new DeleteButton() {
          @Override
          protected void afterElementDeleted(Object element) {
            rd.removeResourceProperty(((ResourceProperty) element).getName());
          }
        };
    delb.createDeleteButton(bGroup, tviewer);

    ResourceProperty rp = rd.getProperty(ResourceDescriptor.PROP_DATASOURCE_CUSTOM_PROPERTY_MAP);
    if (rp == null) {
      rp = new ResourceProperty(ResourceDescriptor.PROP_DATASOURCE_CUSTOM_PROPERTY_MAP);
      rp.setProperties(new ArrayList<ResourceProperty>());
      rd.setResourceProperty(rp);
    }
    rebind();
    tviewer.setInput(rp.getProperties());
    return composite;
  }
コード例 #26
0
  /**
   * @brief constructor
   * @param name
   * @param manager
   * @param vp
   * @param parent
   */
  public GrxPropertyView(
      String name, GrxPluginManager manager, GrxBaseViewPart vp, Composite parent) {

    super(name, manager, vp, parent);

    GrxDebugUtil.println("GrxPropertyView init"); // $NON-NLS-1$

    GridLayout gl = new GridLayout(1, false);
    composite_.setLayout(gl);

    nameText_ = new Text(composite_, SWT.SINGLE | SWT.BORDER);
    GridData textGridData = new GridData(GridData.FILL_HORIZONTAL);
    textGridData.heightHint = 20;
    nameText_.setLayoutData(textGridData);

    final GrxPropertyView view = this;
    nameText_.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            if (e.character == SWT.CR && !nameText_.getText().equals(oldText)) {
              GrxBasePlugin p = null;
              if ((p = manager_.getView(nameText_.getText(), true)) != null) {
                if (currentPlugin_ != p) {
                  if (currentPlugin_ != null) currentPlugin_.deleteObserver(view);
                  _setInput(p);
                  currentPlugin_ = p;
                  currentPlugin_.addObserver(view);
                }
              } else if ((p = manager_.getItem(nameText_.getText())) != null) {
                manager_.focusedItem((GrxBaseItem) p);
              } else {
                nameText_.setText(""); // $NON-NLS-1$
                if (currentPlugin_ != null) currentPlugin_.deleteObserver(view);
                _setInput(null);
                currentPlugin_ = null;
              }
            }
          }
        });

    viewer_ =
        new TableViewer(composite_, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(40, true));
    layout.addColumnData(new ColumnWeightData(60, true));
    table_ = viewer_.getTable();
    table_.setLayout(layout);
    GridData tableGridData = new GridData(GridData.FILL_BOTH);
    table_.setLayoutData(tableGridData);

    TableColumn column1 = new TableColumn(table_, SWT.LEFT);
    TableColumn column2 = new TableColumn(table_, SWT.LEFT);
    column1.setText(clmName_[0]);
    column2.setText(clmName_[1]);
    column1.setMoveable(true);
    column2.setMoveable(true);
    column1.addSelectionListener(new ColumnSelectionListener());
    column2.addSelectionListener(new ColumnSelectionListener());

    viewer_.setColumnProperties(clmName_);

    viewer_.setContentProvider(new PropertyTableContentProvider());
    viewer_.setLabelProvider(new PropertyTableLabelProvider());
    CellEditor[] editors =
        new CellEditor[] {new TextCellEditor(table_), new TextCellEditor(table_)};
    viewer_.setCellEditors(editors);
    viewer_.setCellModifier(new PropertyTableCellModifier());
    viewer_.setSorter(new PropertyTableViewerSorter());

    table_.setLinesVisible(true);
    table_.setHeaderVisible(true);

    setScrollMinSize(SWT.DEFAULT, SWT.DEFAULT);

    setUp();
    manager_.registerItemChangeListener(this, GrxBaseItem.class);

    //      右クリックメニュー
    table_.setMenu(menuMgr_.createContextMenu(table_));
    table_.addListener(
        SWT.MenuDetect,
        new Listener() {
          public void handleEvent(Event event) {
            final TableItem[] selection = table_.getSelection();
            menuMgr_.removeAll();
            if (selection.length != 0)
              menuMgr_.add(
                  new Action() {
                    public String getText() {
                      return MessageBundle.get("GrxPropertyView.menu.InputValue");
                    }

                    public void run() {
                      InputDialog dialog =
                          new InputDialog(
                              null,
                              getText(),
                              MessageBundle.get("GrxPropertyView.dialog.message.input"),
                              "",
                              null); //$NON-NLS-1$
                      if (dialog.open() == InputDialog.OK && dialog.getValue() != null) {
                        String _value = dialog.getValue();
                        String[] _key = new String[selection.length];
                        for (int i = 0;
                            i < selection.length;
                            i++) { // value を変更するとソートがかかってselectionが変わってしまうので、まずkeyを保存
                          _key[i] = selection[i].getText(0);
                        }
                        for (int i = 0; i < _key.length; i++) {
                          if (isValidChangeValue(_key[i], _value) == false) continue;

                          if (!currentPlugin_.getProperty(_key[i]).equals(_value)) {
                            if (!currentPlugin_.propertyChanged(_key[i], _value)) {
                              currentPlugin_.setProperty(_key[i], _value);
                            }
                          }
                        }
                      }
                    }
                  });
          }
        });

    updateTableFont();
  }
コード例 #27
0
  @Override
  public void createEditorContents(Composite parent) {
    List<INodeInfo> selectedNodeInfos = null;
    if (outlinePage != null) {
      selectedNodeInfos = ((ArchEditOutlinePage) outlinePage).getSelectedNodeInfos();
    }

    if (selectedNodeInfos == null || selectedNodeInfos.size() == 0) {
      Label lNothingSelected = new Label(parent, SWT.LEFT);
      lNothingSelected.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
      lNothingSelected.setFont(resources.getPlatformFont(IResources.PLATFORM_DEFAULT_FONT_ID));
      lNothingSelected.setText("Select one or more elements in the outline view.");
    } else {
      for (INodeInfo selectedNodeInfo : selectedNodeInfos) {
        Label lElement = new Label(parent, SWT.LEFT);
        lElement.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
        lElement.setFont(resources.getPlatformFont(IResources.PLATFORM_HEADER_FONT_ID));

        if (selectedNodeInfo instanceof IReferenceNodeInfo) {
          IReferenceNodeInfo referenceNodeInfo = (IReferenceNodeInfo) selectedNodeInfo;
          String headerLine = "Link: " + referenceNodeInfo.getFeatureName();
          lElement.setText(headerLine.toString());
          createDragSourceComposite(parent, referenceNodeInfo);
        } else if (selectedNodeInfo instanceof IElementNodeInfo) {
          ObjRef selectedRef = ((IElementNodeInfo) selectedNodeInfo).getRef();

          IXArchADTTypeMetadata typeMetadata = xarch.getTypeMetadata(selectedRef);
          StringBuffer headerLine = new StringBuffer();
          headerLine.append(XadlUtils.getDisplayName(xarch, selectedRef));
          headerLine.append(": ");
          headerLine.append(typeMetadata.getTypeName());
          lElement.setText(headerLine.toString());

          boolean hasAttribute = false;
          for (IXArchADTFeature feature : typeMetadata.getFeatures().values()) {
            if (feature.getType().equals(IXArchADTFeature.FeatureType.ATTRIBUTE)) {
              hasAttribute = true;
              break;
            }
          }

          if (!hasAttribute) {
            // No attributes.
            Label lNoAttributes = new Label(parent, SWT.LEFT);
            lNoAttributes.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            lNoAttributes.setFont(resources.getPlatformFont(IResources.PLATFORM_DEFAULT_FONT_ID));
            lNoAttributes.setText("This element has no attributes.");
          } else {
            TableViewer tv =
                new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.NO_FOCUS);
            tv.setContentProvider(new ViewContentProvider());
            tv.setLabelProvider(new ViewLabelProvider());
            tv.setInput(selectedRef);

            Table table = tv.getTable();

            TableColumn column = new TableColumn(table, SWT.LEFT);
            column.setText(COLUMN_NAMES[0]);

            TableColumn column2 = new TableColumn(table, SWT.LEFT);
            column2.setText(COLUMN_NAMES[1]);

            TableLayout tableLayout = new AutoResizeTableLayout(table);
            tableLayout.addColumnData(new ColumnWeightData(30, true));
            tableLayout.addColumnData(new ColumnWeightData(70, true));
            table.setLayout(tableLayout);

            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            table.setLayoutData(
                new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));

            tv.setColumnProperties(COLUMN_NAMES);
            CellEditor tce = new TextCellEditor(table);
            tv.setCellEditors(new CellEditor[] {null, tce});
            tv.setCellModifier(new ViewCellModifier(selectedRef));

            tv.refresh();
          }
        }
      }
    }
  }