Revision 34719
branches/v2_0_0_prep/libraries/libCorePlugin/src/org/gvsig/coreplugin/mdiManager/NewSkin.java | ||
---|---|---|
41 | 41 |
package org.gvsig.coreplugin.mdiManager; |
42 | 42 |
|
43 | 43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Color; |
|
44 | 45 |
import java.awt.Component; |
45 | 46 |
import java.awt.Container; |
46 | 47 |
import java.awt.Cursor; |
... | ... | |
50 | 51 |
import java.awt.Point; |
51 | 52 |
import java.awt.event.ActionEvent; |
52 | 53 |
import java.awt.event.ActionListener; |
54 |
import java.awt.event.ComponentEvent; |
|
55 |
import java.awt.event.ComponentListener; |
|
53 | 56 |
import java.awt.event.KeyEvent; |
54 | 57 |
import java.awt.event.WindowAdapter; |
55 | 58 |
import java.awt.event.WindowEvent; |
56 | 59 |
import java.beans.PropertyVetoException; |
57 | 60 |
import java.util.ArrayList; |
58 | 61 |
import java.util.HashMap; |
62 |
import java.util.Hashtable; |
|
59 | 63 |
import java.util.Iterator; |
64 |
import java.util.Map; |
|
60 | 65 |
import java.util.TreeMap; |
61 | 66 |
|
62 | 67 |
import javax.swing.DefaultDesktopManager; |
... | ... | |
67 | 72 |
import javax.swing.JFrame; |
68 | 73 |
import javax.swing.JInternalFrame; |
69 | 74 |
import javax.swing.JLayeredPane; |
75 |
import javax.swing.JPanel; |
|
70 | 76 |
import javax.swing.JPopupMenu; |
77 |
import javax.swing.JScrollPane; |
|
71 | 78 |
import javax.swing.KeyStroke; |
72 | 79 |
import javax.swing.event.InternalFrameEvent; |
73 | 80 |
import javax.swing.event.InternalFrameListener; |
... | ... | |
89 | 96 |
import org.slf4j.LoggerFactory; |
90 | 97 |
|
91 | 98 |
|
99 |
|
|
92 | 100 |
/** |
93 | 101 |
* |
94 | 102 |
*/ |
... | ... | |
133 | 141 |
private Cursor lastCursor = null; |
134 | 142 |
private ImageIcon image; |
135 | 143 |
private String typeDesktop; |
144 |
|
|
145 |
//Anyade barras de scroll |
|
146 |
private void addScrolledDesktopPanel( JFrame parent, MyDesktopPane desktopPane) { |
|
147 |
JPanel toppanel; |
|
136 | 148 |
|
149 |
toppanel = new JPanel(); |
|
150 |
toppanel.setLayout(new BorderLayout()); |
|
151 |
toppanel.setPreferredSize(new Dimension(200,200)); |
|
152 |
toppanel.setBackground(Color.RED); |
|
153 |
|
|
154 |
JScrollPane scrollPanel = new JScrollPane(desktopPane); |
|
155 |
|
|
156 |
toppanel.add(scrollPanel, BorderLayout.CENTER); |
|
157 |
|
|
158 |
parent.getContentPane().add(toppanel, BorderLayout.CENTER); |
|
159 |
} |
|
160 |
|
|
137 | 161 |
/* |
138 | 162 |
* @see com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame.MDIFrame) |
139 | 163 |
*/ |
140 | 164 |
public void init(MDIFrame f) { |
165 |
|
|
141 | 166 |
// Inicializa el Frame y la consola |
142 |
mainFrame = f;
|
|
143 |
mainFrame.setGlassPane(glassPane);
|
|
167 |
mainFrame = f;
|
|
168 |
mainFrame.setGlassPane(glassPane);
|
|
144 | 169 |
panel.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); |
145 | 170 |
|
146 |
mainFrame.getContentPane().add(panel, BorderLayout.CENTER); |
|
171 |
//Anyade barras de scroll |
|
172 |
//mainFrame.getContentPane().add(panel, BorderLayout.CENTER); |
|
173 |
addScrolledDesktopPanel(mainFrame,panel); |
|
174 |
|
|
147 | 175 |
panel.setDesktopManager(desktopManager); |
148 | 176 |
|
149 | 177 |
fws = new FrameWindowSupport(mainFrame); |
... | ... | |
976 | 1004 |
} |
977 | 1005 |
class MyDesktopPane extends JDesktopPane |
978 | 1006 |
{ |
979 |
public MyDesktopPane(){ |
|
1007 |
protected Map listeners = new Hashtable(); |
|
1008 |
|
|
1009 |
|
|
1010 |
public MyDesktopPane(){ |
|
980 | 1011 |
} |
981 |
public void paintComponent(Graphics g){ |
|
1012 |
|
|
1013 |
public Dimension getPreferredSize() { |
|
1014 |
JInternalFrame[] array = this.getAllFrames(); |
|
1015 |
int maxX = 0; |
|
1016 |
int maxY = 0; |
|
1017 |
for (int i = 0; i < array.length; i++) { |
|
1018 |
int x = array[i].getX() + array[i].getWidth(); |
|
1019 |
if (x > maxX) |
|
1020 |
maxX = x; |
|
1021 |
int y = array[i].getY() + array[i].getHeight(); |
|
1022 |
if (y > maxY) |
|
1023 |
maxY = y; |
|
1024 |
} |
|
1025 |
return new Dimension(maxX, maxY); |
|
1026 |
} |
|
1027 |
|
|
1028 |
/** |
|
1029 |
* Add an internal-frame to the desktop. Sets a component-listener on |
|
1030 |
* it, which resizes the desktop if a frame is resized. |
|
1031 |
*/ |
|
1032 |
public Component add(Component comp) { |
|
1033 |
super.add(comp); |
|
1034 |
ComponentListener listener = new ComponentListener() { |
|
1035 |
public void componentResized(ComponentEvent e) { // Layout the |
|
1036 |
// JScrollPane |
|
1037 |
getParent().getParent().validate(); |
|
1038 |
} |
|
1039 |
|
|
1040 |
public void componentMoved(ComponentEvent e) { |
|
1041 |
JInternalFrame comp = (JInternalFrame) e.getSource(); |
|
1042 |
|
|
1043 |
//no deja que la ventana se vaya hacia la izquierda o arriba |
|
1044 |
if( comp.getX()<0 ) { |
|
1045 |
comp.setLocation(0, comp.getY()); |
|
1046 |
} |
|
1047 |
if (comp.getY()<0){ |
|
1048 |
comp.setLocation(comp.getX(), 0); |
|
1049 |
} |
|
1050 |
componentResized(e); |
|
1051 |
} |
|
1052 |
public void componentShown(ComponentEvent e) { |
|
1053 |
} |
|
1054 |
|
|
1055 |
public void componentHidden(ComponentEvent e) { |
|
1056 |
} |
|
1057 |
|
|
1058 |
}; |
|
1059 |
comp.addComponentListener(listener); |
|
1060 |
listeners.put(comp, listener); |
|
1061 |
return comp; |
|
1062 |
} |
|
1063 |
|
|
1064 |
/** |
|
1065 |
* Remove an internal-frame from the desktop. Removes the |
|
1066 |
* component-listener and resizes the desktop. |
|
1067 |
*/ |
|
1068 |
public void remove(Component comp) { |
|
1069 |
comp.removeComponentListener((ComponentListener) listeners |
|
1070 |
.get(comp)); |
|
1071 |
super.remove(comp); |
|
1072 |
getParent().getParent().validate(); // Layout the JScrollPane |
|
1073 |
} |
|
1074 |
|
|
1075 |
public void paintComponent(Graphics g){ |
|
982 | 1076 |
super.paintComponent(g); |
983 | 1077 |
int x=0; |
984 | 1078 |
int y=0; |
Also available in: Unified diff