001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.ui.support;
014:
015: import java.beans.PropertyChangeListener;
016: import java.beans.PropertyChangeSupport;
017: import java.util.HashSet;
018: import java.util.Set;
019:
020: import javax.swing.Icon;
021: import javax.swing.ImageIcon;
022: import javax.swing.JComponent;
023:
024: import com.eviware.soapui.model.ModelItem;
025: import com.eviware.soapui.support.UISupport;
026: import com.eviware.soapui.ui.desktop.DesktopPanel;
027:
028: /**
029: * Default implementation for simple DesktopPanels
030: *
031: * @author Ole.Matzura
032: */
033:
034: public class DefaultDesktopPanel implements DesktopPanel {
035: private PropertyChangeSupport propertyChangeSupport;
036: private String title;
037: private JComponent component;
038: private Set<ModelItem> depends = new HashSet<ModelItem>();
039: private ImageIcon icon;
040: private final String description;
041:
042: public DefaultDesktopPanel(String title, String description,
043: JComponent component) {
044: this .title = title;
045: this .description = description;
046: this .component = component;
047:
048: propertyChangeSupport = new PropertyChangeSupport(this );
049: }
050:
051: public void loadIcon(String path) {
052: icon = UISupport.createImageIcon(path);
053: }
054:
055: public String getTitle() {
056: return title;
057: }
058:
059: public String getDescription() {
060: return description;
061: }
062:
063: public void setTitle(String title) {
064: String oldTitle = this .title;
065: this .title = title;
066:
067: propertyChangeSupport.firePropertyChange(TITLE_PROPERTY,
068: oldTitle, title);
069: }
070:
071: public ModelItem getModelItem() {
072: return null;
073: }
074:
075: public boolean onClose(boolean canCancel) {
076: return true;
077: }
078:
079: public JComponent getComponent() {
080: return component;
081: }
082:
083: public boolean dependsOn(ModelItem modelItem) {
084: return depends != null && depends.contains(modelItem);
085: }
086:
087: public void addDependency(ModelItem modelItem) {
088: depends.add(modelItem);
089: }
090:
091: public void addPropertyChangeListener(String propertyName,
092: PropertyChangeListener listener) {
093: propertyChangeSupport.addPropertyChangeListener(propertyName,
094: listener);
095: }
096:
097: public void addPropertyChangeListener(
098: PropertyChangeListener listener) {
099: propertyChangeSupport.addPropertyChangeListener(listener);
100: }
101:
102: public void removePropertyChangeListener(
103: PropertyChangeListener listener) {
104: propertyChangeSupport.removePropertyChangeListener(listener);
105: }
106:
107: public void removePropertyChangeListener(String propertyName,
108: PropertyChangeListener listener) {
109: propertyChangeSupport.removePropertyChangeListener(
110: propertyName, listener);
111: }
112:
113: public Icon getIcon() {
114: return icon;
115: }
116: }
|