下面列出了怎么用org.eclipse.ui.forms.widgets.TableWrapLayout的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Create TableWrapLayout for the whole page
* @param makeColumnsEqualWidth
* @param numColumns
* @return
*/
public static TableWrapLayout createFormTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns)
{
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = FORM_BODY_MARGIN_TOP;
layout.bottomMargin = FORM_BODY_MARGIN_BOTTOM;
layout.leftMargin = FORM_BODY_MARGIN_LEFT;
layout.rightMargin = FORM_BODY_MARGIN_RIGHT;
layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING;
layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
layout.numColumns = numColumns;
return layout;
}
/**
* Constructs a section and returns a section client composite
*
* the section layout is TableWrapLayout
*
*
* @param parent parent container for the section
* @param title title of the section
* @param description description of the section
* @param toolkit toolkit to create the composite
* @param sectionFlags parameters of the section
* @param expansionListener
* @return a section client (the content container of the section)
*/
public static Section createSectionComposite(Composite parent, String title, String description,
FormToolkit toolkit, int sectionFlags, IExpansionListener expansionListener)
{
final Section section = toolkit.createSection(parent, sectionFlags);
section.setData(SECTION_IS_NOT_SPACE_GRABBING, new Object());
section.setText(title);
section.setDescription(description);
if (expansionListener != null)
{
section.addExpansionListener(expansionListener);
}
// create section client
Composite sectionClient = toolkit.createComposite(section);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 1;
sectionClient.setLayout(layout);
section.setClient(sectionClient);
// draw flat borders
toolkit.paintBordersFor(sectionClient);
return section;
}
/**
* For form bodies.
*
* @param makeColumnsEqualWidth
* @param numColumns
* @return
*/
public static TableWrapLayout createFormTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = FORM_BODY_MARGIN_TOP;
layout.bottomMargin = FORM_BODY_MARGIN_BOTTOM;
layout.leftMargin = FORM_BODY_MARGIN_LEFT;
layout.rightMargin = FORM_BODY_MARGIN_RIGHT;
layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING;
layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
layout.numColumns = numColumns;
return layout;
}
/**
* For composites used to group sections in left and right panes.
*
* @param makeColumnsEqualWidth
* @param numColumns
* @return
*/
public static TableWrapLayout createFormPaneTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = FORM_PANE_MARGIN_TOP;
layout.bottomMargin = FORM_PANE_MARGIN_BOTTOM;
layout.leftMargin = FORM_PANE_MARGIN_LEFT;
layout.rightMargin = FORM_PANE_MARGIN_RIGHT;
layout.horizontalSpacing = FORM_PANE_HORIZONTAL_SPACING;
layout.verticalSpacing = FORM_PANE_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
layout.numColumns = numColumns;
return layout;
}
/**
* For composites set as section clients. For composites containg form text.
*
* @param makeColumnsEqualWidth
* @param numColumns
* @return
*/
public static TableWrapLayout createSectionClientTableWrapLayout(boolean makeColumnsEqualWidth, int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = SECTION_CLIENT_MARGIN_TOP;
layout.bottomMargin = SECTION_CLIENT_MARGIN_BOTTOM;
layout.leftMargin = SECTION_CLIENT_MARGIN_LEFT;
layout.rightMargin = SECTION_CLIENT_MARGIN_RIGHT;
layout.horizontalSpacing = SECTION_CLIENT_HORIZONTAL_SPACING;
layout.verticalSpacing = SECTION_CLIENT_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
layout.numColumns = numColumns;
return layout;
}
public static TableWrapLayout createClearTableWrapLayout(
boolean makeColumnsEqualWidth, int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = CLEAR_MARGIN_TOP;
layout.bottomMargin = CLEAR_MARGIN_BOTTOM;
layout.leftMargin = CLEAR_MARGIN_LEFT;
layout.rightMargin = CLEAR_MARGIN_RIGHT;
layout.horizontalSpacing = CLEAR_HORIZONTAL_SPACING;
layout.verticalSpacing = CLEAR_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
layout.numColumns = numColumns;
return layout;
}
/**
* Constructor.
*/
public NodeInfoViewer(Composite parent, int style) {
super(parent, style);
this.setLayout(new FillLayout());
this.toolkit = new FormToolkit(Utilities.getDisplay());
this.global = this.toolkit.createScrolledForm(this);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
this.global.getBody().setLayout(layout);
/* For disposing the toolkit. */
this.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
toolkit.dispose();
}
});
/* For the wheel event. */
this.global.addListener(SWT.Activate, new Listener() {
public void handleEvent(Event event) {
global.setFocus();
}
});
}
@Override
public void createPartControl(Composite parent){
parent.setLayout(new FillLayout());
form = tk.createScrolledForm(parent);
TableWrapLayout twl = new TableWrapLayout();
form.getBody().setLayout(twl);
tblArtikel =
new LabeledInputField.AutoForm(form.getBody(), getFieldDefs(parent.getShell()));
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
twd.grabHorizontal = true;
tblArtikel.setLayoutData(twd);
GlobalEventDispatcher.addActivationListener(this, this);
}
public Composite createDisplay(Composite parent, IViewSite site){
form = UiDesk.getToolkit().createForm(parent);
TableWrapLayout twl = new TableWrapLayout();
form.getBody().setLayout(twl);
tblPls = new LabeledInputField.AutoForm(form.getBody(), data);
tblPls.setModelService(ModelServiceHolder.get());
TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB);
twd.grabHorizontal = true;
tblPls.setLayoutData(twd);
TableWrapData twd2 = new TableWrapData(TableWrapData.FILL_GRAB);
tComment = UiDesk.getToolkit().createText(form.getBody(), StringTool.leer, SWT.BORDER);
tComment.setLayoutData(twd2);
return form.getBody();
}
public static TableWrapLayout createFormTableWrapLayout(int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = FORM_BODY_MARGIN_TOP;
layout.bottomMargin = FORM_BODY_MARGIN_BOTTOM;
layout.leftMargin = FORM_BODY_MARGIN_LEFT;
layout.rightMargin = FORM_BODY_MARGIN_RIGHT;
layout.horizontalSpacing = FORM_BODY_HORIZONTAL_SPACING;
layout.verticalSpacing = FORM_BODY_VERTICAL_SPACING;
layout.makeColumnsEqualWidth = true;
layout.numColumns = numColumns;
return layout;
}
public static TableWrapLayout createFormPaneTableWrapLayout(int numColumns) {
TableWrapLayout layout = new TableWrapLayout();
layout.topMargin = FORM_PANE_MARGIN_TOP;
layout.bottomMargin = FORM_PANE_MARGIN_BOTTOM;
layout.leftMargin = FORM_PANE_MARGIN_LEFT;
layout.rightMargin = FORM_PANE_MARGIN_RIGHT;
layout.horizontalSpacing = FORM_PANE_HORIZONTAL_SPACING;
layout.verticalSpacing = FORM_PANE_VERTICAL_SPACING;
layout.numColumns = numColumns;
return layout;
}
public static StickerComposite createWrappedStickerComposite(Composite parent, FormToolkit tk){
Composite wrapper = new Composite(parent, SWT.NONE);
TableWrapLayout wlayout = new TableWrapLayout();
wlayout.bottomMargin = 0;
wlayout.topMargin = 0;
wrapper.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
wrapper.setLayout(wlayout);
wrapper.setBackground(UiDesk.getColor(UiDesk.COL_WHITE));
StickerComposite stickerComposite = new StickerComposite(wrapper, SWT.NONE, tk);
stickerComposite.setBackground(UiDesk.getColor(UiDesk.COL_WHITE));
return stickerComposite;
}
/**
* Constructor wrapper for TableWrapLayout, so that parameters are identical to
* GridLayout(numColumns, makeColumnsEqualWidth)
*/
public static TableWrapLayout createTableWrapLayout(final int numColumns,
final boolean makeColumnsEqualWidth){
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = numColumns;
layout.makeColumnsEqualWidth = makeColumnsEqualWidth;
return layout;
}
private void createContent() {
toolkit.adapt(this);
TableWrapLayout layout = createLayout();
setLayout(layout);
// order of the method calls is important (fills from left to right)
createAddButton();
createTextField();
addDropToText();
createRemoveButton();
}
private TableWrapLayout createLayout() {
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 3;
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.topMargin = 0;
layout.bottomMargin = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
return layout;
}
/**
* Add a form to the supplied Composite.
*/
private Control createForm(Composite parent) {
final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
final ScrolledForm form = toolkit.createScrolledForm(parent);
/*
* For the life of me I can't understand why I have to supply
* a GridData instance to the form object in order to get the form
* to fill the dialog area.
*
* BTW, I only found this out through trial and error.
*/
form.setLayoutData(new GridData(GridData.FILL_BOTH));
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 15;
layout.verticalSpacing = 10;
form.getBody().setLayout(layout);
form.getBody().setLayoutData(new TableWrapData(
TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 3));
for (Task item : items) {
// add an expandable description of the task, with a pretty title
ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(),
ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
ec.setText(item.getTitle());
Label label = toolkit.createLabel(ec, item.getDescription(), SWT.WRAP);
ec.setClient(label);
ec.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
ec.setExpanded(true);
ec.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
// add a combo box allowing the user to select the repair action to take
createDecisionCombo(form.getBody(), item);
}
return parent;
}
public void createControl(Composite parent){
DBImportWizard wiz = (DBImportWizard) getWizard();
FormToolkit tk = UiDesk.getToolkit();
Form form = tk.createForm(parent);
form.setText(Messages.DBImportFirstPage_Connection); //$NON-NLS-1$
Composite body = form.getBody();
body.setLayout(new TableWrapLayout());
tk.createLabel(body, Messages.DBImportFirstPage_EnterType); //$NON-NLS-1$
dbTypes = new List(body, SWT.BORDER);
dbTypes.setItems(supportedDB);
dbTypes.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e){
int it = dbTypes.getSelectionIndex();
switch (it) {
case MYSQL:
case POSTGRESQL:
server.setEnabled(true);
dbName.setEnabled(true);
defaultUser = ""; //$NON-NLS-1$
defaultPassword = ""; //$NON-NLS-1$
break;
case H2:
server.setEnabled(false);
dbName.setEnabled(true);
defaultUser = "sa";
defaultPassword = "";
break;
case ODBC:
server.setEnabled(false);
dbName.setEnabled(true);
defaultUser = "sa"; //$NON-NLS-1$
defaultPassword = ""; //$NON-NLS-1$
break;
default:
break;
}
DBImportSecondPage sec = (DBImportSecondPage) getNextPage();
sec.name.setText(defaultUser);
sec.pwd.setText(defaultPassword);
}
});
tk.adapt(dbTypes, true, true);
tk.createLabel(body, Messages.DBImportFirstPage_serverAddress); //$NON-NLS-1$
server = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
TableWrapData twr = new TableWrapData(TableWrapData.FILL_GRAB);
server.setLayoutData(twr);
tk.createLabel(body, Messages.DBImportFirstPage_databaseName); //$NON-NLS-1$
dbName = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
TableWrapData twr2 = new TableWrapData(TableWrapData.FILL_GRAB);
dbName.setLayoutData(twr2);
if (wiz.preset != null && wiz.preset.length > 1) {
int idx = StringTool.getIndex(supportedDB, wiz.preset[0]);
if (idx < dbTypes.getItemCount()) {
dbTypes.select(idx);
}
server.setText(wiz.preset[1]);
dbName.setText(wiz.preset[2]);
}
setControl(form);
}
public void createControl(Composite parent){
FormToolkit tk = UiDesk.getToolkit();
Form form = tk.createForm(parent);
form.setText(Messages.DBConnectFirstPage_connectioNDetails); //$NON-NLS-1$
Composite body = form.getBody();
body.setLayout(new TableWrapLayout());
FormText alt = tk.createFormText(body, false);
StringBuilder old = new StringBuilder();
old.append("<form>"); //$NON-NLS-1$
String driver = "";
String user = "";
String typ = "";
String connectString = "";
Hashtable<Object, Object> hConn = null;
String cnt = CoreHub.localCfg.get(Preferences.CFG_FOLDED_CONNECTION, null);
if (cnt != null) {
hConn = PersistentObject.fold(StringTool.dePrintable(cnt));
if (hConn != null) {
driver =
PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_DRIVER));
connectString =
PersistentObject.checkNull(hConn
.get(Preferences.CFG_FOLDED_CONNECTION_CONNECTSTRING));
user =
PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_USER));
typ = PersistentObject.checkNull(hConn.get(Preferences.CFG_FOLDED_CONNECTION_TYPE));
}
}
// Check whether we were overridden
String dbUser = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_USERNAME);
String dbPw = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_PASSWORD);
String dbFlavor = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_FLAVOR);
String dbSpec = System.getProperty(ElexisSystemPropertyConstants.CONN_DB_SPEC);
if (dbUser != null && dbPw != null && dbFlavor != null && dbSpec != null) {
old.append("<br/><li><b>Aktuelle Verbindung wurde via Übergabeparameter ans Programm gesetzt!</b></li><br/>"); //$NON-NLS-1$
}
if (ch.rgw.tools.StringTool.isNothing(connectString)) {
old.append("<br/>"); //$NON-NLS-1$
old.append("Keine konfigurierte Verbindung."); //$NON-NLS-1$
} else {
old.append("Konfigurierte Verbindung ist:<br/>"); //$NON-NLS-1$
old.append("<li><b>Typ:</b> ").append(typ).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
old.append("<li><b>Treiber</b> ").append(driver).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
old.append("<li><b>Verbinde</b> ").append(connectString).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
old.append("<li><b>Username</b> ").append(user).append("</li>"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (PersistentObject.getConnection() != null
&& PersistentObject.getConnection().getConnectString() != null) {
old.append("<li><b>Effektiv</b> verwendet wird:").append( //$NON-NLS-1$
PersistentObject.getConnection().getConnectString()).append("</li>"); //$NON-NLS-1$
}
old.append("</form>"); //$NON-NLS-1$
alt.setText(old.toString(), true, false);
// Composite form=new Composite(parent, SWT.BORDER);
Label sep = tk.createSeparator(body, SWT.NONE);
TableWrapData twd = new TableWrapData();
twd.heightHint = 5;
sep.setLayoutData(twd);
tk.createLabel(body, Messages.DBConnectFirstPage_enterType); //$NON-NLS-1$
dbTypes = new Combo(body, SWT.BORDER | SWT.SIMPLE);
dbTypes.setItems(supportedDB);
dbTypes.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e){
int it = dbTypes.getSelectionIndex();
switch (it) {
case 0:
case 1:
server.setEnabled(true);
dbName.setEnabled(true);
defaultUser = "elexis"; //$NON-NLS-1$
defaultPassword = "elexisTest"; //$NON-NLS-1$
break;
case 2:
server.setEnabled(false);
dbName.setEnabled(true);
defaultUser = "sa"; //$NON-NLS-1$
defaultPassword = ""; //$NON-NLS-1$
break;
default:
break;
}
DBConnectSecondPage sec = (DBConnectSecondPage) getNextPage();
sec.name.setText(defaultUser);
sec.pwd.setText(defaultPassword);
}
});
tk.adapt(dbTypes, true, true);
tk.createLabel(body, Messages.DBConnectFirstPage_serevrAddress); //$NON-NLS-1$
server = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
TableWrapData twr = new TableWrapData(TableWrapData.FILL_GRAB);
server.setLayoutData(twr);
tk.createLabel(body, Messages.DBConnectFirstPage_databaseName); //$NON-NLS-1$
dbName = tk.createText(body, "", SWT.BORDER); //$NON-NLS-1$
TableWrapData twr2 = new TableWrapData(TableWrapData.FILL_GRAB);
dbName.setLayoutData(twr2);
setControl(form);
}