1 19 package org.openharmonise.him.serverconfig; 20 21 import java.awt.event.*; 22 import java.util.*; 23 24 import org.openharmonise.commons.xml.namespace.*; 25 import org.openharmonise.him.*; 26 import org.openharmonise.him.editors.report.swing.*; 27 import org.openharmonise.vfs.*; 28 import org.openharmonise.vfs.metadata.*; 29 import org.openharmonise.vfs.metadata.range.*; 30 import org.openharmonise.vfs.metadata.value.*; 31 import org.openharmonise.vfs.servers.ServerList; 32 import org.openharmonise.webdav.client.value.*; 33 34 35 41 public class RelatedResourceDisplay extends JComboTree { 42 43 private PropertyInstance m_prop = null; 44 private HashMap m_changedValues = null; 45 private PropertyInstance m_propInst = null; 46 private static final String COMMAND_CHANGE = "CHANGE"; 47 private AbstractPreviewConfigOptions m_options = null; 48 51 public RelatedResourceDisplay(AbstractPreviewConfigOptions options) { 52 super(); 53 m_options = options; 54 m_changedValues = new HashMap(); 55 this.setActionCommand(COMMAND_CHANGE); 56 this.addActionListener(this); 57 } 58 public void actionPerformed(ActionEvent ae) { 59 60 if(ae.getActionCommand().equals(COMMAND_CHANGE)) { 61 String valPath = getPath(); 62 String sPath = m_propInst.getVirtualFile().getFullPath(); 63 this.m_changedValues.put(sPath,valPath); 64 m_options.fireChangesMade(); 65 } else { 66 super.actionPerformed(ae); 67 } 68 } 69 public void populate(PropertyInstance propInst){ 70 AbstractVirtualFileSystem vfs = propInst.getVirtualFile().getVFS(); 71 m_propInst = propInst; 72 VirtualFile vFile = propInst.getVirtualFile(); 73 String path = vFile.getFullPath(); 74 if(m_changedValues!= null && m_changedValues.containsKey(path)){ 75 String pagePath = (String )m_changedValues.get(path); 76 this.setPath(vfs,pagePath); 77 } else { 78 Property prop = propInst.getDefinition(); 79 80 ResourceRange propRange = 81 (ResourceRange) 82 prop 83 .getRange(); 84 List aHREFs = propRange.getHREFs(); 85 86 Iterator itor = aHREFs.iterator(); 87 String sGroupPath = null; 88 while (itor.hasNext()) { 89 sGroupPath = (String ) itor.next(); 90 this.addCollectionPath(sGroupPath); 91 Iterator iter = propInst.getValues().iterator(); 92 String sPath = null; 93 if(iter.hasNext()){ 94 ResourceValue val = (ResourceValue)iter.next(); 95 sPath = val.getValue(); 96 } 97 if(sPath!=null){ 98 this.setPath(vfs,sPath); 99 } else { 100 this.m_value.setText(""); 101 } 102 } 103 } 104 } 105 public void saveChangedValues(){ 106 Iterator itor = m_changedValues.keySet().iterator(); 107 String pagePath = null; 108 String valPath = null; 109 AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS(); 110 while (itor.hasNext()) { 111 pagePath = (String )itor.next(); 112 valPath = (String )m_changedValues.get(pagePath); 113 VirtualFile vFile = vfs.getVirtualFile(pagePath).getResource(); 114 PropertyInstance propInst = vFile.getProperty(NamespaceType.OHRM.getURI(),"PREVIEWPAGE"); 115 DAVResourceValue val = new DAVResourceValue(); 116 val.setValue(valPath); 117 propInst.setValue(val); 118 vFile.sync(); 119 } 120 } 121 122 public static void main(String [] args) { 123 } 124 } 125 | Popular Tags |