use of com.twinsoft.convertigo.eclipse.dnd.TreeDragListener in project convertigo by convertigo.
the class ProjectExplorerView method createPartControl.
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
@SuppressWarnings("deprecation")
public void createPartControl(Composite parent) {
viewContentProvider = new ViewContentProvider(this);
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION) {
@Override
public void refresh(Object element) {
if (Engine.objectsProvider != null) {
viewer.getTree().getDisplay().asyncExec(() -> {
try {
super.refresh(element);
} catch (Exception e) {
ConvertigoPlugin.logDebug3("Failed to refresh: " + e);
}
});
packColumns();
}
}
@Override
public void update(Object element, String[] properties) {
super.update(element, properties);
packColumns();
}
};
viewer.setContentProvider(viewContentProvider);
// DND support
int ops = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] dragtfs = new Transfer[] { TextTransfer.getInstance() };
Transfer[] droptfs = new Transfer[] { TextTransfer.getInstance(), StepSourceTransfer.getInstance(), PaletteSourceTransfer.getInstance(), MobileSourceTransfer.getInstance() };
viewer.addDragSupport(ops, dragtfs, new TreeDragListener(viewer));
viewer.addDropSupport(ops, droptfs, new TreeDropAdapter(viewer));
viewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeExpanded(TreeExpansionEvent event) {
packColumns();
}
@Override
public void treeCollapsed(TreeExpansionEvent event) {
packColumns();
}
});
viewer.setSorter(new TreeObjectSorter());
viewer.setInput(getViewSite());
TreeViewerColumn treeViewerColumn = new TreeViewerColumn(viewer, SWT.LEFT);
ILabelProvider lp = new ViewLabelProvider();
ILabelDecorator ld = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
treeViewerColumn.setLabelProvider(new DecoratingColumnLabelProvider(lp, ld));
treeViewerColumn = new TreeViewerColumn(viewer, SWT.LEFT);
treeViewerColumn.setLabelProvider(new CommentColumnLabelProvider());
treeViewerColumn.setEditingSupport(new CommentEditingSupport(viewer));
// drillDownAdapter = new DrillDownAdapter(viewer);
makeActions();
hookContextMenu();
hookSelectionChangedEvent();
hookDoubleClickAction();
hookGlobalActions();
hookKeyboardActions();
contributeToActionBars();
getSite().setSelectionProvider(viewer);
ConvertigoPlugin.runAtStartup(() -> initialize());
}
Aggregations