1 19 package org.openharmonise.him.actions.sync; 20 21 import java.awt.event.*; 22 23 import javax.swing.*; 24 25 import org.openharmonise.him.actions.*; 26 import org.openharmonise.him.actions.rules.*; 27 import org.openharmonise.him.context.StateHandler; 28 import org.openharmonise.him.files.*; 29 import org.openharmonise.him.window.session.*; 30 import org.openharmonise.vfs.*; 31 import org.openharmonise.vfs.context.*; 32 import org.openharmonise.vfs.gui.*; 33 34 35 43 public class ActionSynchronize extends AbstractHIMAction implements HIMAction { 44 45 public static String ACTION_NAME = "SYNC_FILE"; 46 47 50 private static final String WAIT_LABEL = "SYNC-ACTION"; 51 52 55 private SessionWindow m_session = null; 56 57 60 public ActionSynchronize(SessionWindow session) { 61 super(); 62 this.m_session = session; 63 this.setup(); 64 } 65 66 69 public ActionSynchronize(VirtualFile vfFile) { 70 super(vfFile); 71 this.setup(); 72 } 73 74 78 private void setup() { 79 RuleGroup andGroup = new RuleGroup(); 80 SecurityRule secRule = new SecurityRule(VirtualFile.METHOD_SYNC); 81 andGroup.addEnableRule(null); 82 IsLockedByOtherUser lockRule = new IsLockedByOtherUser(); 83 lockRule.setResultComparator(false); 84 andGroup.addEnableRule(lockRule); 85 super.addEnableRule(andGroup); 86 } 87 88 91 public void actionPerformed(ActionEvent arg0) { 92 StateHandler.getInstance().addWait(WAIT_LABEL); 93 String sFileName = null; 94 try { 95 FilesSynchroniser filesSyncer = new FilesSynchroniser(); 96 97 VirtualFile vfFile = this.m_session.getSelectedEntry().getVFS().getVirtualFile(this.m_session.getSelectedEntry().getPath()).getResource(); 98 filesSyncer.syncFile(vfFile); 99 } catch (Exception e) { 100 e.printStackTrace(); 101 } finally { 102 StateHandler.getInstance().removeWait(WAIT_LABEL); 103 } 104 } 105 106 109 public String getText() { 110 return "Submit Resource"; 111 } 112 113 116 public String getToolTip() { 117 return this.getDescription(); 118 } 119 120 123 public Icon getIcon() { 124 return IconManager.getInstance().getIcon("16-command-sync-all.gif"); 125 } 126 127 130 public String getMnemonic() { 131 return "S"; 132 } 133 134 137 public String getDescription() { 138 return "Submits the currently selected resource"; 139 } 140 141 144 public int getAcceleratorKeycode() { 145 return 0; 146 } 147 148 151 public int getAcceleratorMask() { 152 return 0; 153 } 154 155 } 156 | Popular Tags |