use of org.eclipse.jface.viewers.CheckStateChangedEvent in project osate2 by osate.
the class WSPage method createControl.
@Override
public void createControl(Composite parent) {
comp = new Composite(parent, SWT.BORDER);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
comp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_BOTH);
comp.setLayoutData(gd);
setControl(comp);
tv = CheckboxTableViewer.newCheckList(comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
IStructuredContentProvider contentProvider = createContentProvider();
tv.setContentProvider(contentProvider);
tv.setLabelProvider(new WorkingSetLabelProvider());
tv.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tv.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
selectionChanged();
}
});
setInput(contentProvider.getElements(null));
Composite fileSelectCom = new Composite(comp, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
fileSelectCom.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
fileSelectCom.setLayoutData(gd);
IPreferenceStore store = OsateUiPlugin.getDefault().getPreferenceStore();
String lastUsedFile = store.getString(LAST_USED_WS_FILE);
usedFiles.add(lastUsedFile);
dest = new Combo(fileSelectCom, SWT.DROP_DOWN);
dest.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
updateItems(lastUsedFile);
dest.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validateInput();
}
});
Button chooserBtn = new Button(fileSelectCom, SWT.NONE);
chooserBtn.setText("Browse...");
chooserBtn.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// ignored
}
@Override
public void widgetSelected(SelectionEvent e) {
updateItems(getFileFromUser());
validateInput();
}
});
validateInput();
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project spotbugs by spotbugs.
the class GroupSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
int columns = 2;
composite.setLayout(new GridLayout(columns, false));
GridData layoutData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_HORIZONTAL);
layoutData.minimumHeight = 200;
layoutData.minimumWidth = 250;
layoutData.heightHint = 200;
layoutData.widthHint = 250;
composite.setLayoutData(layoutData);
checkList = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER | SWT.RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
Table table = checkList.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(false);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
TableColumn nameColumn = new TableColumn(table, SWT.NONE);
nameColumn.setText("Group Visibility / Sort Order");
nameColumn.setResizable(true);
nameColumn.setWidth(170);
checkList.setContentProvider(new ArrayContentProvider());
// ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
// checkList.setLabelProvider(labelProvider);
checkList.setInput(allowedGroups);
checkList.setCheckedElements(preSelectedGroups.toArray());
checkList.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
GroupType element = (GroupType) event.getElement();
selectionMap.put(element, Boolean.valueOf(checked));
}
});
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleTableSelection();
}
});
createButtonList(composite);
return composite;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-jst by jbosstools.
the class EditPreprocessingList method createControl.
public Control createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
File root = projectTemplate.getLocation();
ArrayList input = new ArrayList();
input.add(root);
selectionGroup = new CustomCheckboxTreeAndListGroup(composite, input, new ResourceContentProvider(ResourceContentProvider.FOLDER), new ResourceLabelProvider(), new ResourceContentProvider(ResourceContentProvider.FILE), new ResourceLabelProvider(), SWT.NONE, SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT);
composite.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
TableColumn[] columns = selectionGroup.getListTable().getColumns();
for (int i = 0; i < columns.length; i++) {
columns[i].pack();
}
}
});
selectionGroup.setTreeChecked(root, false);
Iterator excluded = getIncludedResources().iterator();
while (excluded.hasNext()) {
File o = (File) excluded.next();
if (o.isDirectory()) {
selectionGroup.setTreeChecked(o, true);
} else if (o.isFile()) {
selectionGroup.initialCheckListItem((File) o);
}
}
selectionGroup.setExpansions();
selectionGroup.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
validate();
}
});
return composite;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-base by jbosstools.
the class RuntimePreferencePage method createDetectorViewer.
private TableViewer createDetectorViewer(Composite parent) {
final CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
Table table = tableViewer.getTable();
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 150;
table.setLayoutData(gd);
table.setHeaderVisible(true);
table.setLinesVisible(true);
String[] columnNames = new String[] { Messages.RuntimePreferencePage_Type, Messages.RuntimePreferencePage_Link };
for (int i = 0; i < columnNames.length; i++) {
TableColumn tc = new TableColumn(table, SWT.LEFT);
tc.setText(columnNames[i]);
}
ColumnLayoutData[] layouts = { new ColumnWeightData(300, 300), new ColumnWeightData(100, 50) };
TableLayout layout = new TableLayout();
for (int i = 0; i < layouts.length; i++) {
layout.addColumnData(layouts[i]);
}
table.setLayout(layout);
tableViewer.setLabelProvider(new RuntimeDetectorLabelProvider());
tableViewer.setContentProvider(new RuntimeDetectorContentProvider(runtimeDetectors));
tableViewer.setInput(runtimeDetectors);
for (IRuntimeDetector detector : runtimeDetectors) {
tableViewer.setChecked(detector, detector.isEnabled());
}
tableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
IRuntimeDetector detector = (IRuntimeDetector) event.getElement();
if (detector.isValid()) {
detector.setEnabled(!detector.isEnabled());
} else {
MessageDialog.openWarning(getShell(), Messages.RuntimePreferencePage_Information, NLS.bind(Messages.RuntimePreferencePage_Detector_is_invalid, detector.getName()));
tableViewer.setChecked(detector, false);
}
}
});
for (int i = 0; i < runtimeDetectors.size(); i++) {
TableItem item = table.getItem(i);
Object data = item.getData();
if (data instanceof IRuntimeDetector) {
IRuntimeDetector detector = (IRuntimeDetector) data;
final String preferenceId = detector.getPreferenceId();
final String prefName = detector.getName();
if (preferenceId != null && preferenceId.trim().length() > 0) {
Link link = new Link(table, SWT.NONE);
link.setText(Messages.RuntimePreferencePage_A_Link_a);
link.setEnabled(detector.isValid());
TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor(link, item, 1);
link.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
boolean switchPage = true;
if (isDirty)
switchPage = MessageDialog.open(MessageDialog.QUESTION, getShell(), NLS.bind(Messages.RuntimePreferencePage_Open_preferences, prefName), NLS.bind(Messages.RuntimePreferencePage_You_have_unsaved_changes, prefName), SWT.NONE);
if (switchPage) {
if (isDirty) {
performOk();
RuntimeWorkbenchUtils.refreshPreferencePageUIThread(getShell(), preferenceId);
} else {
PreferencesUtil.createPreferenceDialogOn(getShell(), preferenceId, null, null);
}
}
}
});
}
}
}
return tableViewer;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-base by jbosstools.
the class EditRuntimePathDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.EditRuntimePathDialog_Edit_runtime_detection_path);
Composite area = (Composite) super.createDialogArea(parent);
Composite contents = new Composite(area, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 400;
gd.widthHint = 700;
contents.setLayoutData(gd);
contents.setLayout(new GridLayout(1, false));
applyDialogFont(contents);
initializeDialogUnits(area);
Composite pathComposite = new Composite(contents, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
pathComposite.setLayoutData(gd);
pathComposite.setLayout(new GridLayout(3, false));
Label pathLabel = new Label(pathComposite, SWT.NONE);
pathLabel.setText(Messages.EditRuntimePathDialog_Path);
final Text pathText = new Text(pathComposite, SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
pathText.setLayoutData(gd);
pathText.setText(runtimePath.getPath());
Button browseButton = new Button(pathComposite, SWT.NONE);
browseButton.setText(Messages.EditRuntimePathDialog_Browse);
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IDialogSettings dialogSettings = RuntimeUIActivator.getDefault().getDialogSettings();
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setMessage(Messages.EditRuntimePathDialog_Edit_Path);
dialog.setFilterPath(pathText.getText());
final String path = dialog.open();
if (path == null) {
return;
}
runtimePath.setPath(path);
dialogSettings.put(JBossRuntimePreferencesInitializer.LASTPATH, path);
pathText.setText(path);
refreshRuntimes(getShell(), new RuntimePath[] { runtimePath }, treeViewer, false);
}
});
Label refreshLabel = new Label(pathComposite, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.horizontalSpan = 2;
refreshLabel.setLayoutData(gd);
refreshLabel.setText(Messages.EditRuntimePathDialog_Runtimes_found_at_this_path);
final Button refreshButton = new Button(pathComposite, SWT.NONE);
refreshButton.setText(Messages.EditRuntimePathDialog_Refresh);
refreshButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
refreshRuntimes(getShell(), new RuntimePath[] { runtimePath }, treeViewer, false);
}
});
pathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
runtimePath.setPath(pathText.getText());
if (!pathText.getText().isEmpty()) {
refreshButton.setEnabled((new File(pathText.getText()).isDirectory()));
}
}
});
refreshButton.setEnabled((new File(pathText.getText()).isDirectory()));
treeViewer = createRuntimeViewer(new RuntimePath[] { runtimePath }, contents, 100);
treeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
RuntimeDefinition definition = (RuntimeDefinition) event.getElement();
definition.setEnabled(!definition.isEnabled());
}
});
return area;
}
Aggregations