- composite = new FeatureTreeEditorComposite(parent, SWT.NULL);
- composite.init(new FeatureNodeDragListener(composite.getViewer()),
- new FeatureNodeDropAdapter(dirty, composite.getViewer()), this, new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(isDirty()){
- if(MessagingUtils.confirmDialog("Editor has to be saved", "You have to save before loading another feature tree. Save now?")){
- save();
- }
- else{
- return;
- }
-
- }
- FeatureTree tree = FeatureTreeSelectionDialog.select(composite.getDisplay().getActiveShell(), conversation, null);
- if (tree != null) {
- composite.setSelectedTree(tree, FeatureTreeEditor.this);
- }
- }
- }, new AddButtonListener(), new RemoveSelectionListener(), new FeatureTreeExportListener(composite.getDisplay().getActiveShell(), composite));
+ parent.setLayout(new FillLayout());
+ viewer = new TreeViewer(parent);
+ viewer.setContentProvider(new FeatureTreeContentProvider());
+ viewer.setLabelProvider(new FeatureTreeLabelProvider());
+
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] {
+ FeatureNodeTransfer.getInstance(),
+ TermTransfer.getInstance(),
+ LocalSelectionTransfer.getTransfer()};
+ viewer.addDragSupport(ops, transfers, new FeatureNodeDragListener(viewer));
+ viewer.addDropSupport(ops, transfers, new FeatureTreeDropAdapter(this, viewer, sync));
+ viewer.addSelectionChangedListener(this);
+ viewer.getTree().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if(e.stateMask == SWT.MOD1 && e.keyCode == 'c'){
+ copy(viewer.getStructuredSelection());
+ }
+ else if(e.stateMask == SWT.MOD1 && e.keyCode == 'v'){
+ paste(viewer.getStructuredSelection());
+ }
+ }
+ });
+
+ List<FeatureTree> trees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
+ Collections.sort(trees, (tree1, tree2) -> tree1.getTitleCache().compareTo(tree2.getTitleCache()));
+ viewer.setInput(trees);