Java Code Examples for org.eclipse.swt.widgets.Table#setLinesVisible()

The following examples show how to use org.eclipse.swt.widgets.Table#setLinesVisible() . 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: SvnRevPropertiesView.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private TableViewer createTable(Composite parent) {
    Table table =   new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(gridData);
    TableLayout layout = new TableLayout();
    table.setLayout(layout);
    
    tableViewer = new TableViewer(table);
    createColumns(table, layout);

    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new PropertiesLabelProvider());
    return tableViewer;
}
 
Example 2
Source File: UsersWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createGeneralDataTable(final Composite tables) {
    final Composite generalDataTableComposite = new Composite(tables, SWT.NONE);
    generalDataTableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
    generalDataTableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Table generalDataTable = new Table(generalDataTableComposite, SWT.BORDER);
    generalDataTable.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    generalDataTable.setLinesVisible(true);
    generalDataTable.setHeaderVisible(true);

    final String[] generalDataItems = getGeneralDataItems();
    final TableColumn generalData = new TableColumn(generalDataTable, SWT.NONE);
    generalData.setText(Messages.defaultInformationGroupGeneralDataTableTitle);
    generalData.setResizable(false);

    for (int i = 0; i < generalDataItems.length; i++) {
        final TableItem item = new TableItem(generalDataTable, SWT.NONE | SWT.FILL);
        item.setText(generalDataItems[i]);
    }

    addTableColumLayout(generalDataTable);
}
 
Example 3
Source File: RelationshipByExistingColumnsDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
private void createForeignKeyColumnMapper(Composite composite) {
    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 2;
    tableGridData.heightHint = 100;
    tableGridData.horizontalAlignment = GridData.FILL;
    tableGridData.grabExcessHorizontalSpace = true;
    foreignKeyColumnMapper = new Table(composite, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
    foreignKeyColumnMapper.setLayoutData(tableGridData);
    foreignKeyColumnMapper.setHeaderVisible(true);
    foreignKeyColumnMapper.setLinesVisible(true);
    final TableColumn referredColumn = new TableColumn(foreignKeyColumnMapper, SWT.NONE);
    referredColumn.setWidth(COLUMN_WIDTH);
    referredColumn.setText("Referred Column");
    final TableColumn foreignKeyColumn = new TableColumn(foreignKeyColumnMapper, SWT.NONE);
    foreignKeyColumn.setWidth(COLUMN_WIDTH);
    foreignKeyColumn.setText("ForeignKey Column");
}
 
Example 4
Source File: ChangePathsTableProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ChangePathsTableProvider(Composite parent, IContentProvider contentProvider) {
  super(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
  
  TableLayout layout = new TableLayout();
  GridData data = new GridData(GridData.FILL_BOTH);
  
  Table table = (Table) getControl();
  table.setHeaderVisible(true);
  table.setLinesVisible(true);
  table.setLayoutData(data);    
  table.setLayout(layout);
  table.addDisposeListener(new DisposeListener() {
    public void widgetDisposed(DisposeEvent e) {
      if(currentPathFont != null) {
        currentPathFont.dispose();
      }
    }
  });
  
  createColumns(table, layout);
  
  setLabelProvider(new ChangePathLabelProvider());
  setContentProvider(contentProvider);
  
  ChangePathsSorter sorter = new ChangePathsSorter(COL_PATH);
  setSorter(sorter);
  table.setSortDirection(SWT.UP);
}
 
Example 5
Source File: HistoryTableProvider.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a TableViewer that can be used to display a list of ILogEntry instances.
 * Ths method provides the labels and sorter but does not provide a content provider
 * 
 * @param parent
 * @return TableViewer
 */
public TableViewer createTable(Composite parent) {
	Table table = new Table(parent, style);
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	GridData data = new GridData(GridData.FILL_BOTH);
	data.horizontalIndent = 0;
	data.verticalIndent = 0;
	table.setLayoutData(data);

	TableLayout layout = new TableLayout();
	table.setLayout(layout);
	
	TableViewer viewer = new TableViewer(table);
	
	createColumns(table, layout, viewer);

	viewer.setLabelProvider(new HistoryLabelProvider());
	
	HistorySorter sorter = new HistorySorter(COL_REVISION);
	viewer.setSorter(sorter);
	table.setSortDirection(SWT.DOWN);
	table.setSortColumn(table.getColumn(0));

       table.addDisposeListener(new DisposeListener() {
           public void widgetDisposed(DisposeEvent e) {
               if(currentRevisionFont != null) {
                   currentRevisionFont.dispose();
               }
           }
       });
       
	this.viewer = viewer;
	return viewer;
}
 
Example 6
Source File: ManageableTableTreeEx.java    From SWET with MIT License 5 votes vote down vote up
private void createContents(final Shell shell) {
	shell.setLayout(new FillLayout());

	TableTree tableTree = new TableTree(shell, SWT.NONE);
	Table table = tableTree.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(false);

	for (int col = 0; col < cols; col++) {
		new TableColumn(table, SWT.LEFT).setText("Column " + (col + 1));
	}

	for (int row = 0; row < rows; row++) {
		TableTreeItem parent = new TableTreeItem(tableTree, SWT.NONE);
		parent.setText(0, "Parent " + (row + 1));
		parent.setText(1, "Data");
		parent.setText(2, "More data");

		// Add children items
		for (int j = 0; j < rows; j++) {
			// Create a child item and add data to the columns
			TableTreeItem child = new TableTreeItem(parent, SWT.NONE);
			child.setText(0, "Child " + (j + 1));
			child.setText(1, "Some child data");
			child.setText(2, "More child data");
		}
		// Expand the parent item
		parent.setExpanded(true);
	}

	// Pack the columns
	TableColumn[] columns = table.getColumns();
	for (int i = 0, n = columns.length; i < n; i++) {
		columns[i].pack();
	}
}
 
Example 7
Source File: SetupOptionsPage.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** @return table created with the provided data and tool tip, or {@code null} if no data. */
private static Table createTable(Composite parent, Map<String, String> data, String toolTipText, String label) {
	if (data == null || data.isEmpty())
		return null;

	new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	new Label(parent, SWT.NONE).setText(label);
	Table table = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	table.setToolTipText(toolTipText);
	TableColumn nameColumn = new TableColumn(table, SWT.NONE);
	nameColumn.setText("name");
	TableColumn locationColumn = new TableColumn(table, SWT.NONE);
	locationColumn.setText("Location");
	TableItem defaultItem = new TableItem(table, SWT.NONE);
	defaultItem.setText(0, "default");
	defaultItem.setText(1, "default settings");

	data.forEach((path, name) -> {
		TableItem item = new TableItem(table, SWT.NONE);
		item.setText(0, name);
		item.setText(1, path);
	});

	table.getColumn(0).pack();
	table.getColumn(1).pack();
	table.pack(true);
	return table;
}
 
Example 8
Source File: TasksPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param parent
 */
private void createTaskTableArea(Composite parent)
{
	fTasksTableViewer = new TableViewer(parent, SWT.BORDER | SWT.SINGLE);
	Table table = fTasksTableViewer.getTable();
	table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	table.setFont(parent.getFont());

	TableColumn tagNameColumn = new TableColumn(table, SWT.NONE);
	tagNameColumn.setText(Messages.TasksPreferencePage_TagNameColumnHeader);
	tagNameColumn.setWidth(100);
	TableColumn tagPriorityColumn = new TableColumn(table, SWT.NONE);
	tagPriorityColumn.setText(Messages.TasksPreferencePage_PriorityColumnHeader);
	tagPriorityColumn.setWidth(100);

	fTasksTableViewer.setContentProvider(ArrayContentProvider.getInstance());
	fTasksTableViewer.setLabelProvider(new TaskLabelProvider());
	fTasksTableViewer.setComparator(new ViewerComparator());
	fTasksTableViewer.setInput(getTaskTags());

	fTasksTableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{
		public void selectionChanged(SelectionChangedEvent event)
		{
			// Enable/disable buttons
			updateButtonStates();
		}
	});

	createTaskButtons(parent);
}
 
Example 9
Source File: MetricDisplay.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {

	setTitleImage(null);
	setTitle("Metric informations");
	Composite area = (Composite) super.createDialogArea(parent);
	area.setLayout(new GridLayout(1, false));

	Composite textContainer = new Composite(area, SWT.NONE);
	textContainer.setLayout(new FillLayout(SWT.HORIZONTAL));
	textContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

	table = new Table(textContainer, SWT.BORDER | SWT.FULL_SELECTION);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);

	TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn.setWidth(300);
	tblclmnNewColumn.setText("ID");

	TableColumn tblclmnNewColumn_1 = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn_1.setWidth(100);
	tblclmnNewColumn_1.setText("Value");
	
	TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE);
	tblclmnNewColumn_2.setWidth(300);
	tblclmnNewColumn_2.setText("Description");
	

	progressBar = new ProgressBar(area, SWT.SMOOTH);
	progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

	refreshMetrics();

	return area;
}
 
Example 10
Source File: DetectorConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Build rule table viewer
 */
private Table createDetectorsTableViewer(Composite parent, IProject project) {
    final BugPatternTableSorter sorter = new BugPatternTableSorter(this);

    int tableStyle = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK;
    availableFactoriesTableViewer = CheckboxTableViewer.newCheckList(parent, tableStyle);
    availableFactoriesTableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            syncUserPreferencesWithTable();
        }
    });

    int currentColumnIdx = 0;
    Table factoriesTable = availableFactoriesTableViewer.getTable();

    TableColumn factoryNameColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.detectorName"), 230,
            COLUMN.DETECTOR_NAME);
    addColumnSelectionListener(sorter, factoryNameColumn, COLUMN.DETECTOR_NAME);

    currentColumnIdx++;
    TableColumn bugsAbbrevColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.bugCodes"), 75,
            COLUMN.BUG_CODES);
    addColumnSelectionListener(sorter, bugsAbbrevColumn, COLUMN.BUG_CODES);

    currentColumnIdx++;
    TableColumn speedColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.speed"), 70,
            COLUMN.DETECTOR_SPEED);
    addColumnSelectionListener(sorter, speedColumn, COLUMN.DETECTOR_SPEED);

    currentColumnIdx++;
    TableColumn pluginColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.provider"), 100,
            COLUMN.PLUGIN);
    addColumnSelectionListener(sorter, pluginColumn, COLUMN.PLUGIN);

    currentColumnIdx++;
    TableColumn categoryColumn = createColumn(currentColumnIdx, factoriesTable, getMessage("property.category"), 75,
            COLUMN.BUG_CATEGORIES);
    addColumnSelectionListener(sorter, categoryColumn, COLUMN.BUG_CATEGORIES);

    factoriesTable.setLinesVisible(true);
    factoriesTable.setHeaderVisible(true);
    // initial sort indicator
    factoriesTable.setSortDirection(sorter.revertOrder ? SWT.UP : SWT.DOWN);
    factoriesTable.setSortColumn(factoryNameColumn);
    sorter.setSortColumnIndex(COLUMN.DETECTOR_NAME);

    availableFactoriesTableViewer.setContentProvider(new DetectorFactoriesContentProvider());
    availableFactoriesTableViewer.setLabelProvider(new DetectorFactoryLabelProvider(this));

    availableFactoriesTableViewer.setSorter(sorter);

    populateAvailableRulesTable(project);
    factoriesTable.setEnabled(true);

    return factoriesTable;
}
 
Example 11
Source File: CodeAssistAdvancedConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void createSeparateViewer(Composite composite) {
	fSeparateViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
	Table table= fSeparateViewer.getTable();
	table.setHeaderVisible(false);
	table.setLinesVisible(false);
	table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1));

	TableColumn nameColumn= new TableColumn(table, SWT.NONE);
	nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
	nameColumn.setResizable(false);

	fSeparateViewer.setContentProvider(new ArrayContentProvider());

	ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
	fSeparateViewer.setLabelProvider(labelProvider);
	fSeparateViewer.setInput(fModel.elements);

	final int ICON_AND_CHECKBOX_WITH= 50;
	final int HEADER_MARGIN= 20;
	int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
	for (int i= 0; i < fModel.elements.size(); i++) {
		minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
	}

	nameColumn.setWidth(minNameWidth);

	fSeparateViewer.addCheckStateListener(new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			boolean checked= event.getChecked();
			ModelElement element= (ModelElement) event.getElement();
			element.setSeparateCommand(checked);
		}
	});

	table.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			handleTableSelection();
		}
	});

}
 
Example 12
Source File: ModelPropertiesDialog.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * This method initializes composite1
 * 
 */
private void createTableComposite(Composite parent) {
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 3;

	GridData gridData = new GridData();
	gridData.heightHint = 320;

	GridData tableGridData = new GridData();
	tableGridData.horizontalSpan = 3;
	tableGridData.heightHint = 185;

	Composite composite = new Composite(parent, SWT.BORDER);
	composite.setLayout(gridLayout);
	composite.setLayoutData(gridData);

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

	TableColumn tableColumn0 = new TableColumn(table, SWT.NONE);
	tableColumn0.setWidth(200);
	tableColumn0.setText(ResourceString
			.getResourceString("label.property.name"));
	TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
	tableColumn1.setWidth(200);
	tableColumn1.setText(ResourceString
			.getResourceString("label.property.value"));

	this.tableEditor = new TableEditor(table);
	this.tableEditor.grabHorizontal = true;

	this.table.addMouseListener(new MouseAdapter() {

		@Override
		public void mouseDown(MouseEvent event) {
			int index = table.getSelectionIndex();
			if (index == -1) {
				return;
			}

			TableItem item = table.getItem(index);
			Point selectedPoint = new Point(event.x, event.y);

			targetColumn = -1;

			for (int i = 0; i < table.getColumnCount(); i++) {
				Rectangle rect = item.getBounds(i);
				if (rect.contains(selectedPoint)) {
					targetColumn = i;
					break;
				}
			}

			if (targetColumn == -1) {
				return;
			}

			edit(item, tableEditor);
		}

	});
}
 
Example 13
Source File: UpdateTMWizardPage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void createContent(Composite parent) {
	TableViewer tableViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
	final Table table = tableViewer.getTable();
	GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
	tableData.heightHint = 160;
	table.setLayoutData(tableData);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	
	TableColumn columnNumber = new TableColumn(table, SWT.LEFT);
	columnNumber.setText(Messages.getString("wizard.UpdateTMWizardPage.columnNumber"));
	columnNumber.setWidth(50);
	
	TableColumn columnPath = new TableColumn(table, SWT.LEFT);
	columnPath.setText(Messages.getString("wizard.UpdateTMWizardPage.columnPath"));
	columnPath.setWidth(400);
	
	tableViewer.setLabelProvider(new TableViewerLabelProvider());
	tableViewer.setContentProvider(new ArrayContentProvider());
	tableViewer.setInput(getTableInfo());
	
	Group groupStatus = new Group(parent, SWT.None);
	groupStatus.setLayout(new GridLayout());
	groupStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	groupStatus.setText(Messages.getString("dialog.UpdateTMDialog.lbl"));
	btnDraft = new Button(groupStatus, SWT.CHECK);
	btnDraft.setText(Messages.getString("dialog.UpdateTMDialog.btnDraft"));

	btnTranslated = new Button(groupStatus, SWT.CHECK);
	btnTranslated.setText(Messages.getString("dialog.UpdateTMDialog.btnTranslated"));
	btnTranslated.setSelection(true);

	btnApproved = new Button(groupStatus, SWT.CHECK);
	btnApproved.setText(Messages.getString("dialog.UpdateTMDialog.btnApproved"));
	btnApproved.setSelection(true);

	btnSignedOff = new Button(groupStatus, SWT.CHECK);
	btnSignedOff.setText(Messages.getString("dialog.UpdateTMDialog.btnSignedOff"));
	btnSignedOff.setSelection(true);
	
	btnLocked = new Button(groupStatus, SWT.CHECK);
	btnLocked.setText(Messages.getString("dialog.UpdateTMWizardPage.btnLocked"));
}
 
Example 14
Source File: InfoPage.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void initContent(final PageContainer container,
		Composite composite) {
	mapBrowser.getGeoMap().addInternalGeoMapListener(this);

	addHeaderRow(container, composite, "Actions");
	addActionLink(container, composite, "<a>Back to main menu</a>",
			new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					container.showPage(0);
				}
			});

	addHeaderRow(container, composite, "Infos");
	addInfoText(container, composite,
			"The following search results were retrieved from openstreetmap.org. "
					+ "Double-click to open a location.");

	table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI
			| SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
	table.setLayoutData(
			new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));

	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	TableColumn column1 = new TableColumn(table, SWT.NONE);
	column1.setText("Place");
	column1.setWidth(120);
	TableColumn column2 = new TableColumn(table, SWT.NONE);
	column2.setText("Place");
	column2.setWidth(160);

	for (Spec spec : specs) {
		TableItem item = new TableItem(table, SWT.NONE);
		item.setText(0, spec.key);
	}

	addHeaderRow(container, composite, "Authors Remarks");
	addInfoText(container, composite,
			"The number of image fetcher threads determines how many background tasks are "
					+ "run simultaneously to fetch tiles. The search is also performed in the background. "
					+ "The tilecache fill never drops below its maximum size once its filled, but the eldest "
					+ "entries are discarded on a LRU (Least-Recently-Used) basis.");
	addInfoText(container, composite,
			"The MapWidget can be used without all of this quite useless showcase application. Its "
					+ "main purpose is to showcase the MapWidget.");

	addHeaderRow(container, composite, "Quick Help");
	addInfoText(container, composite,
			"Use the mouse wheel to zoom in and zoom out. Drag the mouse to change "
					+ "your position on the map");
	updateInfos();
}
 
Example 15
Source File: SourceView.java    From lapse-plus with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates the table control.
 */
private static Table createTable(Composite parent) {
    Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    table.setLinesVisible(true);
    return table;
}
 
Example 16
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 17
Source File: ModelPropertiesDialog.java    From erflute with Apache License 2.0 4 votes vote down vote up
/**
 * This method initializes composite1
 */
private void createTableComposite(Composite parent) {
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;

    final GridData gridData = new GridData();
    gridData.heightHint = 320;

    final GridData tableGridData = new GridData();
    tableGridData.horizontalSpan = 3;
    tableGridData.heightHint = 185;

    final Composite composite = new Composite(parent, SWT.BORDER);
    composite.setLayout(gridLayout);
    composite.setLayoutData(gridData);

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

    final TableColumn tableColumn0 = new TableColumn(table, SWT.NONE);
    tableColumn0.setWidth(200);
    tableColumn0.setText(DisplayMessages.getMessage("label.property.name"));
    final TableColumn tableColumn1 = new TableColumn(table, SWT.NONE);
    tableColumn1.setWidth(200);
    tableColumn1.setText(DisplayMessages.getMessage("label.property.value"));

    tableEditor = new TableEditor(table);
    tableEditor.grabHorizontal = true;

    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            final int index = table.getSelectionIndex();
            if (index == -1) {
                return;
            }

            final TableItem item = table.getItem(index);
            final Point selectedPoint = new Point(event.x, event.y);

            targetColumn = -1;

            for (int i = 0; i < table.getColumnCount(); i++) {
                final Rectangle rect = item.getBounds(i);
                if (rect.contains(selectedPoint)) {
                    targetColumn = i;
                    break;
                }
            }

            if (targetColumn == -1) {
                return;
            }

            edit(item, tableEditor);
        }
    });
}
 
Example 18
Source File: LayoutTable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public LayoutTable( Composite parent,
		ColumnsDescription columnsDescription, int style,
		boolean isFormStyle )
{
	super( parent, SWT.NONE );
	formStyle = isFormStyle;
	Assert.isNotNull( columnsDescription );
	this.columnDescription = columnsDescription;
	if ( formStyle )
		setLayout( UIUtil.createGridLayoutWithMargin( 1 ) );
	else
		setLayout( UIUtil.createGridLayoutWithoutMargin( ) );
	if ( !formStyle )
		table = new Table( this, style );
	else
		table = FormWidgetFactory.getInstance( ).createTable( this, style );
	table.setHeaderVisible( columnsDescription.headers != null );
	table.setLinesVisible( columnsDescription.drawLines );
	table.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	int columnCount = columnDescription.isHeaderVisible( ) ? columnDescription.headers.length
			: columnDescription.columns.length;
	for ( int i = 0; i < columnCount; i++ )
	{
		TableColumn column = new TableColumn( table, SWT.NONE );
		if ( columnDescription.isHeaderVisible( ) )
		{
			column.setText( columnDescription.headers[i] );
		}
		column.setMoveable( false );
		if ( i < columnsDescription.columns.length )
		{
			column.setResizable( columnsDescription.columns[i].resizable );
		}
	}

	addControlListener( new ControlAdapter( ) {

		public void controlResized( ControlEvent e )
		{
			if ( table != null && !table.isDisposed( ) )
			{
				Rectangle area = getClientArea( );
				Point preferredSize = computeTableSize( table );
				int width = area.width - 2 * table.getBorderWidth( );
				if ( preferredSize.y > area.height )
				{
					// Subtract the scrollbar width from the total column
					// width
					// if a vertical scrollbar will be required
					Point vBarSize = table.getVerticalBar( ).getSize( );
					width -= vBarSize.x;
				}
				if ( formStyle )
					width -= 2;
				layoutTable( width, area );
			}
		}
	} );
}
 
Example 19
Source File: ResolvablePropertiesDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the dialogs main contents.
 *
 * @param parent
 *          the parent composite
 */
@Override
protected Control createDialogArea(Composite parent) {

  // set the logo
  this.setTitleImage(CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.PLUGIN_LOGO));
  this.setTitle(Messages.ResolvablePropertiesDialog_titleMessageArea);
  this.setMessage(Messages.ResolvablePropertiesDialog_msgAdditionalProperties);

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

  Composite contents = new Composite(composite, SWT.NULL);
  contents.setLayout(new GridLayout(2, false));
  GridData fd = new GridData(GridData.FILL_BOTH);
  contents.setLayoutData(fd);

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

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

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

  TableColumn column1 = new TableColumn(table, SWT.NULL);
  column1.setText(Messages.ResolvablePropertiesDialog_colName);
  tableLayout.addColumnData(new ColumnWeightData(50));

  TableColumn column2 = new TableColumn(table, SWT.NULL);
  column2.setText(Messages.ResolvablePropertiesDialog_colValue);
  tableLayout.addColumnData(new ColumnWeightData(50));

  mTableViewer = new EnhancedTableViewer(table);
  PropertiesLabelProvider multiProvider = new PropertiesLabelProvider();
  mTableViewer.setLabelProvider(multiProvider);
  mTableViewer.setTableComparableProvider(multiProvider);
  mTableViewer.setTableSettingsProvider(multiProvider);
  mTableViewer.installEnhancements();

  mTableViewer.setContentProvider(new ArrayContentProvider());
  mTableViewer.addDoubleClickListener(mController);
  mTableViewer.getTable().addKeyListener(mController);

  Composite buttonBar = new Composite(contents, SWT.NULL);
  GridLayout layout = new GridLayout(1, false);
  layout.marginHeight = 0;
  layout.marginWidth = 0;
  buttonBar.setLayout(layout);
  GridData gd = new GridData();
  gd.verticalAlignment = GridData.BEGINNING;
  buttonBar.setLayoutData(gd);

  mBtnAdd = new Button(buttonBar, SWT.PUSH);
  mBtnAdd.setText(Messages.ResolvablePropertiesDialog_btnAdd);
  mBtnAdd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  mBtnAdd.addSelectionListener(mController);

  mBtnEdit = new Button(buttonBar, SWT.PUSH);
  mBtnEdit.setText(Messages.ResolvablePropertiesDialog_btnEdit);
  mBtnEdit.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  mBtnEdit.addSelectionListener(mController);

  mBtnRemove = new Button(buttonBar, SWT.PUSH);
  mBtnRemove.setText(Messages.ResolvablePropertiesDialog_btnRemove);
  mBtnRemove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  mBtnRemove.addSelectionListener(mController);

  return composite;
}
 
Example 20
Source File: CheckConfigurationConfigureDialog.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private Control createTableViewer(Composite parent) {

    mConfiguredModulesGroup = new Group(parent, SWT.NULL);
    mConfiguredModulesGroup.setLayout(new GridLayout());
    mConfiguredModulesGroup.setText("\0"); //$NON-NLS-1$

    Table table = new Table(mConfiguredModulesGroup,
            SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

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

    TableColumn column1 = new TableColumn(table, SWT.NULL);
    column1.setAlignment(SWT.CENTER);
    column1.setText(Messages.CheckConfigurationConfigureDialog_colEnabled);
    tableLayout.addColumnData(new ColumnWeightData(15));

    TableColumn column2 = new TableColumn(table, SWT.NULL);
    column2.setText(Messages.CheckConfigurationConfigureDialog_colModule);
    tableLayout.addColumnData(new ColumnWeightData(30));

    TableColumn column3 = new TableColumn(table, SWT.NULL);
    column3.setText(Messages.CheckConfigurationConfigureDialog_colSeverity);
    tableLayout.addColumnData(new ColumnWeightData(20));

    TableColumn column4 = new TableColumn(table, SWT.NULL);
    column4.setText(Messages.CheckConfigurationConfigureDialog_colComment);
    tableLayout.addColumnData(new ColumnWeightData(35));

    mTableViewer = new EnhancedCheckBoxTableViewer(table);
    ModuleLabelProvider multiProvider = new ModuleLabelProvider();
    mTableViewer.setLabelProvider(multiProvider);
    mTableViewer.setTableComparableProvider(multiProvider);
    mTableViewer.setTableSettingsProvider(multiProvider);
    mTableViewer.setContentProvider(new ArrayContentProvider());
    mTableViewer.addFilter(mGroupFilter);
    mTableViewer.installEnhancements();

    mTableViewer.addDoubleClickListener(mController);
    mTableViewer.addSelectionChangedListener(mController);
    mTableViewer.addCheckStateListener(mController);
    mTableViewer.getTable().addKeyListener(mController);

    Composite buttons = new Composite(mConfiguredModulesGroup, SWT.NULL);
    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    buttons.setLayoutData(new GridData());

    mRemoveButton = new Button(buttons, SWT.PUSH);
    mRemoveButton.setText((Messages.CheckConfigurationConfigureDialog_btnRemove));
    mRemoveButton.setLayoutData(new GridData());
    mRemoveButton.addSelectionListener(mController);

    mEditButton = new Button(buttons, SWT.PUSH);
    mEditButton.setText((Messages.CheckConfigurationConfigureDialog_btnOpen));
    mEditButton.setLayoutData(new GridData());
    mEditButton.addSelectionListener(mController);

    return mConfiguredModulesGroup;
  }