diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-12-05 21:41:56 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-12-05 21:41:56 +0000 |
commit | 32ce352f077d3be34105d4645bfd8ddc4572c45c (patch) | |
tree | 5854cc9d4bcdaf4c479eb85aa21d9e4656458e65 /java/src/IceGridGUI | |
parent | Fixed compile errors (diff) | |
download | ice-32ce352f077d3be34105d4645bfd8ddc4572c45c.tar.bz2 ice-32ce352f077d3be34105d4645bfd8ddc4572c45c.tar.xz ice-32ce352f077d3be34105d4645bfd8ddc4572c45c.zip |
Fix for bug #1574
Diffstat (limited to 'java/src/IceGridGUI')
-rwxr-xr-x | java/src/IceGridGUI/Application/ApplicationEditor.java | 14 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/Root.java | 285 | ||||
-rwxr-xr-x | java/src/IceGridGUI/ApplicationPane.java | 17 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Coordinator.java | 119 |
4 files changed, 345 insertions, 90 deletions
diff --git a/java/src/IceGridGUI/Application/ApplicationEditor.java b/java/src/IceGridGUI/Application/ApplicationEditor.java index bb3b006f5a0..4a28607e2c6 100755 --- a/java/src/IceGridGUI/Application/ApplicationEditor.java +++ b/java/src/IceGridGUI/Application/ApplicationEditor.java @@ -202,7 +202,7 @@ class ApplicationEditor extends Editor (ApplicationDescriptor)root.getDescriptor(); _name.setText(descriptor.name); - _name.setEditable(!root.isLive()); + _name.setEditable(!root.isLive() && isEditable); _description.setText( Utils.substitute(descriptor.description, resolver)); @@ -235,6 +235,18 @@ class ApplicationEditor extends Editor detectUpdates(true); } + Utils.Resolver getDetailResolver() + { + if(_target.getCoordinator().substitute()) + { + return _target.getResolver(); + } + else + { + return null; + } + } + static private final Object NO_DISTRIB = new Object() { public String toString() diff --git a/java/src/IceGridGUI/Application/Root.java b/java/src/IceGridGUI/Application/Root.java index 7aec1d77fbc..9c7453fdc8d 100755 --- a/java/src/IceGridGUI/Application/Root.java +++ b/java/src/IceGridGUI/Application/Root.java @@ -14,6 +14,7 @@ import java.awt.Cursor; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTree; +import javax.swing.SwingUtilities; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; @@ -385,9 +386,38 @@ public class Root extends ListTreeNode // Runnable runnable = new Runnable() { + private void release() + { + _coordinator.releaseExclusiveWriteAccess(); + _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + private void handleFailure(String prefix, String title, String message) + { + release(); + + if(isSelected()) + { + _coordinator.getSaveAction().setEnabled(isLive() && _coordinator.connectedToMaster() || hasFile()); + _coordinator.getSaveToRegistryAction().setEnabled(true); + _coordinator.getDiscardUpdatesAction().setEnabled(true); + } + + _coordinator.getStatusBar().setText(prefix + "failed!"); + + JOptionPane.showMessageDialog( + _coordinator.getMainFrame(), + message, + title, + JOptionPane.ERROR_MESSAGE); + } + + public void run() { _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + boolean asyncRelease = false; + try { if(_live && _canUseUpdateDescriptor) @@ -395,10 +425,68 @@ public class Root extends ListTreeNode ApplicationUpdateDescriptor updateDescriptor = createUpdateDescriptor(); if(updateDescriptor != null) { - _coordinator.getAdmin().updateApplication(updateDescriptor); - commit(); + final String prefix = "Updating application '" + _id + "'..."; + _coordinator.getStatusBar().setText(prefix); + + AMI_Admin_updateApplication cb = new AMI_Admin_updateApplication() + { + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + commit(); + release(); + _coordinator.getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _skipUpdates--; + handleFailure(prefix, "Update failed", + "IceGrid exception: " + e.toString()); + } + + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _skipUpdates--; + handleFailure(prefix, "Update failed", + "Communication exception: " + e.toString()); + } + }); + } + + }; + + _coordinator.getAdmin().updateApplication_async(cb, updateDescriptor); + asyncRelease = true; + + // + // If updateApplication fails, we know we can't get other updates + // since we have exclusive write access + // _skipUpdates++; } + else + { + final String prefix = "Application '" + _id + "' is already up-to-date"; + _coordinator.getStatusBar().setText(prefix); + commit(); + } } else { @@ -408,41 +496,142 @@ public class Root extends ListTreeNode if(_coordinator.getLiveDeploymentRoot().getApplicationDescriptor(_id) == null) { assert _live == false; - _coordinator.getAdmin().addApplication(_descriptor); - commit(); - liveReset(); - _coordinator.addLiveApplication(Root.this); + + + final String prefix = "Adding application '" + _id + "'..."; + _coordinator.getStatusBar().setText(prefix); + + AMI_Admin_addApplication cb = new AMI_Admin_addApplication() + { + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + commit(); + liveReset(); + _coordinator.addLiveApplication(Root.this); + release(); + _coordinator.getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure(prefix, "Add failed", + "IceGrid exception: " + e.toString()); + } + + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure(prefix, "Add failed", + "Communication exception: " + e.toString()); + } + }); + } + + }; + + _coordinator.getAdmin().addApplication_async(cb, _descriptor); + asyncRelease = true; } else { - _coordinator.getAdmin().syncApplication(_descriptor); - commit(); + final String prefix = "Synchronizing application '" + _id + "'..."; + _coordinator.getStatusBar().setText(prefix); - if(_live) - { - liveReset(); - _skipUpdates++; - } - else - { - // - // Make this tab live or close it if there is one already open - // - ApplicationPane app = _coordinator.getLiveApplication(_id); - if(app == null) - { - liveReset(); - _coordinator.addLiveApplication(Root.this); - } - else + AMI_Admin_syncApplication cb = new AMI_Admin_syncApplication() { - boolean selected = isSelected(); - _coordinator.getMainPane().removeApplication(Root.this); - if(selected) + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + commit(); + if(!_live) + { + // + // Make this tab live or close it if there is one already open + // + ApplicationPane app = _coordinator.getLiveApplication(_id); + if(app == null) + { + liveReset(); + _coordinator.addLiveApplication(Root.this); + } + else + { + boolean selected = isSelected(); + _coordinator.getMainPane().removeApplication(Root.this); + if(selected) + { + _coordinator.getMainPane().setSelectedComponent(app); + } + } + } + + release(); + _coordinator.getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) { - _coordinator.getMainPane().setSelectedComponent(app); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(_live) + { + _skipUpdates--; + } + + handleFailure(prefix, "Sync failed", + "IceGrid exception: " + e.toString()); + } + + }); } - } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(_live) + { + _skipUpdates--; + } + + handleFailure(prefix, "Sync failed", + "Communication exception: " + e.toString()); + } + }); + } + + }; + + _coordinator.getAdmin().syncApplication_async(cb, _descriptor); + asyncRelease = true; + if(_live) + { + _skipUpdates++; } } } @@ -453,32 +642,6 @@ public class Root extends ListTreeNode _coordinator.getDiscardUpdatesAction().setEnabled(false); } } - catch(DeploymentException e) - { - JOptionPane.showMessageDialog( - _coordinator.getMainFrame(), - "Application '" + _id + "': "+ e.reason, - "Deployment Exception", - JOptionPane.ERROR_MESSAGE); - } - catch(ApplicationNotExistException e) - { - // - // Should never happen - // - JOptionPane.showMessageDialog( - _coordinator.getMainFrame(), - "Application '" + _id + "' was not found in the IceGrid registry", - "Deployment Exception", - JOptionPane.ERROR_MESSAGE); - } - catch(AccessDeniedException e) - { - // - // Should never happen - // - _coordinator.accessDenied(e); - } catch(Ice.LocalException e) { JOptionPane.showMessageDialog( @@ -489,8 +652,11 @@ public class Root extends ListTreeNode } finally { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - _coordinator.releaseExclusiveWriteAccess(); + if(!asyncRelease) + { + _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + _coordinator.releaseExclusiveWriteAccess(); + } } } }; @@ -573,6 +739,7 @@ public class Root extends ListTreeNode private void liveReset() { _live = true; + _skipUpdates = 0; _file = null; _coordinator.getMainPane().resetIcon(this); } @@ -937,7 +1104,7 @@ public class Root extends ListTreeNode _coordinator.getSaveAction().setEnabled(false); _coordinator.getDiscardUpdatesAction().setEnabled(false); - _coordinator.getSaveToRegistryAction().setEnabled(false); + _coordinator.getSaveToRegistryAction().setEnabled(hasFile()); } } diff --git a/java/src/IceGridGUI/ApplicationPane.java b/java/src/IceGridGUI/ApplicationPane.java index 6827accb31e..bb57e18c2d1 100755 --- a/java/src/IceGridGUI/ApplicationPane.java +++ b/java/src/IceGridGUI/ApplicationPane.java @@ -71,10 +71,13 @@ public class ApplicationPane extends JSplitPane implements Tab public void refresh() { - _root.cancelEdit(); - if(_currentNode != null) { + if(_currentEditor != null) + { + _currentEditor.save(true); + } + _currentEditor = _currentNode.getEditor(); if(_root.getCoordinator().getCurrentTab() == this) { @@ -123,7 +126,14 @@ public class ApplicationPane extends JSplitPane implements Tab } else { - refresh(); + _currentEditor = _currentNode.getEditor(); + if(_root.getCoordinator().getCurrentTab() == this) + { + // + // Refresh actions as well + // + _root.getCoordinator().showActions(_currentNode); + } } } @@ -326,7 +336,6 @@ public class ApplicationPane extends JSplitPane implements Tab private void showCurrentNode() { - _root.cancelEdit(); _root.getCoordinator().showActions(_currentNode); if(_currentNode == null) diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index 1ea813f88b1..73b272b502a 100755 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -722,7 +722,7 @@ public class Coordinator void adapterInit(AdapterInfo[] adapters) { _liveDeploymentRoot.adapterInit(adapters); - // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()? + _liveDeploymentPane.refresh(); } void adapterAdded(AdapterInfo info) @@ -793,33 +793,108 @@ public class Coordinator root.setSelectedNode(root); } - public void removeApplicationFromRegistry(String name) + public void removeApplicationFromRegistry(final String name) { _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - boolean acquired = false; try { - acquireExclusiveWriteAccess(null); - acquired = true; - _sessionKeeper.getAdmin().removeApplication(name); + Runnable runnable = new Runnable() + { + private void release() + { + releaseExclusiveWriteAccess(); + getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + private void handleFailure(String prefix, String title, String message) + { + release(); + getStatusBar().setText(prefix + "failed!"); + + JOptionPane.showMessageDialog( + getMainFrame(), + message, + title, + JOptionPane.ERROR_MESSAGE); + } + + public void run() + { + getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + boolean asyncRelease = false; + + + final String prefix = "Deleting application '" + name + "'..."; + AMI_Admin_removeApplication cb = new AMI_Admin_removeApplication() + { + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + release(); + getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure(prefix, "Delete failed", + "IceGrid exception: " + e.toString()); + } + + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure(prefix, "Delete failed", + "Communication exception: " + e.toString()); + } + }); + } + }; + + try + { + _sessionKeeper.getAdmin().removeApplication_async(cb, name); + } + catch(Ice.LocalException e) + { + JOptionPane.showMessageDialog( + getMainFrame(), + e.toString(), + "Communication Exception", + JOptionPane.ERROR_MESSAGE); + } + finally + { + if(!asyncRelease) + { + releaseExclusiveWriteAccess(); + getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } + } + }; + + acquireExclusiveWriteAccess(runnable); } catch(AccessDeniedException e) { accessDenied(e); } - catch(DeploymentException e) - { - // - // TODO: XXX: The application couldn't be removed (probably because we tried to remove it from a slave). - // - } - catch(ApplicationNotExistException e) - { - // - // Somebody else deleted this application at about the same time - // - } catch(Ice.LocalException e) { JOptionPane.showMessageDialog( @@ -829,14 +904,6 @@ public class Coordinator "Trouble with IceGrid registry", JOptionPane.ERROR_MESSAGE); } - finally - { - if(acquired) - { - releaseExclusiveWriteAccess(); - } - _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } } public void acquireExclusiveWriteAccess(Runnable runnable) |