KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > table > navi > NonEmptyUI


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.table.navi;
14
15 import com.tonbeller.jpivot.core.ModelChangeEvent;
16 import com.tonbeller.jpivot.core.ModelChangeListener;
17 import com.tonbeller.jpivot.olap.navi.NonEmpty;
18 import com.tonbeller.jpivot.table.TableComponent;
19 import com.tonbeller.jpivot.table.TableComponentExtensionSupport;
20 import com.tonbeller.wcf.controller.RequestContext;
21
22 /**
23  * show/hide non empty rows/columns. The toolbar button is connected to the boolean suppress property.
24  *
25  * @author av
26  */

27 public class NonEmptyUI extends TableComponentExtensionSupport implements ModelChangeListener {
28
29   public static final String JavaDoc ID = "nonEmpty";
30   public String JavaDoc getId() {
31     return ID;
32   }
33
34   NonEmpty extension;
35
36   public void initialize(RequestContext context, TableComponent table) throws Exception JavaDoc {
37     super.initialize(context, table);
38         table.getOlapModel().addModelChangeListener(this);
39         extension = getNonEmpty();
40   }
41
42   public boolean isButtonPressed() {
43     if (extension != null)
44       return extension.isNonEmpty();
45     return false;
46   }
47
48   public void setButtonPressed(boolean value) {
49     if (extension != null)
50       extension.setNonEmpty(value);
51   }
52
53   public boolean isAvailable() {
54     return getNonEmpty() != null;
55   }
56
57   NonEmpty getNonEmpty() {
58     return (NonEmpty) table.getOlapModel().getExtension(NonEmpty.ID);
59   }
60
61   public void modelChanged(ModelChangeEvent e) {
62   }
63
64   public void structureChanged(ModelChangeEvent e) {
65         extension = getNonEmpty();
66   }
67
68 }
69
Popular Tags