001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.modules;
019:
020: import java.awt.BorderLayout;
021: import java.util.List;
022: import java.util.Vector;
023: import java.util.logging.Level;
024: import java.util.logging.Logger;
025:
026: import javax.swing.Action;
027: import javax.swing.ImageIcon;
028: import javax.swing.JPanel;
029:
030: import de.finix.contelligent.client.i18n.Resources;
031: import de.finix.contelligent.client.modules.event.ModuleAdapter;
032: import de.finix.contelligent.client.modules.event.ModuleEvent;
033: import de.finix.contelligent.client.modules.event.ModuleListener;
034: import de.finix.contelligent.client.util.MenuAndToolbarComposer;
035:
036: public abstract class AbstractModule extends JPanel implements Module {
037:
038: private static Logger logger = Logger
039: .getLogger(AbstractModule.class.getName());
040:
041: private MenuAndToolbarComposer menuAndToolbarComposer;
042:
043: private ModuleDescription moduleDescription;
044:
045: private List<ModuleListener> moduleListeners = new Vector<ModuleListener>();
046:
047: private boolean active = false;
048:
049: public AbstractModule() {
050: super (new BorderLayout());
051: // setPreferredSize(new Dimension(800,600));
052: setOpaque(false);
053:
054: addModuleListener(new ModuleAdapter() {
055: public void moduleActivated(ModuleEvent event) {
056: logger.log(Level.FINE,
057: "Module [AbstractModule] activated.");
058: active = true;
059: }
060:
061: public void moduleDeactivated(ModuleEvent event) {
062: logger.log(Level.FINE,
063: "Module [AbstractModule] deactivated.");
064: active = false;
065: }
066:
067: public void moduleDestroyed(ModuleEvent event) {
068: logger.log(Level.FINE,
069: "Module [AbstractModule] destroyed.");
070: }
071: });
072: }
073:
074: public abstract void init() throws ModuleInitException;
075:
076: public boolean isActive() {
077: return active;
078: }
079:
080: public void setModuleDescription(ModuleDescription moduleDescription) {
081: this .moduleDescription = moduleDescription;
082: }
083:
084: public ModuleDescription getModuleDescription() {
085: return moduleDescription;
086: }
087:
088: public void addModuleListener(ModuleListener listener) {
089: moduleListeners.add(listener);
090: }
091:
092: public void removeModuleListener(ModuleListener listener) {
093: moduleListeners.remove(listener);
094: }
095:
096: public List<ModuleListener> getModuleListeners() {
097: return moduleListeners;
098: }
099:
100: public ImageIcon getIcon() {
101: return Resources.genericModule;
102: }
103:
104: public Action[] getActions() {
105: return new Action[0];
106: }
107:
108: public void setMenuAndToolbarComposer(
109: MenuAndToolbarComposer menuAndToolbarComposer) {
110: this .menuAndToolbarComposer = menuAndToolbarComposer;
111: }
112:
113: public MenuAndToolbarComposer getMenuAndToolbarComposer() {
114: return menuAndToolbarComposer;
115: }
116:
117: public boolean isLightweightFrame() {
118: return false;
119: }
120: }
|