use of org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent in project netxms by netxms.
the class ObjectBrowser method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
FormLayout formLayout = new FormLayout();
parent.setLayout(formLayout);
// Read custom root objects
long[] rootObjects = null;
objectTree = new ObjectTree(parent, SWT.NONE, ObjectTree.MULTI, rootObjects, null, true, true);
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
objectTree.setLayoutData(fd);
objectTree.setHideSubInterfaces(initHideSubInterfaces);
objectTree.setHideTemplateChecks(initHideTemplateChecks);
objectTree.setHideUnmanaged(initHideUnmanaged);
objectTree.enableFilter(initShowFilter);
objectTree.enableStatusIndicator(initShowStatus);
objectTree.addOpenListener(new ObjectOpenListener() {
@Override
public boolean openObject(AbstractObject object) {
return callOpenObjectHandler(object);
}
});
createActions();
createMenu();
createToolBar();
createPopupMenu();
objectTree.enableDropSupport(this);
objectTree.enableDragSupport();
getSite().setSelectionProvider(objectTree.getTreeViewer());
objectTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int size = ((IStructuredSelection) objectTree.getTreeViewer().getSelection()).size();
actionMoveObject.setEnabled(size == 1);
}
});
objectTree.setFilterCloseAction(new Action() {
@Override
public void run() {
actionShowFilter.setChecked(false);
objectTree.enableFilter(false);
}
});
final TreeViewer tree = objectTree.getTreeViewer();
TreeViewerEditor.create(tree, new ColumnViewerEditorActivationStrategy(tree) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
}, ColumnViewerEditor.DEFAULT);
TextCellEditor editor = new TextCellEditor(tree.getTree(), SWT.BORDER);
editor.addListener(new ICellEditorListener() {
@Override
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
}
@Override
public void cancelEditor() {
objectTree.enableRefresh();
}
@Override
public void applyEditorValue() {
}
});
// TODO: override editor method that creates control to disable refresh
tree.setCellEditors(new CellEditor[] { editor });
// $NON-NLS-1$
tree.setColumnProperties(new String[] { "name" });
tree.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
final Object data = (element instanceof Item) ? ((Item) element).getData() : element;
if (// $NON-NLS-1$
property.equals("name")) {
if (data instanceof AbstractObject) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final String newName = value.toString();
new ConsoleJob(Messages.get().ObjectBrowser_RenameJobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.setObjectName(((AbstractObject) data).getObjectId(), newName);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ObjectBrowser_RenameJobError, ((AbstractObject) data).getObjectName());
}
}.start();
}
}
objectTree.enableRefresh();
}
@Override
public Object getValue(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AbstractObject) {
return ((AbstractObject) element).getObjectName();
}
}
return null;
}
@Override
public boolean canModify(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
objectTree.disableRefresh();
return true;
}
// $NON-NLS-1$
return false;
}
});
activateContext();
restoreSelection();
}
use of org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent in project translationstudio8 by heartsome.
the class GridTableViewer method editElement.
/**
* {@inheritDoc}
*/
public void editElement(Object element, int column) {
try {
getControl().setRedraw(false);
Widget item = findItem(element);
if (item != null) {
ViewerRow row = getViewerRowFromItem(item);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
}
}
}
} finally {
getControl().setRedraw(true);
}
// }
}
use of org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent in project netxms by netxms.
the class AgentFileManager method enableInPlaceRename.
/**
* Enable in-place renames
*/
private void enableInPlaceRename() {
TreeViewerEditor.create(viewer, new ColumnViewerEditorActivationStrategy(viewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
}, ColumnViewerEditor.DEFAULT);
viewer.setCellEditors(new CellEditor[] { new TextCellEditor(viewer.getTree()) });
// $NON-NLS-1$
viewer.setColumnProperties(new String[] { "name" });
viewer.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof Item)
element = ((Item) element).getData();
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AgentFile) {
doRename((AgentFile) element, value.toString());
}
}
}
@Override
public Object getValue(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AgentFile) {
return ((AgentFile) element).getName();
}
}
return null;
}
@Override
public boolean canModify(Object element, String property) {
// $NON-NLS-1$
return property.equals("name");
}
});
}
use of org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent in project netxms by netxms.
the class GalleryTreeViewer method editElement.
public void editElement(Object element, int column) {
if (element instanceof TreePath) {
setSelection(new TreeSelection((TreePath) element));
GalleryItem[] items = gallery.getSelection();
if (items.length == 1) {
ViewerRow row = getViewerRowFromItem(items[0]);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
getControl().setRedraw(false);
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
getControl().setRedraw(true);
}
}
}
} else {
super.editElement(element, column);
}
}
use of org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent in project usbdm-eclipse-plugins by podonoghue.
the class PeripheralConfigurationEditor method createPeripheralsTab.
// class SelectViewAction extends MyAction {
// private final Control fPanel;
//
// SelectViewAction(String text, String toolTip, int style, String imageId, Control panel) {
// super(text, style);
// fPanel = panel;
// }
//
// @Override
// public void run() {
// stackLayout.topControl = fPanel;
// panel.layout();
// }
// }
TabItem createPeripheralsTab(TabFolder parent) {
TabItem tabItem = new TabItem(parent, SWT.NONE);
tabItem.setText("Peripherals");
Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(new FillLayout());
tabItem.setControl(composite);
TreeViewer viewer = new TreeViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
Tree tree = viewer.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
ColumnViewerToolTipSupport.enableFor(viewer);
// viewer.setContentProvider(new ViewContentProvider());
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION;
}
};
TreeViewerEditor.create(viewer, actSupport, ColumnViewerEditor.DEFAULT);
/*
* Do columns
*/
TreeViewerColumn column;
column = new TreeViewerColumn(viewer, SWT.NONE);
column.getColumn().setWidth(400);
column.getColumn().setText("Option Name");
column.getColumn().setResizable(true);
column.setLabelProvider(new MyNameColumnLabelProvider());
column = new TreeViewerColumn(viewer, SWT.NONE);
column.getColumn().setWidth(300);
column.getColumn().setText("Option Value");
column.getColumn().setResizable(true);
return tabItem;
}
Aggregations