improved syntax highlighting (php tag/return keyword/brackets and operators)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / PasteAction.java
1 package com.quantum.view.bookmark;
2
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;
7
8 import com.quantum.ImageStore;
9 import com.quantum.Messages;
10 import com.quantum.model.Bookmark;
11 import com.quantum.model.BookmarkCollection;
12
13
14 final class PasteAction extends SelectionListenerAction {
15     private BookmarkClipboard bookmarkClipboard;
16     /**
17      * @param BookmarkView
18      */
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;
25     }
26     public void run() {
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);
32                 }
33         }
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
37      */
38     protected boolean updateSelection(IStructuredSelection selection) {
39         boolean enabled = super.updateSelection(selection);
40         enabled &= this.bookmarkClipboard.getBookmark() != null;
41         return enabled;
42     }
43
44 }