1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package com.sun.star.wizards.agenda;
24 
25 
26 import com.sun.star.beans.PropertyValue;
27 import com.sun.star.wizards.common.ConfigGroup;
28 import com.sun.star.wizards.common.Indexable;
29 import com.sun.star.wizards.common.PropertyNames;
30 
31 /**
32  * CGTopic means: Configuration Group Topic.
33  * This object encapsulates a configuration group with topic information.
34  * Since the topics gui conftrol uses its own data model, there is
35  * also code here to convert from the data model to CGTopic object (the constructor)
36  * and vice versa (setDataToRow method - used when loading the last session...)
37  */
38 public class CGTopic extends ConfigGroup implements Indexable {
39 
40     /** sort order  */
41     public int cp_Index;
42     /** topic name  */
43     public String cp_Topic;
44     /** responsible */
45     public String cp_Responsible;
46     /** time */
47     public String cp_Time;
48 
CGTopic()49     public CGTopic() {}
50 
51     /**
52      * create a new CGTopic object with data from the given row.
53      * the row object is a PropertyValue array, as used
54      * by the TopicsControl's data model.
55      * @param row PropertyValue array as used by the TopicsControl data model.
56      */
CGTopic( Object row)57     public CGTopic( Object row) {
58         PropertyValue[] pv = (PropertyValue[])row;
59         String num = (String)pv[0].Value;
60         cp_Index = Integer.valueOf(num.substring(0,num.length() - 1)).intValue();
61         cp_Topic = (String)pv[1].Value;
62         cp_Responsible = (String)pv[2].Value;
63         cp_Time = (String)pv[3].Value;
64     }
65 
66     /**
67      * copies the data in this CGTopic object
68      * to the given row.
69      * @param row the row object (PropertyValue array) to
70      * copy the data to.
71      */
setDataToRow(Object row)72     public void setDataToRow(Object row) {
73         PropertyValue[] pv = (PropertyValue[])row;
74         pv[0].Value = PropertyNames.EMPTY_STRING + cp_Index + ".";
75         pv[1].Value = cp_Topic;
76         pv[2].Value = cp_Responsible;
77         pv[3].Value = cp_Time;
78     }
79 
getIndex()80     public int getIndex() {
81         return cp_Index;
82     }
83 
84 }
85