/v3.2/nimbits-tds/src/com/nimbits/client/panels/MainPanel.java
http://nimbits-server.googlecode.com/ · Java · 195 lines · 120 code · 63 blank · 12 comment · 2 complexity · 6acebfe8556d2089d1a5e47be9885021 MD5 · raw file
- /*
- * Copyright (c) 2010 Tonic Solutions LLC.
- *
- * http://www.nimbits.com
- *
- *
- * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/gpl.html
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- */
-
- package com.nimbits.client.panels;
-
- import com.extjs.gxt.ui.client.Style.LayoutRegion;
- import com.extjs.gxt.ui.client.Style.Orientation;
- import com.extjs.gxt.ui.client.util.Margins;
- import com.extjs.gxt.ui.client.widget.ContentPanel;
- import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
- import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
- import com.extjs.gxt.ui.client.widget.layout.FillLayout;
- import com.nimbits.client.exception.NimbitsException;
- import com.nimbits.client.model.LoginInfo;
- import com.nimbits.client.model.category.Category;
- import com.nimbits.client.model.diagram.Diagram;
- import com.nimbits.client.model.email.EmailAddress;
- import com.nimbits.client.model.point.Point;
-
- public class MainPanel extends NavigationEventProvider {
-
- private final CenterPanel center = new CenterPanel();
- private final EmailAddress emailAddress;
-
-
- final NavigationPanel createNavigationPanel() {
- final NavigationPanel navTree = new NavigationPanel(emailAddress, false);
-
-
- navTree.addCategoryClickedListeners(new NavigationEventProvider.CategoryClickedListener() {
-
- @Override
- public void onCategoryClicked(final Category c, boolean readOnly) throws NimbitsException {
-
- notifyCategoryClickedListener(c, readOnly);
-
- }
-
- });
-
- navTree.addPointClickedListeners(new NavigationEventProvider.PointClickedListener() {
-
- @Override
- public void onPointClicked(final Point p) {
-
- notifyPointClickedListener(p);
- }
-
- });
-
- navTree.addDiagramClickedListeners(new NavigationEventProvider.DiagramClickedListener() {
-
- @Override
- public void onDiagramClicked(final Diagram p) {
-
- notifyDiagramClickedListener(p);
- }
-
- });
-
-
- navTree.addPointDeletedListeners(new NavigationEventProvider.PointDeletedListener() {
-
- @Override
- public void onPointDeleted(final Point c) throws NimbitsException {
- notifyPointDeletedListener(c);
- center.removePoint(c);
- }
-
- });
-
- navTree.addDiagramDeletedListeners(new NavigationEventProvider.DiagramDeletedListener() {
-
- @Override
- public void onDiagramDeleted(final Diagram c, final boolean readOnly) throws NimbitsException {
- notifyDiagramDeletedListener(c, readOnly);
- }
-
- });
- return navTree;
-
-
- }
-
-
- public void addPoint(final Point point) {
- center.addPoint(point);
- }
-
-
- public MainPanel(final LoginInfo loginInfo, final boolean loadConnections) throws NimbitsException {
-
- final BorderLayout layout = new BorderLayout();
- this.emailAddress = loginInfo.getEmailAddress();
- setLayout(layout);
-
-
- final ContentPanel west = new ContentPanel();
- final ContentPanel east = new ContentPanel();
-
- east.setHeading("Connections");
- if (loadConnections) {
- ConnectionPanel connections = createConnections(loginInfo.getEmailAddress());
- east.add(connections);
- }
-
- final NavigationPanel navigationPanel = createNavigationPanel();
- navigationPanel.setLayout(new FillLayout());
- west.add(navigationPanel);
- west.setHeight("100%");
- west.setHeading("Navigator");
-
-
- final BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 250);
- westData.setSplit(true);
- westData.setCollapsible(true);
- westData.setMargins(new Margins(5));
-
- final BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
- centerData.setMargins(new Margins(5, 5, 5, 0));
-
- final BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 175);
- eastData.setSplit(true);
- eastData.setCollapsible(true);
- eastData.setMargins(new Margins(5));
-
- final BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH,
- 125);
- southData.setSplit(true);
- southData.setCollapsible(true);
- southData.setMargins(new Margins(0, 0, 0, 0));
- west.setLayout(new FillLayout(Orientation.VERTICAL));
-
- add(west, westData);
- if (loadConnections) {
- add(east, eastData);
- }
-
- center.setLayout(new FillLayout());
- add(center, centerData);
-
-
- }
-
-
- private ConnectionPanel createConnections(final EmailAddress email) throws NimbitsException {
- final ConnectionPanel connections = new ConnectionPanel(email);
-
- connections.addCategoryClickedListeners(new NavigationEventProvider.CategoryClickedListener() {
-
- @Override
- public void onCategoryClicked(final Category c, boolean readOnly) throws NimbitsException {
-
- notifyCategoryClickedListener(c, readOnly);
-
- }
-
- });
-
- connections.addPointClickedListeners(new NavigationEventProvider.PointClickedListener() {
-
- @Override
- public void onPointClicked(final Point p) {
-
- notifyPointClickedListener(p);
- }
-
- });
- connections.addDiagramClickedListeners(new NavigationEventProvider.DiagramClickedListener() {
-
- @Override
- public void onDiagramClicked(final Diagram p) {
-
- notifyDiagramClickedListener(p);
- }
-
- });
-
- return connections;
- }
-
- public void addDiagram(final Diagram d) {
- center.addDiagram(d);
- }
- }