Search in sources :

Example 1 with ClipboardAction

use of org.erlide.wrangler.refactoring.duplicatedcode.actions.ClipboardAction in project erlide_eclipse by erlang.

the class DuplicatesView method makeActions.

private void makeActions() {
    copyGeneralisedToClipboard = new ClipboardAction(PlatformUI.getWorkbench().getDisplay());
    copyGeneralisedToClipboard.setToolTipText("Copy generalised function to the clipboard");
    copyGeneralisedToClipboard.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    copyFunCallToClipboard.setToolTipText("Copy FunCall to the clipboard");
    copyFunCallToClipboard.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final ISelection sel = event.getSelection();
            if (sel == null || sel.isEmpty()) {
                return;
            }
            final TreeSelection tsel = (TreeSelection) sel;
            final AbstractResultTreeObject selection = (AbstractResultTreeObject) tsel.getFirstElement();
            copyGeneralisedToClipboard.setText(selection.getSuggestedCode());
            if (selection instanceof DuplicatedCodeInstanceElement) {
                final DuplicatedCodeInstanceElement dcie = (DuplicatedCodeInstanceElement) selection;
                copyFunCallToClipboard.setText(dcie.getReplicationFunction());
            }
        }
    });
}
Also used : AbstractResultTreeObject(org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.AbstractResultTreeObject) ClipboardAction(org.erlide.wrangler.refactoring.duplicatedcode.actions.ClipboardAction) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DuplicatedCodeInstanceElement(org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeInstanceElement)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 ClipboardAction (org.erlide.wrangler.refactoring.duplicatedcode.actions.ClipboardAction)1 AbstractResultTreeObject (org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.AbstractResultTreeObject)1 DuplicatedCodeInstanceElement (org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeInstanceElement)1