From: <aki...@us...> - 2006-12-24 10:41:35
|
Revision: 1264 http://svn.sourceforge.net/gridarta/?rev=1264&view=rev Author: akirschbaum Date: 2006-12-24 02:41:35 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Split ConnectionView class into view/controller; move code to register listeners to connection view implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/src/app/net/sf/gridarta/gui/ConnectionView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -724,7 +724,6 @@ setCurrentLevel(map); refreshMenusAndToolbars(); } - map.getMapModel().addMapModelListener(mainView.getMapArchPanel().getConnectionView()); return map; } Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -56,7 +56,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; -import net.sf.gridarta.gui.ConnectionView; +import net.sf.gridarta.gui.ConnectionControl; import net.sf.gridarta.gui.GSplitPane; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -126,9 +126,6 @@ private final JPanel animationPanel; - /** The JPanel holding the connection information. */ - private final ConnectionView connectionView = new ConnectionView(); - /** Arch text field. */ private final JTextArea archTextArea = new JTextArea(4, 25); @@ -173,6 +170,8 @@ final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); setLayout(new BorderLayout()); + final ConnectionControl connectionControl = new ConnectionControl(mainControl); + // scrollPane2 contains the document for archtext editing final JScrollPane scrollPane2 = new JScrollPane(archEdit); scrollPane2.setBackground(archEdit.getBackground()); @@ -219,7 +218,7 @@ panelDesktop.add(createScriptPanel(), "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionView, "Connection"); + panelDesktop.add(connectionControl.getView(), "Connection"); // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); @@ -230,8 +229,6 @@ updateFont(true); document = archEdit.getDocument(); - - mainControl.addMainControlListener(connectionView); } /** @@ -905,12 +902,4 @@ aRemove.setEnabled(removeButton); } - /** - * Get the ConnectionView. - * @return ConnectionView - */ - public ConnectionView getConnectionView() { - return connectionView; - } - } // class CMapArchPanel Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -893,7 +893,6 @@ refreshMenusAndToolbars(); } map.getMapModel().addMapModelListener(this); - map.getMapModel().addMapModelListener(mainView.getMapArchPanel().getConnectionView()); return map; } Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -61,7 +61,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; -import net.sf.gridarta.gui.ConnectionView; +import net.sf.gridarta.gui.ConnectionControl; import net.sf.gridarta.gui.GSplitPane; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -148,9 +148,6 @@ private final JPanel animationPanel; - /** The JPanel holding the connection information. */ - private final ConnectionView connectionView = new ConnectionView(); - /** The JPanel holding the error information. */ private final ErrorListView errorListView = new ErrorListView(); @@ -192,6 +189,8 @@ mainView = view; setLayout(new BorderLayout()); + final ConnectionControl connectionControl = new ConnectionControl(mainControl); + // scrollPane2 contains the document for archtext editing final JScrollPane scrollPane2 = new JScrollPane(archEdit); scrollPane2.setBackground(archEdit.getBackground()); @@ -238,7 +237,7 @@ panelDesktop.add(createScriptPanel(), "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionView, "Connection"); + panelDesktop.add(connectionControl.getView(), "Connection"); panelDesktop.add(errorListView, "Errors"); // calculate default value in case there is no settings file @@ -250,8 +249,6 @@ updateFont(true); document = archEdit.getDocument(); - - mainControl.addMainControlListener(connectionView); } /** {@inheritDoc} */ @@ -1043,12 +1040,4 @@ aRemove.setEnabled(removeButton); } - /** - * Get the ConnectionView. - * @return ConnectionView - */ - public ConnectionView getConnectionView() { - return connectionView; - } - } // class CMapArchPanel Added: trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -0,0 +1,58 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 The Gridarta Developers + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.gridarta.gui; + +import net.sf.gridarta.MainControl; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * The controller for the connection view. + * + * @author Andreas Kirschbaum + */ +public class ConnectionControl { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ConnectionControl.class); + + /** The view for this controller. */ + @NotNull private final ConnectionView view; + + /* + * Create a new instance. + * + * @param mainControl the main control to use + */ + public ConnectionControl(@NotNull final MainControl mainControl) { + view = new ConnectionView(mainControl); + } + + /** + * Return the view for this controller. + * + * @return the view for this controller + */ + @NotNull public ConnectionView getView() { + return view; + } + +} // class ConnectionControl Property changes on: trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -1,6 +1,7 @@ /* * Gridarta Java Editor. * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. - * */ package net.sf.gridarta.gui; @@ -29,6 +29,7 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import net.sf.gridarta.MainControl; import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -44,6 +45,7 @@ * A Panel that holds information about the connections of the selected arch on the selected map. * It is unfinished. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum * @todo more user interface features * @todo make this a MapHighlightModel * @todo better react on changes, don't always scan the whole map @@ -62,9 +64,10 @@ private MapControl mapControl = null; /** Create a ConnectionPanel. */ - public ConnectionView() { + public ConnectionView(@NotNull final MainControl mainControl) { setLayout(new BorderLayout()); add(new JScrollPane(connectionList)); + mainControl.addMainControlListener(this); } /** {@inheritDoc} */ @@ -90,12 +93,12 @@ /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl mapControl) { - // ignore: a current map changed event will be generated + mapControl.getMapModel().addMapModelListener(this); } /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl mapControl) { - // ignore: a current map changed event will be generated + mapControl.getMapModel().removeMapModelListener(this); } /** @@ -123,4 +126,4 @@ connectionList.setListData(connections.keySet().toArray()); } -} // class ConnectionPanel +} // class ConnectionView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |