use of org.eclipse.jface.layout.TableColumnLayout in project jbosstools-openshift by jbosstools.
the class PortForwardingWizardPage method createTable.
protected TableViewer createTable(Composite tableContainer, DataBindingContext dbc) {
Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumnLayout tableLayout = new TableColumnLayout();
tableContainer.setLayout(tableLayout);
TableViewer viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
createTableColumn("Name", 1, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement();
cell.setText(StringUtils.defaultIfBlank(port.getName(), ""));
}
}, viewer, tableLayout);
createTableColumn("Local Port", 2, new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement();
int local = port.getLocalPort();
if (wizardModel.getPortForwarding() || !PortForwardingUtils.isPortInUse(local)) {
cell.setText(Integer.toString(local));
cell.setStyleRanges(new StyleRange[0]);
} else {
String text = Integer.toString(local) + " (in use)";
StyledString styledString = new StyledString();
styledString.append(text, usedPortStyler);
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
}
super.update(cell);
}
}, viewer, tableLayout);
createTableColumn("Remote Port", 2, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement();
cell.setText(Integer.toString(port.getRemotePort()));
}
}, viewer, tableLayout);
createTableColumn("Status", 1, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
final boolean started = wizardModel.getPortForwarding();
cell.setText(started ? "Started" : "Stopped");
}
}, viewer, tableLayout);
IObservableValue forwardablePortsModelObservable = BeanProperties.value(PortForwardingWizardModel.PROPERTY_FORWARDABLE_PORTS).observe(wizardModel);
final ForwardablePortListValidator validator = new ForwardablePortListValidator(forwardablePortsModelObservable);
dbc.addValidationStatusProvider(validator);
viewer.setInput(wizardModel.getForwardablePorts());
//
return viewer;
}
use of org.eclipse.jface.layout.TableColumnLayout in project archi-modelrepository-plugin by archi-contribs.
the class ConflictsDialog method createTableControl.
private void createTableControl(Composite parent) {
Composite tableComp = new Composite(parent, SWT.BORDER);
TableColumnLayout tableLayout = new TableColumnLayout();
tableComp.setLayout(tableLayout);
tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
Table table = new Table(tableComp, SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
table.setHeaderVisible(true);
fTableViewer = new CheckboxTableViewer(table);
fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer.getTable().setLinesVisible(true);
fTableViewer.setComparator(new ViewerComparator());
// Columns
TableViewerColumn column1 = new TableViewerColumn(fTableViewer, SWT.NONE, 0);
column1.getColumn().setText(Messages.ConflictsDialog_5);
tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(100, true));
// Content Provider
fTableViewer.setContentProvider(new IStructuredContentProvider() {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public void dispose() {
}
public Object[] getElements(Object inputElement) {
MergeResult result = fHandler.getMergeResult();
return result.getConflicts().keySet().toArray();
}
});
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
String path = (String) ((StructuredSelection) event.getSelection()).getFirstElement();
try {
fFileViewerOurs.setText(fHandler.getArchiRepository().getFileContents(path, IGraficoConstants.HEAD));
fFileViewerTheirs.setText(fHandler.getArchiRepository().getFileContents(path, IGraficoConstants.ORIGIN_MASTER));
fFileViewerDiff.setText(fHandler.getArchiRepository().getWorkingTreeFileContents(path));
} catch (IOException ex) {
ex.printStackTrace();
}
}
});
// Label Provider
fTableViewer.setLabelProvider(new LabelProvider());
// Start the table
// anything will do //$NON-NLS-1$
fTableViewer.setInput("");
}
use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.
the class FileValidateTarget method createControls.
@Override
public void createControls(Composite parent) {
super.createControls(parent);
// page has a 3-column grid layout
Group validatorGroup = new Group(parent, SWT.NONE);
validatorGroup.setText("Validation");
validatorGroup.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).span(3, 1).indent(8, 10).create());
validatorGroup.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).margins(10, 8).create());
// Add project validator by default
IOProviderDescriptor pvDescriptor = HaleIO.findIOProviderFactory(IOProvider.class, getWizard().getContentType(), ProjectValidator.PROVIDER_ID);
if (pvDescriptor != null) {
ProjectValidator projectValidator = new ProjectValidator();
List<? extends Locatable> schemas = getWizard().getProvider().getValidationSchemas();
projectValidator.setSchemas(schemas.toArray(new Locatable[schemas.size()]));
ValidatorEntry entry = new ValidatorEntry(projectValidator, pvDescriptor);
validators.add(entry);
getWizard().addValidator(projectValidator);
}
// viewer with validator list
Composite tableContainer = new Composite(validatorGroup, SWT.NONE);
tableContainer.setLayoutData(GridDataFactory.swtDefaults().span(3, 1).minSize(100, 100).align(SWT.FILL, SWT.FILL).grab(true, true).create());
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
validatorsTableViewer = new TableViewer(tableContainer, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
validatorsTableViewer.getTable().setLinesVisible(true);
validatorsTableViewer.getTable().setHeaderVisible(true);
validatorsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
validatorsTableViewer.setInput(validators);
TableViewerColumn typeColumn = new TableViewerColumn(validatorsTableViewer, SWT.NONE);
layout.setColumnData(typeColumn.getColumn(), new ColumnWeightData(4));
typeColumn.getColumn().setText("Validator");
typeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ValidatorEntry validator = (ValidatorEntry) element;
return validator.getDescriptor().getDisplayName();
}
/**
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
ValidatorEntry validator = (ValidatorEntry) element;
if (validator.getStatusMessage() != null && !validator.getStatusMessage().isEmpty()) {
return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_DEC_FIELD_ERROR);
}
return null;
}
});
TableViewerColumn errorColumn = new TableViewerColumn(validatorsTableViewer, SWT.NONE);
layout.setColumnData(errorColumn.getColumn(), new ColumnWeightData(3));
errorColumn.getColumn().setText("Status");
errorColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ValidatorEntry validator = (ValidatorEntry) element;
String message = validator.getStatusMessage();
if (message == null || message.trim().isEmpty()) {
message = "OK";
}
return message;
}
});
validatorsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateWizard(getSelectedValidator(event.getSelection()));
}
});
// Selection dialog for adding validators to the list
final ValidatorSelectionDialog validatorSelectionDialog = new ValidatorSelectionDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
addValidatorButton = new Button(validatorGroup, SWT.PUSH);
addValidatorButton.setText("Add validator...");
addValidatorButton.setEnabled(false);
addValidatorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
validatorSelectionDialog.create();
validatorSelectionDialog.setContentType(getWizard().getContentType());
if (validatorSelectionDialog.open() == Dialog.OK) {
IOProviderDescriptor selection = validatorSelectionDialog.getSelection();
addValidator(selection);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
// Remove button
removeValidatorButton = new Button(validatorGroup, SWT.PUSH);
removeValidatorButton.setText("Remove validator...");
removeValidatorButton.setEnabled(false);
removeValidatorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
ValidatorEntry selection = getSelectedValidator();
getWizard().removeValidator(selection.getValidator());
validators.remove(selection);
updateWizard(getSelectedValidator());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
// Configure button
configureValidatorButton = new Button(validatorGroup, SWT.PUSH);
configureValidatorButton.setText("Configure validator...");
configureValidatorButton.setEnabled(false);
getWizard().addIOWizardListener(this);
}
use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.
the class AbstractFunctionTableSection method createControls.
/**
* @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
* org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
*/
@Override
@SuppressWarnings("unchecked")
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
Composite compparent = getWidgetFactory().createComposite(parent);
compparent.setLayout(new FormLayout());
Composite composite = getWidgetFactory().createComposite(compparent);
TableColumnLayout columnLayout = new TableColumnLayout();
composite.setLayout(columnLayout);
FormData data = new FormData();
data.width = 100;
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, -0);
data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
composite.setLayoutData(data);
tableViewer = new TableViewer(composite, SWT.FULL_SELECTION);
Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
TableViewerColumn nameviewercol = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn namecol = nameviewercol.getColumn();
columnLayout.setColumnData(namecol, new ColumnWeightData(20));
namecol.setText("Name");
nameviewercol.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((P) cell.getElement()).getName());
}
});
TableViewerColumn lableviewercol = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn lablecol = lableviewercol.getColumn();
columnLayout.setColumnData(lablecol, new ColumnWeightData(20));
lablecol.setText("Lable");
lableviewercol.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(((P) cell.getElement()).getDisplayName());
}
});
TableViewerColumn occurenceviewercol = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn occurencecol = occurenceviewercol.getColumn();
columnLayout.setColumnData(occurencecol, new ColumnWeightData(20));
occurencecol.setText("Occurence");
occurenceviewercol.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
P cellparameter = ((P) cell.getElement());
cell.setText(String.valueOf(cellparameter.getMinOccurrence()) + ".." + (String.valueOf(cellparameter.getMaxOccurrence())));
}
});
TableViewerColumn descriptionviewercol = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn descriptioncol = descriptionviewercol.getColumn();
columnLayout.setColumnData(descriptioncol, new ColumnWeightData(20));
descriptioncol.setText("Description");
descriptionviewercol.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
cell.setText(String.valueOf(((P) cell.getElement()).getDescription()));
}
});
}
use of org.eclipse.jface.layout.TableColumnLayout in project eclipse-pmd by acanda.
the class AddRuleSetConfigurationWizardPage method createControl.
@Override
public void createControl(final Composite parent) {
final Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(3, false));
final Label lblLocation = new Label(container, SWT.NONE);
lblLocation.setText("Location:");
location = new Text(container, SWT.BORDER);
location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
SWTBotID.set(location, SWTBotID.LOCATION);
browse = new Button(container, SWT.NONE);
browse.setText("Browse...");
SWTBotID.set(browse, SWTBotID.BROWSE);
browse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
controller.browse(((Control) e.widget).getShell());
}
});
final Label lblName = new Label(container, SWT.NONE);
lblName.setText("Name:");
name = new Text(container, SWT.BORDER);
name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
SWTBotID.set(name, SWTBotID.NAME);
// This button is only here to make this row the same height as the previous row.
// Without this button the distance between the text of this row and the text of
// the previous row is much larger than the distance between the text of this row
// and the table of the next row.
final Button button = new Button(container, SWT.NONE);
button.setEnabled(false);
button.setVisible(false);
final Label lblRules = new Label(container, SWT.NONE);
final GridData lblRulesGridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
lblRulesGridData.verticalIndent = 3;
lblRules.setLayoutData(lblRulesGridData);
lblRules.setText("Rules:");
final Composite tableComposite = new Composite(container, SWT.NONE);
tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final TableColumnLayout tableCompositeTableColumnLayout = new TableColumnLayout();
tableComposite.setLayout(tableCompositeTableColumnLayout);
tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
final Table table = tableViewer.getTable();
table.setLinesVisible(true);
SWTBotID.set(table, SWTBotID.RULES);
final TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
final TableColumn tblclmnName = tableViewerColumn.getColumn();
tableCompositeTableColumnLayout.setColumnData(tblclmnName, new ColumnWeightData(1, 200, false));
tblclmnName.setText("Name");
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
initDataBindings();
}
Aggregations