use of org.eclipse.swt.custom.TableEditor in project cicada by aquariusStudio.
the class PTDateEditor method render.
/**
* @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTEditor#render(org.eclipse.nebula.widgets.opal.propertytable.PTWidget,
* org.eclipse.swt.widgets.Item,
* org.eclipse.nebula.widgets.opal.propertytable.PTProperty)
*/
@Override
public ControlEditor render(final PTWidget widget, final Item item, final PTProperty property) {
ControlEditor editor;
if (widget.getWidget() instanceof Table) {
editor = new TableEditor((Table) widget.getWidget());
} else {
editor = new TreeEditor((Tree) widget.getWidget());
}
final DateTime dateEditor = new DateTime(widget.getWidget(), SWT.DATE | SWT.MEDIUM | SWT.DROP_DOWN);
final Date date = (Date) property.getValue();
final Calendar c = Calendar.getInstance();
if (date != null) {
c.setTime(date);
dateEditor.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
}
dateEditor.addListener(SWT.Selection, e -> {
c.setTime(new Date());
c.clear();
c.set(dateEditor.getYear(), dateEditor.getMonth(), dateEditor.getDay());
property.setValue(c.getTime());
});
dateEditor.addListener(SWT.FocusIn, event -> {
widget.updateDescriptionPanel(property);
});
editor.grabHorizontal = true;
editor.horizontalAlignment = SWT.LEFT;
if (widget.getWidget() instanceof Table) {
((TableEditor) editor).setEditor(dateEditor, (TableItem) item, 1);
} else {
((TreeEditor) editor).setEditor(dateEditor, (TreeItem) item, 1);
}
dateEditor.setEnabled(property.isEnabled());
return editor;
}
use of org.eclipse.swt.custom.TableEditor in project cicada by aquariusStudio.
the class PTSpinnerEditor method render.
/**
* @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTEditor#render(org.eclipse.nebula.widgets.opal.propertytable.PTWidget,
* org.eclipse.swt.widgets.Item,
* org.eclipse.nebula.widgets.opal.propertytable.PTProperty)
*/
@Override
public ControlEditor render(final PTWidget widget, final Item item, final PTProperty property) {
ControlEditor editor;
if (widget.getWidget() instanceof Table) {
editor = new TableEditor((Table) widget.getWidget());
} else {
editor = new TreeEditor((Tree) widget.getWidget());
}
final Spinner spinner = new Spinner(widget.getWidget(), SWT.HORIZONTAL);
spinner.setMinimum(min);
spinner.setMaximum(max);
final Integer originalValue = (Integer) property.getValue();
spinner.setSelection(originalValue == null ? min : originalValue.intValue());
spinner.addListener(SWT.FocusIn, event -> {
widget.updateDescriptionPanel(property);
});
spinner.addListener(SWT.Modify, event -> {
property.setValue(Integer.valueOf(spinner.getSelection()));
});
editor.grabHorizontal = true;
if (widget.getWidget() instanceof Table) {
((TableEditor) editor).setEditor(spinner, (TableItem) item, 1);
} else {
((TreeEditor) editor).setEditor(spinner, (TreeItem) item, 1);
}
spinner.setEnabled(property.isEnabled());
return editor;
}
use of org.eclipse.swt.custom.TableEditor in project convertigo by convertigo.
the class SharedComponentWizardPage2Composite method initialize.
private void initialize() {
setLayout(new GridLayout(1, false));
Label labelTable = new Label(this, SWT.NONE);
labelTable.setText("The table below helps selecting a variable to change its name. Click on the 'Finish' button when done.");
table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn columnVar = new TableColumn(table, SWT.NONE);
columnVar.setWidth(500);
columnVar.setText("Informations");
TableColumn columnInfos = new TableColumn(table, SWT.NONE);
columnInfos.setWidth(100);
columnInfos.setText("Variable");
for (String var_name : tableMap.keySet()) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, tableMap.get(var_name));
item.setText(1, var_name);
}
tableEditor = new TableEditor(table);
tableEditor.horizontalAlignment = SWT.LEFT;
tableEditor.grabHorizontal = true;
tableEditor.minimumWidth = 50;
final int EDITABLECOLUMN = 1;
table.addSelectionListener(widgetSelectedAdapter(e -> {
Control oldEditor = tableEditor.getEditor();
if (oldEditor != null)
oldEditor.dispose();
TableItem item = (TableItem) e.item;
if (item == null)
return;
Text newEditor = new Text(table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updatePageStatus(((Text) tableEditor.getEditor()).getText(), false);
}
});
newEditor.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
updatePageStatus(null, true);
Text text = (Text) tableEditor.getEditor();
String name = text.getText();
if (e.detail == SWT.TRAVERSE_RETURN && isValidName(name)) {
tableEditor.getItem().setText(EDITABLECOLUMN, name);
updatePageStatus(name, true);
}
text.dispose();
e.doit = false;
}
}
});
newEditor.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
updatePageStatus(null, true);
}
@Override
public void focusGained(FocusEvent e) {
updatePageStatus(null, false);
}
});
newEditor.selectAll();
newEditor.setFocus();
tableEditor.setEditor(newEditor, item, EDITABLECOLUMN);
}));
this.setSize(new org.eclipse.swt.graphics.Point(514, 264));
}
use of org.eclipse.swt.custom.TableEditor in project convertigo by convertigo.
the class SharedComponentWizardPage2Composite method initialize.
private void initialize() {
setLayout(new GridLayout(1, false));
Label labelTable = new Label(this, SWT.NONE);
labelTable.setText("The table below helps selecting a variable to change its name. Click on the 'Finish' button when done.");
table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn columnVar = new TableColumn(table, SWT.NONE);
columnVar.setWidth(500);
columnVar.setText("Informations");
TableColumn columnInfos = new TableColumn(table, SWT.NONE);
columnInfos.setWidth(100);
columnInfos.setText("Variable");
for (String var_name : tableMap.keySet()) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, tableMap.get(var_name));
item.setText(1, var_name);
}
tableEditor = new TableEditor(table);
tableEditor.horizontalAlignment = SWT.LEFT;
tableEditor.grabHorizontal = true;
tableEditor.minimumWidth = 50;
final int EDITABLECOLUMN = 1;
table.addSelectionListener(widgetSelectedAdapter(e -> {
Control oldEditor = tableEditor.getEditor();
if (oldEditor != null)
oldEditor.dispose();
TableItem item = (TableItem) e.item;
if (item == null)
return;
Text newEditor = new Text(table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updatePageStatus(((Text) tableEditor.getEditor()).getText(), false);
}
});
newEditor.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
updatePageStatus(null, true);
Text text = (Text) tableEditor.getEditor();
String name = text.getText();
if (e.detail == SWT.TRAVERSE_RETURN && isValidName(name)) {
tableEditor.getItem().setText(EDITABLECOLUMN, name);
updatePageStatus(name, true);
}
text.dispose();
e.doit = false;
}
}
});
newEditor.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
updatePageStatus(null, true);
}
@Override
public void focusGained(FocusEvent e) {
updatePageStatus(null, false);
}
});
newEditor.selectAll();
newEditor.setFocus();
tableEditor.setEditor(newEditor, item, EDITABLECOLUMN);
}));
this.setSize(new org.eclipse.swt.graphics.Point(514, 264));
}
use of org.eclipse.swt.custom.TableEditor in project ecf by eclipse.
the class SearchContactDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
final int editableColumn = 1;
try {
parent = (Composite) super.createDialogArea(parent);
parent.setLayout(new GridLayout(2, false));
String[] fields = null;
IUserSearchManager userManager = account.getPresenceContainerAdapter().getUserSearchManager();
fields = userManager.getUserPropertiesFields();
GridData searchButtonData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, false, false, 1, 1);
GridData addContactData = new GridData(SWT.RIGHT, GridData.FILL_HORIZONTAL, true, false, 1, 1);
Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
group.setLayout(new GridLayout(2, false));
group.setText(Messages.SearchContactDialog_InfoSearchFields);
Group groupContact = new Group(parent, SWT.SHADOW_ETCHED_IN);
groupContact.setLayout(new GridLayout(2, false));
groupContact.setText(Messages.SearchContactDialog_InfoContactFields);
tableResult = new Table(groupContact, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
tableResult.setLinesVisible(true);
tableResult.setHeaderVisible(true);
GridData dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1);
dataTable.heightHint = 200;
tableResult.setLayoutData(dataTable);
new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnName);
new TableColumn(tableResult, SWT.NONE).setText(Messages.SearchContactDialog_TableResultColumnUsername);
new TableItem(tableResult, SWT.NONE);
for (int i = 0; i < 2; i++) {
tableResult.getColumn(i).setWidth(130);
}
addContactButton = new Button(groupContact, SWT.PUSH | SWT.RIGHT);
addContactButton.setText(Messages.SearchContactDialog_ButtonAddContact);
addContactButton.setLayoutData(addContactData);
tableFields = new Table(group, SWT.BORDER | SWT.MULTI | SWT.CHECK);
tableFields.setLinesVisible(true);
tableFields.setHeaderVisible(true);
dataTable = new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true, 2, 1);
dataTable.heightHint = 200;
tableFields.setLayoutData(dataTable);
TableColumn colField = new TableColumn(tableFields, SWT.NONE);
colField.setText(Messages.SearchContactDialog_TableSearchColumnField);
TableColumn colValue = new TableColumn(tableFields, SWT.NONE);
colValue.setText(Messages.SearchContactDialog_TableSearchColumnValue);
colValue.setWidth(130);
for (int i = 0; i < fields.length; i++) {
TableItem item = new TableItem(tableFields, SWT.NONE);
// $NON-NLS-1$
item.setText(new String[] { fields[i], "" });
item.setChecked(true);
}
TableItem[] items = tableFields.getItems();
for (int i = 0; i < items.length; i++) {
final TableEditor editor = new TableEditor(tableFields);
Text text = new Text(tableFields, SWT.NONE);
text.setText(items[i].getText(editableColumn));
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
editor.getItem().setText(editableColumn, ((Text) editor.getEditor()).getText());
}
});
text.selectAll();
text.setFocus();
editor.grabHorizontal = true;
editor.setEditor(text, items[i], editableColumn);
}
colField.pack();
runInBackgroundButton = new Button(group, SWT.CHECK);
runInBackgroundButton.setText(Messages.SearchContactDialog_RunInBackground);
runInBackgroundButton.setToolTipText(Messages.SearchContactDialog_RunInBackGroundToolTip);
searchButton = new Button(group, SWT.PUSH | SWT.RIGHT);
searchButton.setText(Messages.SearchContactDialog_ButtonSearch);
searchButton.setLayoutData(searchButtonData);
} catch (ECFException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getLocalizedMessage(), e));
new Label(parent, SWT.LEFT).setText(e.getLocalizedMessage());
}
addListeners();
applyDialogFont(parent);
return parent;
}
Aggregations