Java Code Examples for org.eclipse.jface.viewers.ITableLabelProvider

The following are top voted examples for showing how to use org.eclipse.jface.viewers.ITableLabelProvider. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hydrograph   File: ELTOperationClassDialog.java   View source code 6 votes vote down vote up
public TableViewer setTableViewer(TableViewer tableViewer, Composite composite, String[] prop,
		IStructuredContentProvider iStructuredContentProvider, ITableLabelProvider iTableLabelProvider) {

	tableViewer.setContentProvider(iStructuredContentProvider);

	tableViewer.setColumnProperties(prop);

	tableViewerTable = tableViewer.getTable();

	tableViewerTable.setVisible(true);
	tableViewerTable.setLinesVisible(true);
	tableViewerTable.setHeaderVisible(true);
	createTableColumns(tableViewerTable, prop);
	editors = createCellEditorList(tableViewerTable, prop.length);
	tableViewer.setCellEditors(editors);

	TableViewerEditor.create(tableViewer, new ColumnViewerEditorActivationStrategy(tableViewer),
			ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.TABBING_HORIZONTAL
					| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL);

	return tableViewer;
}
 
Example 2
Project: depan   File: NodeStatsTableControl.java   View source code 6 votes vote down vote up
private ViewerComparator buildColumnSorter(int columnIndex) {
  switch (columnIndex) {
  case INDEX_ROOT:
    return new RootSorter();
  case INDEX_RANK:
    return new RankSorter();
  case INDEX_PREDS:
    return new PredecessorCountSorter();
  case INDEX_SUCCS:
    return new SuccessorCountSorter();
  }

  // By default, use an alphabetic sort over the column labels.
  ITableLabelProvider labelProvider =
      (ITableLabelProvider) propViewer.getLabelProvider();
  ViewerComparator result = new AlphabeticSorter(
      new LabelProviderToString(labelProvider, columnIndex));
  return result;
}
 
Example 3
Project: depan   File: NodeKindTableControl.java   View source code 6 votes vote down vote up
private void setSortColumn(
    TableColumn column, int colIndex, int direction) {

  ITableLabelProvider labelProvider =
      (ITableLabelProvider) kindViewer.getLabelProvider();
  ViewerComparator sorter = new AlphabeticSorter(
      new LabelProviderToString(labelProvider, colIndex));
  if (SWT.UP == direction) {
    sorter = new InverseSorter(sorter);
  }

  Table tableControl = (Table) kindViewer.getControl();
  kindViewer.setComparator(sorter);
  tableControl.setSortColumn(column);
  tableControl.setSortDirection(direction);
}
 
Example 4
Project: depan   File: NodeDisplayTableControl.java   View source code 6 votes vote down vote up
private ViewerComparator buildColumnSorter(int colIndex) {
  if (INDEX_VISIBLE == colIndex) {
    return new BooleanVisibleSorter();
  }
  if (INDEX_XPOS == colIndex) {
    return new PositionSorter(true);
  }
  if (INDEX_YPOS == colIndex) {
    return new PositionSorter(false);
  }

  // By default, use an alphabetic sort over the column labels.
  ITableLabelProvider labelProvider =
      (ITableLabelProvider) propViewer.getLabelProvider();
  ViewerComparator result = new AlphabeticSorter(
      new LabelProviderToString(labelProvider, colIndex));
  return result;
}
 
Example 5
Project: scouter   File: TreeLabelSorter.java   View source code 6 votes vote down vote up
protected int compareNormal(Object e1, Object e2) {
	ITableLabelProvider labelProvider = (ITableLabelProvider) viewer.getLabelProvider();
	String t1 = labelProvider.getColumnText(e1, colIndex);
	String t2 = labelProvider.getColumnText(e2, colIndex);
	Boolean isNumber = (Boolean) this.col.getData("isNumber");
	if (isNumber != null && isNumber.booleanValue()) {
		t1 = ColumnLabelSorter.numonly(t1);
		t2 = ColumnLabelSorter.numonly(t2);
		double n1 = CastUtil.cdouble(t1);
		double n2 = CastUtil.cdouble(t2);
		return n1 == n2 ? 0 : (n1 > n2) ? 1 : -1;
	} else {
		if (t1 == null) t1 = "";
		if (t2 == null) t2 = "";
	}
	return t1.compareTo(t2);
}
 
Example 6
Project: scouter   File: TableLabelSorter.java   View source code 6 votes vote down vote up
protected int compareNormal(Object e1, Object e2) {
	ITableLabelProvider labelProvider = (ITableLabelProvider) viewer.getLabelProvider();
	String t1 = labelProvider.getColumnText(e1, colIndex);
	String t2 = labelProvider.getColumnText(e2, colIndex);
	Boolean isNumber = (Boolean) this.col.getData("isNumber");
	if (isNumber != null && isNumber.booleanValue()) {
		t1 = ColumnLabelSorter.numonly(t1);
		t2 = ColumnLabelSorter.numonly(t2);
		double n1 = CastUtil.cdouble(t1);
		double n2 = CastUtil.cdouble(t2);
		return n1 == n2 ? 0 : (n1 > n2) ? 1 : -1;
	} else {
		if (t1 == null) t1 = "";
		if (t2 == null) t2 = "";
	}
	return t1.compareTo(t2);
}
 
Example 7
Project: relations   File: RelationsKeysPreferencePage.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private int compareColumn(final Viewer inViewer, final Object inA,
        final Object inB, final int inColumnNumber) {
	if (inColumnNumber == USER_DELTA_COLUMN) {
		return sortUser(inA, inB);
	}
	final IBaseLabelProvider lBaseLabel = ((TreeViewer) inViewer)
	        .getLabelProvider();
	if (lBaseLabel instanceof ITableLabelProvider) {
		final ITableLabelProvider lTableProvider = (ITableLabelProvider) lBaseLabel;
		final String lProvider1 = lTableProvider.getColumnText(inA,
		        inColumnNumber);
		final String lProvider2 = lTableProvider.getColumnText(inB,
		        inColumnNumber);
		if (lProvider1 != null && lProvider2 != null) {
			return getComparator().compare(lProvider1, lProvider2);
		}
	}
	return 0;
}
 
Example 8
Project: Hydrograph   File: ELTSWTWidgets.java   View source code 5 votes vote down vote up
public TableViewer createTableViewer(Composite composite, String[] prop,
		int[] bounds, int columnWidth,
		IStructuredContentProvider iStructuredContentProvider,
		ITableLabelProvider iTableLabelProvider) {
	final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER
			| SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);

	Table table = tableViewer.getTable();
	table.setBounds(bounds[0], bounds[1], bounds[2], bounds[3]);
	tableViewer.setContentProvider(iStructuredContentProvider);
	tableViewer.setLabelProvider(iTableLabelProvider);
	tableViewer.setColumnProperties(prop);
	tableViewer.getTable().addTraverseListener(new TraverseListener() {

		@Override
		public void keyTraversed(TraverseEvent e) {
			if (e.keyCode == SWT.ARROW_UP) {
				e.doit = false;
			} else if (e.keyCode == SWT.ARROW_DOWN) {
				e.doit = false;
			} else if (e.keyCode == SWT.TRAVERSE_ARROW_NEXT) {
				e.doit = false;
			} else if (e.keyCode == SWT.TRAVERSE_ARROW_PREVIOUS) {
				e.doit = false;
			}

		}
	});

	table.setVisible(true);
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	/*
	 * createTableColumns(table,prop, columnWidth); CellEditor[] editors
	 * =createCellEditorList(table,1); tableViewer.setCellEditors(editors);
	 */

	return tableViewer;
}
 
Example 9
Project: tm4e   File: ColumnViewerComparator.java   View source code 5 votes vote down vote up
@Override
public int compare(Viewer viewer, Object e1, Object e2) {

	if (viewer instanceof TableViewer) {
		IBaseLabelProvider baseLabel = ((TableViewer) viewer).getLabelProvider();

		String left = ((ITableLabelProvider) baseLabel).getColumnText(e1, fSortColumn);
		String right = ((ITableLabelProvider) baseLabel).getColumnText(e2, fSortColumn);
		int sortResult = getComparator().compare(left != null ? left : "", right != null ? right : "");
		return sortResult * fSortOrder;
	}

	return super.compare(viewer, e1, e2);
}
 
Example 10
Project: TranskribusSwtGui   File: DefaultTableColumnViewerSorter.java   View source code 5 votes vote down vote up
@Override protected int doCompare(Viewer viewer, Object e1, Object e2) {
	logger.trace("e1 = "+e1+" e2 = "+e2);
	
	String l1 = null, l2 = null;
	if (false) {
		ITableLabelProvider labelProvider = (ITableLabelProvider) ((TableViewer)viewer).getLabelProvider();
		l1 = labelProvider.getColumnText(e1, columnIndex);
		l2 = labelProvider.getColumnText(e2, columnIndex);
	} else {
		Table t = ((TableViewer)viewer).getTable();
		int r1 = getRowIndex(viewer, e1);
		int r2 = getRowIndex(viewer, e2);
		
		if (r1 != -1)
			l1 = t.getItem(r1).getText(columnIndex);
		if (r2 != -1)
			l2 = t.getItem(r2).getText(columnIndex);
	}
	
	if (l1 == null && l2 == null)
		return 0;
	else if (l1 == null && l2 != null)
		return -1;
	else if (l1 != null && l2 == null)
		return 1;

	try {
		int i1 = Integer.parseInt(l1);
		int i2 = Integer.parseInt(l2);
		return Integer.compare(i1, i2);
	} catch (NumberFormatException e) {
		return l1.compareTo(l2);	
	}
}
 
Example 11
Project: cppcheclipse   File: TableEditor.java   View source code 5 votes vote down vote up
/**
 * Overwrite this compare method if text comparison isn't what you need
 * @param TableViewer
 * @param e1
 * @param e2
 * @return
 */
protected int doCompare(Viewer TableViewer, Object e1, Object e2) {
	ITableLabelProvider lp = ((ITableLabelProvider) viewer
        .getLabelProvider());
        String t1 = lp.getColumnText(e1, index);
        String t2 = lp.getColumnText(e2, index);
        return t1.compareTo(t2);
}
 
Example 12
Project: depan   File: EdgeDisplayTableControl.java   View source code 5 votes vote down vote up
private ViewerComparator buildColumnSorter(int colIndex) {

    // By default, use an alphabetic sort over the column labels.
    ITableLabelProvider labelProvider =
        (ITableLabelProvider) propViewer.getLabelProvider();
    ViewerComparator result = new AlphabeticSorter(
        new LabelProviderToString(labelProvider, colIndex));
    return result;
  }
 
Example 13
Project: depan   File: RelationDisplayTableControl.java   View source code 5 votes vote down vote up
private ViewerComparator buildColumnSorter(int colIndex) {

    // By default, use an alphabetic sort over the column labels.
    ITableLabelProvider labelProvider =
        (ITableLabelProvider) propViewer.getLabelProvider();
    ViewerComparator result = new AlphabeticSorter(
        new LabelProviderToString(labelProvider, colIndex));
    return result;
  }
 
Example 14
Project: depan   File: RelationSetTableControl.java   View source code 5 votes vote down vote up
private ViewerComparator buildColumnSorter(int colIndex) {
  if (INDEX_VISIBLE == colIndex) {
    return new BooleanViewSorter();
  }

  // By default, use an alphabetic sort over the column labels.
  ITableLabelProvider labelProvider =
      (ITableLabelProvider) relSetViewer.getLabelProvider();
  ViewerComparator result = new AlphabeticSorter(
      new LabelProviderToString(labelProvider, colIndex));
  return result;
}
 
Example 15
Project: PDFReporter-Studio   File: TableFieldEditor.java   View source code 5 votes vote down vote up
public TableFieldEditor(String name, String labelText, Composite parent, IStructuredContentProvider contentProvider,
		ITableLabelProvider labelProvider, String[] columnHeaders, Object input) {
	this.contentProvider = contentProvider;
	this.labelProvider = labelProvider;
	this.columnHeaders = columnHeaders;
	this.input = input;
	this.init(name, labelText);
	this.createControl(parent);
}
 
Example 16
Project: mytourbook   File: LocalizeDialog.java   View source code 5 votes vote down vote up
public int compare(Viewer viewer, Object e1, Object e2) {
	if (viewer instanceof TableViewer) {
		TableViewer tableViewer = (TableViewer) viewer;
		IBaseLabelProvider baseLabel = tableViewer.getLabelProvider();
		if (baseLabel instanceof ITableLabelProvider) {
			ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
			String e1p = tableProvider.getColumnText(e1, sortColumn);
			String e2p = tableProvider.getColumnText(e2, sortColumn);
			int result = getComparator().compare(e1p, e2p);
			return ascending ?  result : (-1) * result;
		}
	}

	return super.compare(viewer, e1, e2);
}
 
Example 17
Project: translationstudio8   File: LanguageCodesPreferencePage.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) {
	IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider();
	if (baseLabel instanceof ITableLabelProvider) {
		ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
		String e1p = tableProvider.getColumnText(a, columnNumber);
		String e2p = tableProvider.getColumnText(b, columnNumber);
		if (e1p != null && e2p != null) {
			return getComparator().compare(e1p, e2p);
		}
	}
	return 0;
}
 
Example 18
Project: translationstudio8   File: KeysPreferencePage.java   View source code 5 votes vote down vote up
private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) {
	// if (columnNumber == CATEGORY_COLUMN) {
	// return sortUser(a, b);
	// }
	IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider();
	if (baseLabel instanceof ITableLabelProvider) {
		ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
		String e1p = tableProvider.getColumnText(a, columnNumber);
		String e2p = tableProvider.getColumnText(b, columnNumber);
		if (e1p != null && e2p != null) {
			return getComparator().compare(e1p, e2p);
		}
	}
	return 0;
}
 
Example 19
Project: tmxeditor8   File: KeysPreferencePage.java   View source code 5 votes vote down vote up
private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) {
	// if (columnNumber == CATEGORY_COLUMN) {
	// return sortUser(a, b);
	// }
	IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider();
	if (baseLabel instanceof ITableLabelProvider) {
		ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
		String e1p = tableProvider.getColumnText(a, columnNumber);
		String e2p = tableProvider.getColumnText(b, columnNumber);
		if (e1p != null && e2p != null) {
			return getComparator().compare(e1p, e2p);
		}
	}
	return 0;
}
 
Example 20
Project: tmxeditor8   File: KeysPreferencePage.java   View source code 5 votes vote down vote up
private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) {
	// if (columnNumber == CATEGORY_COLUMN) {
	// return sortUser(a, b);
	// }
	IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider();
	if (baseLabel instanceof ITableLabelProvider) {
		ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
		String e1p = tableProvider.getColumnText(a, columnNumber);
		String e2p = tableProvider.getColumnText(b, columnNumber);
		if (e1p != null && e2p != null) {
			return getComparator().compare(e1p, e2p);
		}
	}
	return 0;
}
 
Example 21
Project: tmxeditor8   File: LanguageCodesPreferencePage.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
private int compareColumn(final Viewer viewer, final Object a, final Object b, final int columnNumber) {
	IBaseLabelProvider baseLabel = ((TreeViewer) viewer).getLabelProvider();
	if (baseLabel instanceof ITableLabelProvider) {
		ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel;
		String e1p = tableProvider.getColumnText(a, columnNumber);
		String e2p = tableProvider.getColumnText(b, columnNumber);
		if (e1p != null && e2p != null) {
			return getComparator().compare(e1p, e2p);
		}
	}
	return 0;
}
 
Example 22
Project: olca-app   File: Viewers.java   View source code 5 votes vote down vote up
public static <T> void sortByDouble(ColumnViewer viewer, ITableLabelProvider labelProvider, int... cols) {
	for (int i = 0; i < cols.length; i++) {
		LabelSorter<T> s = new LabelSorter<>(cols[i], labelProvider);
		s.asNumbers = true;
		addSorter(viewer, s);
	}
}
 
Example 23
Project: team-explorer-everywhere   File: TableViewerSorter.java   View source code 4 votes vote down vote up
/**
 * Performs a default column-wise comparison of two elements. This method is
 * called after checking for any {@link Comparator} set through
 * {@link #setComparator(int, Comparator)}. Subclasses may override. The
 * base class implementation uses this sorter's {@link Collator} to compare
 * the column text for each element provided by the viewer's label provider.
 *
 * @param columnIndex
 *        the index of the column being sorted by
 * @param viewer
 *        the {@link Viewer} we are sorting for
 * @param e1
 *        the first element
 * @param e2
 *        the second element
 * @return a comparison value
 */
protected int defaultColumnCompare(final int columnIndex, final Viewer viewer, final Object e1, final Object e2) {
    final ITableLabelProvider labelProvider = (ITableLabelProvider) ((StructuredViewer) viewer).getLabelProvider();

    String s1 = labelProvider.getColumnText(e1, columnIndex);
    String s2 = labelProvider.getColumnText(e2, columnIndex);

    if (s1 == null) {
        s1 = ""; //$NON-NLS-1$
    }
    if (s2 == null) {
        s2 = ""; //$NON-NLS-1$
    }

    return getCollator().compare(s1, s2);
}
 
Example 24
Project: team-explorer-everywhere   File: SafeLabelProvider.java   View source code 4 votes vote down vote up
public TableLabelProviderWrapper(final ITableLabelProvider delegate) {
    super(delegate);
    this.delegate = delegate;
}
 
Example 25
Project: subclipse   File: MergeWizardAdvancedPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 26
Project: subclipse   File: MergeWizardStandardPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 27
Project: subclipse   File: BranchTagWizardRepositoryPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 28
Project: subclipse   File: SvnWizardCompareMultipleResourcesWithBranchTagPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 29
Project: subclipse   File: SvnWizardSwitchPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 30
Project: TranskribusSwtGui   File: APreviewListViewer.java   View source code 4 votes vote down vote up
public APreviewListViewer(Composite parent, int style, ColumnConfig[] columns, ITableLabelProvider labelProvider, boolean showUpDownBtns, boolean withCheckboxes, boolean renderOriginalImages) {
	this(parent, style, columns, labelProvider, showUpDownBtns, withCheckboxes, renderOriginalImages, true);
}
 
Example 31
Project: CARMA   File: SimulationWizard.java   View source code 4 votes vote down vote up
ITableLabelProvider getProvider() {
	return new MeasuresProvider();
}
 
Example 32
Project: depan   File: NodeStatsTableControl.java   View source code 4 votes vote down vote up
public ITableLabelProvider getLabelProvider() {
  return (ITableLabelProvider) getTreeViewer().getLabelProvider();
}
 
Example 33
Project: depan   File: LabelProviderToString.java   View source code 4 votes vote down vote up
/**
 * @param labelProvider
 * @param sortColumn
 */
public LabelProviderToString(
    ITableLabelProvider labelProvider, int sortColumn) {
  this.labelProvider = labelProvider;
  this.sortColumn = sortColumn;
}
 
Example 34
Project: depan   File: NodeDisplayTableControl.java   View source code 4 votes vote down vote up
public ITableLabelProvider getLabelProvider() {
  return (ITableLabelProvider) getTreeViewer().getLabelProvider();
}
 
Example 35
Project: APICloud-Studio   File: BranchTagWizardRepositoryPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 36
Project: APICloud-Studio   File: SvnWizardCompareMultipleResourcesWithBranchTagPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 37
Project: APICloud-Studio   File: SvnWizardSwitchPage.java   View source code 4 votes vote down vote up
public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
	super(provider, decorator);
	this.provider = (ITableLabelProvider) provider;
    this.decorator = decorator;
}
 
Example 38
Project: Eclipse-Postfix-Code-Completion   File: CodeAssistAdvancedConfigurationBlock.java   View source code 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 39
Project: emfstore-rest   File: ProjectTabContent.java   View source code 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ITableLabelProvider getLabelProvider() {
	return new ITableLabelProviderImplementation();
}
 
Example 40
Project: Eclipse-Postfix-Code-Completion-Juno38   File: CodeAssistAdvancedConfigurationBlock.java   View source code 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();
		}
	});

}