root / branches / v10 / extensions / extPublish / src / com / iver / cit / gvsig / publish / gui / control / MainController.java @ 13570
History | View | Annotate | Download (4.03 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Iba?ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.publish.gui.control; |
42 |
|
43 |
import java.awt.event.ActionEvent; |
44 |
import java.awt.event.ActionListener; |
45 |
import java.util.EventListener; |
46 |
|
47 |
import javax.swing.JPanel; |
48 |
|
49 |
import com.iver.cit.gvsig.publish.gui.view.PublishPanel; |
50 |
import com.iver.cit.gvsig.publish.gui.window.MainWindow; |
51 |
import com.iver.cit.gvsig.publish.infoProject.IViewInfo; |
52 |
import com.iver.cit.gvsig.publish.serversModel.Publication; |
53 |
import com.iver.cit.gvsig.publish.serversModel.PublishException; |
54 |
import com.iver.cit.gvsig.publish.serversModel.Server; |
55 |
|
56 |
public class MainController implements ActionListener { |
57 |
/*
|
58 |
* Events
|
59 |
*/
|
60 |
public static final String PUBLISH_EVENT_ACCEPT="accept_publish"; |
61 |
public static final String PUBLISH_EVENT_CANCEL="cancel_publish"; |
62 |
|
63 |
/*
|
64 |
* Main window
|
65 |
*/
|
66 |
MainWindow window = null;
|
67 |
/*
|
68 |
* Active publication
|
69 |
*/
|
70 |
Publication activePublication = null;
|
71 |
/*
|
72 |
* InfoView
|
73 |
*/
|
74 |
private IViewInfo infoView = null; |
75 |
/**
|
76 |
* Constructor
|
77 |
*/
|
78 |
public MainController(){
|
79 |
window = new MainWindow();
|
80 |
window.setListener(this);
|
81 |
initialize(); |
82 |
} |
83 |
/**
|
84 |
* Get publications from persistence and creates the windows
|
85 |
* with controls a select publication
|
86 |
*/
|
87 |
private void initialize(){ |
88 |
if (getPublicationsFromPersistence()==null){ |
89 |
//start();
|
90 |
}else{
|
91 |
//relleno el combo de publicaciones y activo la publicacion por defecto
|
92 |
return;
|
93 |
} |
94 |
} |
95 |
|
96 |
public void start(){ |
97 |
//window.showWindow();
|
98 |
//if there isn't publications it creates one
|
99 |
if (activePublication==null){ |
100 |
NewPublicationController newServerCtrl = new NewPublicationController(this); |
101 |
newServerCtrl.start(); |
102 |
}else{
|
103 |
//get active publication
|
104 |
String key = activePublication.getServer().getType();
|
105 |
//get controller
|
106 |
IPublishController controller = (IPublishController) PublishController.register.getInstance(key); |
107 |
controller.setModel(activePublication); |
108 |
//TODO: check casting
|
109 |
PublishPanel view = controller.getView(); |
110 |
window.setPublicationPanel(view); |
111 |
window.showWindow(); |
112 |
} |
113 |
} |
114 |
/**
|
115 |
* Sets the infoView to pass into the model
|
116 |
* @param info
|
117 |
*/
|
118 |
public void setViewInfo(IViewInfo info) { |
119 |
infoView = info; |
120 |
} |
121 |
/**
|
122 |
* Sets the active publication
|
123 |
*
|
124 |
* @param publication
|
125 |
*/
|
126 |
public void setActivePublication(Publication publication){ |
127 |
activePublication = publication; |
128 |
activePublication.getServer().initialize(infoView); |
129 |
start(); |
130 |
} |
131 |
|
132 |
private Publication[] getPublicationsFromPersistence(){ |
133 |
return null; |
134 |
} |
135 |
public void actionPerformed(ActionEvent e) { |
136 |
if (e.getActionCommand().equals(MainController.PUBLISH_EVENT_CANCEL)){
|
137 |
window.closeWindow(); |
138 |
return;
|
139 |
} |
140 |
if (e.getActionCommand().equals(MainController.PUBLISH_EVENT_ACCEPT)){
|
141 |
window.closeWindow(); |
142 |
try {
|
143 |
activePublication.getServer().publish(); |
144 |
} catch (PublishException e1) {
|
145 |
// TODO Auto-generated catch block
|
146 |
e1.printStackTrace(); |
147 |
} |
148 |
//get model
|
149 |
return;
|
150 |
} |
151 |
|
152 |
} |
153 |
|
154 |
|
155 |
} |