Revision 6880 trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/NewSkin.java
NewSkin.java | ||
---|---|---|
80 | 80 |
import com.iver.andami.ui.mdiManager.MDIManager; |
81 | 81 |
import com.iver.andami.ui.mdiManager.MDIUtilities; |
82 | 82 |
import com.iver.andami.ui.mdiManager.SingletonDialogAlreadyShownException; |
83 |
import com.iver.andami.ui.mdiManager.SingletonView;
|
|
83 |
import com.iver.andami.ui.mdiManager.SingletonWindow;
|
|
84 | 84 |
import com.iver.andami.ui.mdiManager.IWindow; |
85 |
import com.iver.andami.ui.mdiManager.ViewInfo;
|
|
86 |
import com.iver.andami.ui.mdiManager.ViewListener;
|
|
85 |
import com.iver.andami.ui.mdiManager.WindowInfo;
|
|
86 |
import com.iver.andami.ui.mdiManager.IWindowListener;
|
|
87 | 87 |
import com.iver.core.StatusBar; |
88 | 88 |
|
89 | 89 |
/** |
... | ... | |
154 | 154 |
PluginServices.registerKeyStroke(controlTab, new KeyEventDispatcher() { |
155 | 155 |
|
156 | 156 |
public boolean dispatchKeyEvent(KeyEvent e) { |
157 |
IWindow[] views = getAllViews();
|
|
157 |
IWindow[] views = getAllWindows();
|
|
158 | 158 |
if (views.length<=0 || e.getID() == KeyEvent.KEY_PRESSED) |
159 | 159 |
return false; |
160 | 160 |
|
161 | 161 |
|
162 | 162 |
int current = 0; |
163 | 163 |
for (int i = 0; i < views.length; i++) { |
164 |
if (views[i].equals(getActiveView())) {
|
|
164 |
if (views[i].equals(getActiveWindow())) {
|
|
165 | 165 |
current = i; |
166 | 166 |
break; |
167 | 167 |
} |
168 | 168 |
} |
169 |
addView(views[(current +1) % views.length]);
|
|
169 |
addWindow(views[(current +1) % views.length]);
|
|
170 | 170 |
return true; |
171 | 171 |
} |
172 | 172 |
|
... | ... | |
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
/** |
177 |
* @see com.iver.andami.ui.mdiManager.MDIManager#addView(com.iver.andami.ui.mdiManager.IWindow)
|
|
177 |
* @see com.iver.andami.ui.mdiManager.MDIManager#addWindow(com.iver.andami.ui.mdiManager.IWindow)
|
|
178 | 178 |
*/ |
179 |
public IWindow addView(IWindow p) throws SingletonDialogAlreadyShownException {
|
|
179 |
public IWindow addWindow(IWindow p) throws SingletonDialogAlreadyShownException {
|
|
180 | 180 |
// se obtiene la informaci?n de la vista |
181 |
ViewInfo vi = vis.getViewInfo(p);
|
|
181 |
WindowInfo vi = vis.getViewInfo(p);
|
|
182 | 182 |
|
183 | 183 |
// Se comprueban las incompatibilidades que pudieran haber en la vista |
184 |
MDIUtilities.checkViewInfo(vi);
|
|
185 |
if ((p instanceof SingletonView) && (vi.isModal())) {
|
|
184 |
MDIUtilities.checkWindowInfo(vi);
|
|
185 |
if ((p instanceof SingletonWindow) && (vi.isModal())) {
|
|
186 | 186 |
throw new RuntimeException("A modal view cannot be a SingletonView"); |
187 | 187 |
} |
188 | 188 |
|
... | ... | |
192 | 192 |
*/ |
193 | 193 |
boolean singletonPreviouslyAdded = false; |
194 | 194 |
|
195 |
if (p instanceof SingletonView) {
|
|
196 |
SingletonView sv = (SingletonView) p;
|
|
197 |
if (svs.registerView(sv.getClass(), sv.getViewModel(), vis
|
|
195 |
if (p instanceof SingletonWindow) {
|
|
196 |
SingletonWindow sv = (SingletonWindow) p;
|
|
197 |
if (svs.registerView(sv.getClass(), sv.getWindowModel(), vis
|
|
198 | 198 |
.getViewInfo(sv))) { |
199 | 199 |
singletonPreviouslyAdded = true; |
200 | 200 |
} |
... | ... | |
202 | 202 |
|
203 | 203 |
if (singletonPreviouslyAdded) { |
204 | 204 |
// Si la vista no est? actualmente abierta |
205 |
if (!svs.contains((SingletonView) p)) {
|
|
205 |
if (!svs.contains((SingletonWindow) p)) {
|
|
206 | 206 |
JInternalFrame frame = fvs.getJInternalFrame(p); |
207 |
svs.openSingletonView((SingletonView) p, frame);
|
|
207 |
svs.openSingletonView((SingletonWindow) p, frame);
|
|
208 | 208 |
addJInternalFrame(frame, vi); |
209 | 209 |
vss.add(p, new ActionListener() { |
210 | 210 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
218 | 218 |
} else { |
219 | 219 |
// La vista est? actualmente abierta |
220 | 220 |
JInternalFrame frame = (JInternalFrame) svs |
221 |
.getFrame((SingletonView) p);
|
|
221 |
.getFrame((SingletonWindow) p);
|
|
222 | 222 |
activateJInternalFrame(frame); |
223 | 223 |
vss.setActive(p); |
224 | 224 |
return fvs.getView((JInternalFrame) frame); |
... | ... | |
246 | 246 |
/** |
247 | 247 |
* Similar method as 'addView' but in this case centres the new JInternalFrame of the View in the contentPane of the MainFrame |
248 | 248 |
* |
249 |
* @see com.iver.core.mdiManager.NewSkin#addView(com.iver.andami.ui.mdiManager.IWindow)
|
|
249 |
* @see com.iver.core.mdiManager.NewSkin#addWindow(com.iver.andami.ui.mdiManager.IWindow)
|
|
250 | 250 |
* |
251 | 251 |
* @author Pablo Piqueras Bartolom? |
252 | 252 |
*/ |
253 |
public IWindow addCentredView(IWindow p) throws SingletonDialogAlreadyShownException {
|
|
253 |
public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException {
|
|
254 | 254 |
// se obtiene la informaci?n de la vista |
255 |
ViewInfo vi = vis.getViewInfo(p);
|
|
255 |
WindowInfo vi = vis.getViewInfo(p);
|
|
256 | 256 |
|
257 | 257 |
// Se comprueban las incompatibilidades que pudieran haber en la vista |
258 |
MDIUtilities.checkViewInfo(vi);
|
|
259 |
if ((p instanceof SingletonView) && (vi.isModal())) {
|
|
258 |
MDIUtilities.checkWindowInfo(vi);
|
|
259 |
if ((p instanceof SingletonWindow) && (vi.isModal())) {
|
|
260 | 260 |
throw new RuntimeException("A modal view cannot be a SingletonView"); |
261 | 261 |
} |
262 | 262 |
|
... | ... | |
266 | 266 |
*/ |
267 | 267 |
boolean singletonPreviouslyAdded = false; |
268 | 268 |
|
269 |
if (p instanceof SingletonView) {
|
|
270 |
SingletonView sv = (SingletonView) p;
|
|
271 |
if (svs.registerView(sv.getClass(), sv.getViewModel(), vis
|
|
269 |
if (p instanceof SingletonWindow) {
|
|
270 |
SingletonWindow sv = (SingletonWindow) p;
|
|
271 |
if (svs.registerView(sv.getClass(), sv.getWindowModel(), vis
|
|
272 | 272 |
.getViewInfo(sv))) { |
273 | 273 |
singletonPreviouslyAdded = true; |
274 | 274 |
} |
... | ... | |
276 | 276 |
|
277 | 277 |
if (singletonPreviouslyAdded) { |
278 | 278 |
// Si la vista no est? actualmente abierta |
279 |
if (!svs.contains((SingletonView) p)) {
|
|
279 |
if (!svs.contains((SingletonWindow) p)) {
|
|
280 | 280 |
JInternalFrame frame = fvs.getJInternalFrame(p); |
281 |
svs.openSingletonView((SingletonView) p, frame);
|
|
281 |
svs.openSingletonView((SingletonWindow) p, frame);
|
|
282 | 282 |
addJInternalFrame(frame, vi); |
283 | 283 |
vss.add(p, new ActionListener() { |
284 | 284 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
293 | 293 |
} else { |
294 | 294 |
// La vista est? actualmente abierta |
295 | 295 |
JInternalFrame frame = (JInternalFrame) svs |
296 |
.getFrame((SingletonView) p);
|
|
296 |
.getFrame((SingletonWindow) p);
|
|
297 | 297 |
activateJInternalFrame(frame); |
298 | 298 |
centreJInternalFrame(frame); // Centre this JInternalFrame |
299 | 299 |
vss.setActive(p); |
... | ... | |
379 | 379 |
* @param vi |
380 | 380 |
* DOCUMENT ME! |
381 | 381 |
*/ |
382 |
private void addJInternalFrame(JInternalFrame wnd, ViewInfo vi) {
|
|
382 |
private void addJInternalFrame(JInternalFrame wnd, WindowInfo vi) {
|
|
383 | 383 |
wnd.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); |
384 | 384 |
wnd.addInternalFrameListener(new FrameListener()); |
385 | 385 |
|
... | ... | |
400 | 400 |
* @param p |
401 | 401 |
*/ |
402 | 402 |
private void addJInternalFrame(IWindow p) { |
403 |
ViewInfo vi = vis.getViewInfo(p);
|
|
403 |
WindowInfo vi = vis.getViewInfo(p);
|
|
404 | 404 |
|
405 | 405 |
JInternalFrame wnd = fvs.getJInternalFrame(p); |
406 | 406 |
|
407 |
if (p instanceof SingletonView) {
|
|
408 |
SingletonView sv = (SingletonView) p;
|
|
407 |
if (p instanceof SingletonWindow) {
|
|
408 |
SingletonWindow sv = (SingletonWindow) p;
|
|
409 | 409 |
svs.openSingletonView(sv, wnd); |
410 | 410 |
} |
411 | 411 |
|
... | ... | |
460 | 460 |
} |
461 | 461 |
|
462 | 462 |
/** |
463 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getActiveView()
|
|
463 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getActiveWindow()
|
|
464 | 464 |
*/ |
465 |
public IWindow getActiveView() {
|
|
465 |
public IWindow getActiveWindow() {
|
|
466 | 466 |
JInternalFrame jif = panel.getSelectedFrame(); |
467 | 467 |
|
468 | 468 |
if (jif != null) { |
469 | 469 |
IWindow theView = fvs.getView(jif); |
470 | 470 |
if (theView == null) |
471 | 471 |
return null; |
472 |
if (theView.getViewInfo().isPalette())
|
|
472 |
if (theView.getWindowInfo().isPalette())
|
|
473 | 473 |
return vss.getActiveView(); |
474 | 474 |
else |
475 | 475 |
return fvs.getView(jif); |
... | ... | |
478 | 478 |
|
479 | 479 |
return null; |
480 | 480 |
} |
481 |
public IWindow getFocusView(){
|
|
481 |
public IWindow getFocusWindow(){
|
|
482 | 482 |
JInternalFrame jif = panel.getSelectedFrame(); |
483 | 483 |
|
484 | 484 |
if (jif != null) { |
... | ... | |
490 | 490 |
return null; |
491 | 491 |
} |
492 | 492 |
/** |
493 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeView(com.iver.andami.ui.mdiManager.IWindow)
|
|
493 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeWindow(com.iver.andami.ui.mdiManager.IWindow)
|
|
494 | 494 |
*/ |
495 |
public void closeView(IWindow p) {
|
|
495 |
public void closeWindow(IWindow p) {
|
|
496 | 496 |
// Si es un di?logo modal |
497 |
if (p.getViewInfo().isModal()) {
|
|
497 |
if (p.getWindowInfo().isModal()) {
|
|
498 | 498 |
closeJDialog(); |
499 | 499 |
} else { // Si no es modal se cierra el JInternalFrame |
500 | 500 |
closeJInternalFrame(fvs.getJInternalFrame(p)); |
... | ... | |
502 | 502 |
} |
503 | 503 |
|
504 | 504 |
/** |
505 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeAllViews()
|
|
505 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeAllWindows()
|
|
506 | 506 |
*/ |
507 |
public void closeAllViews() {
|
|
507 |
public void closeAllWindows() {
|
|
508 | 508 |
ArrayList eliminar = new ArrayList(); |
509 | 509 |
Iterator i = fvs.getViewIterator(); |
510 | 510 |
|
... | ... | |
514 | 514 |
|
515 | 515 |
for (Iterator iter = eliminar.iterator(); iter.hasNext();) { |
516 | 516 |
IWindow vista = (IWindow) iter.next(); |
517 |
closeView(vista);
|
|
517 |
closeWindow(vista);
|
|
518 | 518 |
} |
519 | 519 |
} |
520 | 520 |
|
521 | 521 |
/** |
522 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getViewInfo(com.iver.andami.ui.mdiManager.IWindow)
|
|
522 |
* @see com.iver.andami.ui.mdiManager.MDIManager#getWindowInfo(com.iver.andami.ui.mdiManager.IWindow)
|
|
523 | 523 |
*/ |
524 |
public ViewInfo getViewInfo(IWindow v) {
|
|
524 |
public WindowInfo getWindowInfo(IWindow v) {
|
|
525 | 525 |
//ViewInfo vi = new ViewInfo(); |
526 |
ViewInfo vi = vis.getViewInfo(v);
|
|
526 |
WindowInfo vi = vis.getViewInfo(v);
|
|
527 | 527 |
JInternalFrame f = fvs.getJInternalFrame(v); |
528 | 528 |
vi.setX(f.getX()); |
529 | 529 |
vi.setY(f.getY()); |
... | ... | |
555 | 555 |
fvs.closeView(s); |
556 | 556 |
|
557 | 557 |
// Si es singleton se desasocia el modelo con la vista |
558 |
if (s instanceof SingletonView) {
|
|
559 |
svs.closeView((SingletonView) s);
|
|
558 |
if (s instanceof SingletonWindow) {
|
|
559 |
svs.closeView((SingletonWindow) s);
|
|
560 | 560 |
} |
561 | 561 |
} |
562 | 562 |
|
... | ... | |
567 | 567 |
* DOCUMENT ME! |
568 | 568 |
*/ |
569 | 569 |
private void callViewClosed(IWindow view) { |
570 |
if (view instanceof ViewListener) {
|
|
571 |
((ViewListener) view).viewClosed();
|
|
570 |
if (view instanceof IWindowListener) {
|
|
571 |
((IWindowListener) view).windowClosed();
|
|
572 | 572 |
} |
573 | 573 |
} |
574 | 574 |
|
... | ... | |
579 | 579 |
* DOCUMENT ME! |
580 | 580 |
*/ |
581 | 581 |
private void callViewActivated(IWindow view) { |
582 |
logger.debug("View " + view.getViewInfo().getTitle()
|
|
582 |
logger.debug("View " + view.getWindowInfo().getTitle()
|
|
583 | 583 |
+ " activated (callViewActivated)"); |
584 |
if (view instanceof ViewListener) {
|
|
585 |
((ViewListener) view).viewActivated();
|
|
584 |
if (view instanceof IWindowListener) {
|
|
585 |
((IWindowListener) view).windowActivated();
|
|
586 | 586 |
} |
587 | 587 |
} |
588 | 588 |
|
... | ... | |
693 | 693 |
|
694 | 694 |
IWindow panel = fvs.getView((JInternalFrame) e.getSource()); |
695 | 695 |
|
696 |
ViewInfo vi = vis.getViewInfo(panel);
|
|
696 |
WindowInfo vi = vis.getViewInfo(panel);
|
|
697 | 697 |
if (vi.isPalette()) |
698 | 698 |
return; |
699 | 699 |
|
... | ... | |
729 | 729 |
// e.getInternalFrame().getTitle()); |
730 | 730 |
|
731 | 731 |
JInternalFrame c = (JInternalFrame) e.getSource(); |
732 |
ViewInfo vi = vis.getViewInfo((IWindow) fvs.getView(c));
|
|
732 |
WindowInfo vi = vis.getViewInfo((IWindow) fvs.getView(c));
|
|
733 | 733 |
|
734 | 734 |
IWindow view = fvs.getView(c); |
735 | 735 |
callViewClosed(view); |
736 | 736 |
boolean alwaysLive; |
737 |
if (view instanceof SingletonView) {
|
|
738 |
svs.closeView((SingletonView) view);
|
|
737 |
if (view instanceof SingletonWindow) {
|
|
738 |
svs.closeView((SingletonWindow) view);
|
|
739 | 739 |
} |
740 | 740 |
|
741 | 741 |
fvs.closeView(view); |
... | ... | |
754 | 754 |
// La activamos |
755 | 755 |
if (lastView != null) { |
756 | 756 |
System.err.println("Devuelvo el foco a " |
757 |
+ lastView.getViewInfo().getTitle());
|
|
757 |
+ lastView.getWindowInfo().getTitle());
|
|
758 | 758 |
JInternalFrame frame = fvs.getJInternalFrame(lastView); |
759 | 759 |
try { |
760 | 760 |
frame.setSelected(true); |
... | ... | |
776 | 776 |
JInternalFrame c = (JInternalFrame) e.getSource(); |
777 | 777 |
IWindow andamiView = fvs.getView(c); |
778 | 778 |
if (andamiView != null) { |
779 |
ViewInfo vi = vis.getViewInfo(andamiView);
|
|
779 |
WindowInfo vi = vis.getViewInfo(andamiView);
|
|
780 | 780 |
if (vi.isPalette()) |
781 | 781 |
return; |
782 | 782 |
vi.setSelectedTool(mainFrame.getSelectedTool()); |
... | ... | |
808 | 808 |
} |
809 | 809 |
|
810 | 810 |
/** |
811 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonView(java.lang.Class,
|
|
811 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonWindow(java.lang.Class,
|
|
812 | 812 |
* java.lang.Object) |
813 | 813 |
*/ |
814 |
public boolean closeSingletonView(Class viewClass, Object model) {
|
|
814 |
public boolean closeSingletonWindow(Class viewClass, Object model) {
|
|
815 | 815 |
JInternalFrame frame = svs.getFrame(viewClass, model); |
816 | 816 |
if (frame == null) |
817 | 817 |
return false; |
... | ... | |
820 | 820 |
} |
821 | 821 |
|
822 | 822 |
/** |
823 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonView(java.lang.Object)
|
|
823 |
* @see com.iver.andami.ui.mdiManager.MDIManager#closeSingletonWindow(java.lang.Object)
|
|
824 | 824 |
*/ |
825 |
public boolean closeSingletonView(Object model) {
|
|
825 |
public boolean closeSingletonWindow(Object model) {
|
|
826 | 826 |
JInternalFrame[] frames = svs.getFrames(model); |
827 | 827 |
if (frames.length == 0) |
828 | 828 |
return false; |
... | ... | |
832 | 832 |
return true; |
833 | 833 |
} |
834 | 834 |
|
835 |
public IWindow[] getAllViews() {
|
|
835 |
public IWindow[] getAllWindows() {
|
|
836 | 836 |
ArrayList views = new ArrayList(); |
837 | 837 |
Iterator i = fvs.getViewIterator(); |
838 | 838 |
|
... | ... | |
848 | 848 |
f.setMaximum(bMaximum); |
849 | 849 |
} |
850 | 850 |
|
851 |
public void changeViewInfo(IWindow v, ViewInfo vi){
|
|
851 |
public void changeWindowInfo(IWindow v, WindowInfo vi){
|
|
852 | 852 |
JInternalFrame f = fvs.getJInternalFrame(v); |
853 | 853 |
f.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); |
854 | 854 |
JDesktopPane pnl = f.getDesktopPane(); |
... | ... | |
862 | 862 |
pnl.add(f, JDesktopPane.DEFAULT_LAYER); |
863 | 863 |
f.setFocusable(true); |
864 | 864 |
if (vi.isClosed()) { |
865 |
closeView(v);
|
|
865 |
closeWindow(v);
|
|
866 | 866 |
} |
867 | 867 |
} |
868 | 868 |
|
Also available in: Unified diff