下面列出了org.eclipse.ui.forms.widgets.ColumnLayout#org.eclipse.ui.forms.widgets.FormText 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates a form text.
*
* @param parent the parent to put the form text on
* @param text the form text to be displayed
* @return the created form text
*
* @see FormToolkit#createFormText(org.eclipse.swt.widgets.Composite, boolean)
*/
private FormText createFormText(Composite parent, String text) {
FormToolkit toolkit= new FormToolkit(getShell().getDisplay());
try {
FormText formText= toolkit.createFormText(parent, true);
formText.setFont(parent.getFont());
try {
formText.setText(text, true, false);
} catch (IllegalArgumentException e) {
formText.setText(e.getMessage(), false, false);
JavaPlugin.log(e);
}
formText.marginHeight= 2;
formText.marginWidth= 0;
formText.setBackground(null);
formText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
return formText;
} finally {
toolkit.dispose();
}
}
/**
* Create a label with a hyperlink and a picture.
*
* @param parent the parent widget of the label
* @param text the text of the label
* @param action the action to be executed if the hyperlink is activated
*/
private void createLabel(Composite parent, String text, final BuildpathModifierAction action) {
FormText formText= createFormText(parent, text);
Image image= fImageMap.get(action.getId());
if (image == null) {
image= action.getImageDescriptor().createImage();
fImageMap.put(action.getId(), image);
}
formText.setImage("defaultImage", image); //$NON-NLS-1$
formText.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
action.run();
}
});
}
private void createPluginsSection(Composite parent) {
Section sctnPlugins = createSection(parent, "Plug-ins");
sctnPlugins.setLayout(FormUtils.createClearTableWrapLayout(false, 1));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
sctnPlugins.setLayoutData(data);
FormText text = formToolkit.createFormText(sctnPlugins, true);
ImageDescriptor idesc = HybridUI.getImageDescriptor(HybridUI.PLUGIN_ID, "/icons/etool16/cordovaplug_wiz.png");
text.setImage("plugin", idesc.createImage());
text.setText(PLUGINS_SECTION_CONTENT, true, false);
sctnPlugins.setClient(text);
text.addHyperlinkListener(this);
}
public void createControl(Composite parent) {
toolkit = new FormToolkit(parent.getDisplay());
int borderStyle = toolkit.getBorderStyle() == SWT.BORDER ? SWT.NULL : SWT.BORDER;
container = new Composite(parent, borderStyle);
FillLayout flayout = new FillLayout();
flayout.marginWidth = 1;
flayout.marginHeight = 1;
container.setLayout(flayout);
formText = new ScrolledFormText(container, SWT.V_SCROLL | SWT.H_SCROLL, false);
if (borderStyle == SWT.NULL) {
formText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
toolkit.paintBordersFor(container);
}
FormText ftext = toolkit.createFormText(formText, false);
formText.setFormText(ftext);
formText.setExpandHorizontal(true);
formText.setExpandVertical(true);
formText.setBackground(toolkit.getColors().getBackground());
formText.setForeground(toolkit.getColors().getForeground());
ftext.marginWidth = 2;
ftext.marginHeight = 2;
ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup());
formText.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (toolkit != null) {
toolkit.dispose();
toolkit = null;
}
}
});
if (text != null)
formText.setText(text);
}
private void createExportSection(Composite parent) {
Section sctnExport = createSection(parent, "Export");
sctnExport.setLayout(FormUtils.createClearTableWrapLayout(false, 1));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
sctnExport.setLayoutData(data);
FormText text = formToolkit.createFormText(sctnExport, true);
ImageDescriptor idesc = HybridUI.getImageDescriptor(HybridUI.PLUGIN_ID, "/icons/etool16/export_wiz.png");
text.setImage("export", idesc.createImage());
text.setText(EXPORT_SECTION_CONTENT, true, false);
sctnExport.setClient(text);
text.addHyperlinkListener(this);
}
protected FormText getTextControl( Composite parent )
{
if ( textField == null )
{
textField = FormWidgetFactory.getInstance( )
.createFormText( parent, false );
textField.setLayoutData( new GridData( ) );
textField.addDisposeListener( new DisposeListener( ) {
public void widgetDisposed( DisposeEvent event )
{
textField = null;
}
} );
if ( text != null )
{
textField.setText( text, true, false );
}
Iterator iter = map.keySet( ).iterator( );
while ( iter.hasNext( ) )
{
String key = (String) iter.next( );
Object obj = map.get( key );
if ( obj instanceof Image )
textField.setImage( key, (Image) obj );
else if ( obj instanceof Color )
textField.setColor( key, (Color) obj );
}
}
else
{
checkParent( textField, parent );
}
return textField;
}
private void createTextPluginMissingForm(Composite parent){
String expl =
Messages.TextTemplateVeiw_NoTxtPluginDescription
+ Messages.TextTemplateVeiw_NoTxtPluginReason1
+ Messages.TextTemplateVeiw_NoTxtPluginReason2
+ Messages.TextTemplateVeiw_NoTxtPluginReason3;
Form form = UiDesk.getToolkit().createForm(parent);
form.setText(Messages.TextTemplateVeiw_NoTxtPluginTitel);
form.setLayoutData(SWTHelper.fillGrid(parent, 1));
form.getBody().setLayout(new GridLayout(1, false));
FormText ft = UiDesk.getToolkit().createFormText(form.getBody(), false);
ft.setText(expl, true, false);
}
public Composite createContainer(final Composite parent, final ITextPlugin.ICallback h){
parent.setLayout(new FillLayout());
// Composite ret=new Composite(parent,SWT.BORDER);
Form form = UiDesk.getToolkit().createForm(parent);
form.setText(Messages.TextContainer_NoPluginCaption);
form.getBody().setLayout(new FillLayout());
FormText ft = UiDesk.getToolkit().createFormText(form.getBody(), false);
ft.setText(expl, true, false);
return form.getBody();
}
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
main.setLayout(new GridLayout(1, false));
Label availableTemplatesLabel = new Label(main, SWT.NONE);
availableTemplatesLabel.setText(Messages.NewProjectWizardTemplateSelectionPage_available_templates);
availableTemplatesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
SashForm sash = new SashForm(main, SWT.HORIZONTAL);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.widthHint = 400;
sash.setLayoutData(data);
TableViewer templateTable = new TableViewer(sash, SWT.BORDER);
templateTable.setContentProvider(new ArrayContentProvider());
templateTable.setLabelProvider(labelProvider);
AbstractProjectTemplate[] templates = loadTemplatesFromExtensionPoint();
templateTable.setInput(templates);
FormText text = new FormText(sash, SWT.BORDER);
text.setText("", false, false); //$NON-NLS-1$
text.setBackground(templateTable.getTable().getBackground());
// register images
for (AbstractProjectTemplate template : templates) {
for (Pair<String, Image> image : template.getImages()) {
text.setImage(image.getKey(), image.getValue());
}
}
templateTable.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object element = structuredSelection.getFirstElement();
if (element instanceof AbstractProjectTemplate) {
selectedTemplate = (AbstractProjectTemplate) element;
setPageComplete(true);
String content = "<form>" + selectedTemplate.getDescription() + "</form>"; //$NON-NLS-1$ //$NON-NLS-2$
try {
text.setText(content, true, true);
} catch (Exception e) {
text.setText(e.getMessage(), false, false);
}
} else {
selectedTemplate = null;
text.setText("", false, false); //$NON-NLS-1$
setPageComplete(false);
}
} else {
selectedTemplate = null;
text.setText("", false, false); //$NON-NLS-1$
setPageComplete(false);
}
}
});
templateTable.setSelection(new StructuredSelection(templateTable.getElementAt(0)));
setControl(main);
}
public FormText getTextControl( )
{
return textField;
}
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);
}