Revision 42867

View differences:

tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/test/java/org/gvsig/andami/AllTests.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami;
25

  
26
import junit.framework.Test;
27
import junit.framework.TestSuite;
28

  
29
public class AllTests {
30

  
31
	public static Test suite() {
32
		TestSuite suite = new TestSuite("Test for com.iver.andami");
33
		//$JUnit-BEGIN$
34

  
35
		//$JUnit-END$
36
		return suite;
37
	}
38

  
39
}
0 40

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/assembly/gvsig-andami-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
  <id>gvsig-andami-package</id>
28
  <formats>
29
    <format>zip</format>
30
  </formats>
31
  <baseDirectory>.</baseDirectory>
32
  <!-- 
33
  <includeBaseDirectory>true</includeBaseDirectory>
34
   -->
35
  <files>
36
    <file>
37
      <source>target/${project.artifactId}-${project.version}.jar</source>
38
      <outputDirectory>lib</outputDirectory>
39
    </file>
40
    <file>
41
      <source>src/main/resources/default-log4j/log4j.properties</source>
42
      <outputDirectory>.</outputDirectory>
43
    </file>  
44
  </files>
45
  <fileSets>
46
    <fileSet>
47
      <directory>src/main/resources-application</directory>
48
      <outputDirectory>.</outputDirectory>
49
    </fileSet>
50
    <fileSet>
51
      <directory>src/main/resources/org/gvsig/andami</directory>
52
      <outputDirectory>i18n/andami</outputDirectory>
53
    </fileSet>
54
  </fileSets>
55
  
56
  <dependencySets>
57
    <dependencySet>
58
      <useProjectArtifact>false</useProjectArtifact>
59
      <useTransitiveDependencies>true</useTransitiveDependencies>
60
      <outputDirectory>lib</outputDirectory>
61
    </dependencySet>
62
  </dependencySets>
63

  
64
</assembly>
65

  
0 66

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/AndamiEventQueue.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui;
25

  
26
import java.awt.AWTEvent;
27
import java.awt.EventQueue;
28
import java.awt.event.MouseEvent;
29

  
30
import javax.swing.JOptionPane;
31

  
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.andami.messages.Messages;
34
import org.gvsig.andami.messages.NotificationManager;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38

  
39

  
40
/**
41
 * DOCUMENT ME!
42
 *
43
 * @author Fernando Gonz?lez Cort?s
44
 */
45
public class AndamiEventQueue extends EventQueue {
46
	private static Logger logger = LoggerFactory.getLogger(AndamiEventQueue.class);
47
	
48
	protected void dispatchEvent(AWTEvent event){
49
		try{
50
			super.dispatchEvent(event);
51
		} catch(RuntimeException e){
52
		    
53
		    if (canShowWindow(e, event)) {
54
		        NotificationManager.addError(e);//Messages.getString("PluginServices.Bug en el c?digo"), e);
55
		    } else {
56
                try {
57
                    PluginServices.getMainFrame().getStatusBar().message(e.getMessage(), JOptionPane.ERROR_MESSAGE);
58
                } catch(Throwable ex) {
59
                    // Ignora cualquier error que se produzca intentando mostrar el mensaje de error y nos
60
                    // conformaremos con que este en el log.
61
                }
62
                logger.info("Error dispaching event",e);
63
			}
64
			
65
		} catch (Error e){
66
			NotificationManager.addError(
67
			    Messages.getString("Error de la applicacion.  \nEs conveniente que salga de la aplicaci?n\n\n"+e.getLocalizedMessage()), e);
68
		}
69
	}
70
	
71
	private boolean canShowWindow(Throwable th, AWTEvent event) {
72
	    
73
	    try {
74
	        if( event instanceof MouseEvent ) {
75
	            MouseEvent me = (MouseEvent)event;
76
	            if( me.getButton() == 0 && me.getClickCount()==0 ) {
77
	                // Intentamos que los errores que se produzcan con los eventos de movimiento del raton
78
                    // no provoquen la aparicion de la ventana de errores ya que llega a bloquear al usuario.
79
                    // Intentaremos sacarlos en la barra de estado si podemos.
80
	                return false;
81
	            }
82
	        }
83
	        StackTraceElement[] stack_ee = th.getStackTrace();
84
	        for (int i=0; i<stack_ee.length; i++) {
85
	            StackTraceElement se = stack_ee[i];
86
	            if (se.getClassName().startsWith("org.gvsig.fmap.mapcontrol.MapControl")) {
87
	                return false;
88
	            }
89
	        }
90
	    } catch (Throwable t) {
91
	        
92
	    }
93
        return true;
94
	    
95
	}
96
}
0 97

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/wizard/WizardAndami.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.wizard;
25

  
26
import java.awt.BorderLayout;
27

  
28
import javax.swing.ImageIcon;
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.andami.ui.mdiManager.WindowInfo;
34

  
35
import jwizardcomponent.CancelAction;
36
import jwizardcomponent.DefaultJWizardComponents;
37
import jwizardcomponent.FinishAction;
38

  
39

  
40
public class WizardAndami extends JPanel implements IWindow {
41
	WindowInfo viewInfo = null;
42
	WizardPanelWithLogo wizardPanel;
43

  
44
	// No deber?an necesitarse un FinishAction y un CancelAction, pero bueno,
45
	// lo mantengo por ahora.
46
	private class CloseAction extends FinishAction
47
	{
48
		IWindow v;
49
		public CloseAction(IWindow view)
50
		{
51
			super(wizardPanel.getWizardComponents());
52
			v = view;
53
		}
54
		public void performAction() {
55
			PluginServices.getMDIManager().closeWindow(v);
56
		}
57

  
58
	}
59
	private class CloseAction2 extends CancelAction
60
	{
61

  
62
		IWindow v;
63
		public CloseAction2(IWindow view)
64
		{
65
			super(wizardPanel.getWizardComponents());
66
			v = view;
67
		}
68
		public void performAction() {
69
			PluginServices.getMDIManager().closeWindow(v);
70
		}
71

  
72
	}
73

  
74

  
75
	public WizardAndami(ImageIcon logo)
76
	{
77
		wizardPanel = new WizardPanelWithLogo(logo);
78
		CloseAction closeAction = new CloseAction(this);
79
		CloseAction2 closeAction2 = new CloseAction2(this);
80
		wizardPanel.getWizardComponents().setFinishAction(closeAction);
81
		wizardPanel.getWizardComponents().setCancelAction(closeAction2);
82

  
83
		this.setLayout(new BorderLayout());
84
		this.add(wizardPanel, BorderLayout.CENTER);
85
	}
86

  
87
	public DefaultJWizardComponents getWizardComponents()
88
	{
89
		return wizardPanel.getWizardComponents();
90
	}
91

  
92

  
93
	public WindowInfo getWindowInfo() {
94
		if (viewInfo == null)
95
		{
96
			viewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
97
		}
98
		return viewInfo;
99
	}
100

  
101
	public Object getWindowProfile() {
102
		// TODO Auto-generated method stub
103
		return WindowInfo.DIALOG_PROFILE;
104
	}
105

  
106
}
0 107

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/wizard/WizardPanelWithLogo.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.wizard;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Color;
28

  
29
import javax.swing.ImageIcon;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JSeparator;
33

  
34
import jwizardcomponent.CancelAction;
35
import jwizardcomponent.DefaultJWizardComponents;
36
import jwizardcomponent.FinishAction;
37
import jwizardcomponent.common.SimpleButtonPanel;
38

  
39
public class WizardPanelWithLogo extends JPanel {
40
	  DefaultJWizardComponents wizardComponents;
41

  
42
	  JPanel buttonPanel;
43
	  JLabel statusLabel = new JLabel();
44

  
45
	  ImageIcon logo;
46

  
47
	  public WizardPanelWithLogo(ImageIcon logo) {
48
	    this.logo = logo;
49
	    wizardComponents = new DefaultJWizardComponents();
50
	    init();
51
	  }
52

  
53
	  private void init() {
54
	    
55

  
56
	    JPanel logoPanel = new JPanel();
57

  
58
	    String fileString;
59
	    if (logo.toString().indexOf("file:") < 0 &&
60
	        logo.toString().indexOf("http:") < 0) {
61
	      fileString = "file:///" +System.getProperty("user.dir") +"/"
62
	                        +logo.toString();
63
	      fileString = fileString.replaceAll("\\\\", "/");
64
	    } else {
65
	      fileString = logo.toString();
66
	    }
67
	    logoPanel.add(new JLabel(logo));
68
	    logoPanel.setBackground(Color.WHITE);
69
	    this.setLayout(new BorderLayout());
70
	    this.add(logoPanel, BorderLayout.WEST);
71
	    this.add(wizardComponents.getWizardPanelsContainer(),
72
	    							BorderLayout.CENTER);
73

  
74
	    JPanel auxPanel = new JPanel(new BorderLayout());
75
	    auxPanel.add(new JSeparator(), BorderLayout.NORTH);
76

  
77
	    buttonPanel = new SimpleButtonPanel(wizardComponents);
78
	    auxPanel.add(buttonPanel);
79
	    this.add(auxPanel, BorderLayout.SOUTH);
80
	    
81

  
82
	    wizardComponents.setFinishAction(new FinishAction(wizardComponents) {
83
	      public void performAction() {
84
	        // dispose();
85
	      }
86
	    });
87
	    wizardComponents.setCancelAction(new CancelAction(wizardComponents) {
88
	      public void performAction() {
89
	        // dispose();
90
	      }
91
	    });
92
	  }
93

  
94
	  public DefaultJWizardComponents getWizardComponents(){
95
	    return wizardComponents;
96
	  }
97

  
98
	  public void setWizardComponents(DefaultJWizardComponents aWizardComponents){
99
	    wizardComponents = aWizardComponents;
100
	  }
101

  
102
	  public void show() {
103
	    wizardComponents.updateComponents();
104
	    super.setVisible(true);
105
	  }
106

  
107
}
0 108

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/wizard/UnsavedDataPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.wizard;
25

  
26
import java.awt.BorderLayout;
27
import java.awt.Color;
28
import java.awt.Dimension;
29
import java.awt.FlowLayout;
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.GridLayout;
33
import java.awt.Insets;
34
import java.awt.event.ActionEvent;
35
import java.awt.event.ActionListener;
36
import java.awt.event.MouseEvent;
37
import java.awt.event.MouseListener;
38
import java.awt.image.BufferedImage;
39
import java.util.ArrayList;
40
import java.util.Arrays;
41
import java.util.Iterator;
42
import java.util.List;
43

  
44
import javax.swing.BorderFactory;
45
import javax.swing.ImageIcon;
46
import javax.swing.JCheckBox;
47
import javax.swing.JLabel;
48
import javax.swing.JPanel;
49
import javax.swing.JScrollPane;
50

  
51
import org.gvsig.andami.IconThemeHelper;
52
import org.gvsig.andami.PluginServices;
53
import org.gvsig.andami.plugins.status.IUnsavedData;
54
import org.gvsig.andami.ui.mdiManager.IWindow;
55
import org.gvsig.andami.ui.mdiManager.WindowInfo;
56
import org.gvsig.gui.beans.swing.JButton;
57

  
58

  
59
/**
60
 * Ask for elements to save before application exit
61
 *
62
 *
63
 */
64
public class UnsavedDataPanel extends JPanel implements IWindow, ActionListener {
65
	/**
66
	 *
67
	 */
68
	private static final long serialVersionUID = -4745219917358767905L;
69

  
70

  
71
	private static ImageIcon blanckIcon = null;
72
	private JPanel pResources = null;
73
	private JPanel pButtons = null;
74
	private JScrollPane pScrollList = null;
75
	private myList list = null;
76
	private JLabel lblDescription = null;
77
	private JButton botSave = null;
78
	private JButton botDiscard = null;
79
	private JButton botDontExit = null;
80
	private JPanel pActionButtons = null;
81
	private JPanel pSelectionButtons = null;
82
	private JButton botSelectAll = null;
83
	private JButton botDeselectAll = null;
84

  
85
	private ArrayList listeners = new ArrayList();
86
	private JLabel lblResourceDescription = null;
87
	private IUnsavedData[] unsavedDataList;
88
	private String windowTitle = PluginServices.getText(this, "save_resources");
89
	private String prompt = PluginServices.getText(this, "select_resources_to_save_before_exit");
90

  
91

  
92

  
93
	/**
94
	 * This is the default constructor
95
	 */
96
	public UnsavedDataPanel(IUnsavedData[] unsavedDatalist) {
97
		super();
98
		initialize();
99
		this.setUnsavedDataArray(unsavedDatalist);
100
	}
101

  
102
	public UnsavedDataPanel(String prompt) {
103
        super();
104
        initialize();
105
        this.setUnsavedDataArray(new IUnsavedData[0]);
106
        this.prompt = prompt;
107
    }
108

  
109

  
110
	/**
111
	 * This method initializes this
112
	 *
113
	 * @return void
114
	 */
115
	private void initialize() {
116
		BorderLayout borderLayout = new BorderLayout();
117
		borderLayout.setHgap(5);
118
		borderLayout.setVgap(5);
119
		lblDescription = new JLabel();
120
		lblDescription.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
121
		lblDescription.setText(prompt);
122
		lblDescription.setPreferredSize(new Dimension(497, 30));
123
		lblDescription.setName("lblDescription");
124
		this.setLayout(borderLayout);
125
		this.setSize(396, 272);
126
		this.add(getPResources(), java.awt.BorderLayout.CENTER);
127
		this.add(getPButtons(), java.awt.BorderLayout.SOUTH);
128
		this.add(lblDescription, BorderLayout.NORTH);
129
	}
130

  
131
	/**
132
	 * This method initializes pResources
133
	 *
134
	 * @return javax.swing.JPanel
135
	 */
136
	private JPanel getPResources() {
137
		if (pResources == null) {
138
			pResources = new JPanel();
139
			pResources.setLayout(new BorderLayout());
140
			pResources.add(getPScrollList(), BorderLayout.CENTER);
141
			// pResources.add(getLblResourceDescription(), BorderLayout.SOUTH);
142
		}
143
		return pResources;
144
	}
145

  
146

  
147
	/**
148
	 * This method initializes lblResourceDescription
149
	 *
150
	 * @return javax.swing.JLabel
151
	 */
152
	private JLabel getLblResourceDescription() {
153
		if (lblResourceDescription == null) {
154
			lblResourceDescription = new JLabel();
155
			lblResourceDescription.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
156
			lblResourceDescription.setText("");
157
			lblResourceDescription.setPreferredSize(new Dimension(38, 50));
158
			lblResourceDescription.setName("lblResourceDescription");
159
		}
160
		return lblResourceDescription;
161
	}
162

  
163

  
164
	/**
165
	 * This method initializes pButtons
166
	 *
167
	 * @return javax.swing.JPanel
168
	 */
169
	private JPanel getPButtons() {
170
		if (pButtons == null) {
171
			BorderLayout borderLayout2 = new BorderLayout();
172
			borderLayout2.setHgap(5);
173
			borderLayout2.setVgap(5);
174
			pButtons = new JPanel();
175
			pButtons.setLayout(borderLayout2);
176
			pButtons.add(getPSelectionButtons(), BorderLayout.NORTH);
177
			pButtons.add(getPActionButtons(), BorderLayout.SOUTH);
178
		}
179
		return pButtons;
180
	}
181

  
182
	/**
183
	 * This method initializes pScrollList
184
	 *
185
	 * @return javax.swing.JScrollPane
186
	 */
187
	private JScrollPane getPScrollList() {
188
		if (pScrollList == null) {
189
			pScrollList = new JScrollPane();
190
			pScrollList.setPreferredSize(new java.awt.Dimension(350,350));
191
			pScrollList.setViewportView(getList());
192
		}
193
		return pScrollList;
194
	}
195

  
196
	/**
197
	 * This method initializes list
198
	 *
199
	 * @return javax.swing.JList
200
	 */
201
	private myList getList() {
202
		if (list == null) {
203
			list = new myList();
204
			list.setBackground(Color.white);
205
		}
206
		return list;
207
	}
208

  
209
	/**
210
	 * This method initializes botSave
211
	 *
212
	 * @return javax.swing.JButton
213
	 */
214
	private JButton getBotSave() {
215
		if (botSave == null) {
216
			botSave = new JButton();
217
			botSave.setName("botSave");
218
			botSave.setToolTipText(PluginServices.getText(this, "save_selected_resources_and_exit"));
219
			botSave.setText(PluginServices.getText(this, "ok"));
220
			botSave.setActionCommand("Accept");
221
			botSave.addActionListener(this);
222
		}
223
		return botSave;
224
	}
225

  
226
	/**
227
	 * This method initializes botDiscard
228
	 *
229
	 * @return javax.swing.JButton
230
	 */
231
	private JButton getBotDiscard() {
232
		if (botDiscard == null) {
233
			botDiscard = new JButton();
234
			botDiscard.setName("botDiscard");
235
			botDiscard.setToolTipText(PluginServices.getText(this, "discard_changes_and_exit"));
236
			botDiscard.setText(PluginServices.getText(this, "discard_changes"));
237
			botDiscard.setActionCommand("Discard");
238
			botDiscard.addActionListener(this);
239
		}
240
		return botDiscard;
241
	}
242

  
243
	/**
244
	 * This method initializes botDontExit
245
	 *
246
	 * @return javax.swing.JButton
247
	 */
248
	private JButton getBotDontExit() {
249
		if (botDontExit == null) {
250
			botDontExit = new JButton();
251
			botDontExit.setName("botDontExit");
252
			botDontExit.setToolTipText(PluginServices.getText(this, "cancel_the_application_termination"));
253
			botDontExit.setText(PluginServices.getText(this, "cancelar"));
254
			botDontExit.setActionCommand("Cancel");
255
			botDontExit.addActionListener(this);
256
		}
257
		return botDontExit;
258
	}
259

  
260
	/**
261
	 * This method initializes pActionButtons
262
	 *
263
	 * @return javax.swing.JPanel
264
	 */
265
	private JPanel getPActionButtons() {
266
		if (pActionButtons == null) {
267

  
268
		    GridLayout gl = new GridLayout(1, 3, 8, 0);
269
		    /*
270
			FlowLayout flowLayout = new FlowLayout();
271
			flowLayout.setAlignment(FlowLayout.RIGHT);
272
			*/
273
			pActionButtons = new JPanel();
274
			pActionButtons.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
275
			pActionButtons.setLayout(gl);
276
			pActionButtons.setName("pActionButtons");
277
			pActionButtons.add(getBotSave());
278
			pActionButtons.add(getBotDiscard());
279
			pActionButtons.add(getBotDontExit());
280
		}
281
		return pActionButtons;
282
	}
283

  
284
	/**
285
	 * This method initializes pSelectionButtons
286
	 *
287
	 * @return javax.swing.JPanel
288
	 */
289
	private JPanel getPSelectionButtons() {
290
		if (pSelectionButtons == null) {
291
		    GridLayout gl = new GridLayout(2, 3, 8, 8);
292
		    /*
293
			FlowLayout flowLayout1 = new FlowLayout();
294
			flowLayout1.setAlignment(FlowLayout.LEFT);
295
			*/
296
			pSelectionButtons = new JPanel();
297
			pSelectionButtons.setBorder(BorderFactory.createEmptyBorder(5,8,8,8));
298
			pSelectionButtons.setLayout(gl);
299
			pSelectionButtons.setName("pSelectionButtons");
300
			pSelectionButtons.add(getBotSelectAll());
301
			pSelectionButtons.add(new JLabel());
302
			pSelectionButtons.add(new JLabel());
303
			// new row
304
			pSelectionButtons.add(getBotDeselectAll());
305
			pSelectionButtons.add(new JLabel());
306
            pSelectionButtons.add(new JLabel());
307

  
308
		}
309
		return pSelectionButtons;
310
	}
311

  
312
	/**
313
	 * This method initializes botSelectAll
314
	 *
315
	 * @return javax.swing.JButton
316
	 */
317
	private JButton getBotSelectAll() {
318
		if (botSelectAll == null) {
319
			botSelectAll = new JButton();
320
			botSelectAll.setText(PluginServices.getText(this, "select_all"));
321
			botSelectAll.setName("botSelectAll");
322
			botSelectAll.setToolTipText(PluginServices.getText(this, "select_all_resources"));
323
			botSelectAll.setActionCommand("SelectAll");
324
			botSelectAll.addActionListener(this);
325
		}
326
		return botSelectAll;
327
	}
328

  
329
	/**
330
	 * This method initializes botDeselectAll
331
	 *
332
	 * @return javax.swing.JButton
333
	 */
334
	private JButton getBotDeselectAll() {
335
		if (botDeselectAll == null) {
336
			botDeselectAll = new JButton();
337
			botDeselectAll.setName("botDeselectAll");
338
			botDeselectAll.setToolTipText(PluginServices.getText(this, "deselect_all_resources"));
339
			botDeselectAll.setText(PluginServices.getText(this, "deselect_all"));
340
			botDeselectAll.setActionCommand("DeselectAll");
341
			botDeselectAll.addActionListener(this);
342
		}
343
		return botDeselectAll;
344
	}
345

  
346
	public WindowInfo getWindowInfo() {
347
		WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG
348
				| WindowInfo.RESIZABLE
349
				| WindowInfo.MAXIMIZABLE);
350
		wi.setTitle(windowTitle);
351
		wi.setHeight(270);
352
		wi.setWidth(450);
353
		return wi;
354
	}
355

  
356
	public void setWindowTitle(String windowTitle) {
357
		this.windowTitle = windowTitle;
358
	}
359

  
360
	public void setCancelText(String text, String tooltipText) {
361
		getBotDontExit().setToolTipText(tooltipText);
362
		getBotDontExit().setText(text);
363
	}
364

  
365
	public void setDiscardText(String text, String tooltipText) {
366
		getBotDiscard().setToolTipText(tooltipText);
367
		getBotDiscard().setText(text);
368
	}
369

  
370
	public void setAcceptText(String text, String tooltipText) {
371
		getBotSave().setToolTipText(tooltipText);
372
		getBotSave().setText(text);
373
	}
374

  
375
	public void setHeaderText(String text) {
376
		lblDescription.setText(text);
377
	}
378

  
379
	/**
380
	 * Register a listener to call
381
	 *
382
	 * @param a UnsavedDataPanelListener instance
383
	 */
384
	public void addActionListener(UnsavedDataPanelListener listener){
385
		this.listeners.add(listener);
386
	}
387

  
388
	public void removeActionListener(UnsavedDataPanelListener listener){
389
		this.listeners.remove(listener);
390
	}
391

  
392
	public class UnsavedDataPanelListener {
393
		public void cancel(UnsavedDataPanel panel){
394

  
395
		}
396

  
397
		public void accept(UnsavedDataPanel panel){
398

  
399
		}
400

  
401
		public void discard(UnsavedDataPanel panel) {
402

  
403
		}
404
	}
405

  
406
	private class myList extends JPanel{
407

  
408
		/**
409
		 *
410
		 */
411
		private static final long serialVersionUID = 3179254463477354501L;
412

  
413
		private GridBagConstraints constraints;
414
		private GridBagConstraints constraintsLast;
415

  
416
		public myList(){
417
			super();
418
			initialize();
419
		}
420

  
421
		private void initialize(){
422
			this.setLayout(new GridBagLayout());
423
			this.constraints = new GridBagConstraints();
424
			this.constraints.fill = GridBagConstraints.HORIZONTAL;
425
			this.constraints.gridwidth = GridBagConstraints.REMAINDER;
426
			this.constraints.weightx =0;
427
			this.constraints.gridx =0;
428
			this.constraints.gridy=0;
429
			this.constraints.anchor = GridBagConstraints.WEST;
430
			this.constraints.insets =new Insets(3,3,0,0);
431

  
432
			this.constraintsLast = new GridBagConstraints();
433
			this.constraintsLast.fill = GridBagConstraints.BOTH;
434
			this.constraintsLast.gridheight = GridBagConstraints.REMAINDER;
435
			this.constraintsLast.gridwidth = GridBagConstraints.REMAINDER;
436
			this.constraintsLast.gridx =0;
437
			this.constraintsLast.weightx =1;
438
			this.constraintsLast.weighty =1;
439
			this.constraintsLast.anchor = GridBagConstraints.FIRST_LINE_START;
440

  
441

  
442
		}
443

  
444
		public void addItems(IUnsavedData[] itemList){
445
			int i;
446
			this.removeAll();
447
			if (itemList.length == 0){
448
				return;
449
			}
450

  
451
			for (i=0;i< itemList.length;i++){
452
				this.constraints.gridy = i;
453
				this.add(newItem(itemList[i]), this.constraints);
454
			}
455
			this.constraintsLast.gridy=itemList.length;
456
			this.add(new JLabel(),this.constraintsLast);
457

  
458
		}
459
		public int getItemsCount(){
460
			return this.getComponentCount() -1;
461
		}
462

  
463
		public myUnsavedItem getItem(int i){
464
			if (i>= this.getComponentCount()){
465
				return null;
466
			}
467
			return (myUnsavedItem)this.getComponent(i);
468
		}
469

  
470
		private myUnsavedItem newItem(IUnsavedData itemData){
471
			myUnsavedItem item;
472
			item = new myUnsavedItem(itemData);
473
			item.addMouseListener(new MouseListener(){
474
				public void mouseClicked(MouseEvent e) {
475
					myUnsavedItem item = (myUnsavedItem)e.getComponent();
476
					getLblResourceDescription().setText(item.getDescription());
477
				}
478
				public void mouseEntered(MouseEvent e) {
479
				}
480

  
481
				public void mouseExited(MouseEvent e) {
482
				}
483

  
484
				public void mousePressed(MouseEvent e) {
485
				}
486

  
487
				public void mouseReleased(MouseEvent e) {
488
				}
489

  
490
			});
491
			return item;
492
		}
493

  
494
	}
495

  
496
	private class myUnsavedItem extends JPanel{
497
		/**
498
		 *
499
		 */
500
		private static final long serialVersionUID = -6280057775368437349L;
501
		private JCheckBox chkChecked;
502
		private JLabel lblText;
503
		private IUnsavedData dataItem;
504

  
505
		public myUnsavedItem(IUnsavedData dataItem ){
506
			super();
507
			this.initialize();
508
			this.setData(dataItem);
509
		}
510

  
511
		private void initialize(){
512
			this.setOpaque(false);
513
			BorderLayout layout = new BorderLayout();
514
			layout.setHgap(5);
515
			this.setLayout(layout);
516
			this.add(this.getChkChecked(),BorderLayout.WEST);
517
			this.add(this.getLblText(),BorderLayout.CENTER);
518
		}
519

  
520
		private JLabel getLblText() {
521
			if (lblText == null){
522
				lblText = new JLabel();
523
				lblText.setName("lblText");
524
			}
525
			return lblText;
526
		}
527

  
528
		private JCheckBox getChkChecked() {
529
			if (chkChecked == null){
530
				chkChecked = new JCheckBox();
531
				chkChecked.setName("chkChecked");
532
				chkChecked.setSelected(true);
533
				chkChecked.setOpaque(false);
534
			}
535
			return chkChecked;
536
		}
537

  
538
		public boolean isSelected(){
539
			return getChkChecked().isSelected();
540
		}
541

  
542
		public void setSelected(boolean selected){
543
			getChkChecked().setSelected(selected);
544
		}
545

  
546
		public void setData(IUnsavedData dataItem){
547
			this.dataItem = dataItem;
548
			JLabel lbl = getLblText();
549
			if (dataItem.getIcon() != null){
550
			    ImageIcon ii = IconThemeHelper.getImageIcon(dataItem.getIcon());
551
				lbl.setIcon(ii);
552
			} else{
553
				lbl.setIcon(getBlanckIcon());
554
			}
555
			lbl.setText(dataItem.getResourceName());
556
			getChkChecked().setSelected(true);
557
		}
558

  
559
		public IUnsavedData getData(){
560
			return this.dataItem;
561
		}
562

  
563
		public String getDescription(){
564
			return this.dataItem.getDescription();
565
		}
566

  
567
		private ImageIcon getBlanckIcon(){
568
			if (blanckIcon== null){
569
				BufferedImage buff =new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
570
				blanckIcon = new ImageIcon(buff);
571
			}
572
			return blanckIcon;
573
		}
574

  
575
	}
576

  
577
	public void actionPerformed(ActionEvent e) {
578
		if (e.getActionCommand() == "Cancel"){
579
			fireDontExitEvent();
580
			return;
581
		}
582
		if (e.getActionCommand() == "Accept"){
583
			fireAcceptEvent();
584
			return;
585
		}
586
		if (e.getActionCommand() == "Discard") {
587
			fireDiscardEvent();
588
			return;
589
		}
590
		if (e.getActionCommand() == "SelectAll"){
591
			selectAll();
592
			return;
593
		}
594
		if (e.getActionCommand() == "DeselectAll"){
595
			deselectAll();
596
			return;
597
		}
598
	}
599

  
600
	public void close(){
601
		PluginServices.getMDIManager().closeWindow(this);
602

  
603
	}
604

  
605
	private void fireAcceptEvent() {
606
		Iterator iter = this.listeners.iterator();
607
		while (iter.hasNext()){
608
			((UnsavedDataPanelListener)iter.next()).accept(this);
609
		}
610
	}
611

  
612
	private void fireDiscardEvent() {
613
		Iterator iter = this.listeners.iterator();
614
		while (iter.hasNext()){
615
			((UnsavedDataPanelListener)iter.next()).discard(this);
616
		}
617
	}
618

  
619
	private void fireDontExitEvent() {
620
		Iterator iter = this.listeners.iterator();
621
		while (iter.hasNext()){
622
			((UnsavedDataPanelListener)iter.next()).cancel(this);
623
		}
624
	}
625

  
626
	private void setSelectedsAll( boolean selected){
627
		int i;
628
		myList theList = getList();
629
		myUnsavedItem item;
630
		for (i=0;i < theList.getItemsCount();i++){
631
			item = (myUnsavedItem)theList.getItem(i);
632
			item.setSelected(selected);
633
		}
634
		theList.doLayout();
635
	}
636

  
637
	public void deselectAll() {
638
		this.setSelectedsAll(false);
639
	}
640

  
641
	public void selectAll() {
642
		this.setSelectedsAll(true);
643
	}
644

  
645

  
646
	/**
647
	 * Set the resorces to ask for
648
	 *
649
	 * @param IUnsavedData[] resources pending to save
650
	 */
651
	public void setUnsavedDataArray(IUnsavedData[] unsavedDatalist){
652
		this.unsavedDataList = unsavedDatalist;
653
		myList theList = getList();
654

  
655
		theList.addItems(unsavedDatalist);
656
		theList.validate();
657

  
658
	}
659

  
660
	   /**
661
     * Set the resorces to ask for
662
     *
663
     * @param IUnsavedData[] resources pending to save
664
     */
665
    public void setUnsavedData(List<IUnsavedData> unsavedDatalist){
666
        setUnsavedDataArray(unsavedDatalist.toArray(new IUnsavedData[0]));
667
    }
668

  
669
    public List<IUnsavedData> getSelectedsUnsavedDataList(){
670
        return Arrays.asList(this.getSelectedsUnsavedData());
671
    }
672

  
673
	private IUnsavedData[] getUnsavedData(boolean selected){
674
		int i;
675
		myList theList = getList();
676
		ArrayList aList = new ArrayList();
677
		myUnsavedItem item;
678
		IUnsavedData[] result;
679

  
680
		for (i=0;i < theList.getItemsCount();i++){
681
			item = (myUnsavedItem)theList.getItem(i);
682
			if (item.isSelected() == selected){
683
				aList.add(item.getData());
684
			}
685
		}
686
		result = new IUnsavedData[aList.size()];
687
		System.arraycopy(aList.toArray(), 0, result, 0, aList.size());
688
		return result;
689
	}
690

  
691

  
692
	/**
693
	 * Returns the IUnsavedData selecteds for the user to save
694
	 *
695
	 * @return IUnsaveData[] to save
696
	 */
697
	public IUnsavedData[] getSelectedsUnsavedData(){
698
		return this.getUnsavedData(true);
699

  
700
	}
701

  
702
	/**
703
	 * Returns the IUnsavedData not selecteds for the user
704
	 *
705
	 * @return IUnsavedData[] to ignore
706
	 */
707
	public IUnsavedData[] getUnselectedsUnsavedData(){
708
		return this.getUnsavedData(false);
709
	}
710

  
711
	public Object getWindowProfile() {
712
		return WindowInfo.DIALOG_PROFILE;
713
	}
714

  
715
}  //  @jve:decl-index=0:visual-constraint="10,10"
716

  
0 717

  
tags/org.gvsig.desktop-2.0.142/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/theme/Theme.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.theme;
25

  
26
import java.awt.Color;
27
import java.awt.Point;
28
import java.io.File;
29
import java.io.FileInputStream;
30
import java.io.FileNotFoundException;
31
import java.io.IOException;
32
import java.util.ArrayList;
33
import java.util.Map;
34

  
35
import javax.swing.ImageIcon;
36
import javax.swing.UIManager;
37
import org.apache.commons.io.IOUtils;
38
import org.apache.commons.lang.text.StrSubstitutor;
39
import org.apache.commons.lang3.StringUtils;
40

  
41
import org.gvsig.andami.Launcher;
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.andami.messages.NotificationManager;
44
import org.gvsig.tools.util.XMLUtils;
45
import org.kxml2.io.KXmlParser;
46
import org.slf4j.Logger;
47
import org.slf4j.LoggerFactory;
48
import org.xmlpull.v1.XmlPullParser;
49
import org.xmlpull.v1.XmlPullParserException;
50

  
51
/**
52
 * Personalization of the program according to the file xml with the necessary
53
 * information.
54
 *
55
 * @author Vicente Caballero Navarro
56
 */
57
public class Theme {
58

  
59
    private static final Logger logger = LoggerFactory.getLogger(Theme.class);
60

  
61
    public static final String CENTERED = "CENTERED";
62
    public static final String EXPAND = "EXPAND";
63
    public static final String MOSAIC = "MOSAIC";
64

  
65
    private static final String ANDAMI_PROPERTIES = "AndamiProperties";
66
    private static final String APPLICATION_IMAGES = "ApplicationImages";
67
    private static final String SPLASH_IMAGES = "SplashImages";
68
    private static final String SPLASH = "Splash";
69
    private static final String PATH = "path";
70
    private static final String TIMER = "timer";
71
    private static final String ICON = "Icon";
72
    private static final String APPLICATION_NAME = "ApplicationName";
73
    private static final String PRIORITY = "priority";
74
    private static final String VALUE = "value";
75
    private static final String BACKGROUND_IMAGE = "BackgroundImage";
76
    private static final String BACKGROUND_COLOR = "BackgroundColor";
77
    private static final String WALLPAPER_TYPE = "WallpaperType";
78

  
79
    private static final String VERSION = "version";
80
    private static final String FONTPOSITIONX = "x";
81
    private static final String FONTPOSITIONY = "y";
82

  
83
    private static final String FONTSIZE = "fontsize";
84
    private static final String FONTCOLOR = "color";
85

  
86
    private ArrayList<String> images = new ArrayList<String>();
87
    private String icon;
88
    private ArrayList<String> timers = new ArrayList<String>();
89
    private ArrayList<String> versions = new ArrayList<String>();
90
    private ArrayList<String> fontColors = new ArrayList<String>();
91
    private ArrayList<String> fontSizes = new ArrayList<String>();
92
    private ArrayList<String> fontpositionsX = new ArrayList<String>();
93
    private ArrayList<String> fontpositionsY = new ArrayList<String>();
94

  
95
    private String name = null;
96
    private String backgroundimage = null;
97
    private Color backgroundColor = null;
98
    private String wallpaperType = CENTERED;
99
    private int priority = 0;
100

  
101
    /**
102
     * Spurce file of the theme *
103
     */
104
    private File source = null;
105
    private StrSubstitutor strSubstitutor = null;
106

  
107
    public Theme() {
108
    }
109

  
110
    public Theme(Map vars) {
111
        this();
112
        this.strSubstitutor = new StrSubstitutor(vars);
113
    }
114

  
115
    public File getSource() {
116
        return source;
117
    }
118

  
119
    /**
120
     * Read the file xml with the personalization.
121
     *
122
     * @param file xml
123
     */
124
    public void readTheme(File file) {
125
        FileInputStream fis = null;
126
        try {
127
            String encoding = XMLUtils.getEncoding(file, "UTF-8");
128

  
129
            fis = new FileInputStream(file);
130
            KXmlParser parser = new KXmlParser();
131
            parser.setInput(fis, encoding);
132

  
133
            int tag = parser.nextTag();
134

  
135
            if ( parser.getEventType() != XmlPullParser.END_DOCUMENT ) {
136
                parser.require(XmlPullParser.START_TAG, null, ANDAMI_PROPERTIES);
137

  
138
                while ( tag != XmlPullParser.END_DOCUMENT ) {
139
                    //parser.next();
140
                    switch (tag) {
141
                    case XmlPullParser.START_TAG:
142
                        if ( parser.getName().compareTo(ANDAMI_PROPERTIES) == 0 ) {
143
                            parser.nextTag();
144
                            if ( parser.getName().compareTo(APPLICATION_IMAGES) == 0 ) {
145
                                int splashtag = parser.nextTag();
146
                                if ( parser.getName().compareTo(SPLASH_IMAGES) == 0 ) {
147
                                    splashtag = parser.nextTag();
148
                                    boolean endSplash = false;
149

  
150
                                    // parser.require(KXmlParser.START_TAG,null, SPLASH);
151
                                    while ( (splashtag != XmlPullParser.END_DOCUMENT)
152
                                            && !endSplash ) {
153
                                        if ( splashtag == XmlPullParser.END_TAG ) {
154
                                            splashtag = parser.nextTag();
155
                                            continue;
156
                                        }
157

  
158
                                        if ( parser.getName().compareTo(SPLASH) == 0 ) {
159
                                            images.add(fixPath(file, parser.getAttributeValue("", PATH)));
160
                                            timers.add(parser.getAttributeValue("", TIMER));
161
                                            versions.add(expand(parser.getAttributeValue("", VERSION)));
162
                                            fontpositionsX.add(parser.getAttributeValue("", FONTPOSITIONX));
163
                                            fontpositionsY.add(parser.getAttributeValue("", FONTPOSITIONY));
164
                                            fontSizes.add(parser.getAttributeValue("", FONTSIZE));
165
                                            fontColors.add(parser.getAttributeValue("", FONTCOLOR));
166

  
167
                                            splashtag = parser.nextTag();
168
                                        } else {
169
                                            endSplash = true;
170
                                        }
171
                                    }
172
                                }
173
                                int tagOptions = XmlPullParser.START_TAG;
174
                                while ( (tagOptions != XmlPullParser.END_TAG) ) {
175
                                    if ( parser.getName().compareTo(BACKGROUND_IMAGE) == 0 ) {
176
                                        backgroundimage = fixPath(file, parser.getAttributeValue("", PATH));
177
                                        tag = parser.next();
178
                                    } else if ( parser.getName().compareTo(BACKGROUND_COLOR) == 0 ) {
179
                                        backgroundColor = parseColor(parser.getAttributeValue("", "color"));
180
                                        tag = parser.next();
181
                                    } else if ( parser.getName().compareTo(ICON) == 0 ) {
182
                                        icon = fixPath(file, parser.getAttributeValue("", PATH));
183
                                        tag = parser.next();
184
                                    } else if ( parser.getName().compareTo(WALLPAPER_TYPE) == 0 ) {
185
                                        wallpaperType = parser.getAttributeValue("", VALUE);
186
                                        tag = parser.next();
187
                                    }
188
                                    tagOptions = parser.nextTag();
189

  
190
                                }
191
                            }
192
                        }
193
                        if ( parser.getName().compareTo(APPLICATION_NAME) == 0 ) {
194
                            name = expand(parser.getAttributeValue("", VALUE));
195
                            tag = parser.next();
196
                        }
197
                        if ( parser.getName().compareTo(PRIORITY) == 0 ) {
198
                            String s = parser.getAttributeValue("", VALUE);
199
                            try {
200
                                this.priority = Integer.parseInt(s);
201
                            } catch (Exception ex) {
202
                                this.priority = 0;
203
                            }
204
                            tag = parser.next();
205
                        }
206
                        break;
207

  
208
                    case XmlPullParser.END_TAG:
209
                        break;
210

  
211
                    case XmlPullParser.TEXT:
212
                        // System.out.println("[TEXT]["+kxmlParser.getText()+"]");
213
                        break;
214
                    }
215
                    tag = parser.next();
216
                }
217
            }
218

  
219
            parser.require(XmlPullParser.END_DOCUMENT, null, null);
220
            this.source = file;
221

  
222
        } catch (FileNotFoundException ex) {
223
            logger.warn("Can't open theme file '" + file.getAbsolutePath() + "'.", ex);
224

  
225
        } catch (XmlPullParserException ex) {
226
            logger.warn("Can't parse theme file '" + file.getAbsolutePath() + "'.", ex);
227

  
228
        } catch (IOException ex) {
229
            logger.warn("Can't read theme file '" + file.getAbsolutePath() + "'.", ex);
230

  
231
        } finally {
232
            IOUtils.closeQuietly(fis);
233
        }
234
    }
235

  
236
    private String fixPath(File theme, String path) {
237
        path = path.replace("$GVSIG_INSTALL", Launcher.getApplicationDirectory());
238
        path = path.replace("$GVSIG_HOME", Launcher.getAppHomeDir());
239
        path = path.replace("$GVSIG_PLUGINS", Launcher.getAndamiConfig().getPluginsDirectory());
240
        File parent = theme.getParentFile().getAbsoluteFile();
241
        File fpath = new File(path);
242
        if ( !fpath.isAbsolute() ) {
243
            fpath = new File(parent, path);
244
        }
245
        return fpath.getAbsolutePath();
246
    }
247

  
248
    /**
249
     * Returns image to the splashwindow.
250
     *
251
     * @return ImageIcon[]
252
     */
253
    public ImageIcon[] getSplashImages() {
254
        ImageIcon[] imgs = new ImageIcon[images.size()];
255

  
256
        for ( int i = 0; i < images.size(); i++ ) {
257
            imgs[i] = new ImageIcon(images.get(i));
258
        }
259

  
260
        return imgs;
261
    }
262

  
263
    public String getTypeDesktop() {
264
        return wallpaperType;
265
    }
266

  
267
    /**
268
     * Return the icon.
269
     *
270
     * @return ImageIcon
271
     */
272
    public ImageIcon getIcon() {
273
        if ( icon == null ) {
274
            return null;
275
        }
276

  
277
        try {
278
            return new ImageIcon(icon);
279
        } catch (Exception e) {
280
            return null;
281
        }
282
    }
283

  
284
    /**
285
     * Return the backgroundimage.
286
     *
287
     * @return ImageIcon
288
     */
289
    public ImageIcon getBackgroundImage() {
290
        if ( backgroundimage == null ) {
291
            return null;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff