org.eclipse.swt.custom.ControlEditor Java Examples

The following examples show how to use org.eclipse.swt.custom.ControlEditor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PTWidgetTable.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#refillData()
 */
@Override
public void refillData() {
	try {
		table.setRedraw(false);
		for (final TableItem item : table.getItems()) {
			item.dispose();
		}

		if (table.getData() != null) {
			@SuppressWarnings("unchecked")
			final List<ControlEditor> list = (List<ControlEditor>) table.getData();
			for (final ControlEditor c : list) {
				c.dispose();
			}
			list.clear();
			table.setData(null);
		}

		fillData();
	} finally {
		table.setRedraw(true);
		table.redraw();
		table.update();
	}
}
 
Example #2
Source File: PTWidgetTable.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Fill Data in the widget
 */
private void fillData() {
	List<PTProperty> props;
	if (getParentPropertyTable().sorted) {
		props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList());
		Collections.sort(props, new Comparator<PTProperty>() {

			@Override
			public int compare(final PTProperty o1, final PTProperty o2) {
				if (o1 == null && o2 == null) {
					return 0;
				}

				if (o1.getName() == null && o2.getName() != null) {
					return -1;
				}

				if (o1.getName() != null && o2.getName() == null) {
					return 1;
				}

				return o1.getName().compareTo(o2.getName());
			}
		});
	} else {
		props = new ArrayList<PTProperty>(getParentPropertyTable().getPropertiesAsList());
	}

	final List<ControlEditor> editors = new ArrayList<ControlEditor>();
	for (final PTProperty p : props) {
		final TableItem item = new TableItem(table, SWT.NONE);
		item.setData(p);
		item.setText(0, StringUtil.safeToString(p.getDisplayName()));
		if (p.getEditor() == null) {
			p.setEditor(new PTStringEditor());
		}

		final ControlEditor editor = p.getEditor().render(this, item, p);
		item.addListener(SWT.Dispose, event -> {
			if (editor.getEditor() != null) {
				editor.getEditor().dispose();
			}
			editor.dispose();
		});
		if (!p.isEnabled()) {
			item.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_GRAY));
		}
	}

	table.setData(editors);

}
 
Example #3
Source File: PTEditor.java    From nebula with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Renders an editor
 * 
 * @param parent the parent PTWidget (a table or a tree table)
 * @param item the item on which the editor is displayed
 * @param property the property associated to the editor
 * @return a control editor
 */
public abstract ControlEditor render(PTWidget parent, Item item, PTProperty property);