001: /*
002: * CoadunationAdmin: The admin frontend for coadunation.
003: * Copyright (C) 2007 - 2008 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * ObjectsPanel.java
020: */
021:
022: package com.rift.coad.web.admin.client;
023:
024: // imports
025: import com.google.gwt.user.client.ui.AbstractImagePrototype;
026: import com.google.gwt.user.client.ui.Composite;
027: import com.google.gwt.user.client.ui.ImageBundle;
028: import com.google.gwt.user.client.ui.VerticalPanel;
029: import com.google.gwt.user.client.ui.Label;
030: import com.google.gwt.user.client.ui.ListBox;
031: import com.google.gwt.user.client.ui.ChangeListener;
032: import com.google.gwt.user.client.ui.Widget;
033:
034: /**
035: * This panel lists the objects that will be displayed on the frontend.
036: *
037: * @author brett chaldecott
038: */
039: public class ObjectsPanel extends Composite implements ChangeListener {
040:
041: // private member variables
042: private ObjectsListener listener = null;
043: private ListBox objects = new ListBox();
044:
045: /**
046: * Creates a new instance of ObjectsPanel
047: *
048: * @param listener The object listener.
049: */
050: public ObjectsPanel(ObjectsListener listener) {
051: this .listener = listener;
052: VerticalPanel panel = new VerticalPanel();
053: panel.setStyleName("panel-Border");
054: Label objectLabel = new Label("Objects");
055: objectLabel.setStyleName("header-Label");
056: panel.add(objectLabel);
057: objects.setVisibleItemCount(10);
058: objects.setPixelSize(150, 200);
059: panel.add(objects);
060: objects.addChangeListener(this );
061: initWidget(panel);
062: }
063:
064: /**
065: * Creates a new instance of ObjectsPanel
066: *
067: * @param listener The object listener.
068: */
069: public ObjectsPanel(ObjectsListener listener, int height) {
070: this .listener = listener;
071: VerticalPanel panel = new VerticalPanel();
072: panel.setStyleName("panel-Border");
073: Label objectLabel = new Label("Objects");
074: objectLabel.setStyleName("header-Label");
075: panel.add(objectLabel);
076: objects.setVisibleItemCount(10);
077: objects.setPixelSize(150, height);
078: panel.add(objects);
079: objects.addChangeListener(this );
080: initWidget(panel);
081: }
082:
083: /**
084: * This method adds the list of objects
085: */
086: public void setObjects(String[] entries) {
087: objects.clear();
088: for (int index = 0; index < entries.length; index++) {
089: objects.addItem(entries[index]);
090: }
091: }
092:
093: /**
094: * This method will be called when the list changes
095: */
096: public void onChange(Widget sender) {
097: if (sender == objects) {
098: listener.objectSelected(objects.getItemText(objects
099: .getSelectedIndex()));
100: }
101: }
102:
103: }
|