X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java new file mode 100644 index 0000000..a7bf476 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java @@ -0,0 +1,46 @@ +package com.quantum.view.bookmark; + +import com.quantum.Messages; +import com.quantum.QuantumPlugin; +import com.quantum.model.Bookmark; +import com.quantum.model.BookmarkCollection; + +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.actions.SelectionListenerAction; + + +final class PasteAction extends SelectionListenerAction { + private IViewPart view; + private BookmarkClipboard bookmarkClipboard; + /** + * @param BookmarkView + */ + public PasteAction(IViewPart view, BookmarkClipboard bookmarkClipboard, + ISelectionProvider selectionProvider) { + super(Messages.getString(PasteAction.class.getName() + ".text")); + setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif")); + this.view = view; + selectionProvider.addSelectionChangedListener(this); + this.bookmarkClipboard = bookmarkClipboard; + } + public void run() { + if (this.bookmarkClipboard.getBookmark() != null) { + Bookmark bookmark = new Bookmark(this.bookmarkClipboard.getBookmark()); + String copyName = BookmarkCollection.getInstance().getCopyName(bookmark.getName()); + bookmark.setName(copyName); //$NON-NLS-1$ + BookmarkCollection.getInstance().addBookmark(bookmark); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) + */ + protected boolean updateSelection(IStructuredSelection selection) { + boolean enabled = super.updateSelection(selection); + enabled &= this.bookmarkClipboard.getBookmark() != null; + return enabled; + } + +} \ No newline at end of file