use of org.eclipse.swt.layout.RowData in project cubrid-manager by CUBRID.
the class DatabaseSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite newComp = new Composite(parentComp, SWT.NONE);
GridLayout dialogShellLayout = new GridLayout();
dialogShellLayout.makeColumnsEqualWidth = true;
newComp.setLayout(dialogShellLayout);
GridData compData = new GridData();
compData.grabExcessHorizontalSpace = true;
compData.grabExcessVerticalSpace = true;
compData.verticalAlignment = GridData.FILL;
compData.horizontalAlignment = GridData.FILL;
newComp.setLayoutData(compData);
try {
{
GridData dbTreeLData = new GridData();
dbTreeLData.grabExcessHorizontalSpace = true;
dbTreeLData.grabExcessVerticalSpace = true;
dbTreeLData.verticalAlignment = GridData.FILL;
dbTreeLData.horizontalAlignment = GridData.FILL;
dbTree = new Tree(newComp, SWT.BORDER | SWT.LINE_SOLID | SWT.MULTI | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL);
dbTree.setLayoutData(dbTreeLData);
}
{
buttonComp = new Composite(newComp, SWT.NONE);
RowLayout buttonCompLayout = new RowLayout(org.eclipse.swt.SWT.HORIZONTAL);
GridData buttonCompLData = new GridData();
buttonComp.setLayoutData(buttonCompLData);
buttonComp.setLayout(buttonCompLayout);
{
btnSelectAll = new Button(buttonComp, SWT.PUSH | SWT.CENTER);
RowData btnSelectAllLData = new RowData();
btnSelectAll.setLayoutData(btnSelectAllLData);
btnSelectAll.setText(Messages.lblSelectAll);
btnSelectAll.addSelectionListener(this);
btnSelectAll.setData(KEY_ID, TYPE.SELECT);
btnSelectAll.setData(KEY_VALUE, true);
btnSelectAll.setVisible(false);
}
{
btnUnSelectAll = new Button(buttonComp, SWT.PUSH | SWT.CENTER);
RowData btnUnSelectAllLData = new RowData();
btnUnSelectAll.setLayoutData(btnUnSelectAllLData);
btnUnSelectAll.setText(Messages.lblDeSelectAll);
// btnUnSelectAll.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
btnUnSelectAll.addSelectionListener(this);
btnUnSelectAll.setData(KEY_ID, TYPE.SELECT);
btnUnSelectAll.setData(KEY_VALUE, false);
btnUnSelectAll.setVisible(false);
}
{
btnExpandAll = new Button(buttonComp, SWT.PUSH | SWT.CENTER);
RowData btnExpandAllLData = new RowData();
btnExpandAll.setLayoutData(btnExpandAllLData);
btnExpandAll.setText(Messages.lblExpandAll);
btnExpandAll.addSelectionListener(this);
btnExpandAll.setData(KEY_ID, TYPE.EXPAND);
btnExpandAll.setData(KEY_VALUE, true);
btnExpandAll.setVisible(false);
}
{
btnUnExpandAll = new Button(buttonComp, SWT.PUSH | SWT.CENTER);
RowData btnUnExpandAllLData = new RowData();
btnUnExpandAll.setLayoutData(btnUnExpandAllLData);
btnUnExpandAll.setText(Messages.lblUnExpandAll);
// btnUnExpandAll.setImage(CommonUIPlugin.getImage("icons/action/collapseall.gif"));
btnUnExpandAll.addSelectionListener(this);
btnUnExpandAll.setData(KEY_ID, TYPE.EXPAND);
btnUnExpandAll.setData(KEY_VALUE, false);
btnUnExpandAll.setVisible(false);
}
}
} catch (Exception e) {
e.printStackTrace();
}
dbTree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem item = (TreeItem) e.item;
boolean checked = item.getChecked();
checkItems(item.getItems(), checked);
if (item.getParentItem() != null) {
if (checked)
item.getParentItem().setChecked(checked);
checkParentChecked(item.getParentItem(), checked);
}
}
private void checkItems(TreeItem[] items, boolean value) {
if (items == null || items.length == 0)
return;
for (TreeItem item : items) {
item.setChecked(value);
}
}
private void checkParentChecked(TreeItem pitem, boolean value) {
TreeItem[] items = pitem.getItems();
for (TreeItem item : items) {
if (item.getChecked() == value) {
continue;
} else {
return;
}
}
pitem.setChecked(value);
}
});
initTreeData();
if (this.lastSelectedDbs != null)
initSelection(this.lastSelectedDbs);
return parentComp;
}
use of org.eclipse.swt.layout.RowData in project translationstudio8 by heartsome.
the class LicenseManageDialog method createStatusComp.
private void createStatusComp(Composite parent) {
Group statusGroup = new Group(parent, SWT.NONE);
statusGroup.setText(Messages.getString("license.LicenseManageDialog.statusGroup"));
GridData dataStatusGroup = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
dataStatusGroup.heightHint = 150;
statusGroup.setLayoutData(dataStatusGroup);
statusGroup.setLayout(new GridLayout());
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
RowLayout layout = new RowLayout();
layout.center = true;
Composite comp0 = new Composite(statusGroup, SWT.NONE);
comp0.setLayoutData(data);
comp0.setLayout(layout);
Label statusLbl = new Label(comp0, SWT.NONE);
statusLbl.setText(Messages.getString("license.LicenseManageDialog.statusLabel"));
if (type == Constants.STATE_NOT_ACTIVATED) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.notActiveLabel"));
} else if (type == Constants.STATE_VALID) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.activeLabel"));
new Label(comp0, SWT.NONE).setLayoutData(new RowData(30, SWT.DEFAULT));
Button btnCancelActive = new Button(comp0, SWT.NONE);
btnCancelActive.setText(Messages.getString("license.LicenseManageDialog.cancelActiveButton"));
btnCancelActive.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean result = MessageDialog.openConfirm(getShell(), Messages.getString("license.LicenseManageDialog.confirm"), Messages.getString("license.LicenseManageDialog.confirmMessage"));
if (result) {
try {
int re = ServiceUtil.cancel();
if (re == Constants.LOGOUT_SUCCESS) {
MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveSuccess"));
LicenseManageDialog.this.close();
PlatformUI.getWorkbench().restart();
} else {
MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.notice"), Messages.getString("license.LicenseManageDialog.unactiveFail"));
}
} catch (Exception e1) {
e1.printStackTrace();
Throwable t = e1;
while (t.getCause() != null) {
t = t.getCause();
}
if (t instanceof java.security.cert.CertificateException) {
MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING16));
} else {
MessageDialog.openInformation(getShell(), Messages.getString("license.LicenseManageDialog.titleNet"), MessageFormat.format(Messages.getString("license.LicenseManageDialog.infoNet"), Constants.EXCEPTION_STRING17));
}
}
}
}
});
Composite comp1 = new Composite(statusGroup, SWT.NONE);
comp1.setLayoutData(data);
comp1.setLayout(layout);
Label typeLbl = new Label(comp1, SWT.NONE);
typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
Label typeLbl1 = new Label(comp1, SWT.NONE);
typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
if (utilDate != null) {
Composite comp2 = new Composite(statusGroup, SWT.NONE);
comp2.setLayoutData(data);
comp2.setLayout(layout);
Label typeLbl2 = new Label(comp2, SWT.NONE);
typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
Label dateLbl = new Label(comp2, SWT.NONE);
dateLbl.setText(utilDate);
}
} else if (type == Constants.STATE_INVALID) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.invalidLicense"));
} else if (type == Constants.STATE_EXPIRED) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.expired"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
comp1.setLayoutData(data);
comp1.setLayout(layout);
Label typeLbl = new Label(comp1, SWT.NONE);
typeLbl.setText(Messages.getString("license.LicenseManageDialog.typeLabel"));
Label typeLbl1 = new Label(comp1, SWT.NONE);
typeLbl1.setText(Messages.getString(utilDate == null ? "license.LicenseManageDialog.typeBusiness" : "license.LicenseManageDialog.typeTemp"));
if (utilDate != null) {
Composite comp2 = new Composite(statusGroup, SWT.NONE);
comp2.setLayoutData(data);
comp2.setLayout(layout);
Label typeLbl2 = new Label(comp2, SWT.NONE);
typeLbl2.setText(Messages.getString("license.LicenseManageDialog.utilDate"));
Label dateLbl = new Label(comp2, SWT.NONE);
dateLbl.setText(utilDate);
}
} else if (type == Constants.EXCEPTION_INT16 || type == Constants.EXCEPTION_INT17) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.unvalidate"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
comp1.setLayoutData(data1);
GridLayout layout1 = new GridLayout();
comp1.setLayout(layout1);
Label noticeLbl = new Label(comp1, SWT.WRAP);
GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
noticeLbl.setLayoutData(dataLabel);
noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noticeLbl"), StringUtils.getErrorCode(type)));
} else if (type == Constants.EXCEPTION_INT14) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
comp1.setLayoutData(data1);
GridLayout layout1 = new GridLayout();
comp1.setLayout(layout1);
Label noticeLbl = new Label(comp1, SWT.WRAP);
GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
noticeLbl.setLayoutData(dataLabel);
noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.noSameVersion"), getVersionContent(System.getProperty("TSEdition")), getVersionContent(new LicenseIdGenerator(licenseId).getVersion())));
} else if (type == Constants.EXCEPTION_INT15) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
comp1.setLayoutData(data1);
GridLayout layout1 = new GridLayout();
comp1.setLayout(layout1);
Label noticeLbl = new Label(comp1, SWT.WRAP);
GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
noticeLbl.setLayoutData(dataLabel);
noticeLbl.setText(Messages.getString("license.LicenseManageDialog.maccodeError"));
} else if (type == Constants.EXCEPTION_INT1 || type == Constants.EXCEPTION_INT2 || type == Constants.EXCEPTION_INT3 || type == Constants.EXCEPTION_INT4) {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
comp1.setLayoutData(data1);
GridLayout layout1 = new GridLayout();
comp1.setLayout(layout1);
Label noticeLbl = new Label(comp1, SWT.WRAP);
GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
noticeLbl.setLayoutData(dataLabel);
noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo1"), StringUtils.getErrorCode(type)));
} else {
Label statusLbl1 = new Label(comp0, SWT.NONE);
statusLbl1.setText(Messages.getString("license.LicenseManageDialog.licenseException"));
Composite comp1 = new Composite(statusGroup, SWT.NONE);
GridData data1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
comp1.setLayoutData(data1);
GridLayout layout1 = new GridLayout();
comp1.setLayout(layout1);
Label noticeLbl = new Label(comp1, SWT.WRAP);
GridData dataLabel = new GridData(GridData.FILL_HORIZONTAL);
noticeLbl.setLayoutData(dataLabel);
noticeLbl.setText(MessageFormat.format(Messages.getString("license.LicenseManageDialog.licenseExceptionInfo"), StringUtils.getErrorCode(type)));
}
}
use of org.eclipse.swt.layout.RowData in project knime-core by knime.
the class LabeledFilterViewContributionItem method createControl.
/**
* {@inheritDoc}
*/
@Override
protected Control createControl(final Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout();
layout.fill = true;
layout.wrap = false;
layout.center = true;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
comp.setLayout(layout);
m_label = new Text(comp, SWT.NONE);
m_label.setText("Filter");
m_label.setEditable(false);
m_label.setBackground(parent.getBackground());
Combo combo = new Combo(comp, SWT.DROP_DOWN);
combo.addKeyListener(this);
combo.addSelectionListener(createSelectionAdaptor());
RowData rowData = new RowData();
rowData.width = 150;
combo.setLayoutData(rowData);
setCombo(combo);
return comp;
}
use of org.eclipse.swt.layout.RowData in project eclipse.platform.swt by eclipse.
the class RowLayoutTab method generateLayoutCode.
/**
* Generates code for the example layout.
*/
@Override
StringBuilder generateLayoutCode() {
StringBuilder code = new StringBuilder();
code.append("\t\tRowLayout rowLayout = new RowLayout ();\n");
if (rowLayout.type == SWT.VERTICAL) {
code.append("\t\trowLayout.type = SWT.VERTICAL;\n");
}
if (rowLayout.wrap == false) {
code.append("\t\trowLayout.wrap = false;\n");
}
if (rowLayout.pack == false) {
code.append("\t\trowLayout.pack = false;\n");
}
if (rowLayout.fill == true) {
code.append("\t\trowLayout.fill = true;\n");
}
if (rowLayout.justify == true) {
code.append("\t\trowLayout.justify = true;\n");
}
if (rowLayout.center == true) {
code.append("\t\trowLayout.center = true;\n");
}
if (rowLayout.marginWidth != 0) {
code.append("\t\trowLayout.marginWidth = " + rowLayout.marginWidth + ";\n");
}
if (rowLayout.marginHeight != 0) {
code.append("\t\trowLayout.marginHeight = " + rowLayout.marginHeight + ";\n");
}
if (rowLayout.marginLeft != 3) {
code.append("\t\trowLayout.marginLeft = " + rowLayout.marginLeft + ";\n");
}
if (rowLayout.marginRight != 3) {
code.append("\t\trowLayout.marginRight = " + rowLayout.marginRight + ";\n");
}
if (rowLayout.marginTop != 3) {
code.append("\t\trowLayout.marginTop = " + rowLayout.marginTop + ";\n");
}
if (rowLayout.marginBottom != 3) {
code.append("\t\trowLayout.marginBottom = " + rowLayout.marginBottom + ";\n");
}
if (rowLayout.spacing != 3) {
code.append("\t\trowLayout.spacing = " + rowLayout.spacing + ";\n");
}
code.append("\t\tshell.setLayout (rowLayout);\n");
boolean first = true;
for (int i = 0; i < children.length; i++) {
Control control = children[i];
code.append(getChildCode(control, i));
RowData rowData = (RowData) control.getLayoutData();
if (rowData != null) {
if (rowData.width != -1 || rowData.height != -1 || rowData.exclude) {
code.append("\t\t");
if (first) {
code.append("RowData ");
first = false;
}
if (rowData.width == -1 && rowData.height == -1) {
code.append("rowData = new RowData ();\n");
} else if (rowData.width == -1) {
code.append("rowData = new RowData (SWT.DEFAULT, " + rowData.height + ");\n");
} else if (rowData.height == -1) {
code.append("rowData = new RowData (" + rowData.width + ", SWT.DEFAULT);\n");
} else {
code.append("rowData = new RowData (" + rowData.width + ", " + rowData.height + ");\n");
}
if (rowData.exclude) {
code.append("\t\trowData.exclude = true;\n");
}
code.append("\t\t" + names[i] + ".setLayoutData (rowData);\n");
}
}
}
return code;
}
use of org.eclipse.swt.layout.RowData in project eclipse.platform.swt by eclipse.
the class MJ_Table method virtual_addManyItems_Snippet144.
/**
* Snippet 144 modified to auto-populate items when shell is activated instead.
*/
@Test
public void virtual_addManyItems_Snippet144() {
final Shell shell = mkShell("Shell Should show and items should be populated in lazy way");
shell.setSize(SWIDTH, SHEIGHT);
final int COUNT = 100000;
shell.setLayout(new RowLayout(SWT.VERTICAL));
final Table table = new Table(shell, SWT.VIRTUAL | SWT.BORDER);
final Label label1 = new Label(shell, SWT.NONE);
table.addListener(SWT.SetData, event -> {
TableItem item = (TableItem) event.item;
int index = table.indexOf(item);
item.setText("Item " + index);
label1.setText("Added " + item.getText());
});
table.setLayoutData(new RowData(shell.getBounds().width - 100, 400));
final Label label2 = new Label(shell, SWT.NONE);
shell.addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
System.out.println("activated");
long t1 = System.currentTimeMillis();
table.setItemCount(COUNT);
long t2 = System.currentTimeMillis();
label2.setText("Items: " + COUNT + ", Time: " + (t2 - t1) + " (ms)");
shell.layout();
}
});
shell.open();
mainLoop(shell);
}
Aggregations