1 19 package org.openharmonise.him.actions.system; 20 21 import java.awt.event.ActionEvent ; 22 import java.awt.event.InputEvent ; 23 import java.awt.event.KeyEvent ; 24 import java.util.Iterator ; 25 26 import javax.swing.Icon ; 27 import javax.swing.JMenuItem ; 28 import javax.swing.KeyStroke ; 29 30 import org.openharmonise.him.*; 31 import org.openharmonise.him.actions.*; 32 import org.openharmonise.him.context.StateHandler; 33 import org.openharmonise.him.window.messages.*; 34 import org.openharmonise.vfs.*; 35 import org.openharmonise.vfs.context.*; 36 import org.openharmonise.vfs.gui.*; 37 import org.openharmonise.vfs.servers.*; 38 39 40 47 public class ActionSyncWithServer 48 extends AbstractHIMAction 49 implements HIMAction { 50 51 public static String ACTION_NAME = "SYNC_ALL"; 52 53 56 private static final String WAIT_LABEL = "SYNC-ACTION"; 57 58 61 public ActionSyncWithServer() { 62 super(); 63 } 64 65 68 public ActionSyncWithServer(VirtualFile vfFile) { 69 super(vfFile); 70 } 71 72 75 public void actionPerformed(ActionEvent arg0) { 76 StateHandler.getInstance().addWait(WAIT_LABEL); 77 try { 78 Iterator itor = ServerList.getInstance().getServers().iterator(); 79 while (itor.hasNext()) { 80 Server element = (Server) itor.next(); 81 if(element.getVFS().synchroniseAllFiles().isOK()) { 82 MessageHandler.getInstance().fireMessageEvent("You have successfully submitted with the server, see the Session window for a list of submitted resources.", MessageHandler.TYPE_CONFIRM); 83 } else { 84 MessageHandler.getInstance().fireMessageEvent("There was a problem submitting to the server.", MessageHandler.TYPE_ERROR); 85 } 86 } 87 } catch (Exception e) { 88 e.printStackTrace(System.err); 89 MessageHandler.getInstance().fireMessageEvent("There was a problem submitting with to server.", MessageHandler.TYPE_ERROR); 90 } finally { 91 StateHandler.getInstance().removeWait(WAIT_LABEL); 92 } 93 } 94 95 98 public JMenuItem getMenuItem() { 99 JMenuItem menuItem = super.getMenuItem(); 100 menuItem.setAccelerator( KeyStroke.getKeyStroke(this.getAcceleratorKeycode(), this.getAcceleratorMask()) ); 101 102 return menuItem; 103 } 104 105 108 public String getDescription() { 109 return "Submits all, uncommited, changes with the server"; 110 } 111 112 115 public String getText() { 116 return "Submit all changes"; 117 } 118 119 122 public String getToolTip() { 123 return this.getDescription(); 124 } 125 126 129 public Icon getIcon() { 130 return IconManager.getInstance().getIcon("16-command-sync-all.gif"); 131 } 132 133 136 public int getAcceleratorKeycode() { 137 return KeyEvent.VK_S; 138 } 139 140 143 public String getMnemonic() { 144 return "S"; 145 } 146 147 150 public int getAcceleratorMask() { 151 return InputEvent.CTRL_MASK; 152 } 153 154 } 155 | Popular Tags |