1 package com.quantum.actions;
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.Iterator;
8 import com.quantum.Messages;
9 import com.quantum.view.bookmark.EntityNode;
11 import org.eclipse.jface.viewers.IStructuredSelection;
12 import org.eclipse.ui.IViewPart;
13 import org.eclipse.ui.actions.SelectionListenerAction;
16 * <p>This action takes an EntityNode and adds a copy of it to the quicklist
21 public class AddToQuickListAction extends SelectionListenerAction {
22 private IViewPart view;
23 private List entities = Collections.synchronizedList(new ArrayList());
25 public AddToQuickListAction(IViewPart view) {
26 super(Messages.getString(AddToQuickListAction.class.getName() + ".text"));
31 for (Iterator i = this.entities.iterator(); i.hasNext(); ) {
32 EntityNode entityNode = (EntityNode) i.next();
33 entityNode.getBookmark().addQuickListEntry(entityNode.getEntity());
38 * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
40 public boolean updateSelection(IStructuredSelection selection) {
41 boolean enabled = super.updateSelection(selection);
42 this.entities.clear();
43 for (Iterator i = selection.iterator(); enabled && i.hasNext(); ) {
44 Object object = i.next();
45 if (object != null && object instanceof EntityNode) {
46 EntityNode node = (EntityNode) object;
47 enabled &= !(node.getBookmark().isInQuickList(node.getEntity()));
48 this.entities.add(node);