use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.
the class SourceListParameterPage method createContent.
/**
* @see HaleWizardPage#createContent(Composite)
*/
@Override
protected void createContent(Composite page) {
GridLayout layout = GridLayoutFactory.swtDefaults().create();
// Add margin to leave space for control decorations
layout.marginLeft = 5;
layout.marginRight = 5;
page.setLayout(layout);
// input field
textField = createAndLayoutTextField(page);
// let subclasses for example add validation
configure(textField);
addContentProposalProvider(projectVariablesProposalsProvider);
setText(textField, initialValue);
// variables
Label label = new Label(page, SWT.NONE);
label.setText("Available variables (double click to insert)");
label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).indent(4, 12).create());
// variables table
Composite tableComposite = new Composite(page, SWT.NONE);
tableComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 100).create());
TableColumnLayout columnLayout = new TableColumnLayout();
tableComposite.setLayout(columnLayout);
varTable = new TableViewer(tableComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
varTable.getTable().setHeaderVisible(true);
TableViewerColumn entityColumn = new TableViewerColumn(varTable, SWT.NONE);
columnLayout.setColumnData(entityColumn.getColumn(), new ColumnWeightData(2, true));
entityColumn.getColumn().setText("Entity");
varTable.setContentProvider(ArrayContentProvider.getInstance());
varTable.setLabelProvider(new StyledDefinitionLabelProvider(varTable) {
@Override
protected Object extractElement(Object element) {
if (element instanceof Entry) {
return ((Entry<?, ?>) element).getKey();
}
return super.extractElement(element);
}
});
varTable.getTable().addMouseListener(new MouseAdapter() {
/**
* @see MouseAdapter#mouseDoubleClick(MouseEvent)
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
ISelection sel = varTable.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof Entry) {
selected = ((Entry<?, ?>) selected).getValue();
}
insertTextAtCurrentPos(textField, selected.toString());
}
}
});
// variable name column
TableViewerColumn varColumn = new TableViewerColumn(varTable, SWT.NONE);
columnLayout.setColumnData(varColumn.getColumn(), new ColumnWeightData(1, true));
varColumn.getColumn().setText("Variable");
varColumn.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
if (element instanceof Entry) {
element = ((Entry<?, ?>) element).getValue();
}
cell.setText(element.toString());
}
});
}
use of org.eclipse.jface.layout.TableColumnLayout in project uiautomatorviewer by yangzaiCN.
the class UiAutomatorViewer method createContents.
/**
* Create contents of the application window.
*
* @param parent
*/
@Override
protected Control createContents(Composite parent) {
UiAutomatorModel.createInstance(this);
Composite basePane = new Composite(parent, SWT.NONE);
basePane.setLayout(new GridLayout(2, false));
mScreenshotCanvas = new Canvas(basePane, SWT.NONE);
mScreenshotCanvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
UiAutomatorModel.getModel().toggleExploreMode();
}
});
mScreenshotCanvas.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK));
mScreenshotCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
mScreenshotCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (mCachedScaleImage != null) {
// shifting the image here, so that there's a border around screen shot
// this makes highlighting red rectangles on the screen shot edges more visible
e.gc.drawImage(mCachedScaleImage, IMG_BORDER, IMG_BORDER);
Rectangle rect = UiAutomatorModel.getModel().getCurrentDrawingRect();
if (rect != null) {
e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_RED));
if (UiAutomatorModel.getModel().isExploreMode()) {
// when we highlight nodes dynamically on mouse move,
// use dashed borders
e.gc.setLineStyle(SWT.LINE_DASH);
e.gc.setLineWidth(1);
} else {
// when highlighting nodes on tree node selection,
// use solid borders
e.gc.setLineStyle(SWT.LINE_SOLID);
e.gc.setLineWidth(2);
}
e.gc.drawRectangle(IMG_BORDER + getScaledSize(rect.x), IMG_BORDER + getScaledSize(rect.y), getScaledSize(rect.width), getScaledSize(rect.height));
}
}
}
});
mScreenshotCanvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
if (UiAutomatorModel.getModel().isExploreMode()) {
UiAutomatorModel.getModel().updateSelectionForCoordinates(getInverseScaledSize(e.x - IMG_BORDER), getInverseScaledSize(e.y - IMG_BORDER));
}
}
});
mScreenshotCanvas.setBackgroundImage(ImageHelper.loadImageDescriptorFromResource("images/logo.png").createImage());
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
toolBarManager.add(mOpenFilesAction);
toolBarManager.add(mExpandAllAction);
toolBarManager.add(mScreenshotAction);
toolBarManager.createControl(basePane);
mTreeViewer = new TreeViewer(basePane, SWT.BORDER);
Tree tree = mTreeViewer.getTree();
GridData gd_Tree = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
gd_Tree.widthHint = 350;
tree.setLayoutData(gd_Tree);
mTreeViewer.setContentProvider(new BasicTreeNodeContentProvider());
// default LabelProvider uses toString() to generate text to display
mTreeViewer.setLabelProvider(new LabelProvider());
mTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSelection().isEmpty()) {
UiAutomatorModel.getModel().setSelectedNode(null);
} else if (event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object o = selection.toArray()[0];
if (o instanceof BasicTreeNode) {
UiAutomatorModel.getModel().setSelectedNode((BasicTreeNode) o);
}
}
}
});
// move focus so that it's not on tool bar (looks weird)
tree.setFocus();
Group grpNodeDetail = new Group(basePane, SWT.NONE);
grpNodeDetail.setLayout(new FillLayout(SWT.HORIZONTAL));
GridData gd_grpNodeDetail = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_grpNodeDetail.heightHint = FIXED_DETAIL_VIEW_HEIGHT;
gd_grpNodeDetail.minimumHeight = FIXED_DETAIL_VIEW_HEIGHT;
gd_grpNodeDetail.widthHint = FIXED_RHS_WIDTH;
gd_grpNodeDetail.minimumWidth = FIXED_RHS_WIDTH;
grpNodeDetail.setLayoutData(gd_grpNodeDetail);
grpNodeDetail.setText("Node Detail");
Composite tableContainer = new Composite(grpNodeDetail, SWT.NONE);
tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
TableColumnLayout columnLayout = new TableColumnLayout();
tableContainer.setLayout(columnLayout);
mTableViewer = new TableViewer(tableContainer, SWT.BORDER | SWT.FULL_SELECTION);
Table table = mTableViewer.getTable();
table.setLinesVisible(true);
// use ArrayContentProvider here, it assumes the input to the TableViewer
// is an array, where each element represents a row in the table
mTableViewer.setContentProvider(new ArrayContentProvider());
TableViewerColumn tableViewerColumnKey = new TableViewerColumn(mTableViewer, SWT.NONE);
TableColumn tblclmnKey = tableViewerColumnKey.getColumn();
tableViewerColumnKey.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof AttributePair) {
// first column, shows the attribute name
return ((AttributePair) element).key;
}
return super.getText(element);
}
});
columnLayout.setColumnData(tblclmnKey, new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
TableViewerColumn tableViewerColumnValue = new TableViewerColumn(mTableViewer, SWT.NONE);
tableViewerColumnValue.setEditingSupport(new AttributeTableEditingSupport(mTableViewer));
TableColumn tblclmnValue = tableViewerColumnValue.getColumn();
columnLayout.setColumnData(tblclmnValue, new ColumnWeightData(2, ColumnWeightData.MINIMUM_WIDTH, true));
tableViewerColumnValue.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof AttributePair) {
// second column, shows the attribute value
return ((AttributePair) element).value;
}
return super.getText(element);
}
});
return basePane;
}
use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.
the class DiagramFiguresPreferencePage method createContents.
@Override
public Composite createContents(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
loadFigures();
Composite client = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.marginWidth = layout.marginHeight = 0;
client.setLayout(layout);
GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
Composite tableClient = new Composite(client, SWT.NULL);
tableClient.setLayout(gridLayout);
tableClient.setLayoutData(new GridData(GridData.FILL_BOTH));
Label label = new Label(tableClient, SWT.NULL);
label.setText(Messages.DiagramFiguresPreferencePage_0);
Composite client2 = new Composite(tableClient, SWT.NULL);
client2.setLayout(new TableColumnLayout());
// Need this to stop it getting taller when the splitter is resized in the Prefs dialog
GridDataFactory.create(GridData.FILL_BOTH).hint(SWT.DEFAULT, 200).applyTo(client2);
createTable(client2);
fTableViewer.setInput(fChoices);
// Weird bug on Windows where the table and scroll bars are sometimes not drawn correctly
Display.getCurrent().asyncExec(() -> {
client2.layout();
});
return client;
}
use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.
the class P2PluginDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
setTitle(Messages.P2PluginDialog_1);
setMessage(Messages.P2PluginDialog_2);
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout(1, false));
Composite tableComp = new Composite(container, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
tableComp.setLayout(layout);
GridData gd = new GridData(GridData.FILL_BOTH);
tableComp.setLayoutData(gd);
viewer = new TableViewer(tableComp, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
// Mac Silicon Item height
UIUtils.fixMacSiliconItemHeight(viewer.getTable());
viewer.getTable().setHeaderVisible(true);
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
column.getColumn().setText(Messages.P2PluginDialog_3);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
column.getColumn().setText(Messages.P2PluginDialog_4);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
column.getColumn().setText(Messages.P2PluginDialog_5);
column = new TableViewerColumn(viewer, SWT.NONE);
layout.setColumnData(column.getColumn(), new ColumnWeightData(25, false));
column.getColumn().setText(Messages.P2PluginDialog_6);
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
try {
return P2Handler.getInstance().getInstalledFeatures().toArray();
} catch (ProvisionException ex) {
ex.printStackTrace();
}
return new Object[0];
}
});
class LabelCellProvider extends LabelProvider implements ITableLabelProvider {
@Override
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof IInstallableUnit) {
IInstallableUnit iu = (IInstallableUnit) element;
switch(columnIndex) {
case 0:
return iu.getProperty(IInstallableUnit.PROP_NAME, null);
case 1:
return iu.getVersion().toString();
case 2:
return iu.getId();
case 3:
return iu.getProperty(IInstallableUnit.PROP_PROVIDER, null);
default:
break;
}
}
return element.toString();
}
}
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
IInstallableUnit u1 = (IInstallableUnit) e1;
IInstallableUnit u2 = (IInstallableUnit) e2;
return u1.getProperty(IInstallableUnit.PROP_NAME, null).compareToIgnoreCase(u2.getProperty(IInstallableUnit.PROP_NAME, null));
}
});
viewer.setLabelProvider(new LabelCellProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
getButton(UNINSTALL).setEnabled(!event.getSelection().isEmpty());
}
});
// anything will do //$NON-NLS-1$
viewer.setInput("");
return area;
}
use of org.eclipse.jface.layout.TableColumnLayout in project archi by archimatetool.
the class TemplateManagerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getHelpID());
setTitle(Messages.TemplateManagerDialog_2);
setMessage(Messages.TemplateManagerDialog_3);
Composite composite = (Composite) super.createDialogArea(parent);
Composite client = new Composite(composite, SWT.NULL);
GridLayout layout = new GridLayout(2, false);
client.setLayout(layout);
client.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new SashForm(client, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 580;
gd.heightHint = 300;
sash.setLayoutData(gd);
// Templates Table
Composite tableComp = new Composite(sash, SWT.BORDER);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
tableComp.setLayout(layout);
CLabel label = new CLabel(tableComp, SWT.NULL);
label.setText(Messages.TemplateManagerDialog_4);
Composite tableComp2 = new Composite(tableComp, SWT.NULL);
tableComp2.setLayout(new TableColumnLayout());
tableComp2.setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer = new TemplatesTableViewer(tableComp2, SWT.MULTI);
fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTableViewer.setInput(fTemplateManager.getUserTemplates());
fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
fSelectedControl = fTableViewer;
updateControls(o);
}
});
// Groups Tree
Composite treeComp = new Composite(sash, SWT.BORDER);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
treeComp.setLayout(layout);
label = new CLabel(treeComp, SWT.NULL);
label.setText(Messages.TemplateManagerDialog_5);
// label.setImage(IArchiImages.ImageFactory.getImage(ImageFactory.ECLIPSE_IMAGE_FOLDER));
fTreeViewer = new TemplatesTreeViewer(treeComp, SWT.MULTI);
fTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
fTreeViewer.setInput(fTemplateManager.getUserTemplateGroups());
fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
fSelectedControl = fTreeViewer;
updateControls(o);
}
});
new TemplateManagerDialogDragDropHandler(fTableViewer, fTreeViewer);
// Buttons
Composite buttonBar = new Composite(client, SWT.NULL);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
buttonBar.setLayout(layout);
buttonBar.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
fButtonAddTemplate = new Button(buttonBar, SWT.NULL);
fButtonAddTemplate.setText(Messages.TemplateManagerDialog_6);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonAddTemplate.setLayoutData(gd);
fButtonAddTemplate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
openTemplate();
}
});
fButtonNewGroup = new Button(buttonBar, SWT.NULL);
fButtonNewGroup.setText(Messages.TemplateManagerDialog_7);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonNewGroup.setLayoutData(gd);
fButtonNewGroup.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
newGroup();
}
});
fButtonRemove = new Button(buttonBar, SWT.NULL);
fButtonRemove.setText(Messages.TemplateManagerDialog_8);
gd = new GridData(GridData.FILL_HORIZONTAL);
fButtonRemove.setLayoutData(gd);
fButtonRemove.setEnabled(false);
fButtonRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteSelectedObjects();
}
});
sash.setWeights(new int[] { 30, 70 });
Composite fieldContainer = new Composite(composite, SWT.NULL);
layout = new GridLayout(2, false);
fieldContainer.setLayout(layout);
fieldContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameLabel = new Label(fieldContainer, SWT.NULL);
fNameLabel.setText(Messages.TemplateManagerDialog_9);
fNameLabel.setEnabled(false);
fNameTextField = UIUtils.createSingleTextControl(fieldContainer, SWT.BORDER, false);
fNameTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameTextField.setEnabled(false);
fNameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = fNameTextField.getText();
if (fIsSettingFields || !StringUtils.isSet(text)) {
return;
}
// Edit Template name
if (fSelectedTemplate != null) {
fSelectedTemplate.setName(text);
if (!fModifiedTemplates.contains(fSelectedTemplate)) {
fModifiedTemplates.add(fSelectedTemplate);
}
fTableViewer.refresh();
fTreeViewer.refresh();
} else // Edit Group name
if (fSelectedTemplateGroup != null) {
fSelectedTemplateGroup.setName(text);
fTreeViewer.refresh();
}
}
});
fDescriptionLabel = new Label(fieldContainer, SWT.NULL);
fDescriptionLabel.setText(Messages.TemplateManagerDialog_10);
fDescriptionLabel.setEnabled(false);
fDescriptionTextField = new Text(fieldContainer, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
fDescriptionTextField.setEnabled(false);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 100;
fDescriptionTextField.setLayoutData(gd);
fDescriptionTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = fDescriptionTextField.getText();
if (fIsSettingFields || !StringUtils.isSet(text)) {
return;
}
if (fSelectedTemplate != null) {
fSelectedTemplate.setDescription(fDescriptionTextField.getText());
if (!fModifiedTemplates.contains(fSelectedTemplate)) {
fModifiedTemplates.add(fSelectedTemplate);
}
}
}
});
fFileLabel = new Label(fieldContainer, SWT.NULL);
fFileLabel.setText(Messages.TemplateManagerDialog_11);
fFileLabel.setEnabled(false);
fFileTextField = new Text(fieldContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
fFileTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fFileTextField.setEnabled(false);
return composite;
}
Aggregations