View Javadoc
1   /*
2    * Prometheus: Application Framework
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.prometheus.service.sheet;
18  
19  /**
20   * Class representing a column in Oasis.
21   *
22   * @author Tony Washer
23   */
24  public abstract class PrometheusSheetColumn {
25      /**
26       * The underlying sheet.
27       */
28      private final PrometheusSheetSheet theSheet;
29  
30      /**
31       * The index of this column.
32       */
33      private final int theColIndex;
34  
35      /**
36       * Is the column readOnly?
37       */
38      private final boolean isReadOnly;
39  
40      /**
41       * Constructor.
42       *
43       * @param pSheet    the sheet for the column
44       * @param pIndex    the index
45       * @param pReadOnly is the column readOnly?
46       */
47      protected PrometheusSheetColumn(final PrometheusSheetSheet pSheet,
48                                      final int pIndex,
49                                      final boolean pReadOnly) {
50          /* Store parameters */
51          theSheet = pSheet;
52          theColIndex = pIndex;
53          isReadOnly = pReadOnly;
54      }
55  
56      /**
57       * Obtain the underlying sheet.
58       *
59       * @return the underlying sheet
60       */
61      public PrometheusSheetSheet getSheet() {
62          return theSheet;
63      }
64  
65      /**
66       * Obtain the column index.
67       *
68       * @return column index
69       */
70      public int getColumnIndex() {
71          return theColIndex;
72      }
73  
74      /**
75       * Is the column readOnly?
76       *
77       * @return true/false
78       */
79      public boolean isReadOnly() {
80          return isReadOnly;
81      }
82  
83      /**
84       * Get the next column.
85       *
86       * @return the next column
87       */
88      public abstract PrometheusSheetColumn getNextColumn();
89  
90      /**
91       * Get the previous column.
92       *
93       * @return the previous column
94       */
95      public abstract PrometheusSheetColumn getPreviousColumn();
96  
97      /**
98       * Set hidden status.
99       *
100      * @param isHidden is the column hidden?
101      */
102     public void setHidden(final boolean isHidden) {
103         if (!isReadOnly) {
104             setHiddenValue(isHidden);
105         }
106     }
107 
108     /**
109      * Set hidden status.
110      *
111      * @param isHidden is the column hidden?
112      */
113     protected abstract void setHiddenValue(boolean isHidden);
114 
115     /**
116      * Is the column hidden?
117      *
118      * @return true/false
119      */
120     public abstract boolean isHidden();
121 
122     /**
123      * Set hidden status.
124      *
125      * @param pStyle the cell style
126      */
127     public void setDefaultCellStyle(final PrometheusSheetCellStyleType pStyle) {
128         if (!isReadOnly) {
129             setDefaultCellStyleValue(pStyle);
130         }
131     }
132 
133     /**
134      * Set the default cell style.
135      *
136      * @param pStyle the cell style
137      */
138     protected abstract void setDefaultCellStyleValue(PrometheusSheetCellStyleType pStyle);
139 }