KickJava   Java API By Example, From Geeks To Geeks.

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


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.SwapAxes;
18 import com.tonbeller.jpivot.table.TableComponent;
19 import com.tonbeller.jpivot.table.TableComponentExtensionSupport;
20 import com.tonbeller.wcf.controller.RequestContext;
21
22 /**
23  * swaps table axes. The toolbar button is connected to the boolean action property.
24  *
25  * @author av
26  */

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