001/*
002 * Copyright (c) 2003-2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: barseghian $'
006 * '$Date: 2011-02-12 02:25:44 +0000 (Sat, 12 Feb 2011) $' 
007 * '$Revision: 27102 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.reporting.rio;
031
032import java.io.Serializable;
033import java.net.URL;
034import java.util.ArrayList;
035import java.util.List;
036
037import javax.swing.ImageIcon;
038
039import org.kepler.objectmanager.lsid.KeplerLSID;
040import org.kepler.provenance.Queryable;
041import org.kepler.reporting.gui.ItemsOfInterestPanel;
042import org.kepler.reporting.gui.ReportDesignerPanel;
043
044import ptolemy.actor.gui.TableauFrame;
045
046public abstract class Item implements Serializable {
047                
048        protected String name = "";
049        protected String type = "";
050        protected ImageIcon icon = null;
051        protected List<ItemLabel> labels = new ArrayList<ItemLabel>();
052        protected List<ItemValue> values = new ArrayList<ItemValue>();
053        protected ItemProperties itemProperties = new ItemProperties();
054        
055        public abstract void generateValues(Queryable queryable, KeplerLSID lsid, int execId, 
056                        TableauFrame tableauFrame);
057        
058        private boolean selected = false;
059        
060        public String getName() {
061                return name;
062        }
063
064        public String getShortName() {
065                return name;
066        }
067        
068        public void setName(String name) {
069                this.name = name;
070        }
071        
072        public String getType() {
073                return type;
074        }
075
076        public void setType(String type) {
077                this.type = type;
078        }
079
080        public void setSelected(boolean selected) {
081                this.selected = selected;
082        }
083        
084        public Boolean isSelected() {
085                return selected;
086        }
087        
088        public List<ItemValue> getValues() {
089                return values;
090        }
091        
092        public void setValues(List<ItemValue> values) {
093                this.values = values;
094        }
095        
096        public List<ItemLabel> getLabels() {
097                return labels;
098        }
099        
100        public void addLabel(ItemLabel label) {
101                this.labels.add(label);
102        }
103        
104        public boolean removeLabel(ItemLabel label) {
105                return this.labels.remove(label);
106        }
107        
108        public void addValue(ItemValue value) {
109                this.values.add(value);
110        }
111        
112        public boolean removeValue(ItemValue value) {
113                return this.values.remove(value);
114        }
115
116        public ItemProperties getItemProperties() {
117                return itemProperties;
118        }
119
120        public void setItemProperties(ItemProperties itemProperties) {
121                this.itemProperties = itemProperties;
122        }
123        
124        public ImageIcon getIcon() {
125                return icon;
126        }
127        
128        public void setIcon(ImageIcon port) {
129                this.icon = port;
130        }
131        
132        public URL getIconURL(String iconname, String extension) {
133
134                String IconLocation = ReportDesignerPanel.IMAGES_DIR + iconname + "." + extension;
135                URL iconURL = ItemsOfInterestPanel.class.getResource(IconLocation);
136
137                return iconURL;
138        }
139
140                
141}