xref: /AOO41X/main/qadevOOo/runner/helper/ObjectInspectorModelImpl.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************
27*cdf0e10cSrcweir  */
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir package helper;
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir import com.sun.star.inspection.PropertyCategoryDescriptor;
32*cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspectorModel;
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir /**
35*cdf0e10cSrcweir  * This is an implementation of <CODE>ObjectInspectorModel</CODE>.
36*cdf0e10cSrcweir  * @see com.sun.star.inspection.XObjectInspectorModel
37*cdf0e10cSrcweir  */
38*cdf0e10cSrcweir public class ObjectInspectorModelImpl implements XObjectInspectorModel{
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir     /**
41*cdf0e10cSrcweir      * class variable which contains the implementations of
42*cdf0e10cSrcweir      * <CODE>PropertyCategoryDescriptor</CODE>
43*cdf0e10cSrcweir      * @see com.sun.star.inspection.PropertyCategoryDescriptor
44*cdf0e10cSrcweir      */
45*cdf0e10cSrcweir     PropertyCategoryDescriptor[] m_Categories;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir     /**
48*cdf0e10cSrcweir      * class variable which contains the count of implementations of
49*cdf0e10cSrcweir      *  <CODE>PropertyCategoryDescriptor</CODE>
50*cdf0e10cSrcweir      */
51*cdf0e10cSrcweir     int m_count;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     /**
54*cdf0e10cSrcweir      * Creates a new instance of ObjectInspectorModelImpl
55*cdf0e10cSrcweir      * For every count given in parameter <CODE>count</CODE> an
56*cdf0e10cSrcweir      * <CODE>PropertyCategoryDescriptor</CODE> was created an filled with valuable content.
57*cdf0e10cSrcweir      * @param count count of <CODE>PropertyCategoryDescriptor</CODE> to create
58*cdf0e10cSrcweir      */
59*cdf0e10cSrcweir     public ObjectInspectorModelImpl(int count) {
60*cdf0e10cSrcweir         m_count = count;
61*cdf0e10cSrcweir         m_Categories = new PropertyCategoryDescriptor[m_count];
62*cdf0e10cSrcweir         int CategoryMem = 0;
63*cdf0e10cSrcweir         int inCat = 0;
64*cdf0e10cSrcweir         for (int n=0; n < m_count; n++ ){
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir             m_Categories[n] = new PropertyCategoryDescriptor();
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir             int category = n / 2;
69*cdf0e10cSrcweir             inCat =(CategoryMem == category)? ++inCat: 1;
70*cdf0e10cSrcweir             CategoryMem = category;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir             //System.out.println("Category" + category + "Number" + inCat);
73*cdf0e10cSrcweir             m_Categories[n].ProgrammaticName = "Category" + category;
74*cdf0e10cSrcweir             m_Categories[n].UIName = "Category" + category + "Number" + inCat;
75*cdf0e10cSrcweir             m_Categories[n].HelpURL = "h:" + n;
76*cdf0e10cSrcweir         }
77*cdf0e10cSrcweir     }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     /**
80*cdf0e10cSrcweir      * returns the catrgories
81*cdf0e10cSrcweir      * @return returns the catrgories
82*cdf0e10cSrcweir      */
83*cdf0e10cSrcweir     public PropertyCategoryDescriptor[] describeCategories() {
84*cdf0e10cSrcweir         return m_Categories;
85*cdf0e10cSrcweir     }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     /**
88*cdf0e10cSrcweir      * returns currently nothing
89*cdf0e10cSrcweir      * @return nothing
90*cdf0e10cSrcweir      */
91*cdf0e10cSrcweir     public Object[] getHandlerFactories() {
92*cdf0e10cSrcweir         return null;
93*cdf0e10cSrcweir     }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     /** determines whether the object inspector should have a help section
96*cdf0e10cSrcweir         @return false
97*cdf0e10cSrcweir     */
98*cdf0e10cSrcweir     public boolean getHasHelpSection() {
99*cdf0e10cSrcweir         return false;
100*cdf0e10cSrcweir     }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir     /** returns minimum number of lines in the help text section.
103*cdf0e10cSrcweir         @return 3
104*cdf0e10cSrcweir     */
105*cdf0e10cSrcweir     public int getMinHelpTextLines() {
106*cdf0e10cSrcweir         return 3;
107*cdf0e10cSrcweir     };
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     /** returns maximum number of lines in the help text section.
110*cdf0e10cSrcweir         @return 8
111*cdf0e10cSrcweir     */
112*cdf0e10cSrcweir     public int getMaxHelpTextLines() {
113*cdf0e10cSrcweir         return 8;
114*cdf0e10cSrcweir     };
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     /** returns whether or not the inspector's UI should be read-only
117*cdf0e10cSrcweir     */
118*cdf0e10cSrcweir     public boolean getIsReadOnly() {
119*cdf0e10cSrcweir         return false;
120*cdf0e10cSrcweir     }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     /** sets the inspector's read-only state
123*cdf0e10cSrcweir     */
124*cdf0e10cSrcweir     public void setIsReadOnly( boolean _IsReadOnly ) {
125*cdf0e10cSrcweir         // not supported, and not used so far in our test cases
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     /**
129*cdf0e10cSrcweir      * retrieves an index in a global property ordering, for a given property name
130*cdf0e10cSrcweir      * @param UIName the property whose global order index should be retrieved
131*cdf0e10cSrcweir      * @throws com.sun.star.beans.UnknownPropertyException if the given property is unknown
132*cdf0e10cSrcweir      * @return the global order index of PropertyName
133*cdf0e10cSrcweir      */
134*cdf0e10cSrcweir     public int getPropertyOrderIndex(String UIName) {
135*cdf0e10cSrcweir         int index = 0;
136*cdf0e10cSrcweir         for (int n=0; n < m_Categories.length; n++){
137*cdf0e10cSrcweir             if (m_Categories[n].UIName.equals(UIName)){
138*cdf0e10cSrcweir                 index = n;
139*cdf0e10cSrcweir                 break;
140*cdf0e10cSrcweir             }
141*cdf0e10cSrcweir         }
142*cdf0e10cSrcweir         return index;
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir  }
146