*/
@Override
public void createControl(Composite parent) {
this.overlay = new Composite(parent, SWT.NONE);
final Clipboard clipboard = new Clipboard(Display.getCurrent());
GridLayout layout = new GridLayout();
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
overlay.setLayout(layout);
KeyListener checkSelectedKeyListener = new KeyAdapter() {
public void keyPressed(KeyEvent keyEvent) {
int keyCode = keyEvent.keyCode;
if (keyCode == SWT.CR || keyCode == SWT.LF || keyCode == SWT.KEYPAD_CR) {
uncheckAll();
checkAllVisible();
}
}
};
filterTypeTextField = new Text(overlay, SWT.SINGLE | SWT.BORDER);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.horizontalSpan = 1;
filterTypeTextField.setLayoutData(gd);
filterTypeTextField.setToolTipText("Retain types that contain...");
filterTypeTextField.addListener(SWT.KeyUp, this);
filterTypeTextField.addListener(SWT.MouseUp, this);
filterTypeTextField.addListener(SWT.Modify, this);
// TODO only for 3.3 see pom
filterTypeTextField.setMessage("Only types with...");
filterTypeTextField.addKeyListener(checkSelectedKeyListener);
filterCoveredTextTextField = new Text(overlay, SWT.SINGLE | SWT.BORDER);
GridData gd2 = new GridData();
gd2.grabExcessHorizontalSpace = true;
gd2.horizontalAlignment = GridData.FILL;
gd2.horizontalSpan = 1;
filterCoveredTextTextField.setLayoutData(gd2);
filterCoveredTextTextField.setToolTipText("Only annotation with...");
filterCoveredTextTextField.addListener(SWT.KeyUp, this);
filterCoveredTextTextField.addListener(SWT.MouseUp, this);
filterCoveredTextTextField.addListener(SWT.Modify, this);
// TODO only for 3.3 see pom
filterCoveredTextTextField.setMessage("Only annotations with...");
filterCoveredTextTextField.addKeyListener(checkSelectedKeyListener);
treeView = new CheckboxTreeViewer(overlay, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
treeView.getTree().setLayoutData(gd);
AnnotationTreeContentProvider provider = new AnnotationTreeContentProvider(editor, this);
treeView.setContentProvider(provider);
document.addChangeListener(provider);
lableProvider = new AnnotationTreeLabelProvider(this);
treeView.setLabelProvider(lableProvider);
treeView.addCheckStateListener(this);
treeView.addDoubleClickListener(this);
treeView.getTree().addMouseListener(this);
ToolTipListener tl = new ToolTipListener(treeView.getTree());
treeView.getTree().addListener(SWT.Dispose, tl);
treeView.getTree().addListener(SWT.KeyDown, tl);
treeView.getTree().addListener(SWT.MouseMove, tl);
treeView.getTree().addListener(SWT.MouseHover, tl);
int ops = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
treeView.addDragSupport(ops, transfers, new AnnotationTreeViewDragListener(treeView));
getTreeViewer().getControl().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.keyCode;
// backspace or delete: delete annotations
if (keyCode == SWT.BS || keyCode == SWT.DEL) {
deleteSelectedAnnotations();
}
// ctrl and c: copy type name to clipboard
if ((e.stateMask & SWT.CTRL) == SWT.CTRL && keyCode == 'c') {
TreeItem[] selection = treeView.getTree().getSelection();
if (selection != null && selection.length == 1) {
Object obj = selection[0].getData();
if (obj instanceof TypeTreeNode) {
TypeTreeNode typeTreeNode = (TypeTreeNode) obj;
Type type = typeTreeNode.getType();
TextTransfer textTransfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { type.getName() },
new Transfer[] { textTransfer });
}
}
}
}