use of org.eclipse.swt.layout.RowData in project netxms by netxms.
the class InputFields method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
for (InputField f : objectTool.getInputFields()) fields.add(new InputField(f));
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.horizontalSpan = 2;
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT * 6;
viewer.getTable().setLayoutData(gd);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new InputFieldLabelProvider());
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((InputField) e1).getSequence() - ((InputField) e2).getSequence();
}
});
setupTableColumns();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
buttonEdit.setEnabled(selection.size() == 1);
buttonRemove.setEnabled(selection.size() > 0);
buttonUp.setEnabled(selection.size() == 1);
buttonDown.setEnabled(selection.size() == 1);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editField();
}
});
viewer.setInput(fields.toArray());
Composite buttonsLeft = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonsLeft.setLayout(buttonLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.LEFT;
gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
buttonsLeft.setLayoutData(gd);
buttonUp = new Button(buttonsLeft, SWT.PUSH);
buttonUp.setText(Messages.get().InputFields_Up);
buttonUp.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveFieldUp();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonUp.setLayoutData(rd);
buttonUp.setEnabled(false);
buttonDown = new Button(buttonsLeft, SWT.PUSH);
buttonDown.setText(Messages.get().InputFields_Down);
buttonDown.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveFieldDown();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonDown.setLayoutData(rd);
buttonDown.setEnabled(false);
Composite buttonsRight = new Composite(dialogArea, SWT.NONE);
buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonsRight.setLayout(buttonLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
buttonsRight.setLayoutData(gd);
buttonAdd = new Button(buttonsRight, SWT.PUSH);
buttonAdd.setText(Messages.get().Columns_Add);
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addField();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAdd.setLayoutData(rd);
buttonEdit = new Button(buttonsRight, SWT.PUSH);
buttonEdit.setText(Messages.get().Columns_Edit);
buttonEdit.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editField();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonEdit.setLayoutData(rd);
buttonEdit.setEnabled(false);
buttonRemove = new Button(buttonsRight, SWT.PUSH);
buttonRemove.setText(Messages.get().Columns_Delete);
buttonRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
removeField();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemove.setLayoutData(rd);
buttonRemove.setEnabled(false);
return dialogArea;
}
use of org.eclipse.swt.layout.RowData in project pmd-eclipse-plugin by pmd.
the class PMDPreferencePage2 method layoutControls.
/**
* Main layout
*
* @param parent
* Composite
*/
private void layoutControls(Composite parent) {
GridLayout layout = new GridLayout(1, false);
layout.verticalSpacing = 10;
parent.setLayout(layout);
Composite checkboxPanel = new Composite(parent, 0);
RowLayout checkboxPanelLayout = new RowLayout(SWT.VERTICAL);
checkboxPanelLayout.fill = true;
checkboxPanelLayout.pack = false;
checkboxPanel.setLayout(checkboxPanelLayout);
checkboxPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Button checkButton = new Button(checkboxPanel, SWT.CHECK);
globalRuleManagementCheckButton = checkButton;
final Composite contentPanel = new Composite(parent, 0);
contentPanel.setLayout(new FormLayout());
contentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
checkButton.setText(SWTUtil.stringFor(StringKeys.PREF_RULESET_BUTTON_GLOBALRULEMANAGEMENT));
checkButton.setSelection(preferences.getGlobalRuleManagement());
checkButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean sel = checkButton.getSelection();
SWTUtil.setEnabledRecursive(contentPanel.getChildren(), sel);
setModified();
}
});
Label explanation = new Label(checkboxPanel, SWT.WRAP);
RowData rowData = new RowData();
rowData.width = 450;
explanation.setLayoutData(rowData);
explanation.setText(SWTUtil.stringFor(StringKeys.PREF_RULESET_BUTTON_GLOBALRULEMANAGEMENT_EXPL));
// PreferenceUIStore.instance.tableFraction();
int ruleTableFraction = 55;
// Create the sash first, so the other controls can be attached to it.
final Sash sash = new Sash(contentPanel, SWT.HORIZONTAL);
FormData data = new FormData();
// attach to left
data.left = new FormAttachment(0, 0);
// attach to right
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(ruleTableFraction, 0);
sash.setLayoutData(data);
sash.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Re-attach to the top edge, and we use the y value of the
// event to determine the offset from the top
((FormData) sash.getLayoutData()).top = new FormAttachment(0, event.y);
// PreferenceUIStore.instance.tableFraction(event.y);
contentPanel.layout();
}
});
// Create the first text box and attach its bottom edge to the sash
Composite ruleSection = createRuleSection(contentPanel);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(sash, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
ruleSection.setLayoutData(data);
// Create the second text box and attach its top edge to the sash
TabFolder propertySection = buildTabFolder(contentPanel);
data = new FormData();
data.top = new FormAttachment(sash, 0);
data.bottom = new FormAttachment(100, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
propertySection.setLayoutData(data);
SWTUtil.setEnabledRecursive(contentPanel.getChildren(), checkButton.getSelection());
}
use of org.eclipse.swt.layout.RowData in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method createButton.
private void createButton(Composite container) {
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new RowLayout(SWT.VERTICAL));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
Button btnCreate = new Button(composite, SWT.NONE);
btnCreate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("CREATE");
EventUtil.logEvent(EventType.info, WEBAPP, OPEN_CREATEWEBAPP_DIALOG, buildProperties());
createAppService(project);
}
});
btnCreate.setText("Create...");
btnDelete = new Button(composite, SWT.NONE);
btnDelete.setEnabled(false);
btnDelete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("DELETE");
deleteAppService();
}
});
btnDelete.setText("Delete...");
Button btnRefresh = new Button(composite, SWT.NONE);
btnRefresh.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sendTelemetry("REFRESH");
EventUtil.executeWithLog(WEBAPP, REFRESH_METADATA, (operation) -> {
table.removeAll();
fillAppServiceDetails();
doFillTable(true);
});
}
});
btnRefresh.setText("Refresh");
btnDeployToRoot = new Button(composite, SWT.CHECK);
btnDeployToRoot.setSelection(true);
btnDeployToRoot.setText("Deploy to root");
int size = btnDeployToRoot.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
btnCreate.setLayoutData(new RowData(size, SWT.DEFAULT));
btnDelete.setLayoutData(new RowData(size, SWT.DEFAULT));
btnRefresh.setLayoutData(new RowData(size, SWT.DEFAULT));
btnDeployToRoot.setLayoutData(new RowData(size, SWT.DEFAULT));
}
use of org.eclipse.swt.layout.RowData in project yyl_example by Relucent.
the class MyRowLayout method main.
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
RowLayout rowLayout = new RowLayout();
rowLayout.marginTop = 10;
rowLayout.marginLeft = 5;
rowLayout.spacing = 2;
// true or false
rowLayout.wrap = true;
rowLayout.type = SWT.HORIZONTAL;
// # rowLayout.type = SWT.VERTICAL;
rowLayout.pack = true;
rowLayout.justify = false;
new Button(shell, SWT.NONE).setText("b1");
new Button(shell, SWT.NONE).setText("button2");
Button b = new Button(shell, SWT.NONE);
b.setText("btn3");
RowData rowData = new RowData(50, 50);
b.setLayoutData(rowData);
shell.setLayout(rowLayout);
shell.setText("RowLayout");
shell.setSize(200, 200);
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
use of org.eclipse.swt.layout.RowData in project dbeaver by serge-rider.
the class DataSourceManagementToolbar method createControl.
Control createControl(Composite parent) {
workbenchWindow.addPageListener(pageListener);
IWorkbenchPage activePage = workbenchWindow.getActivePage();
if (activePage != null) {
pageListener.pageOpened(activePage);
}
// Register as datasource listener in all datasources
// We need it because at this moment there could be come already loaded registries (on startup)
DataSourceProviderRegistry.getInstance().addDataSourceRegistryListener(DataSourceManagementToolbar.this);
for (DataSourceRegistry registry : DataSourceRegistry.getAllRegistries()) {
handleRegistryLoad(registry);
}
Composite comboGroup = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
layout.marginTop = 0;
layout.marginBottom = 0;
layout.marginWidth = 5;
layout.marginHeight = 0;
comboGroup.setLayout(layout);
final int fontHeight = UIUtils.getFontHeight(parent);
int comboWidth = fontHeight * 20;
connectionCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new ConnectionLabelProvider());
RowData rd = new RowData();
rd.width = comboWidth;
connectionCombo.setLayoutData(rd);
connectionCombo.setVisibleItemCount(15);
connectionCombo.setWidthHint(comboWidth);
connectionCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_datasource_tooltip);
connectionCombo.addItem(null);
connectionCombo.select(0);
connectionCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
changeDataSourceSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
connectionCombo.setTableFilter(new CSmartCombo.TableFilter<DBPDataSourceContainer>() {
boolean enabled = false;
@Override
public String getFilterLabel() {
return "Connected";
}
@Override
public String getDefaultLabel() {
return "All";
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public boolean setEnabled(boolean enabled) {
this.enabled = enabled;
return enabled;
}
@Override
public boolean filter(DBPDataSourceContainer item) {
return item != null && item.isConnected();
}
});
comboWidth = fontHeight * 16;
databaseCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new DatabaseLabelProvider());
rd = new RowData();
rd.width = comboWidth;
databaseCombo.setLayoutData(rd);
databaseCombo.setVisibleItemCount(15);
databaseCombo.setWidthHint(comboWidth);
databaseCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_database_tooltip);
databaseCombo.addItem(null);
databaseCombo.select(0);
databaseCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
changeDataBaseSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
resultSetSize = new Text(comboGroup, SWT.BORDER);
resultSetSize.setTextLimit(10);
rd = new RowData();
rd.width = fontHeight * 4;
resultSetSize.setLayoutData(rd);
resultSetSize.setToolTipText(CoreMessages.toolbar_datasource_selector_resultset_segment_size);
final DBPDataSourceContainer dataSourceContainer = getDataSourceContainer();
if (dataSourceContainer != null) {
resultSetSize.setText(String.valueOf(dataSourceContainer.getPreferenceStore().getInt(DBeaverPreferences.RESULT_SET_MAX_ROWS)));
}
//resultSetSize.setDigits(7);
resultSetSize.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
resultSetSize.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
changeResultSetSize();
}
});
comboGroup.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
DataSourceManagementToolbar.this.dispose();
}
});
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
setActivePart(workbenchWindow.getActivePage().getActivePart());
}
}
});
return comboGroup;
}
Aggregations