1 19 package org.openharmonise.him.window.session; 20 21 import java.awt.Color ; 22 import java.awt.Component ; 23 import java.awt.Container ; 24 import java.awt.Dimension ; 25 import java.awt.LayoutManager ; 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 29 import javax.swing.JPanel ; 30 31 import org.openharmonise.vfs.*; 32 33 34 40 public class SessionInformation extends JPanel implements LayoutManager { 41 42 ArrayList m_aSessionEntries = new ArrayList (); 43 44 int m_nHeight = 0; 45 int m_nWidth = 200; 46 47 int m_nCount = 0; 48 49 52 public SessionInformation() { 53 super(); 54 this.setup(); 55 } 56 57 private void setup() { 58 this.setLayout(this); 59 this.setBackground(Color.WHITE); 60 61 this.setPreferredSize(new Dimension (200,200)); 62 } 63 64 protected void addEntry(VirtualFile vfFile, String sReason) { 65 boolean bFound=false; 66 for(int i=0; i<this.getComponentCount(); i++) { 67 SessionEntry entry = (SessionEntry) this.getComponent(i); 68 if(entry!=null && entry.getPath()!=null && entry.getVFS()!=null && vfFile!=null && vfFile.getFullPath()!=null&& vfFile.getVFS()!=null) { 69 if(entry.getReason().equals(sReason) && entry.getPath().equals(vfFile.getFullPath()) && entry.getVFS()==vfFile.getVFS()) { 70 bFound=true; 71 break; 72 } 73 } 74 } 75 if(!bFound) { 76 SessionEntry entry = new SessionEntry(this, vfFile, sReason); 77 this.add( entry ); 78 m_aSessionEntries.add( entry ); 79 } 80 } 81 82 protected void entrySelected(SessionEntry entry) { 83 for(int i=0; i<this.getComponentCount(); i++) { 84 SessionEntry currentEntry = (SessionEntry) this.getComponent(i); 85 if(currentEntry!=entry) { 86 currentEntry.deselectEntry(); 87 } 88 } 89 SessionWindow.getInstance().entrySelected(entry); 90 } 91 92 protected SessionEntry getSelectedEntry() { 93 SessionEntry retn = null; 94 for(int i=0; i<this.getComponentCount(); i++) { 95 SessionEntry currentEntry = (SessionEntry) this.getComponent(i); 96 if(currentEntry.isSelected()) { 97 retn = currentEntry; 98 break; 99 } 100 } 101 return retn; 102 } 103 104 107 public void removeLayoutComponent(Component arg0) { 108 } 110 111 114 public void layoutContainer(Container arg0) { 115 int nHeight = 0; 116 int nWidth = this.getParent().getParent().getWidth()-20; 117 Iterator itor = this.m_aSessionEntries.iterator(); 118 while(itor.hasNext()) { 119 SessionEntry entry = (SessionEntry)itor.next(); 120 entry.setSize(this.m_nWidth, 20); 121 entry.setLocation(0, nHeight); 122 nHeight = nHeight+20; 123 } 124 125 if(nHeight!=m_nHeight || nWidth!=m_nWidth) { 126 this.m_nHeight = nHeight; 127 this.m_nWidth = nWidth; 128 this.setPreferredSize(new Dimension (this.m_nWidth, this.m_nHeight)); 129 } 130 } 131 132 135 public void addLayoutComponent(String arg0, Component arg1) { 136 } 138 139 142 public Dimension minimumLayoutSize(Container arg0) { 143 return null; 144 } 145 146 149 public Dimension preferredLayoutSize(Container arg0) { 150 return null; 151 } 152 153 156 private SessionInformation(boolean arg0) { 157 super(arg0); 158 } 159 160 163 private SessionInformation(LayoutManager arg0) { 164 super(arg0); 165 } 166 167 171 private SessionInformation(LayoutManager arg0, boolean arg1) { 172 super(arg0, arg1); 173 } 174 175 178 public void removeEntry(SessionEntry entry) { 179 if(entry!=null) { 180 this.remove(entry); 181 this.m_aSessionEntries.remove(entry); 182 this.validate(); 183 this.repaint(); 184 } 185 } 186 187 } 188 | Popular Tags |