01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.romaframework.aspect.view.echo2.domain;
17:
18: import java.util.Collection;
19:
20: import nextapp.echo2.app.Extent;
21:
22: import org.romaframework.aspect.core.annotation.CoreClass;
23: import org.romaframework.aspect.view.annotation.ViewClass;
24: import org.romaframework.aspect.view.echo2.area.AreaInstance;
25: import org.romaframework.aspect.view.echo2.screen.ConfigurableScreen;
26: import org.romaframework.aspect.view.page.Page;
27: import org.romaframework.aspect.view.screen.Screen;
28: import org.romaframework.core.flow.ObjectContext;
29:
30: import tucana.echo2.app.WidgetDash;
31:
32: /**
33: * User Preferences form to change Dashboard setting. Place this component in the dashboard to allow the user to change own
34: * dashboard setting.
35: *
36: * @author Luca Garulli (luca.garulli@assetdata.it)
37: */
38: @CoreClass(orderActions="save cancel")
39: @ViewClass(columns=3)
40: public class Echo2UserPreferences extends Page {
41:
42: protected WidgetDash dash;
43:
44: public Echo2UserPreferences() {
45: Screen desk = ObjectContext.getInstance().getScreen();
46: if (desk instanceof ConfigurableScreen) {
47: ConfigurableScreen cfgDesk = (ConfigurableScreen) desk;
48: for (AreaInstance a : (Collection<AreaInstance>) cfgDesk
49: .getRootArea().getChildren()) {
50: if (a.getComponent() instanceof WidgetDash) {
51: dash = (WidgetDash) a.getComponent();
52: break;
53: }
54: }
55: }
56: }
57:
58: public void save() {
59: back();
60: }
61:
62: public void cancel() {
63: back();
64: }
65:
66: public int getColumns() {
67: return dash != null ? dash.getColumnCount() : 0;
68: }
69:
70: public void setColumns(int columns) {
71: if (dash != null)
72: dash.setColumnCount(columns);
73: }
74:
75: public int getColumnSpacing() {
76: return dash != null ? dash.getColumnSpacing().getValue() : 0;
77: }
78:
79: public void setColumnSpacing(int iColumnSpacing) {
80: if (dash != null)
81: dash.setColumnSpacing(new Extent(iColumnSpacing));
82: }
83:
84: public int getWidgetSpacing() {
85: return dash != null ? dash.getWidgetSpacing().getValue() : 0;
86: }
87:
88: public void setWidgetSpacing(int iWidgetSpacing) {
89: if (dash != null)
90: dash.setWidgetSpacing(new Extent(iWidgetSpacing));
91: }
92: }
|