Revision 17026 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/panelGroup/PanelGroupDialog.java

View differences:

PanelGroupDialog.java
26 26
import java.io.Serializable;
27 27
import java.util.Hashtable;
28 28

  
29
import javax.swing.JOptionPane;
30

  
31
import org.gvsig.exceptions.BaseException;
29 32
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
30 33
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
31 34
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
32 35
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
33 36
import org.gvsig.gui.beans.panelGroup.AbstractPanelGroup;
34 37
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
38
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupException;
39
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupGUIException;
40
import org.gvsig.gui.beans.panelGroup.exceptions.ListCouldntAddPanelException;
41
import org.gvsig.gui.beans.panelGroup.exceptions.PanelWithNoPreferredSizeDefinedException;
35 42
import org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader;
36
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
37 43
import org.gvsig.gui.beans.panelGroup.panels.IPanel;
38 44

  
39 45
import com.iver.andami.PluginServices;
......
75 81
	private AbstractPanelGroup panelGroup;
76 82

  
77 83
	/**
78
	 * <p>Title of this kind of {@link IWindow IWindow}.</p>
79
	 */
80
	private String windowTitle;
81

  
82
	/**
83 84
	 * <p>Properties about the managing of this dialog by <i>Andami</i>.</p>
84 85
	 */
85 86
	private WindowInfo windowInfo;
86 87

  
87 88
	/**
88
	 * <p>If <code>resizable = true</code>, is the width of this {@link IWindow IWindow}, but if
89
	 *  <code>resizable = false</code>, will be permanently the width of this component.</p>
90
	 */
91
	private int width;
92

  
93
	/**
94
	 * <p>If <code>resizable = true</code>, is the height of this {@link IWindow IWindow}, but if
95
	 *  <code>resizable = false</code>, will be permanently the height of this component.</p>
96
	 */
97
	private int height;
98

  
99
	/**
100
	 * <p>Additional information about this {@link IWindow IWindow}.</p>
101
	 */
102
	private String additionalInfo;
103
//
104
//	/**
105
//	 * <p>Distance between the top of the inner {@link JTabbedPane JTabbedPane} and the top of the box of a
106
//	 *  {@link TabbedPanel TabbedPanel}.</p>
107
//	 */
108
//	private static final int JTABBEDPANE_HEIGHT_EXTRA = 5;
109

  
110
	/**
111 89
	 * <p>Default constructor with two parameters, that creates a panel with an {@link AbstractPanelGroup AbstractPanelGroup}
112 90
	 *  on top and another with <i>accept</i>, <i>apply</i>, and <i>cancel</i> buttons on bottom.</p>
113 91
	 *
......
117 95
	public PanelGroupDialog(String windowTitle, AbstractPanelGroup panelGroup) {
118 96
		super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
119 97

  
120
		this.additionalInfo = defaultAdditionalInfo;
121
		this.windowTitle = windowTitle;
122
		this.width = defaultWidth;
123
		this.height = defaultHeight;
124
		this.windowInfo = new WindowInfo();
98
		windowInfo = new WindowInfo();
99
		windowInfo.setTitle(PluginServices.getText(this, windowTitle));
100
		windowInfo.setWidth(defaultWidth);
101
		windowInfo.setHeight(defaultHeight);
102

  
125 103
		this.panelGroup = panelGroup;
126 104

  
127 105
		initialize();
......
143 121
	public PanelGroupDialog(String additionalInfo, String windowTitle, int  width, int height, byte windowInfoProperties, AbstractPanelGroup panelGroup) {
144 122
		super(ButtonsPanel.BUTTONS_ACCEPTCANCELAPPLY);
145 123

  
146
		this.additionalInfo = additionalInfo;
147
		this.windowTitle = windowTitle;
148
		this.width = width;
149
		this.height = height;
150
		this.windowInfo = new WindowInfo(windowInfoProperties);
124
		windowInfo = new WindowInfo(windowInfoProperties);
125
		windowInfo.setAdditionalInfo(additionalInfo);
126
		windowInfo.setTitle(PluginServices.getText(this, windowTitle));
127
		windowInfo.setWidth(width);
128
		windowInfo.setHeight(height);
129

  
151 130
		this.panelGroup = panelGroup;
152 131

  
153 132
		initialize();
......
158 137
	 */
159 138
	private void initialize() {
160 139
		setLayout(new BorderLayout());
161
		setPreferredSize(new Dimension(width, height));
140
//		setPreferredSize(new Dimension(width, height));
162 141
		addButtonPressedListener(this);
163 142
		// Mask possible extra exceptions
164 143
		if (panelGroup != null) {
......
208 187
	 * @return <code>true</code> if it's resizable; <code>false</code> otherwise.
209 188
	 */
210 189
	public boolean isResizable() {
211
//		return windowInfo.isResizable();
212
		return false;
190
		return windowInfo.isResizable();
213 191
	}
214 192

  
215 193
	/**
......
228 206
	 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
229 207
	 */
230 208
	public WindowInfo getWindowInfo() {
231
		if (this.additionalInfo != null)
232
			windowInfo.setAdditionalInfo(additionalInfo);
233
		windowInfo.setTitle(PluginServices.getText(this, windowTitle));
234
		windowInfo.setWidth(width);
235
		windowInfo.setHeight(height);
236

  
237 209
		return windowInfo;
238 210
	}
239 211

  
......
289 261

  
290 262
	/*
291 263
	 * (non-Javadoc)
292
	 * @see org.gvsig.gui.beans.panelGroup.IPanelGroup#addPanel(org.gvsig.gui.beans.panelGroup.panels.AbstractPanel)
264
	 * @see org.gvsig.gui.beans.panelGroup.IPanelGroup#addPanel(org.gvsig.gui.beans.panelGroup.panels.IPanel)
293 265
	 */
294
	public void addPanel(AbstractPanel panel) {
266
	public void addPanel(IPanel panel) throws EmptyPanelGroupException, EmptyPanelGroupGUIException, PanelWithNoPreferredSizeDefinedException {
295 267
		panelGroup.addPanel(panel);
296 268
	}
297 269

  
......
347 319
	 * (non-Javadoc)
348 320
	 * @see org.gvsig.gui.beans.panelGroup.IPanelGroup#loadPanels(org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader)
349 321
	 */
350
	public void loadPanels(IPanelGroupLoader loader) throws Exception {
351
		panelGroup.loadPanels(loader);
322
	public void loadPanels(IPanelGroupLoader loader) throws ListCouldntAddPanelException, EmptyPanelGroupException, EmptyPanelGroupGUIException {
323
		try {
324
			panelGroup.loadPanels(loader);
325
		}
326
		catch (BaseException be) {
327
			JOptionPane.showMessageDialog(null,	be.getMessageStack(), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
328
		}
329
		catch (Exception e) {
330
			JOptionPane.showMessageDialog(null,	e.getMessage(), PluginServices.getText(this, "error"), JOptionPane.ERROR_MESSAGE);
331
		}
352 332
	}
353 333

  
354 334
	/*
355 335
	 * (non-Javadoc)
356
	 * @see org.gvsig.gui.beans.panelGroup.IPanelGroup#removePanel(org.gvsig.gui.beans.panelGroup.panels.AbstractPanel)
336
	 * @see org.gvsig.gui.beans.panelGroup.IPanelGroup#removePanel(org.gvsig.gui.beans.panelGroup.panels.IPanel)
357 337
	 */
358
	public void removePanel(AbstractPanel panel) {
338
	public void removePanel(IPanel panel) {
359 339
		panelGroup.removePanel(panel);
360 340
	}
361 341

  
......
390 370
	public int getPanelInGUICount() {
391 371
		return panelGroup.getPanelInGUICount();
392 372
	}
373

  
374
	/*
375
	 * (non-Javadoc)
376
	 * @see javax.swing.JComponent#setPreferredSize(java.awt.Dimension)
377
	 */
378
	public void setPreferredSize(Dimension preferredSize) {
379
		super.setPreferredSize(preferredSize);
380
		
381
		windowInfo.setWidth(preferredSize.width);
382
		windowInfo.setHeight(preferredSize.height);
383
	}
393 384
}

Also available in: Unified diff