private void setClosingBehaviour(final LayerManagerProxy internalFrame) { final JInternalFrame i = (JInternalFrame) internalFrame; i.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); i.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { if (1 == getInternalFramesAssociatedWith((LayerManager) internalFrame.getLayerManager()) .size()) { if (confirmClose( "Close Task", internalFrame.getLayerManager().getLayersWithModifiedFeatureCollections())) { GUIUtil.dispose(i, desktopPane); internalFrame.getLayerManager().dispose(); } } else { GUIUtil.dispose(i, desktopPane); } } }); }
// REVISAR: No parece necesario evitar el JInternalFrame // public void addInternalFrame(final TaskComponent internalFrame, public void addInternalFrame( final JInternalFrame internalFrame, boolean alwaysOnTop, boolean autoUpdateToolBar) { if (internalFrame instanceof LayerManagerProxy) { setClosingBehaviour((LayerManagerProxy) internalFrame); installTitleBarModifiedIndicator((LayerManagerProxy) internalFrame); } // <<TODO:IMPROVE>> Listen for when the frame closes, and when it does, // activate the topmost frame. Because Swing does not seem to do this // automatically. [Jon Aquino] internalFrame.setFrameIcon(icon); // Call JInternalFrame#setVisible before JDesktopPane#add; otherwise, // the // TreeLayerNamePanel starts too narrow (100 pixels or so) for some // reason. // <<TODO>>Investigate. [Jon Aquino] internalFrame.setVisible(true); desktopPane.add( (Component) internalFrame, alwaysOnTop ? JLayeredPane.PALETTE_LAYER : JLayeredPane.DEFAULT_LAYER); if (autoUpdateToolBar) { internalFrame.addInternalFrameListener( new InternalFrameListener() { public void internalFrameActivated(InternalFrameEvent e) { toolBar.updateEnabledState(); // Associate current cursortool with the new frame [Jon // Aquino] toolBar.reClickSelectedCursorToolButton(); } public void internalFrameClosed(InternalFrameEvent e) { toolBar.updateEnabledState(); } public void internalFrameClosing(InternalFrameEvent e) { toolBar.updateEnabledState(); } public void internalFrameDeactivated(InternalFrameEvent e) { toolBar.updateEnabledState(); } public void internalFrameDeiconified(InternalFrameEvent e) { toolBar.updateEnabledState(); } public void internalFrameIconified(InternalFrameEvent e) { toolBar.updateEnabledState(); } public void internalFrameOpened(InternalFrameEvent e) { toolBar.updateEnabledState(); } }); // Call #activateFrame *after* adding the listener. [Jon Aquino] activateFrame(internalFrame); position(internalFrame); } }