1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui;
14 import java.util.ArrayList;
15 import java.util.Collections;
16 import java.util.EventObject;
17 import java.util.List;
19 import org.eclipse.jface.action.IAction;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.utils.datastructures.hints.HintContext;
22 import org.simantics.utils.ui.action.IPriorityAction;
23 import org.simantics.utils.ui.action.PriorityActionAdapter;
26 * TODO: multiple selection support
28 * @author Tuukka Lehtonen
30 public class DoubleClickEvent extends EventObject {
32 private static final long serialVersionUID = 1730213767249571862L;
34 private boolean consumed = false;
36 private final ReadGraph graph;
38 private final Object resource;
40 private List<IPriorityAction> actions = new ArrayList<IPriorityAction>();
42 private HintContext hintContext = new HintContext();
44 public DoubleClickEvent(Object source, ReadGraph g, Object resource) {
47 this.resource = resource;
50 public ReadGraph getGraph() {
54 public Object getResource() {
59 * Mark the event as accepted which suppresses further double click handler
62 public void consume() {
66 public boolean isConsumed() {
71 * Add a possible action with normal priority.
75 public void add(IAction action) {
76 actions.add(new PriorityActionAdapter(IPriorityAction.NORMAL, action));
80 * Add a possible prioritized action.
84 public void add(IPriorityAction action) {
89 * Only used internally by the doubleclick extension point.
93 public IPriorityAction[] getOrderedActions() {
94 List<IPriorityAction> copy = new ArrayList<IPriorityAction>(actions);
95 Collections.sort(copy);
96 return copy.toArray(new IPriorityAction[copy.size()]);
99 public HintContext getHintContext() {