1// BEGIN LICENSE BLOCK
2// Version: CMPL 1.1
3//
4// The contents of this file are subject to the Cisco-style Mozilla Public
5// License Version 1.1 (the "License"); you may not use this file except
6// in compliance with the License.  You may obtain a copy of the License
7// at www.eclipse-clp.org/license.
8//
9// Software distributed under the License is distributed on an "AS IS"
10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
11// the License for the specific language governing rights and limitations
12// under the License.
13//
14// The Original Code is  The ECLiPSe Constraint Logic Programming System.
15// The Initial Developer of the Original Code is  Cisco Systems, Inc.
16// Portions created by the Initial Developer are
17// Copyright (C) 2006 Cisco Systems, Inc.  All Rights Reserved.
18//
19// Contributor(s):
20//
21// END LICENSE BLOCK
22
23package com.parctechnologies.eclipse.visualisation;
24
25import java.util.*;
26import java.beans.*;
27import javax.swing.table.*;
28import com.parctechnologies.eclipse.*;
29
30/**
31 * A ViewletDataStore is an abstract mapping between indices and
32 * ViewletData, intended to hold the ViewletType specific data for
33 * viewable elements, size and fixity of the dimensions of a viewable
34 * on the eclipse side.
35 *
36 * Instead of viewable elements, it contains ViewletData. Each viewlet
37 * is produced from a ViewletFactory.
38 *
39 * All ViewletDataStores can be used as models for JTables and
40 * SpreadSheets.
41 *
42 * <p> Note that ViewletDataStore is not responsible for maintaining
43 * location names or the Viewable handle, only for keeping references
44 * to them and providing access to them.  */
45public interface ViewletDataStore extends SpreadSheetModel, SymRefable
46{
47    /**
48     * dimNumber starts from 1. List should be a list of Strings.
49     */
50    public void setLocationNames(int dimNumber, List locationNames);
51
52    /**
53     * dimNumber starts from 1.
54     */
55    public void finishExpandDimension(int dimNumber);
56
57    /**
58     * dimNumber starts from 1.
59     */
60    public List getLocationNames(int dimNumber);
61
62    /**
63     * dimNumber & locNumber start from 1.
64     */
65    public String getLocationName(int dimNumber, int locNumber);
66
67    /**
68     * Set the Java handle to the ECLiPSe side viewable
69     */
70    public void setViewable(Viewable viewable);
71
72    /**
73     * Get the Java handle to the ECLiPSe side viewable
74     */
75    public Viewable getViewable();
76
77    /**
78     * Traverses the entire structure recursively to collect together
79     * all the indices.  */
80    public ViewletRange getEntireViewletRange();
81
82    /**
83     * Returns a data iterator for the given ViewletRange
84     */
85    public Iterator getViewletDataIterator(ViewletRange range);
86
87    /**
88     * Return the number of dimensions in this store.
89     */
90    public int getNDimensions();
91
92    /** Return the length of each dimension */
93    public List getSize();
94
95    /**
96     * Shrinks the ViewletArray to size newSize. Assumes the top-level
97     * fixity is flexible.  */
98    void shrinkTo(List newSize);
99
100    /**
101     * Expand dimension nested at level <code>dimension</code> by
102     * one. If the parameter dimension is greater than 1 this means
103     * that this.elements stays the same size and it is the
104     * sub-ViewletArrays which expand. Otherwise, we have to expand
105     * the top level by adding a new object to elements. This is
106     * created using createSubArray.  */
107    void startExpandDimension(int dimension);
108
109    /**
110     * Get the ViewletData for the given index
111     */
112    public ViewletData getViewletDataAt(List index);
113
114    /**
115     * Sets the ViewletData for the given index
116     */
117    public void setViewletDataAt(List index, ViewletData data);
118
119    /**
120     * Fire data changed events upto any listeneing guis
121     */
122    public void fireViewletRangeUpdated(ViewletRange range);
123
124    /**
125     * Adds a ViewletDataStoreListener
126     */
127    public void addViewletDataStoreListener(ViewletDataStoreListener listener);
128
129    /**
130     * Removes a ViewletDataStoreListener
131     */
132    public void removeViewletDataStoreListener(ViewletDataStoreListener listener);
133
134    /**
135     * Factory method for creating ViewletRange object from any given
136     * collection.
137     *
138     * <p>This method allows DataStores to create their own
139     * specialised ViewletRange classes which can be optimised to the
140     * type of data store being used.  */
141    public ViewletRange createRange(Collection indices);
142
143    /**
144     * Factory method for creating ViewletRange objects to cover all elements between the given start and end indices.
145     *
146     * <p>This method allows DataStores to create their own
147     * specialised ViewletRange classes which can be optimised to the
148     * type of data store being used.  */
149    public ViewletRange createRange(List fromIndex, List toIndex);
150}
151