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