1 package com.quantum.view.bookmark;
3 import com.quantum.Messages;
4 import com.quantum.QuantumPlugin;
5 import com.quantum.model.Bookmark;
6 import com.quantum.model.BookmarkCollection;
8 import org.eclipse.jface.viewers.ISelectionProvider;
9 import org.eclipse.jface.viewers.IStructuredSelection;
10 import org.eclipse.ui.IViewPart;
11 import org.eclipse.ui.actions.SelectionListenerAction;
14 final class PasteAction extends SelectionListenerAction {
15 private IViewPart view;
16 private BookmarkClipboard bookmarkClipboard;
20 public PasteAction(IViewPart view, BookmarkClipboard bookmarkClipboard,
21 ISelectionProvider selectionProvider) {
22 super(Messages.getString(PasteAction.class.getName() + ".text"));
23 setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif"));
25 selectionProvider.addSelectionChangedListener(this);
26 this.bookmarkClipboard = bookmarkClipboard;
29 if (this.bookmarkClipboard.getBookmark() != null) {
30 Bookmark bookmark = new Bookmark(this.bookmarkClipboard.getBookmark());
31 String copyName = BookmarkCollection.getInstance().getCopyName(bookmark.getName());
32 bookmark.setName(copyName); //$NON-NLS-1$
33 BookmarkCollection.getInstance().addBookmark(bookmark);
38 * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
40 protected boolean updateSelection(IStructuredSelection selection) {
41 boolean enabled = super.updateSelection(selection);
42 enabled &= this.bookmarkClipboard.getBookmark() != null;