Java Code Examples for org.eclipse.jface.viewers.CheckboxTableViewer#setLabelProvider()

The following examples show how to use org.eclipse.jface.viewers.CheckboxTableViewer#setLabelProvider() . 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: ConfigureWorkingSetAssignementAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected CheckboxTableViewer createTableViewer(Composite parent) {

			final CheckboxTableViewer result= CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.MULTI);
			result.addCheckStateListener(new ICheckStateListener() {
				public void checkStateChanged(CheckStateChangedEvent event) {
					GrayedCheckedModelElement element= (GrayedCheckedModelElement)event.getElement();
					result.setGrayed(element, false);
					if (event.getChecked()) {
						element.select();
					} else {
						element.deselect();
					}
					result.update(element, null);
				}
			});
			GridData data= new GridData(GridData.FILL_BOTH);
			data.heightHint= convertHeightInCharsToPixels(20);
			data.widthHint= convertWidthInCharsToPixels(50);
			result.getTable().setLayoutData(data);

			result.addFilter(new Filter());
			result.setLabelProvider(new GrayedCheckedModelLabelProvider());
			result.setSorter(new GrayedCheckModelElementSorter());
			result.setContentProvider(new GrayedCheckedModelContentProvider());

			result.setInput(fModel);
			result.setCheckedElements(fModel.getChecked());
			result.setGrayedElements(fModel.getGrayed());

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

    Group composite = new Group(parent, SWT.NONE);
    composite.setText(Messages.FileSetEditDialog_titlePatternsTable);
    composite.setLayout(new FormLayout());

    final Composite buttons = new Composite(composite, SWT.NULL);
    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 3);
    fd.right = new FormAttachment(100, -3);
    fd.bottom = new FormAttachment(100, -3);

    buttons.setLayoutData(fd);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);

    final Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION);
    fd = new FormData();
    fd.left = new FormAttachment(0, 3);
    fd.top = new FormAttachment(0, 3);
    fd.right = new FormAttachment(buttons, -3, SWT.LEFT);
    fd.bottom = new FormAttachment(100, -3);
    table.setLayoutData(fd);

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

    TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.FileSetEditDialog_colInclude);

    tableLayout.addColumnData(new ColumnWeightData(11));

    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.FileSetEditDialog_colRegex);
    tableLayout.addColumnData(new ColumnWeightData(89));

    mPatternViewer = new CheckboxTableViewer(table);

    mPatternViewer.setLabelProvider(new FileMatchPatternLabelProvider());
    mPatternViewer.setContentProvider(new ArrayContentProvider());
    mPatternViewer.addDoubleClickListener(mController);
    mPatternViewer.addCheckStateListener(mController);

    //
    // Build the buttons.
    //

    mAddButton = createPushButton(buttons, Messages.FileSetEditDialog_btnAdd);
    mAddButton.addSelectionListener(mController);

    mEditButton = createPushButton(buttons, Messages.FileSetEditDialog_btnEdit);
    mEditButton.addSelectionListener(mController);

    mRemoveButton = createPushButton(buttons, Messages.FileSetEditDialog_btnRemove);
    mRemoveButton.addSelectionListener(mController);

    mUpButton = createPushButton(buttons, Messages.FileSetEditDialog_btnUp);
    mUpButton.addSelectionListener(mController);

    mDownButton = createPushButton(buttons, Messages.FileSetEditDialog_btnDown);
    mDownButton.addSelectionListener(mController);

    return composite;
  }
 
Example 3
Source File: ContentAssistPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * createUserAgentTable
 * 
 * @param parent
 */
protected void createUserAgentTable(Composite parent)
{
	Label label = new Label(parent, SWT.WRAP);
	label.setText(Messages.UserAgentPreferencePage_Select_User_Agents);
	label.setLayoutData(GridDataFactory.fillDefaults().span(2, 0).grab(true, true).create());

	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(GridLayoutFactory.fillDefaults().create());
	composite.setLayoutData(GridDataFactory.fillDefaults().span(2, 0).hint(400, 120).grab(true, true).create());

	Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE);
	table.setFont(parent.getFont());

	categoryViewer = new CheckboxTableViewer(table);
	categoryViewer.getControl().setFont(parent.getFont());
	categoryViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
	categoryViewer.setContentProvider(ArrayContentProvider.getInstance());

	CategoryLabelProvider categoryLabelProvider = new CategoryLabelProvider(true);
	categoryViewer.setLabelProvider(categoryLabelProvider);
	categoryViewer.setComparator(new ViewerComparator()
	{
		@Override
		public int compare(Viewer viewer, Object e1, Object e2)
		{
			if (e1 instanceof IUserAgent && e2 instanceof IUserAgent)
			{
				IUserAgent ua1 = (IUserAgent) e1;
				IUserAgent ua2 = (IUserAgent) e2;

				String uaName1 = StringUtil.getStringValue(ua1.getName());
				String uaName2 = StringUtil.getStringValue(ua2.getName());

				return uaName1.compareToIgnoreCase(uaName2);
			}

			return super.compare(viewer, e1, e2);
		}
	});

	categoryViewer.setInput(UserAgentManager.getInstance().getAllUserAgents());
}
 
Example 4
Source File: ShowSummaryFieldDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createSummaryFiledViewer( Composite dialogArea )
{
	Table table = new Table( dialogArea, SWT.BORDER
			| SWT.SINGLE
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.FULL_SELECTION
			| SWT.CHECK );
	table.setLinesVisible( true );
	table.setHeaderVisible( true );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.heightHint = 250;
	table.setLayoutData( gd );

	summaryFieldViewer = new CheckboxTableViewer( table );
	SummaryFieldProvider provider = new SummaryFieldProvider( );

	for ( int i = 0; i < columnNames.length; i++ )
	{
		TableColumn column = new TableColumn( table, SWT.LEFT );
		column.setText( columnNames[i] );
		column.setWidth( columnWidth[i] );
	}
	ComboBoxCellEditor comboCell = new ComboBoxCellEditor( table,
			new String[0],
			SWT.READ_ONLY );
	// TextCellEditor textCell = new TextCellEditor(table, SWT.NONE);
	cellEditor = new CellEditor[]{
			null, comboCell
	};
	summaryFieldViewer.setColumnProperties( columnNames );
	summaryFieldViewer.setCellEditors( cellEditor );
	summaryFieldViewer.setCellModifier( cellModifier );
	summaryFieldViewer.setUseHashlookup( true );
	summaryFieldViewer.setContentProvider( provider );
	summaryFieldViewer.setLabelProvider( provider );

	summaryFieldViewer.addCheckStateListener( new ICheckStateListener( ) {

		public void checkStateChanged( CheckStateChangedEvent event )
		{
			MeasureInfo info = (MeasureInfo) event.getElement( );
			if ( event.getChecked( ) )
			{
				info.setShow( true );
			}
			else
			{
				info.setShow( false );
			}
			checkOKButtonStatus( );
		}

	} );
}
 
Example 5
Source File: AggregationDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createGrandTotalArea( Composite content )
{
	CLabel grandTotalLabel = new CLabel( content, SWT.NONE );

	grandTotalLabel.setText( Messages.getString( "AggregationDialog.Label.Grand" ) ); //$NON-NLS-1$
	if ( axis == ICrosstabConstants.ROW_AXIS_TYPE )
	{
		grandTotalLabel.setImage( CrosstabUIHelper.getImage( CrosstabUIHelper.ROW_GRAND_TOTAL_IMAGE ) );
	}
	else if ( axis == ICrosstabConstants.COLUMN_AXIS_TYPE )
	{
		grandTotalLabel.setImage( CrosstabUIHelper.getImage( CrosstabUIHelper.COLUMN_GRAND_TOTAL_IMAGE ) );
	}

	Table table = new Table( content, SWT.SINGLE
			| SWT.BORDER
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.FULL_SELECTION
			| SWT.CHECK );
	table.setLinesVisible( false );
	table.setHeaderVisible( true );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.minimumHeight = 200;
	table.setLayoutData( gd );

	grandTableViewer = new CheckboxTableViewer( table );
	GrandTotalProvider provider = new GrandTotalProvider( grandTableViewer,crosstab, axis );

	String[] columnNames = provider.getColumnNames( );
	int[] columnWidths = provider.columnWidths( );
	for ( int i = 0; i < columnNames.length; i++ )
	{
		TableColumn column = new TableColumn( table, SWT.LEFT );
		column.setText( columnNames[i] );
		column.setWidth( columnWidths[i] );
	}

	grandTableViewer.setUseHashlookup( true );
	grandTableViewer.setColumnProperties( provider.getColumnNames( ) );
	grandTableViewer.setCellEditors( provider.getCellEditors( ) );
	grandTableViewer.setCellModifier( provider );
	grandTableViewer.setCellEditors( provider.getCellEditors() );
	grandTableViewer.setContentProvider( provider );
	grandTableViewer.setLabelProvider( provider );
	grandTableViewer.setCellModifier( provider );

}
 
Example 6
Source File: AggregationDialog.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void createSubTotalArea( Composite content )
{
	CLabel subTotalLabel = new CLabel( content, SWT.NONE );
	subTotalLabel.setText( Messages.getString( "AggregationDialog.Label.Sub" ) ); //$NON-NLS-1$
	if ( axis == ICrosstabConstants.ROW_AXIS_TYPE )
	{
		subTotalLabel.setImage( CrosstabUIHelper.getImage( CrosstabUIHelper.ROW_SUB_TOTAL_IMAGE ) );
	}
	else if ( axis == ICrosstabConstants.COLUMN_AXIS_TYPE )
	{
		subTotalLabel.setImage( CrosstabUIHelper.getImage( CrosstabUIHelper.COLUMN_SUB_TOTAL_IMAGE ) );
	}

	Table table = new Table( content, SWT.SINGLE
			| SWT.BORDER
			| SWT.H_SCROLL
			| SWT.V_SCROLL
			| SWT.FULL_SELECTION
			| SWT.CHECK );
	table.setLinesVisible( false );
	table.setHeaderVisible( true );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.minimumHeight = 200;
	table.setLayoutData( gd );

	subTableViewer = new CheckboxTableViewer( table );
	SubTotalProvider provider = new SubTotalProvider( subTableViewer,crosstab,axis );

	String[] columnNames = provider.getColumnNames( );
	int[] columnWidths = provider.columnWidths( );
	for ( int i = 0; i < columnNames.length; i++ )
	{
		TableColumn column = new TableColumn( table, SWT.LEFT );
		column.setText( columnNames[i] );
		column.setWidth( columnWidths[i] );
	}

	subTableViewer.setUseHashlookup( true );
	subTableViewer.setColumnProperties( provider.getColumnNames( ) );
	subTableViewer.setCellEditors( provider.getCellEditors( ) );
	subTableViewer.setContentProvider( provider );
	subTableViewer.setLabelProvider( provider );
	subTableViewer.setCellModifier( provider );

}