KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > viewers > model > provisional > IModelSelectionPolicy


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.viewers.model.provisional;
12
13 import org.eclipse.jface.viewers.ISelection;
14
15 /**
16  * Resolves selection conflicts within a model. When
17  * a selection exists in a viewer, and a client asks
18  * to set another selection, the selection policy for
19  * that model is asked to determine whether the new
20  * selection should override the previous selection.
21  * When a selection is from a different model, the
22  * original selection is maintained if its model selection
23  * policy specifies the selection to be 'sticky'.
24  * <p>
25  * A selection policy is obtained by querying for the selection
26  * policy factory for a given element. The selection policy factory
27  * will then be asked to create a model selection policy adapter.
28  * The adapter represents selections from an instance of a model.
29  * </p>
30  *
31  * @see IModelSelectionPolicyFactory
32  * @since 3.2
33  */

34 public interface IModelSelectionPolicy {
35     
36     /**
37      * Returns whether the given selection is contained in
38      * this model.
39      *
40      * @param selection
41      * @param context
42      * @return
43      */

44     public boolean contains(ISelection selection, IPresentationContext context);
45     
46     /**
47      * Returns whether the candidate selection overrides the
48      * existing selection. The policy is only asked about selections
49      * that it contains.
50      *
51      * @param existing
52      * @param candidate
53      * @param context
54      * @return
55      */

56     public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context);
57
58     /**
59      * Returns whether the given selection should be maintained in the
60      * face of a selection attempt from a different model.
61      *
62      * @param selection
63      * @param context
64      * @return
65      */

66     public boolean isSticky(ISelection selection, IPresentationContext context);
67     
68     /**
69      * Replaces an invalid selection.
70      * <p>
71      * This method is called if a model change picked up by a viewer
72      * results in an invalid selection. For instance if an element contained in
73      * the selection has been removed from the viewer, the selection policy associated
74      * with the invalid selection is free to specify a new selection. The default
75      * selection policy returns the <code>newSelection</code> as is (with missing
76      * elements removed). Model selection policies may implement a different strategy
77      * for picking a new selection when the old selection becomes invalid.
78      * </p>
79      *
80      * @param invalidSelection
81      * the selection before the viewer was updated
82      * @param newSelection
83      * the selection after the update, or <code>null</code> if none
84      * @return new selection or <code>null</code> if none
85      */

86     public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection);
87 }
88
Popular Tags