下面列出了org.eclipse.swt.widgets.Text#setEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void mappingFileRow(Composite body) {
if (!withMappingFile)
return;
Composite comp = new Composite(body, SWT.NONE);
UI.gridLayout(comp, 3, 5, 0);
UI.gridData(comp, true, false);
new Label(comp, SWT.NONE).setText("Mapping file");
Text text = new Text(comp, SWT.BORDER);
UI.gridData(text, true, false);
text.setEditable(false);
text.setBackground(Colors.white());
Button button = new Button(comp, SWT.NONE);
button.setText(M.Browse);
Controls.onSelect(button, e -> {
mappingFile = FileChooser.open("*.csv");
if (mappingFile == null) {
text.setText("");
} else {
text.setText(mappingFile.getAbsolutePath());
}
});
}
/**
* Adds the text field.
*
* @param parent the parent
* @param strLabel the str label
* @param strText the str text
* @param editable the editable
* @return the text
*/
public Text addTextField(Composite parent, String strLabel, String strText, boolean editable) {
Label label = new Label(parent, SWT.NULL);
label.setText(strLabel);
Text text = new Text(parent, SWT.BORDER | SWT.SINGLE);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setText(strText);
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dialogChanged();
}
});
text.setEditable(editable);
return text;
}
public void render(Composite body, FormToolkit toolkit) {
container = UI.formSection(body, toolkit, M.GeneralInformation, 3);
Widgets.text(container, M.Name, "name", editor, toolkit);
Widgets.multiText(container, M.Description, "description", editor, toolkit);
if (entity.category != null) {
new Label(container, SWT.NONE).setText(M.Category);
createBreadcrumb(container);
new CommentControl(container, toolkit, "category", editor.getComments());
} else if (editor.hasComment("category")) {
new Label(container, SWT.NONE).setText(M.Category);
UI.filler(container);
new CommentControl(container, toolkit, "category", editor.getComments());
}
createVersionText(toolkit);
Text uuidText = UI.formText(container, toolkit, "UUID");
uuidText.setEditable(false);
if (entity.refId != null)
uuidText.setText(entity.refId);
UI.filler(container, toolkit);
createDateText(toolkit);
}
protected Control createDialogArea(Composite parent) {
Composite rtnGroup = (Composite)super.createDialogArea(parent);
getShell().setText(Policy.bind("TrustSSLServerDialog.title")); //$NON-NLS-1$
GridLayout layout = new GridLayout();
layout.numColumns = 1;
rtnGroup.setLayout(layout);
rtnGroup.setLayoutData(
new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Text infoText = new Text(rtnGroup, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
GridData data = new GridData();
data.widthHint = 600;
data.heightHint = 100;
infoText.setLayoutData(data);
infoText.setEditable(false);
infoText.setText(info);
// set F1 help
PlatformUI.getWorkbench().getHelpSystem().setHelp(rtnGroup, IHelpContextIds.TRUST_SSL_SERVER_DIALOG);
return rtnGroup;
}
/**
* Creates the text field showing the established commands.
*
* @param parent the parent composite of the text field
* @return the text field
*/
private static Text createEstablishedCommandsText(final Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().span(2, 1).exclude(true).applyTo(composite);
final Text text = new Text(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
GridDataFactory.fillDefaults().grab(true, true).hint(0 /* Do not layout dependent to the content */, 100)
.span(2, 1).applyTo(text);
text.setEditable(false);
text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_BLACK));
text.setForeground(text.getDisplay().getSystemColor(SWT.COLOR_GRAY));
text.setFont(JFaceResources.getFont(CONSOLE_FONT));
return text;
}
private void setWarningText( String message, int maxTextWidth ) {
description = new Text( shell, SWT.MULTI | SWT.LEFT | SWT.WRAP | SWT.NO_FOCUS | SWT.HIDE_SELECTION );
description.setText( message );
description.setEditable( false );
FormData fdlDesc = new FormData();
fdlDesc.left = new FormAttachment( warningIcon, margin ); // Text should be right of the icon and at the top
fdlDesc.top = new FormAttachment( 0, 0 );
fdlDesc.width = maxTextWidth;
description.setLayoutData( fdlDesc );
props.setLook( description );
}
/**
* Creates an input field
* @param caption
* @param callback
* @return
*/
private Text createInputField(String caption, final Callback<Double> callback) {
// Label
Label label = new Label(root, SWT.NONE);
label.setText(caption);
// Text field
final Text text = new Text(root, SWT.BORDER | SWT.SINGLE);
text.setText("0"); //$NON-NLS-1$
text.setToolTipText("0"); //$NON-NLS-1$
text.setLayoutData(SWTUtil.createFillHorizontallyGridData());
text.setEditable(false);
// Button
Button btn1 = new Button(root, SWT.FLAT);
btn1.setText(Resources.getMessage("ViewCostBenefitModel.0")); //$NON-NLS-1$
btn1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
String value = controller.actionShowInputDialog(root.getShell(),
Resources.getMessage("ViewCostBenefitModel.5"), //$NON-NLS-1$
Resources.getMessage("ViewCostBenefitModel.6"), //$NON-NLS-1$
text.getToolTipText(),
validator);
if (value != null) {
callback.call(Double.valueOf(value));
update();
}
}
});
// Return
return text;
}
/**
* @param content
*/
private void createTextDemo(Composite content) {
final Text text = new Text(content, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
text.setEditable(false);
new Thread("HandleMsg") {
public void run() {
while (true) {
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
if (!text.isDisposed()) {
Msg<?> msg = queue.poll();
if (msg != null) {
if (text.getText().equals(""))
text.setText(msg.toString());
else
text.setText(text.getText() + text.getLineDelimiter() + msg.toString());
}
}
}
});
if (isDisposed() && queue.isEmpty()) {
latch.countDown();
break;
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
}
}
}.start();
}
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginTop = 5;
layout.marginWidth = 10;
tparent.setLayout(layout);
GridData parentData = new GridData(SWT.FILL, SWT.FILL, true, true);
parentData.heightHint = 380;
tparent.setLayoutData(parentData);
Label lbl = new Label(tparent, SWT.NONE);
lbl.setText(Messages.getString("license.LicenseAgreementDialog.label"));
lbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text text = new Text(tparent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
text.setEditable(false);
text.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
text.setText(Messages.getString("license.LicenseAgreementDialog.agreement"));
GridData textData = new GridData(GridData.FILL_BOTH);
text.setLayoutData(textData);
agreeBtn = new Button(tparent, SWT.CHECK);
agreeBtn.setText(Messages.getString("license.LicenseAgreementDialog.agreeBtn"));
agreeBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
agreeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(agreeBtn.getSelection());
}
});
return super.createDialogArea(parent);
}
@Override
public Control createReadonlyControl(Composite parent) {
textReferencedReadonly = new Text(parent, SWT.BORDER);
textReferencedReadonly.setText("");
textReferencedReadonly.setEditable(false);
return textReferencedReadonly;
}
@Override
public Control createReadonlyControl(Composite parent) {
textRecipientReadonly = new Text(parent, SWT.BORDER);
textRecipientReadonly.setText("");
textRecipientReadonly.setEditable(false);
return textRecipientReadonly;
}
/**
* 创建要分割文件的显示区
* @param tparent
*/
public void createSplitXlfNameGroup(Composite tparent) {
final Group xliffDataGroup = new Group(tparent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(2).margins(8, 8).applyTo(xliffDataGroup);
GridDataFactory.fillDefaults().grab(true, false).applyTo(xliffDataGroup);
xliffDataGroup.setText(Messages.getString("wizard.SplitXliffWizardPage.xliffDataGroup"));
GridData textData = new GridData(SWT.FILL, SWT.CENTER, true, false);
textData.widthHint = 200;
Label xlfNameLbl = new Label(xliffDataGroup, SWT.RIGHT);
xlfNameLbl.setText(Messages.getString("wizard.SplitXliffWizardPage.xlfNameLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(xlfNameLbl);
xliffNameTxt = new Text(xliffDataGroup, SWT.BORDER);
xliffNameTxt.setText(splitFile.getFullPath().toOSString());
GridDataFactory.fillDefaults().grab(true, false).applyTo(xliffNameTxt);
xliffNameTxt.setEditable(false);
Label targetFilsPathLbl = new Label(xliffDataGroup, SWT.RIGHT);
targetFilsPathLbl.setText(Messages.getString("wizard.SplitXliffWizardPage.targetFilsPathLbl"));
GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(targetFilsPathLbl);
targetXlfPathTxt = new Text(xliffDataGroup, SWT.BORDER);
targetXlfPathTxt.setLayoutData(textData);
targetXlfPathTxt.setText(splitFile.getParent().getFullPath().append(splitFile.getName() + "_split")
.toOSString());
targetXlfPathTxt.setEditable(false);
if ("\\".equals(System.getProperty("file.separator"))) {
separator = "\\";
} else {
separator = "/";
}
validXliff();
}
@Override
public Control createReadonlyControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);
textDescrReadonly = new Text(comp, SWT.BORDER | SWT.MULTI);
textDescrReadonly.setEditable(false);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.hint(SWT.DEFAULT, 100).applyTo(textDescrReadonly);
return comp;
}
@Override
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
tparent.setLayout(new GridLayout(3, false));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(400, 160).grab(true, true).applyTo(tparent);
createMenu();
PluginUtil.createLabel(tparent, Messages.getString("dialog.Martif2TBXConverterDialog.txtMartif"));
txtMartif = new Text(tparent, SWT.BORDER);
txtMartif.setEditable(false);
txtMartif.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnMartifBrowse = new Button(tparent, SWT.None);
btnMartifBrowse.setText(Messages.getString("dialog.Martif2TBXConverterDialog.btnMartifBrowse"));
PluginUtil.createLabel(tparent, Messages.getString("dialog.Martif2TBXConverterDialog.txtTBX"));
txtTBX = new Text(tparent, SWT.BORDER);
txtTBX.setEditable(false);
txtTBX.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnTBXBrowse = new Button(tparent, SWT.None);
btnTBXBrowse.setText(Messages.getString("dialog.Martif2TBXConverterDialog.btnTBXBrowse"));
initListener();
tparent.layout();
getShell().layout();
return tparent;
}
@Override
public Control createReadonlyControl(Composite parent) {
textNameReadonly = new Text(parent, SWT.BORDER);
textNameReadonly.setText("");
textNameReadonly.setEditable(false);
return textNameReadonly;
}
public ODBCBasedImporter(final Composite parent, final ImporterPage home){
super(parent, SWT.NONE);
setLayout(new GridLayout());
final Label lSource = new Label(this, SWT.NONE);
tSource = new Text(this, SWT.BORDER);
lSource.setText(Messages.ImporterPage_source); //$NON-NLS-1$
tSource.setEditable(false);
lSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
tSource.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
tSource.setText(CoreHub.localCfg.get(
"ImporterPage/" + home.getTitle() + "/ODBC-Source", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
home.results = new String[1];
home.results[0] = tSource.getText();
Button bSource = new Button(this, SWT.PUSH);
bSource.setText(Messages.ImporterPage_enter); //$NON-NLS-1$
bSource.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e){
InputDialog in =
new InputDialog(parent.getShell(), Messages.ImporterPage_odbcSource, //$NON-NLS-1$
Messages.ImporterPage_pleaseEnterODBC, null, null); //$NON-NLS-1$
if (in.open() == Dialog.OK) {
tSource.setText(in.getValue());
home.results[0] = in.getValue();
CoreHub.localCfg.set(
"ImporterPage/" + home.getTitle() + "/ODBC-Source", home.results[0]); //$NON-NLS-1$ //$NON-NLS-2$
}
}
});
}
public static Text createText(Composite parent, boolean editable) {
Text text = createText(parent);
text.setEditable(editable);
return text;
}
private void setupSection(Composite body, FormToolkit tk) {
Composite comp = UI.formSection(body, tk, "Setup");
UI.gridLayout(comp, 3);
// GeoJSON file
UI.gridLayout(comp, 3);
UI.gridData(comp, true, false);
UI.formLabel(comp, tk, "GeoJSON File");
Text fileText = tk.createText(comp, "");
fileText.setEditable(false);
UI.gridData(fileText, false, false).widthHint = 350;
Button fileBtn = tk.createButton(
comp, "Open file", SWT.NONE);
fileBtn.setImage(Icon.FOLDER_OPEN.get());
Controls.onSelect(fileBtn, _e -> {
File file = FileChooser.open("*.geojson");
if (file == null)
return;
Setup s = App.exec("Parse GeoJSON ...",
() -> Setup.read(file));
if (s == null || s.file == null)
return;
// copy possible elementary flow bindings
// into the new setup (note that the parameters
// are already initialized in the new setup)
if (setup != null) {
s.bindings.addAll(setup.bindings);
}
setup = s;
fileText.setText(s.file);
paramSection.update();
flowSection.update();
});
UI.filler(comp, tk);
Composite btnComp = tk.createComposite(comp);
UI.gridLayout(btnComp, 2, 10, 0);
Button openBtn = tk.createButton(
btnComp, "Open setup", SWT.NONE);
openBtn.setImage(Icon.FOLDER_OPEN.get());
Button saveBtn = tk.createButton(
btnComp, "Save setup", SWT.NONE);
saveBtn.setImage(Icon.SAVE.get());
}
@Override
public Control createReadonlyControl(Composite parent) {
textAmountReadonly = new Text(parent, SWT.BORDER);
textAmountReadonly.setEditable(false);
return textAmountReadonly;
}
@Override
public Control createReadonlyControl(Composite parent) {
textQuantityReadonly = new Text(parent, SWT.BORDER);
textQuantityReadonly.setEditable(false);
return textQuantityReadonly;
}