View Javadoc
1 /*** 2 * View.java 3 * 4 * Project: Dependency Tool 5 * 6 * WHEN WHO WHAT 7 * 06.06.2003 pko initial public release 8 * 08.01.2003 pko modification 9 * 01.02.2002 ctr modification 10 * 08.01.2002 ctr creation 11 * 12 * Copyright 2003 ELCA Informatique SA 13 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 14 * www.elca.ch 15 * 16 * This library is free software; you can redistribute it and/or 17 * modify it under the terms of the GNU Lesser General Public License 18 * as published by the Free Software Foundation; either version 2.1 of 19 * the License, or (at your option) any later version. 20 * 21 * This library is distributed in the hope that it will be useful, but 22 * WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 * Lesser General Public License for more details. 25 * 26 * You should have received a copy of the GNU Lesser General Public 27 * License along with this library; if not, write to the Free Software 28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 29 * USA 30 */ 31 32 package ch.elca.dependency.view; 33 34 import javax.swing.JInternalFrame; 35 import ch.elca.dependency.util.gui.*; 36 import ch.elca.dependency.core.*; 37 38 /*** 39 * View component of the MVC Pattern. 40 * All the specific views which extend from this <code>View</code> class are 41 * displayed in an internal frame. And they can be registred as 42 * <code>Observers</code> in the model component of the MVC pattern the 43 * <code>FilteredModel</code> class. 44 * 45 * The views know the model <code>FilteredModel</code> for requesting the 46 * specific data, needed for a new display. This model class is initialized at 47 * the start of the application. 48 * 49 * The two overloaded update methods call the individual display method 50 * implemented in each of the specific views which are subclasses. 51 * 52 * It is important that each view is displaying exactly the same state of the 53 * model. This allows the interaction by the user within the views. 54 * 55 * @see ch.elca.dependency.view.GraphView 56 * @see ch.elca.dependency.view.OverView 57 * @see ch.elca.dependency.view.StatisticView 58 * @see ch.elca.dependency.core.DependencyModel 59 * 60 * @author Christoph Trutmann 61 * @version 1.0-beta 62 */ 63 public abstract class View extends PersistentJInternalFrame implements Observer { 64 65 private static final boolean RESIZBLE = true; 66 private static final boolean CLOSEABLE = true; 67 private static final boolean MAXIMIZABLE = true; 68 private static final boolean ICONIFIABLE = true; 69 protected StatusListenerSupport m_statusListenerSupport = new StatusListenerSupport(); 70 protected DependencyModel m_dependencyModel = null; 71 protected StatusListener m_statusListener; 72 73 /*** 74 * Creates a new <code>View</code> instance. 75 * 76 * @param dependencyModel a <code>DependencyModel</code> value 77 * @param title a <code>String</code> value 78 */ 79 public View(final DependencyModel dependencyModel, final String title) { 80 this(dependencyModel, title, 81 RESIZBLE, CLOSEABLE, MAXIMIZABLE, ICONIFIABLE); 82 } 83 84 /*** 85 * Creates a new <code>View</code> instance. 86 * 87 * @param dependencyModel a <code>DependencyModel</code> value 88 * @param title a <code>String</code> value 89 * @param resizable a <code>boolean</code> value 90 * @param closable a <code>boolean</code> value 91 * @param maximizable a <code>boolean</code> value 92 * @param iconifiable a <code>boolean</code> value 93 */ 94 public View(DependencyModel dependencyModel, String title, 95 boolean resizable, boolean closable, 96 boolean maximizable, boolean iconifiable) { 97 super(title, resizable, closable, maximizable, iconifiable); 98 99 setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE); 100 101 // initialize only if the Dependencymodel is not null and its created 102 // 103 if (dependencyModel != null && dependencyModel.isCreated()) { 104 initData(dependencyModel); 105 } 106 } 107 108 /*** 109 * Init data of this View. Call this method only if passed 110 * dependencyModel is created! 111 * 112 * @param dependencyModel a <code>DependencyModel</code> value 113 */ 114 public final void initData(DependencyModel dependencyModel) { 115 116 m_dependencyModel = dependencyModel; 117 m_dependencyModel.attach(this); 118 119 internalInitData(); 120 initView(); 121 } 122 123 /*** 124 * Internal init data to be ovewritten by subclasses which need to 125 * speciffically init their data. 126 */ 127 protected void internalInitData() { 128 } 129 130 /*** 131 * Init this View. 132 */ 133 protected abstract void initView(); 134 135 /*** 136 * Display the DependencyModel. To be overwritten by subclasses. 137 */ 138 public abstract void display(); 139 140 /*** 141 * Indicate this View that the DependencyModel has changed. 142 * 143 * @param dependencyModel a <code>DependencyModel</code> value 144 */ 145 public final void update(DependencyModel dependencyModel) { 146 if (m_dependencyModel != null 147 && m_dependencyModel.isCreated() 148 && m_dependencyModel == dependencyModel) { 149 display(); 150 } 151 } 152 153 /*** 154 * Set the status listener. 155 * 156 * @param statusListener a <code>StatusListener</code> value 157 */ 158 public final void setStatusListener(StatusListener statusListener) { 159 m_statusListenerSupport.setStatusListener(statusListener); 160 } 161 }

This page was automatically generated by Maven