Java Code Examples for org.eclipse.swt.widgets.TableColumn#pack()

The following examples show how to use org.eclipse.swt.widgets.TableColumn#pack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloneDiffTooltip.java    From JDeodorant with MIT License 6 votes vote down vote up
protected void packAndFillLastColumn(Table table) {
    int columnsWidth = 0;
    for (int i = 0; i < table.getColumnCount() - 1; i++) {
        columnsWidth += table.getColumn(i).getWidth();
    }
    TableColumn lastColumn = table.getColumn(table.getColumnCount() - 1);
    lastColumn.pack();

    Rectangle area = table.getClientArea();

    Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int width = area.width - 2*table.getBorderWidth();

    if (preferredSize.y > area.height + table.getHeaderHeight()) {
        // Subtract the scrollbar width from the total column width
        // if a vertical scrollbar will be required
        Point vBarSize = table.getVerticalBar().getSize();
        width -= vBarSize.x;
    }

    // last column is packed, so that is the minimum. If more space is available, add it.
    if(lastColumn.getWidth() < width - columnsWidth) {
        lastColumn.setWidth(width - columnsWidth + 4);
    }
}
 
Example 2
Source File: BuyOrderTableViewer.java    From offspring with MIT License 6 votes vote down vote up
public BuyOrderTableViewer(Composite parent, UISynchronize sync) {
  super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION
      | SWT.BORDER);

  this.contentProvider = new BuyOrderContentProvider(sync);
  this.comparator = new BuyOrderComparator();

  setUseHashlookup(false);
  setContentProvider(contentProvider);
  setComparator(comparator);

  createColumns();

  /* Pack the columns */
  for (TableColumn column : getTable().getColumns())
    column.pack();

  Table table = getTable();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
}
 
Example 3
Source File: ViewRisksOverview.java    From arx with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createControl(Composite parent) {
    
    this.root = new Composite(parent, SWT.NONE);
    this.root.setLayout(SWTUtil.createGridLayout(1));
    
    table = SWTUtil.createTableDynamic(root, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setMenu(new ClipboardHandlerTable(table).getMenu());
    table.setLayoutData(SWTUtil.createFillGridData());

    DynamicTableColumn c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("50%", "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("RiskAnalysis.6")); //$NON-NLS-1$
    c = new DynamicTableColumn(table, SWT.LEFT);
    SWTUtil.createColumnWithBarCharts(table, c);
    c.setWidth("50%", "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("RiskAnalysis.7")); //$NON-NLS-1$
    for (final TableColumn col : table.getColumns()) {
        col.pack();
    }
    SWTUtil.createGenericTooltip(table);
    return root;
}
 
Example 4
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void packSingleColumn(int i, final TableColumn column) {
    if (i != MARGIN_COLUMN_INDEX && !column.getResizable()) {
        return;
    }
    int minWidth = column.getWidth();
    fPacking = true;
    column.pack();
    /*
     * Workaround for Linux which doesn't consider the image width of
     * search/filter row in TableColumn.pack() after having executed
     * TableItem.setImage(null) for other rows than search/filter row.
     */
    if (IS_LINUX && (i == MARGIN_COLUMN_INDEX) && fCollapseFilterEnabled) {
        column.setWidth(column.getWidth() + SEARCH_IMAGE.getBounds().width);
    }

    if (column.getWidth() < minWidth) {
        column.setWidth(minWidth);
    }
    fPacking = false;
}
 
Example 5
Source File: SWTTable.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void adjustColumnWidth(TableColumn column) {
	int minimumWidth = 0;
	
	String headerText = column.getText();
	if( headerText != null && headerText.length() > 0 ) {
		GC gc = new GC(this.getControl());
		minimumWidth = (gc.stringExtent(headerText).x + (TABLE_COLUMN_MARGIN * 2));
		gc.dispose();
	}
	
	column.pack();
	if( column.getWidth() < minimumWidth ) {
		column.setWidth(minimumWidth);
	}
	
}
 
Example 6
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private IAction createAutoFitAction(TableColumn column) {
    final IAction autoFitAction = new Action(Messages.TmfEventsTable_AutoFit, IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            boolean isChecked = isChecked();
            int index = (int) column.getData(Key.INDEX);
            if (isChecked) {
                fPacking = true;
                column.pack();
                fPacking = false;
                column.setData(Key.WIDTH, SWT.DEFAULT);
                fColumnSize[index] = SWT.DEFAULT;
            } else {
                fColumnSize[index] = column.getWidth();
                column.setData(Key.WIDTH, fColumnSize[index]);
            }
        }
    };
    autoFitAction.setChecked(Objects.equals(column.getData(Key.WIDTH), SWT.DEFAULT));
    return autoFitAction;
}
 
Example 7
Source File: ViewStatisticsSummaryTable.java    From arx with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createControl(Composite parent) {

    this.root = new Composite(parent, SWT.NONE);
    this.root.setLayout(new FillLayout());
    this.table = SWTUtil.createTableDynamic(root, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    this.table.setHeaderVisible(true);
    this.table.setLinesVisible(true);
    this.table.setMenu(new ClipboardHandlerTable(table).getMenu());

    DynamicTableColumn c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("50%", "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("SummaryStatistics.0")); //$NON-NLS-1$
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("50%", "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("SummaryStatistics.1")); //$NON-NLS-1$
    for (final TableColumn col : table.getColumns()) {
        col.pack();
    }
    
    SWTUtil.createGenericTooltip(table);
    return root;
}
 
Example 8
Source File: KeyAssistDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a dialog area with a table of the partial matches for the current
 * key binding state. The table will be either the minimum width, or
 * <code>previousWidth</code> if it is not
 * <code>NO_REMEMBERED_WIDTH</code>.
 * 
 * @param parent
 *            The parent composite for the dialog area; must not be
 *            <code>null</code>.
 * @param partialMatches
 *            The lexicographically sorted map of partial matches for the
 *            current state; must not be <code>null</code> or empty.
 */
private final void createTableDialogArea(final Composite parent) {
    // Layout the table.
    completionsTable = new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE);
    final GridData gridData = new GridData(GridData.FILL_BOTH);
    completionsTable.setLayoutData(gridData);
    completionsTable.setBackground(parent.getBackground());
    completionsTable.setLinesVisible(true);

    // Initialize the columns and rows.
    bindings.clear();
    final TableColumn columnCommandName = new TableColumn(completionsTable, SWT.LEFT, 0);
    final TableColumn columnKeySequence = new TableColumn(completionsTable, SWT.LEFT, 1);
    final Iterator itemsItr = keybindingToActionInfo.entrySet().iterator();
    while (itemsItr.hasNext()) {
        final Map.Entry entry = (Entry) itemsItr.next();
        final String sequence = (String) entry.getKey();
        final ActionInfo actionInfo = (ActionInfo) entry.getValue();
        final String[] text = { sequence, actionInfo.description };
        final TableItem item = new TableItem(completionsTable, SWT.NULL);
        item.setText(text);
        item.setData("ACTION_INFO", actionInfo);
        bindings.add(actionInfo);
    }

    Dialog.applyDialogFont(parent);
    columnKeySequence.pack();
    columnCommandName.pack();

    /*
     * If you double-click on the table, it should execute the selected
     * command.
     */
    completionsTable.addListener(SWT.DefaultSelection, new Listener() {
        @Override
        public final void handleEvent(final Event event) {
            executeKeyBinding(event);
        }
    });
}
 
Example 9
Source File: SinkView.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
private void createColumns() {
    TableLayout layout = new TableLayout();
    getTable().setLayout(layout);
    getTable().setHeaderVisible(true);
    for (int i = 0; i < columnHeaders.length; i++) {
        layout.addColumnData(columnLayouts[i]);
        TableColumn tc = new TableColumn(getTable(), SWT.BORDER, i);
        tc.setResizable(columnLayouts[i].resizable);
        tc.setText(columnHeaders[i]);
        tc.pack();
        final int j = i;
        tc.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                ViewerSorter oldSorter = viewer.getSorter();
                if (oldSorter instanceof ColumnBasedSorter) {
                    ColumnBasedSorter sorter = (ColumnBasedSorter) oldSorter;
                    if (sorter.getColumn() == j) {
                        sorter.toggle();
                        viewer.refresh();
                        // System.err.println("Resorting column " + j +
                        // " in order "
                        // + sorter.getOrientation());
                        return;
                    }
                }
                viewer.setSorter(new ColumnBasedSorter(j));
                logError("Sorting column " + j + " in order " + 1);
                viewer.refresh();
            }
        });
    }
}
 
Example 10
Source File: ICETableComponentSectionPart.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Packs all columns in the {@link #tableComponentViewer}. This can be used
 * to resize each column to fit the maximum width of its content.
 */
private void packTableColumns() {

	if (tableComponentViewer != null) {
		Table table = tableComponentViewer.getTable();
		for (TableColumn column : table.getColumns()) {
			column.pack();
		}
	}

	return;
}
 
Example 11
Source File: ViewStatisticsEquivalenceClassTable.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected Control createControl(Composite parent) {

    // Table
    this.root = new Composite(parent, SWT.NONE);
    this.root.setLayout(new FillLayout());
    this.table = SWTUtil.createTableDynamic(root, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    this.table.setHeaderVisible(true);
    this.table.setLinesVisible(true);
    this.table.setMenu(new ClipboardHandlerTable(table).getMenu());

    // Columns
    String size = "33%";
    DynamicTableColumn c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth(size, "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("EquivalenceClassStatistics.1")); //$NON-NLS-1$
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth(size, "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("EquivalenceClassStatistics.2")); //$NON-NLS-1$
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth(size, "100px"); //$NON-NLS-1$ //$NON-NLS-2$
    c.setText(Resources.getMessage("EquivalenceClassStatistics.3")); //$NON-NLS-1$
    
    // Layout
    for (final TableColumn col : table.getColumns()) {
        col.pack();
    }
    SWTUtil.createGenericTooltip(table);
    return root;
}
 
Example 12
Source File: RuntimeInfoDialog.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
    shell = new Shell(getParent(), getStyle());
    shell.setSize(650, 500);
    shell.setText(RunContainerMessages.getString("RuntimeInfoDialog.Title")); //$NON-NLS-1$
    shell.setLayout(new GridLayout(1, false));

    Composite parent = new Composite(shell, SWT.NONE);
    parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

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

    TableColumn tblName = new TableColumn(table, SWT.NONE);
    tblName.setText(RunContainerMessages.getString("RuntimeInfoDialog.Name")); //$NON-NLS-1$
    TableColumn tblValue = new TableColumn(table, SWT.NONE);
    tblValue.setText(RunContainerMessages.getString("RuntimeInfoDialog.Value")); //$NON-NLS-1$
    // TableColumn tblDesc = new TableColumn(table, SWT.NONE);
    // tblDesc.setText("Type");

    for (Map<String, String> attr : attrInfo) {
        TableItem tableItem = new TableItem(table, SWT.NONE);
        tableItem.setText(new String[] { attr.get("name"), attr.get("value") }); //$NON-NLS-1$ //$NON-NLS-2$
    }

    tblName.pack();
    tblName.setWidth(tblName.getWidth() + 50);
    tblValue.pack();
    // tblDesc.pack();
}
 
Example 13
Source File: ViewRisksHIPAAIdentifiersTable.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected Control createControl(Composite parent) {
    
    this.root = new Composite(parent, SWT.NONE);
    this.root.setLayout(new FillLayout());
    
    table = SWTUtil.createTableDynamic(root, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setMenu(new ClipboardHandlerTable(table).getMenu());
    
    DynamicTableColumn c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("20%%"); //$NON-NLS-1$
    c.setText(Resources.getMessage("RiskAnalysis.27")); //$NON-NLS-1$
    c.setResizable(true);
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("20%"); //$NON-NLS-1$
    c.setText(Resources.getMessage("RiskAnalysis.28")); //$NON-NLS-1$
    c.setResizable(true);
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("20%%"); //$NON-NLS-1$
    c.setText(Resources.getMessage("RiskAnalysis.31")); //$NON-NLS-1$
    c.setResizable(true);
    c = new DynamicTableColumn(table, SWT.LEFT);
    c.setWidth("20%"); //$NON-NLS-1$
    c.setText(Resources.getMessage("RiskAnalysis.29")); //$NON-NLS-1$
    c.setResizable(true);
    c = new DynamicTableColumn(table, SWT.LEFT);
    SWTUtil.createColumnWithBarCharts(table, c);
    c.setWidth("20%"); //$NON-NLS-1$
    c.setText(Resources.getMessage("RiskAnalysis.30")); //$NON-NLS-1$
    c.setResizable(true);
    for (final TableColumn col : table.getColumns()) {
        col.pack();
    }
    SWTUtil.createGenericTooltip(table);
    return root;
}
 
Example 14
Source File: TestDataManageDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void createRightComposite(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.BORDER);

    final GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    composite.setLayoutData(gridData);

    final GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 8;
    composite.setLayout(gridLayout);

    final GridData tableGridData = new GridData();
    tableGridData.heightHint = GROUP_LIST_HEIGHT;
    tableGridData.verticalIndent = 15;

    testDataTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    testDataTable.setHeaderVisible(true);
    testDataTable.setLayoutData(tableGridData);
    testDataTable.setLinesVisible(true);

    final TableColumn nameColumn = new TableColumn(testDataTable, SWT.NONE);
    nameColumn.setWidth(300);
    nameColumn.setResizable(false);
    nameColumn.setText(ResourceString.getResourceString("label.testdata.table.name"));

    final TableColumn dataNumColumn = new TableColumn(testDataTable, SWT.RIGHT);
    dataNumColumn.setResizable(false);
    dataNumColumn.setText(ResourceString.getResourceString("label.testdata.table.test.num"));
    dataNumColumn.pack();
}
 
Example 15
Source File: TableEditorEx.java    From SWET with MIT License 4 votes vote down vote up
public static void packTable(Table table) {
	for (TableColumn tc : table.getColumns()) {
		tc.pack();
	}
}
 
Example 16
Source File: YAMLSchemaPreferencePage.java    From wildwebdeveloper with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
	GridLayout layout = new GridLayout(1, false);
	parent.setLayout(layout);
	
	Label schemaLabel = new Label(parent, SWT.NONE);
	schemaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	schemaLabel.setText("Edit yaml.schemas");
	
	schemaTable = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
	schemaTable.setHeaderVisible(true);
	schemaTable.setLinesVisible(true);
	schemaTable.setLayoutData(new GridData(GridData.FILL_BOTH));
	
	TableColumn schemaCol = new TableColumn(schemaTable, SWT.NONE);
	schemaCol.setText("Schema");
	
	TableColumn globPatternCol = new TableColumn(schemaTable, SWT.NONE);
	globPatternCol.setText("Glob Pattern");
	
	String schemaStr = store.getString(YAMLPreferenceInitializer.YAML_SCHEMA_PREFERENCE);
	Map<String, String> schemas = new Gson().fromJson(schemaStr, new TypeToken<HashMap<String, String>>() {}.getType());
	for (String s : schemas.keySet()) {
		TableItem item = new TableItem(schemaTable, SWT.NONE);
		item.setText(0, s);
		item.setText(1, schemas.get(s));
	}
	
	Composite buttonsBar = new Composite(parent, SWT.NONE);
	buttonsBar.setLayout(new RowLayout());
	buttonsBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
	Button addButton = new Button(buttonsBar, SWT.PUSH);
	addButton.setText("Add");
	addButton.addListener(SWT.Selection, event -> {
		AddShemaGlobPatternDialog dialog = new AddShemaGlobPatternDialog(parent.getShell());
		dialog.create();
		if (dialog.open() == Window.OK) {
			TableItem newItem = new TableItem(schemaTable, SWT.NONE);
			newItem.setText(0, dialog.getSchemaKey());
			newItem.setText(1, dialog.getGlobPattern());
		}
	});
	
	Button removeButton = new Button(buttonsBar, SWT.PUSH);
	removeButton.setText("Remove");
	removeButton.addListener(SWT.Selection, event -> schemaTable.remove(schemaTable.getSelectionIndex()));
	
	schemaCol.pack();
	globPatternCol.pack();
	parent.layout();

	return new Composite(parent, SWT.NONE);
}
 
Example 17
Source File: AbapGitWizardPageApack.java    From ADT_Frontend with MIT License 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite container = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout(3, false);
	container.setLayout(layout);

	Label organizationIdLabel = new Label(container, SWT.NONE);
	organizationIdLabel.setText(Messages.AbapGitWizardPageApack_label_group_id);
	GridDataFactory.swtDefaults().applyTo(organizationIdLabel);
	this.organizationIdContent = new Label(container, SWT.NONE);
	GridDataFactory.swtDefaults().span(2, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.organizationIdContent);
	this.organizationIdContent.setText(Messages.AbapGitWizardPageApack_text_no_information_available);

	Label packageIdLabel = new Label(container, SWT.NONE);
	packageIdLabel.setText(Messages.AbapGitWizardPageApack_label_artifact_id);
	GridDataFactory.swtDefaults().applyTo(packageIdLabel);
	this.packageIdContent = new Label(container, SWT.NONE);
	GridDataFactory.swtDefaults().span(2, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.packageIdContent);
	this.packageIdContent.setText(Messages.AbapGitWizardPageApack_text_no_information_available);

	Label versionLabel = new Label(container, SWT.NONE);
	versionLabel.setText(Messages.AbapGitWizardPageApack_label_version);
	GridDataFactory.swtDefaults().applyTo(versionLabel);
	this.versionContent = new Label(container, SWT.NONE);
	GridDataFactory.swtDefaults().span(2, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.versionContent);
	this.versionContent.setText(Messages.AbapGitWizardPageApack_text_no_information_available);

	Label gitUrlLabel = new Label(container, SWT.NONE);
	gitUrlLabel.setText(Messages.AbapGitWizardPageApack_label_git_repository_url);
	GridDataFactory.swtDefaults().applyTo(gitUrlLabel);
	this.gitUrlContent = new Label(container, SWT.NONE);
	GridDataFactory.swtDefaults().span(2, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.gitUrlContent);
	this.gitUrlContent.setText(Messages.AbapGitWizardPageApack_text_no_information_available);

	if (this.pullScenario) {
		this.pullAllCheckBox = new Button(container, SWT.CHECK);
		this.pullAllCheckBox.setText(Messages.AbapGitWizardPageApack_checkbox_pull_all_dependencies);
		this.pullAllCheckBox.setSelection(true);
		GridDataFactory.swtDefaults().span(3, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(this.pullAllCheckBox);
	}

	Label dependenciesLabel = new Label(container, SWT.NONE);
	dependenciesLabel.setText(Messages.AbapGitWizardPageApack_label_dependencies);
	GridDataFactory.swtDefaults().span(3, 0).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(dependenciesLabel);

	TableViewer tableViewer = new TableViewer(container, SWT.NONE);
	this.table = tableViewer.getTable();
	this.table.setLinesVisible(true);
	this.table.setHeaderVisible(true);
	GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
	gridData.horizontalSpan = 3;
	this.table.setLayoutData(gridData);
	String[] titles = { Messages.AbapGitWizardPageApack_table_header_group_id, Messages.AbapGitWizardPageApack_table_header_artifact_id,
			Messages.AbapGitWizardPageApack_table_header_git_repository_url,
			Messages.AbapGitWizardPageApack_table_header_package_name };
	for (String title : titles) {
		TableViewerColumn viewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn column = viewerColumn.getColumn();
		column.setText(title);
		column.pack();
	}

	setControl(container);

}
 
Example 18
Source File: MarkerStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the table viewer for the detail view.
 *
 * @param parent
 *          the parent composite
 * @return the detail table viewer
 */
private EnhancedTableViewer createDetailView(Composite parent) {
  // le tableau
  EnhancedTableViewer detailViewer = new EnhancedTableViewer(parent,
          SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
  GridData gridData = new GridData(GridData.FILL_BOTH);
  detailViewer.getControl().setLayoutData(gridData);

  // setup the table columns
  Table table = detailViewer.getTable();
  table.setLinesVisible(true);
  table.setHeaderVisible(true);

  TableColumn severityCol = new TableColumn(table, SWT.CENTER, 0);
  severityCol.setWidth(20);
  severityCol.setResizable(false);

  TableColumn idCol = new TableColumn(table, SWT.LEFT, 1);
  idCol.setText(Messages.MarkerStatsView_fileColumn);
  idCol.setWidth(150);

  TableColumn folderCol = new TableColumn(table, SWT.LEFT, 2);
  folderCol.setText(Messages.MarkerStatsView_folderColumn);
  folderCol.setWidth(300);

  TableColumn countCol = new TableColumn(table, SWT.CENTER, 3);
  countCol.setText(Messages.MarkerStatsView_lineColumn);
  countCol.pack();

  TableColumn messageCol = new TableColumn(table, SWT.LEFT, 4);
  messageCol.setText(Messages.MarkerStatsView_messageColumn);
  messageCol.setWidth(300);

  // set the providers
  detailViewer.setContentProvider(new DetailContentProvider());
  DetailViewMultiProvider multiProvider = new DetailViewMultiProvider();
  detailViewer.setLabelProvider(multiProvider);
  detailViewer.setTableComparableProvider(multiProvider);
  detailViewer.setTableSettingsProvider(multiProvider);
  detailViewer.installEnhancements();

  // add selection listener to maintain action state
  detailViewer.addSelectionChangedListener(new ISelectionChangedListener() {
    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      updateActions();
    }
  });

  // hooks the action to double click
  hookDoubleClickAction(mShowErrorAction, detailViewer);

  // and to the context menu too
  ArrayList<Object> actionList = new ArrayList<>(1);
  actionList.add(mDrillBackAction);
  actionList.add(mShowErrorAction);
  actionList.add(new Separator());
  actionList.add(mChartAction);
  hookContextMenu(actionList, detailViewer);

  return detailViewer;
}
 
Example 19
Source File: MarkerStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the table viewer for the master view.
 *
 * @param parent
 *          the parent composite
 * @return the master table viewer
 */
private EnhancedTableViewer createMasterView(Composite parent) {
  EnhancedTableViewer masterViewer = new EnhancedTableViewer(parent,
          SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
  GridData gridData = new GridData(GridData.FILL_BOTH);
  masterViewer.getControl().setLayoutData(gridData);

  // setup the table columns
  Table table = masterViewer.getTable();
  table.setLinesVisible(true);
  table.setHeaderVisible(true);

  TableColumn severityCol = new TableColumn(table, SWT.CENTER, 0);
  severityCol.setWidth(20);
  severityCol.setResizable(false);

  TableColumn idCol = new TableColumn(table, SWT.LEFT, 1);
  idCol.setText(Messages.MarkerStatsView_kindOfErrorColumn);
  idCol.setWidth(400);

  TableColumn countCol = new TableColumn(table, SWT.CENTER, 2);
  countCol.setText(Messages.MarkerStatsView_numberOfErrorsColumn);
  countCol.pack();

  // set the providers
  masterViewer.setContentProvider(new MasterContentProvider());
  MasterViewMultiProvider multiProvider = new MasterViewMultiProvider();
  masterViewer.setLabelProvider(multiProvider);
  masterViewer.setTableComparableProvider(multiProvider);
  masterViewer.setTableSettingsProvider(multiProvider);
  masterViewer.installEnhancements();

  // add selection listener to maintain action state
  masterViewer.addSelectionChangedListener(new ISelectionChangedListener() {
    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      updateActions();
    }
  });

  // hooks the action to double click
  hookDoubleClickAction(mDrillDownAction, masterViewer);

  // and to the context menu too
  ArrayList<Object> actionList = new ArrayList<>(3);
  actionList.add(mDrillDownAction);
  actionList.add(new Separator());
  actionList.add(mChartAction);
  hookContextMenu(actionList, masterViewer);

  return masterViewer;
}
 
Example 20
Source File: GraphStatsView.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the table viewer for the detail view.
 *
 * @param parent
 *          the parent composite
 * @return the detail table viewer
 */
private EnhancedTableViewer createDetailView(Composite parent) {
  // le tableau
  EnhancedTableViewer detailViewer = new EnhancedTableViewer(parent,
          SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
  GridData gridData = new GridData(GridData.FILL_BOTH);
  detailViewer.getControl().setLayoutData(gridData);

  // setup the table columns
  Table table = detailViewer.getTable();
  table.setLinesVisible(true);
  table.setHeaderVisible(true);

  TableColumn severityCol = new TableColumn(table, SWT.CENTER, 0);
  severityCol.setWidth(20);
  severityCol.setResizable(false);

  TableColumn idCol = new TableColumn(table, SWT.LEFT, 1);
  idCol.setText(Messages.MarkerStatsView_fileColumn);
  idCol.setWidth(150);

  TableColumn folderCol = new TableColumn(table, SWT.LEFT, 2);
  folderCol.setText(Messages.MarkerStatsView_folderColumn);
  folderCol.setWidth(300);

  TableColumn countCol = new TableColumn(table, SWT.CENTER, 3);
  countCol.setText(Messages.MarkerStatsView_lineColumn);
  countCol.pack();

  TableColumn messageCol = new TableColumn(table, SWT.LEFT, 4);
  messageCol.setText(Messages.MarkerStatsView_messageColumn);
  messageCol.setWidth(300);

  // set the providers
  detailViewer.setContentProvider(new DetailContentProvider());
  DetailViewMultiProvider multiProvider = new DetailViewMultiProvider();
  detailViewer.setLabelProvider(multiProvider);
  detailViewer.setTableComparableProvider(multiProvider);
  detailViewer.setTableSettingsProvider(multiProvider);
  detailViewer.installEnhancements();

  // add selection listener to maintain action state
  detailViewer.addSelectionChangedListener(new ISelectionChangedListener() {
    @Override
    public void selectionChanged(SelectionChangedEvent event) {
      updateActions();
    }
  });

  // hooks the action to double click
  hookDoubleClickAction(mShowErrorAction, detailViewer);

  // and to the context menu too
  ArrayList<Object> actionList = new ArrayList<>(3);
  actionList.add(mDrillBackAction);
  actionList.add(mShowErrorAction);
  actionList.add(new Separator());
  hookContextMenu(actionList, detailViewer);

  return detailViewer;
}