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

The following examples show how to use org.eclipse.jface.viewers.CheckboxTableViewer#newCheckList() . 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: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createConstraintEditionViewer(Composite parent) {
    constraintEditionViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
    constraintEditionViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    constraintEditionViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, CONSTRAINT_EDITION_VIEWER_ID);
    formPage.getToolkit().adapt(constraintEditionViewer.getTable(), true, true);

    constraintEditionViewer.setContentProvider(new ObservableListContentProvider());
    constraintEditionViewer.setLabelProvider(new LabelProviderBuilder<Field>()
            .withStyledStringProvider(fieldStyleStringProvider)
            .createStyledCellLabelProvider());
    constraintEditionViewer.addFilter(new IndexableFieldFilter());
    constraintEditionViewer.setInput(actualsFieldsObservable);

    selectedAttributeObservable = ViewerProperties.singleSelection(Field.class).observe(constraintEditionViewer);
    constraintEditionViewer.addCheckStateListener(
            new ConstraintAttributeCheckListener(selectedConstraintObservable, selectedAttributeObservable,
                    formPage, constraintViewer));
}
 
Example 2
Source File: CheckedCamelDependenciesPanel.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
protected TableViewer createTableViewer() {
    final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(this, SWT.MULTI | SWT.H_SCROLL
        | SWT.V_SCROLL | SWT.BORDER);
    viewer.setCheckStateProvider(checkStateProvider);
    viewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (((ManifestItem) event.getElement()).isBuiltIn()) {
                viewer.setChecked(event.getElement(), !event.getChecked());
            } else {
                ((ManifestItem) event.getElement()).setOptional(!event.getChecked());
                fireDependenciesChangedListener();
            }
        }
    });
    return viewer;
}
 
Example 3
Source File: InvoiceCorrectionWizard.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent){
	container = new Composite(parent, SWT.NONE);
	container.setLayout(new GridLayout(1, false));
	
	Composite tableComp = new Composite(container, SWT.NONE);
	tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer = CheckboxTableViewer.newCheckList(tableComp,
		SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	viewer.getTable().setLinesVisible(true);
	viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setInput(invoiceCorrectionDTO.getHistory());
	viewer.addCheckStateListener(new ICheckStateListener() {
		
		@Override
		public void checkStateChanged(CheckStateChangedEvent event){
			viewer.setChecked(event.getElement(), !event.getChecked());
		}
	});
	viewer.setLabelProvider(new WizardLabelProvider());
	
	TableColumn singleColumn = new TableColumn(viewer.getTable(), SWT.NONE);
	TableColumnLayout tableColumnLayout = new TableColumnLayout();
	tableColumnLayout.setColumnData(singleColumn, new ColumnWeightData(100));
	tableComp.setLayout(tableColumnLayout);
	
	
	Label lblOutput = new Label(container, SWT.NONE);
	lblOutput.setText("Ausgabe");
	GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.heightHint = 100;
	txtOutput =
		new Text(container,
		SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
	txtOutput.setLayoutData(gd);
	setControl(container);
	setPageComplete(!invoiceCorrectionDTO.getHistory().isEmpty());
}
 
Example 4
Source File: SelectUserMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    super.createControl(parent);

    final Composite mainComposite = (Composite) getControl();
    final Composite viewersComposite = new Composite(mainComposite, SWT.NONE);
    viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).span(2, 1).hint(SWT.DEFAULT, 250).create());
    viewersComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).extendedMargins(0, 0, 10, 0).create());

    availableUserViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION);
    availableUserViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    availableUserViewer.getTable().setHeaderVisible(true);
    availableUserViewer.setContentProvider(new ArrayContentProvider());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100));
    availableUserViewer.getTable().setLayout(layout);

    final TableViewerColumn columnViewer = new TableViewerColumn(availableUserViewer, SWT.NONE);
    final TableColumn usernameColumn = columnViewer.getColumn();
    usernameColumn.setText(Messages.userName);
    columnViewer.setLabelProvider(new ColumnLabelProvider());
    final TableColumnSorter sorter = new TableColumnSorter(availableUserViewer);
    sorter.setColumn(usernameColumn);

    availableUserViewer.setInput(availableUsers);
    availableUserViewer.setCheckedElements(selectedUsers.toArray());

}
 
Example 5
Source File: PyListSelectionDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    // page group
    Composite composite = (Composite) super.createDialogArea(parent);

    initializeDialogUnits(composite);

    createMessageArea(composite);

    listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    listViewer.getTable().setLayoutData(data);

    listViewer.setLabelProvider(labelProvider);
    listViewer.setContentProvider(contentProvider);

    addSelectionButtons(composite);

    initializeViewer();

    // initialize page
    if (!getInitialElementSelections().isEmpty()) {
        checkInitialSelections();
    }

    Dialog.applyDialogFont(composite);

    return composite;
}
 
Example 6
Source File: MOOSETreePropertySection.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the table that displays properties for viewing and editing.
 * 
 * @param client
 *            The client <code>Composite</code> that should contain the
 *            table of properties.
 * @return The <code>TableViewer</code> for the table of properties.
 */
@Override
protected TableViewer createTableViewer(Composite client) {

	CheckboxTableViewer tableViewer = null;

	if (client != null) {
		Table table;

		// Create the TableViewer and the underlying Table Control.
		tableViewer = CheckboxTableViewer.newCheckList(client,
				SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
		// Set some properties for the table.
		table = tableViewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		// Set up the content provider for the table viewer. Now the table
		// viewer's input can be set.
		tableViewer.setContentProvider(new TreePropertyContentProvider());

		// Enable tool tips for the Table's cells.
		ColumnViewerToolTipSupport.enableFor(tableViewer,
				ToolTip.NO_RECREATE);

		// Populate the TableViewer with its columns.
		addTableViewerColumns(tableViewer);
	}

	return tableViewer;
}
 
Example 7
Source File: AddToVersionControlDialog.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void addUnaddedResourcesArea(Composite composite) {
	
	// add a description label
	createWrappingLabel(composite, Policy.bind("ReleaseCommentDialog.unaddedResources")); //$NON-NLS-1$

	// add the selectable checkbox list
	listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
	GridData data = new GridData(GridData.FILL_BOTH);
	data.heightHint = SELECTION_HEIGHT_HINT;
	data.widthHint = WIDTH_HINT;
	listViewer.getTable().setLayoutData(data);

	// set the contents of the list
	listViewer.setLabelProvider(new WorkbenchLabelProvider() {
		protected String decorateText(String input, Object element) {
			if (element instanceof IResource)
				return ((IResource)element).getFullPath().toString();
			else
				return input;
		}
	});
	listViewer.setContentProvider(new WorkbenchContentProvider());
	listViewer.setInput(new AdaptableResourceList(unaddedResources));
	if (resourcesToAdd == null) {
		listViewer.setAllChecked(true);
	} else {
		listViewer.setCheckedElements(resourcesToAdd);
	}
	listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			resourcesToAdd = listViewer.getCheckedElements();
		}
	});
	
	addSelectionButtons(composite);
}
 
Example 8
Source File: WebSearchPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private Composite createTableArea(Composite parent) {
	Composite tableArea = new Composite(parent, SWT.NONE);
	GridLayout gridLayout = new GridLayout(1, false);
	gridLayout.marginWidth = 0;
	tableArea.setLayout(gridLayout);
	GridData gridData = new GridData(GridData.FILL_BOTH);
	tableArea.setLayoutData(gridData);
	checkboxTableViewer = CheckboxTableViewer.newCheckList(tableArea, SWT.BORDER | SWT.FULL_SELECTION);
	table = checkboxTableViewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(false);
	TableLayout tableLayout = new TableLayout();
	tableLayout.addColumnData(new ColumnPixelData(40));
	tableLayout.addColumnData(new ColumnWeightData(50, 50, true));
	tableLayout.addColumnData(new ColumnWeightData(70, 50, true));
	table.setLayout(tableLayout);
	GridData tableGridData = new GridData(GridData.FILL_BOTH);
	table.setLayoutData(tableGridData);
	WebSearchLableProvider webSearchLableProvider = new WebSearchLableProvider();
	webSearchLableProvider.createColumns(checkboxTableViewer);
	checkboxTableViewer.setContentProvider(new WebSearchContentProvider());
	checkboxTableViewer.setLabelProvider(webSearchLableProvider);
	checkboxTableViewer.setCheckStateProvider(new CheckProvider());
	checkboxTableViewer.addCheckStateListener(new CheckListener());
	// checkboxTableViewer.setCellEditors(new CellEditor[] { null, new TextCellEditor(table),
	// new TextCellEditor(table) });
	// checkboxTableViewer.setCellModifier(new NameModifier());
	checkboxTableViewer.setColumnProperties(new String[] { APP_PROP, NAME_PROP, URL_PROP });
	cache = WebSearchPreferencStore.getIns().getSearchConfig();
	checkboxTableViewer.setInput((Object) cache);
	return tableArea;
}
 
Example 9
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 10
Source File: SelectRoleMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(final Composite parent) {
    super.createControl(parent);

    final Composite mainComposite = (Composite) getControl();
    final Composite viewersComposite = new Composite(mainComposite, SWT.NONE);
    viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create());
    viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create());

    availableRoleViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    availableRoleViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    availableRoleViewer.getTable().setHeaderVisible(true);
    availableRoleViewer.setContentProvider(new ArrayContentProvider());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100));
    availableRoleViewer.getTable().setLayout(layout);

    final TableViewerColumn columnViewer = new TableViewerColumn(availableRoleViewer, SWT.NONE);
    final TableColumn usernameColumn = columnViewer.getColumn();
    usernameColumn.setText(Messages.roleName);
    columnViewer.setLabelProvider(new ColumnLabelProvider());
    final TableColumnSorter sorter = new TableColumnSorter(availableRoleViewer);
    sorter.setColumn(usernameColumn);

    availableRoleViewer.setInput(availableRoles);
    availableRoleViewer.setCheckedElements(selectedRoles.toArray());

}
 
Example 11
Source File: ManageConnectorJarDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void createTree(Composite composite) {
	final Text searchText = new Text(composite,SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL) ;
	searchText.setMessage(Messages.search) ;
	searchText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ;

	searchFilter = new ViewerFilter() {

		@Override
		public boolean select(Viewer arg0, Object arg1, Object element) {
			if(!searchText.getText().isEmpty()){
				String searchQuery = searchText.getText().toLowerCase() ;
				IRepositoryFileStore file = (IRepositoryFileStore) element ;
				return file.getName().toLowerCase().contains(searchQuery) ;
			}
			return true;
		}
	};

	//new Label(composite,SWT.NONE) ; //FILLER

	languageViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL) ;
	languageViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 190).create()) ;
	languageViewer.getTable().setLinesVisible(true) ;
	languageViewer.getTable().setHeaderVisible(false) ;
	final TableLayout layout = new TableLayout() ;
	layout.addColumnData(new ColumnWeightData(65)) ;
	languageViewer.getTable().setLayout(layout) ;
	languageViewer.setContentProvider(new ArrayContentProvider()) ;
	languageViewer.setLabelProvider(new FileStoreLabelProvider()) ;
	languageViewer.addFilter(searchFilter) ;
	if(filter != null){
		languageViewer.addFilter(filter);
	}
	languageViewer.setInput(libStore.getChildren()) ;
	languageViewer.getTable().setFocus() ;


	searchText.addModifyListener(new ModifyListener() {

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

}
 
Example 12
Source File: LockStatusDialog.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent){
	setMessage("Overview on the locks currently held by this Elexis instance");
	setTitle("Lock Status");
	Composite area = (Composite) super.createDialogArea(parent);
	Composite container = new Composite(area, SWT.NONE);
	container.setLayout(new GridLayout(1, false));
	container.setLayoutData(new GridData(GridData.FILL_BOTH));
	
	checkboxTableViewer =
		CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.FULL_SELECTION);
	Table table = checkboxTableViewer.getTable();
	table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	checkboxTableViewer.setContentProvider(ArrayContentProvider.getInstance());
	checkboxTableViewer.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element){
			LockInfo li = (LockInfo) element;
			PersistentObject po =
				CoreHub.poFactory.createFromString(li.getElementStoreToString());
			return li.getElementType() + ": " + po.getLabel();
		}
	});
	checkboxTableViewer.setInput(LocalLockServiceHolder.get().getCopyOfAllHeldLocks());
	
	Label lblSystemUuid = new Label(container, SWT.NONE);
	lblSystemUuid.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblSystemUuid.setText("System UUID: " + LocalLockServiceHolder.get().getSystemUuid());
	
	Label lblLockStatus = new Label(container, SWT.NONE);
	Status status = LocalLockServiceHolder.get().getStatus();
	StringBuilder statusString = new StringBuilder();
	statusString.append("Lock-Service: " + status.name());
	if (status != Status.STANDALONE) {
		statusString.append(" @ " + System
			.getProperty(ElexisSystemPropertyConstants.ELEXIS_SERVER_REST_INTERFACE_URL));
	}
	lblLockStatus.setText(statusString.toString());
	
	return area;
}
 
Example 13
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 14
Source File: CodeAssistAdvancedConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void createDefaultViewer(Composite composite, int h_span) {
	fDefaultViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
	Table table= fDefaultViewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(false);
	table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, h_span, 1));

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

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

	fDefaultViewer.setContentProvider(new ArrayContentProvider());

	DefaultTableLabelProvider labelProvider= new DefaultTableLabelProvider();
	fDefaultViewer.setLabelProvider(labelProvider);
	fDefaultViewer.setInput(fModel.elements);
	fDefaultViewer.setComparator(new ViewerComparator()); // sort alphabetically

	final int ICON_AND_CHECKBOX_WITH= 50;
	final int HEADER_MARGIN= 20;
	int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
	int minKeyWidth= computeWidth(table, keyColumn.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);
		minKeyWidth= Math.max(minKeyWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 1)));
	}

	nameColumn.setWidth(minNameWidth);
	keyColumn.setWidth(minKeyWidth);
}
 
Example 15
Source File: SpellingPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Control createContents(Composite parent)
{
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(GridLayoutFactory.swtDefaults().create());
	composite.setLayoutData(GridDataFactory.fillDefaults().create());

	globalPreferencesLink = new Link(composite, SWT.NONE);
	globalPreferencesLink.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).create());

	Label label = new Label(composite, SWT.NONE);
	label.setText(StringUtil.makeFormLabel(Messages.SpellingPreferencePage_label));
	label.setLayoutData(GridDataFactory.swtDefaults().indent(SWT.DEFAULT, 5).align(SWT.FILL, SWT.CENTER).create());

	tableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
	tableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider()
	{
		@Override
		public String getText(Object element)
		{
			return ScopeDefinitions.DEFINITIONS.get(element);
		}
	});
	tableViewer.setInput(ScopeDefinitions.DEFINITIONS.keySet());
	tableViewer.setCheckedElements(SpellingPreferences.getEnabledScopes().toArray());

	globalPreferencesLink.addSelectionListener(new SelectionAdapter()
	{
		@Override
		public void widgetSelected(SelectionEvent e)
		{
			((IWorkbenchPreferenceContainer) getContainer()).openPage(GENERAL_SPELLING_PREF_ID, null);
		}
	});

	applyDialogFont(composite);
	updateStatus();
	return composite;
}
 
Example 16
Source File: PyConfigureExceptionDialog.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    // page group
    Composite composite = (Composite) super.createDialogArea(parent);

    initializeDialogUnits(composite);

    createMessageArea(composite);

    listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
    data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
    listViewer.getTable().setLayoutData(data);

    listViewer.setLabelProvider(labelProvider);
    listViewer.setContentProvider(contentProvider);

    createSelectionButtons(composite);

    initContent();
    // initialize page
    if (!getInitialElementSelections().isEmpty()) {
        checkInitialSelections();
    }

    Dialog.applyDialogFont(composite);

    getViewer().addFilter(new ViewerFilter() {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (getCheckBoxTableViewer().getChecked(element)) {
                addToSelectedElements(element);
            }
            return matchExceptionToShowInList(element);
        }
    });

    getCheckBoxTableViewer().addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                addToSelectedElements(event.getElement());
            } else {
                removeFromSelectedElements(event.getElement());
            }
        }
    });

    createCustomExceptionUI(composite);
    createDealingWithExceptionsOptions(composite);

    return composite;
}
 
Example 17
Source File: ProjectNaturesPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Control createContents(Composite parent)
{
	Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new GridLayout());
	composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	fProject = (IProject) getElement().getAdapter(IResource.class);
	try
	{
		if (fProject.isOpen())
		{
			// Can only access decription if project exists and is open...
			fCurrentProjectNatures = fProject.getDescription().getNatureIds();
		}
		else
		{
			fCurrentProjectNatures = new String[0];
		}
	}
	catch (CoreException e)
	{
		IdeLog.logError(UIEplPlugin.getDefault(), EplMessages.ProjectNaturesPage_ERR_RetrieveNatures, e);
		fCurrentProjectNatures = new String[0];
	}
	fLabelProvider = new NaturesLabelProvider(fNatureDescriptions);

	// assumes the first one in the array is the primary nature
	fInitialPrimaryNature = fCurrentProjectNatures.length == 0 ? null : fCurrentProjectNatures[0];
	updatePrimaryNature(fInitialPrimaryNature);

	setDescription(MessageFormat.format(EplMessages.ProjectNaturesPage_Description, fProject.getName()));
	Label description = createDescriptionLabel(composite);
	description.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

	Composite tableComposite = new Composite(composite, SWT.NONE);
	tableComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
	tableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	fTableViewer = CheckboxTableViewer.newCheckList(tableComposite, SWT.TOP | SWT.BORDER);
	Table table = fTableViewer.getTable();
	table.setLinesVisible(true);
	table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

	TableColumn column = new TableColumn(table, SWT.LEFT);
	column.setWidth(350);

	fTableViewer.setContentProvider(getContentProvider());
	fTableViewer.setLabelProvider(getLabelProvider());
	fTableViewer.setComparator(getViewerComperator());
	fTableViewer.setInput(fProject.getWorkspace());
	if (!fProject.isAccessible())
	{
		fTableViewer.getControl().setEnabled(false);
	}
	fTableViewer.setCheckedElements(fCurrentProjectNatures);
	fTableViewer.addCheckStateListener(this);
	fTableViewer.addSelectionChangedListener(new ISelectionChangedListener()
	{
		public void selectionChanged(SelectionChangedEvent event)
		{
			updateButtons();
		}
	});
	fInitialCheckedItems = fTableViewer.getCheckedElements();
	table.setMenu(createMenu(table));

	// Add the buttons
	Composite buttons = new Composite(tableComposite, SWT.NONE);
	buttons.setLayout(GridLayoutFactory.fillDefaults().create());
	buttons.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
	fMakePrimaryButton = createButton(EplMessages.ProjectNaturesPage_LBL_MakePrimary, buttons);
	updateButtons();

	noDefaultAndApplyButton();

	return composite;
}
 
Example 18
Source File: SelectGroupMappingWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
  public void createControl(Composite parent) {
      super.createControl(parent) ;

      final Composite mainComposite = (Composite) getControl();
      final Composite viewersComposite = new Composite(mainComposite, SWT.NONE) ;
      viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT,250).create()) ;
      viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create()) ;

      availableGroupViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL) ;
      availableGroupViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
      availableGroupViewer.getTable().setHeaderVisible(true) ;
      availableGroupViewer.setContentProvider(new ArrayContentProvider()) ;
      final TableLayout layout = new TableLayout() ;
      layout.addColumnData(new ColumnWeightData(100));
      availableGroupViewer.getTable().setLayout(layout) ;

      final TableViewerColumn columnViewer = new TableViewerColumn(availableGroupViewer, SWT.NONE) ;
      final TableColumn usernameColumn = columnViewer.getColumn() ;
      usernameColumn.setText(Messages.groupName);
      columnViewer.setLabelProvider(new ColumnLabelProvider());
      final TableColumnSorter sorter = new TableColumnSorter(availableGroupViewer) ;
      sorter.setColumn(usernameColumn) ;

      availableGroupViewer.setInput(availableGroups) ;
      availableGroupViewer.setCheckedElements(selectedGroups.toArray());
      
      context = new DataBindingContext();

      final IObservableSet checkedElementsObservable =  ViewersObservables.observeCheckedElements(availableGroupViewer, String.class) ;
      final MultiValidator notEmptyValidator = new MultiValidator() {

      	@Override
          protected IStatus validate() {
		if(groupSelectionIsValid(checkedElementsObservable)){
			return ValidationStatus.ok();
		}
		return ValidationStatus.error(Messages.errorSelectionGroups);
	}
      }  ;

      context.addValidationStatusProvider(notEmptyValidator);
context.bindSet(checkedElementsObservable, PojoObservables.observeSet(this, "selectedGroups"));

WizardPageSupport.create(this, context);
setControl(mainComposite);
  }
 
Example 19
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 20
Source File: SWTUtil.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a checkbox table viewer. Implements hacks for fixing OSX bugs.
 * @param parent
 * @param style
 * @return
 */
public static CheckboxTableViewer createTableViewerCheckbox(Composite container, int style) {
    CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(container, style);
    fixOSXTableBug(viewer.getTable());
    return viewer;
}