[Mc4j-cvs] mc4j/src/org/mc4j/console/connection ConnectionNode.java,1.26,1.27 DisconnectAction.java,
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2004-04-08 21:50:20
|
Update of /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18400/src/org/mc4j/console/connection Modified Files: ConnectionNode.java DisconnectAction.java Log Message: Track dashboards as they are opened on a connection. When were disconnecting a connection, first ask if they really want to close the dashboards, and if they agree close all dashboards open for that connection. Index: ConnectionNode.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/ConnectionNode.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ConnectionNode.java 7 Apr 2004 15:27:35 -0000 1.26 --- ConnectionNode.java 8 Apr 2004 21:37:08 -0000 1.27 *************** *** 40,43 **** --- 40,44 ---- import javax.management.ObjectInstance; import javax.management.ObjectName; + import javax.swing.SwingUtilities; import org.openide.ErrorManager; *************** *** 54,57 **** --- 55,59 ---- import org.openide.util.actions.SystemAction; import org.openide.windows.IOProvider; + import org.openide.windows.TopComponent; import org.mc4j.console.IConnectionNode; *************** *** 93,96 **** --- 95,99 ---- private PooledExecutor remoteExecutor; + private Set openDashboards = new HashSet(); public ConnectionNode() { *************** *** 398,401 **** --- 401,418 ---- public void disconnect() throws Exception { + + if (!openDashboards.isEmpty()) { + for (Iterator iterator = openDashboards.iterator(); iterator.hasNext();) { + final TopComponent topComponent = (TopComponent) iterator.next(); + if (topComponent.isOpened()) { + SwingUtilities.invokeLater( new Runnable() { + public void run() { + topComponent.close(); + } + }); + } + } + } + if (this.refreshTimer != null) this.refreshTimer.cancel(); *************** *** 410,413 **** --- 427,431 ---- super.systemActions = null; super.getContextMenu(); + this.openDashboards.clear(); } *************** *** 518,521 **** --- 536,545 ---- } + public void registerDashboard(TopComponent dashboard) { + this.openDashboards.add(dashboard); + } + public boolean isOpenedDashboards() { + return !this.openDashboards.isEmpty(); + } } Index: DisconnectAction.java =================================================================== RCS file: /cvsroot/mc4j/mc4j/src/org/mc4j/console/connection/DisconnectAction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DisconnectAction.java 7 Feb 2004 16:10:41 -0000 1.5 --- DisconnectAction.java 8 Apr 2004 21:37:08 -0000 1.6 *************** *** 20,24 **** --- 20,28 ---- package org.mc4j.console.connection; + import javax.swing.JOptionPane; + + import org.openide.DialogDisplayer; import org.openide.ErrorManager; + import org.openide.NotifyDescriptor; import org.openide.nodes.Node; import org.openide.util.HelpCtx; *************** *** 35,38 **** --- 39,54 ---- ConnectionNode node = (ConnectionNode)nodes[0]; try { + if (node.isOpenedDashboards()) { + NotifyDescriptor d = + new NotifyDescriptor.Confirmation( + "There are opened dashboards associated with this connection. Disconnecting " + + "will cause these dashboards to close. Are you sure you want to " + + "disconnect?", JOptionPane.YES_NO_OPTION); + Object answer = DialogDisplayer.getDefault().notify(d); + if (((Integer)answer).intValue() != 0) { + return; + } + } + node.disconnect(); } catch (Exception e) { |