Revision 8838

View differences:

trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/NewSkin.java
47 47
import java.awt.Dimension;
48 48
import java.awt.KeyEventDispatcher;
49 49
import java.awt.Point;
50
import java.awt.Window;
51 50
import java.awt.event.ActionEvent;
52 51
import java.awt.event.ActionListener;
53 52
import java.awt.event.KeyEvent;
......
55 54
import java.awt.event.WindowEvent;
56 55
import java.beans.PropertyVetoException;
57 56
import java.util.ArrayList;
58
import java.util.Collection;
59 57
import java.util.Iterator;
60 58
import java.util.TreeMap;
61 59

  
......
65 63
import javax.swing.JDialog;
66 64
import javax.swing.JFrame;
67 65
import javax.swing.JInternalFrame;
68
import javax.swing.JRootPane;
69 66
import javax.swing.KeyStroke;
70 67
import javax.swing.event.InternalFrameEvent;
71 68
import javax.swing.event.InternalFrameListener;
72 69

  
73 70
import org.apache.log4j.Logger;
74 71

  
75
import com.iver.andami.GlobalKeyEventDispatcher;
76
import com.iver.andami.Launcher;
77 72
import com.iver.andami.PluginServices;
78 73
import com.iver.andami.plugins.Extension;
79 74
import com.iver.andami.ui.mdiFrame.GlassPane;
80 75
import com.iver.andami.ui.mdiFrame.MDIFrame;
81 76
import com.iver.andami.ui.mdiFrame.NewStatusBar;
77
import com.iver.andami.ui.mdiManager.IWindow;
78
import com.iver.andami.ui.mdiManager.IWindowListener;
82 79
import com.iver.andami.ui.mdiManager.MDIManager;
83 80
import com.iver.andami.ui.mdiManager.MDIUtilities;
84 81
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException;
85 82
import com.iver.andami.ui.mdiManager.SingletonWindow;
86
import com.iver.andami.ui.mdiManager.IWindow;
87 83
import com.iver.andami.ui.mdiManager.WindowInfo;
88
import com.iver.andami.ui.mdiManager.IWindowListener;
89
import com.iver.core.StatusBar;
90 84

  
91 85
/**
92 86
 *
......
123 117
     */
124 118
    private FrameWindowSupport fws;
125 119

  
126
    private WindowInfoSupport vis;
120
    private WindowInfoSupport wis;
127 121

  
128 122
    private WindowStackSupport wss;
129 123

  
......
145 139

  
146 140
        fws = new FrameWindowSupport(mainFrame);
147 141
        dss = new DialogStackSupport(mainFrame);
148
        sws = new SingletonWindowSupport(vis, fws);
149
        vis = new WindowInfoSupport(mainFrame, fws, sws);
150
        fws.setVis(vis);
151
        wss = new WindowStackSupport(vis);
142
        sws = new SingletonWindowSupport(wis, fws);
143
        wis = new WindowInfoSupport(mainFrame, fws, sws);
144
        fws.setVis(wis);
145
        wss = new WindowStackSupport(wis);
152 146

  
153 147

  
154 148
        // TODO (jaume) esto no deber?a de estar aqu?...
......
183 177
     */
184 178
    public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException {
185 179
        // se obtiene la informaci?n de la vista
186
        WindowInfo wi = vis.getWindowInfo(p);
180
        WindowInfo wi = wis.getWindowInfo(p);
187 181

  
188 182
        // Se comprueban las incompatibilidades que pudieran haber en la vista
189 183
        MDIUtilities.checkWindowInfo(wi);
......
212 206
                addJInternalFrame(frame, wi);
213 207
                wss.add(p, new ActionListener() {
214 208
                    public void actionPerformed(ActionEvent e) {
215
                        IWindow v = vis.getWindowById(Integer.parseInt(e
209
                        IWindow v = wis.getWindowById(Integer.parseInt(e
216 210
                                .getActionCommand()));
217 211
                        JInternalFrame f = fws.getJInternalFrame(v);
218 212
                        activateJInternalFrame(f);
......
234 228
                // Se sit?a la vista en la pila de vistas
235 229
                wss.add(p, new ActionListener() {
236 230
                    public void actionPerformed(ActionEvent e) {
237
                        IWindow v = vis.getWindowById(Integer.parseInt(e
231
                        IWindow v = wis.getWindowById(Integer.parseInt(e
238 232
                                .getActionCommand()));
239 233
                        JInternalFrame f = fws.getJInternalFrame(v);
240 234
                        activateJInternalFrame(f);
......
256 250
     */
257 251
	public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException {
258 252
	    // se obtiene la informaci?n de la vista
259
        WindowInfo vi = vis.getWindowInfo(p);
253
        WindowInfo vi = wis.getWindowInfo(p);
260 254

  
261 255
        // Se comprueban las incompatibilidades que pudieran haber en la vista
262 256
        MDIUtilities.checkWindowInfo(vi);
......
272 266

  
273 267
        if (p instanceof SingletonWindow) {
274 268
            SingletonWindow sv = (SingletonWindow) p;
275
            if (sws.registerWindow(sv.getClass(), sv.getWindowModel(), vis
269
            if (sws.registerWindow(sv.getClass(), sv.getWindowModel(), wis
276 270
                    .getWindowInfo(sv))) {
277 271
                singletonPreviouslyAdded = true;
278 272
            }
......
286 280
                addJInternalFrame(frame, vi);
287 281
                wss.add(p, new ActionListener() {
288 282
                    public void actionPerformed(ActionEvent e) {
289
                        IWindow w = vis.getWindowById(Integer.parseInt(e
283
                        IWindow w = wis.getWindowById(Integer.parseInt(e
290 284
                                .getActionCommand()));
291 285
                        JInternalFrame f = fws.getJInternalFrame(w);
292 286
                        centreJInternalFrame(f); // Centre this JInternalFrame
......
311 305
                // Se sit?a la vista en la pila de vistas
312 306
                wss.add(p, new ActionListener() {
313 307
                    public void actionPerformed(ActionEvent e) {
314
                        IWindow w = vis.getWindowById(Integer.parseInt(e
308
                        IWindow w = wis.getWindowById(Integer.parseInt(e
315 309
                                .getActionCommand()));
316 310
                        JInternalFrame f = fws.getJInternalFrame(w);                        
317 311
                        activateJInternalFrame(f);
......
450 444
     * @param p
451 445
     */
452 446
    private void addJInternalFrame(IWindow p) {
453
        WindowInfo wi = vis.getWindowInfo(p);
447
        WindowInfo wi = wis.getWindowInfo(p);
454 448

  
455 449
        JInternalFrame wnd = fws.getJInternalFrame(p);
456 450

  
......
506 500
        dlg.addWindowListener(new DialogWindowListener());
507 501
        dss.pushDialog(dlg);
508 502

  
509
        dlg.setVisible(vis.getWindowInfo(p).isVisible());
503
        dlg.setVisible(wis.getWindowInfo(p).isVisible());
510 504
    }
511 505

  
512 506
    /**
......
572 566
     * @see com.iver.andami.ui.mdiManager.MDIManager#getWindowInfo(com.iver.andami.ui.mdiManager.IWindow)
573 567
     */
574 568
    public WindowInfo getWindowInfo(IWindow w) {
575
    	WindowInfo wi = vis.getWindowInfo(w);
569
    	WindowInfo wi = wis.getWindowInfo(w);
576 570
    	
577
    	JInternalFrame f = fws.getJInternalFrame(w);
571
    /*	
572
     * This is done now in vis.getWindowInfo(w)
573
     * 
574
     * JInternalFrame f = fws.getJInternalFrame(w);
578 575
    	wi.setX(f.getX());
579 576
    	wi.setY(f.getY());
580 577
    	wi.setHeight(f.getHeight());
......
582 579
    	// isClosed() doesn't work as (I) expected, why? Using isShowing instead
583 580
    	wi.setClosed(!f.isShowing());
584 581
    	wi.setNormalBounds(f.getNormalBounds());
585
    	wi.setMaximized(f.isMaximum());
582
    	wi.setMaximized(f.isMaximum());*/
586 583
    	return wi;
587 584
    }
588 585

  
......
743 740

  
744 741
            IWindow panel = fws.getWindow((JInternalFrame) e.getSource());
745 742

  
746
            WindowInfo wi = vis.getWindowInfo(panel);
743
            WindowInfo wi = wis.getWindowInfo(panel);
747 744
            if (wi.isPalette())
748 745
                return;
749 746

  
......
782 779
            // e.getInternalFrame().getTitle());
783 780

  
784 781
            JInternalFrame c = (JInternalFrame) e.getSource();
785
            WindowInfo wi = vis.getWindowInfo((IWindow) fws.getWindow(c));
782
            WindowInfo wi = wis.getWindowInfo((IWindow) fws.getWindow(c));
786 783

  
787 784
            IWindow win = fws.getWindow(c);
788 785
            callWindowClosed(win);
......
828 825
            JInternalFrame c = (JInternalFrame) e.getSource();
829 826
            IWindow win = fws.getWindow(c);
830 827
            if (win != null) {
831
                WindowInfo wi = vis.getWindowInfo(win);
828
                WindowInfo wi = wis.getWindowInfo(win);
832 829
                if (wi.isPalette())
833 830
                    return;
834 831
                wi.setSelectedTool(mainFrame.getSelectedTool());
......
897 894
        return (IWindow[]) windows.toArray(new IWindow[0]);
898 895
    }
899 896
    
897
    /**
898
     * @see com.iver.andami.ui.mdiManager.MDIManager#getOrderedWindows()
899
     */
900 900
    public IWindow[] getOrderedWindows() {
901 901
        //ArrayList windows = new ArrayList();
902 902
        TreeMap windows = new TreeMap();
......
911 911
        int zPosition;
912 912
        while (winIterator.hasNext()) {
913 913
        	win = (IWindow) winIterator.next();
914
        	
915 914
        	frame = fws.getFrame(win);
916 915
    		zPosition = panel.getPosition(frame);
917 916
    		windows.put(new Integer(zPosition), win);
918
   
919 917
        }
920 918
        winIterator = windows.values().iterator();
921 919
        ArrayList winList = new ArrayList();
trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/FrameWindowSupport.java
46 46
import java.util.Iterator;
47 47

  
48 48
import javax.swing.ImageIcon;
49
import javax.swing.JComponent;
49 50
import javax.swing.JDialog;
50 51
import javax.swing.JFrame;
51 52
import javax.swing.JInternalFrame;
52 53
import javax.swing.JPanel;
53 54

  
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.plugins.PluginClassLoader;
54 57
import com.iver.andami.ui.mdiFrame.MDIFrame;
55 58
import com.iver.andami.ui.mdiManager.IWindow;
56 59
import com.iver.andami.ui.mdiManager.WindowInfo;
......
107 110
            JDialog nuevo = new JDialog(mainFrame);
108 111

  
109 112
            nuevo.getContentPane().add((JPanel) p);
110
            nuevo.setSize(getWidth(p), getHeight(p) + 30);
113
            nuevo.setSize(getWidth(p, vi), getHeight(p, vi) + 30);
111 114
            nuevo.setTitle(vi.getTitle());
112 115
            nuevo.setResizable(vi.isResizable());
113 116

  
......
129 132
     * @return DOCUMENT ME!
130 133
     */
131 134
    public JInternalFrame getJInternalFrame(IWindow p) {
132
        JInternalFrame frame = (JInternalFrame) viewFrame.get(p);
135
    	JInternalFrame frame = (JInternalFrame) viewFrame.get(p);
133 136

  
134 137
        if (frame == null) {
135 138
        	//ViewInfo vi = vis.getViewInfo(p);
......
152 155
        }
153 156
        nuevo.getContentPane().add((JPanel) p);
154 157
        nuevo.setClosable(true);
155
        nuevo.setSize(getWidth(p), getHeight(p));
158
        nuevo.setSize(getWidth(p, vi), getHeight(p, vi));
156 159
        nuevo.setTitle(vi.getTitle());
157 160
        nuevo.setVisible(vi.isVisible());
158 161
        nuevo.setResizable(vi.isResizable());
......
262 265
            return vi.getWidth();
263 266
        }
264 267
    }
268
    
269
    /**
270
     * DOCUMENT ME!
271
     *
272
     * @param v DOCUMENT ME!
273
     *
274
     * @return DOCUMENT ME!
275
     */
276
    private int getWidth(IWindow v, WindowInfo wi) {
277
        if (wi.getWidth() == -1) {
278
            JPanel p = (JPanel) v;
265 279

  
280
            return p.getSize().width;
281
        } else {
282
            return wi.getWidth();
283
        }
284
    }
285

  
266 286
    /**
267 287
     * DOCUMENT ME!
268 288
     *
......
281 301
            return vi.getHeight();
282 302
        }
283 303
    }
304
    
305
    /**
306
     * DOCUMENT ME!
307
     *
308
     * @param v DOCUMENT ME!
309
     *
310
     * @return DOCUMENT ME!
311
     */
312
    private int getHeight(IWindow v, WindowInfo wi) {
313
        if (wi.getHeight() == -1) {
314
            JPanel p = (JPanel) v;
315

  
316
            return p.getSize().height;
317
        } else {
318
            return wi.getHeight();
319
        }
320
    }
321
    
322
    public void updateWindowInfo(IWindow win, WindowInfo windowInfo) {
323
    	Object o = viewFrame.get(win);
324
    	if (windowInfo!=null && o!=null) {
325
    		if (o instanceof JComponent) {
326
        		JComponent component = (JComponent) o;
327
        		windowInfo.setWidth(component.getWidth());
328
				windowInfo.setHeight(component.getHeight());
329
				windowInfo.setX(component.getX());
330
				windowInfo.setY(component.getY());
331
				windowInfo.setClosed(!component.isShowing());
332
				if (component instanceof JInternalFrame) {
333
					JInternalFrame iframe = (JInternalFrame) component;
334
					windowInfo.setNormalBounds(iframe.getNormalBounds());
335
					windowInfo.setMaximized(iframe.isMaximum());
336
				}
337
    		}
338
    	}
339
    }
284 340
}
trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/WindowInfoSupport.java
60 60
 */
61 61
public class WindowInfoSupport {
62 62
	private static int serialId = 0;
63
	private FrameWindowSupport fvs;
63
	
64
	/**
65
	 * Support class which associates Frames and Windows
66
	 */
67
	private FrameWindowSupport fws;
64 68

  
65 69
	// Correspondencias entre las ventanas y su informacion
66 70
	/**
......
84 88
	 */
85 89
	public WindowInfoSupport(MainFrame frame, FrameWindowSupport fvs,
86 90
		SingletonWindowSupport svs) {
87
		this.fvs = fvs;
91
		this.fws = fvs;
88 92
		this.svs = svs;
89 93
		this.mdiFrame = frame;
90 94
	}
......
120 124
	public synchronized WindowInfo getWindowInfo(IWindow w) {
121 125
		WindowInfo wi = (WindowInfo) viewInfo.get(w);
122 126

  
123
		if (wi == null) {
127
		if (wi != null) {
128
			fws.updateWindowInfo(w, wi);
129
		}
130
		else {
124 131
			wi = w.getWindowInfo();
125 132

  
126 133
			//Para el t?tulo
......
193 200
				}
194 201
			} else {
195 202
				if (evt.getPropertyName().equals("x")) {
196
					fvs.setX(view, ((Integer) evt.getNewValue()).intValue());
203
					fws.setX(view, ((Integer) evt.getNewValue()).intValue());
197 204
				} else if (evt.getPropertyName().equals("y")) {
198
					fvs.setY(view, ((Integer) evt.getNewValue()).intValue());
205
					fws.setY(view, ((Integer) evt.getNewValue()).intValue());
199 206
				} else if (evt.getPropertyName().equals("height")) {
200
					fvs.setHeight(view, ((Integer) evt.getNewValue()).intValue());
207
					fws.setHeight(view, ((Integer) evt.getNewValue()).intValue());
201 208
				} else if (evt.getPropertyName().equals("width")) {
202
					fvs.setWidth(view, ((Integer) evt.getNewValue()).intValue());
209
					fws.setWidth(view, ((Integer) evt.getNewValue()).intValue());
203 210
				} else if (evt.getPropertyName().equals("title")) {
204
					fvs.setTitle(view, (String) evt.getNewValue());
211
					fws.setTitle(view, (String) evt.getNewValue());
205 212
					try{
206 213
						mdiFrame.changeMenuName(new String[] {
207 214
								"ventana", (String) evt.getOldValue()

Also available in: Unified diff