1 19 package org.openharmonise.him.serverconfig.permissions.list; 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.Font ; 26 import java.awt.LayoutManager ; 27 import java.awt.event.MouseEvent ; 28 import java.awt.event.MouseListener ; 29 30 import javax.swing.JLabel ; 31 import javax.swing.JPanel ; 32 33 import org.openharmonise.vfs.*; 34 import org.openharmonise.vfs.gui.*; 35 36 37 44 public class PermissionsSelectionCell 45 extends JPanel 46 implements MouseListener , LayoutManager { 47 48 51 private JLabel m_label = null; 52 53 56 private String m_sPath = null; 57 58 61 private AbstractVirtualFileSystem m_vfs = null; 62 63 66 private boolean m_bSelected = false; 67 68 71 private int m_nWidth = 340; 72 73 76 private PermissionsSelectionList m_parent = null; 77 78 85 public PermissionsSelectionCell(PermissionsSelectionList parent, String sPath, AbstractVirtualFileSystem vfs) { 86 super(); 87 this.m_sPath = sPath; 88 this.m_vfs = vfs; 89 90 this.m_parent = parent; 91 this.setup(); 92 } 93 94 98 private void setup() { 99 100 VirtualFile vfFile = this.m_vfs.getVirtualFile(this.m_sPath).getResource(); 101 VirtualFileSystemView vfsView = this.m_vfs.getVirtualFileSystemView(); 102 103 String fontName = "Dialog"; 104 int fontSize = 11; 105 Font font = new Font (fontName, Font.PLAIN, fontSize); 106 107 this.setLayout(this); 108 this.setBackground(Color.WHITE); 109 110 this.m_label = new JLabel ( vfsView.getDisplayName(vfFile) ); 111 this.m_label.addMouseListener(this); 112 this.m_label.setToolTipText( vfFile.getFullPath() ); 113 this.m_label.setFont(font); 114 this.m_label.setBackground(Color.WHITE); 115 this.m_label.setIcon( IconManager.getInstance().getIcon("16-user-container.gif") ); 116 this.add(this.m_label); 117 } 118 119 122 public void removeLayoutComponent(Component arg0) { 123 } 124 125 128 public void layoutContainer(Container arg0) { 129 this.m_label.setSize(m_nWidth-20, 20); 130 this.m_label.setLocation(0,0); 131 } 132 133 136 public void addLayoutComponent(String arg0, Component arg1) { 137 } 138 139 142 public Dimension minimumLayoutSize(Container arg0) { 143 return this.getPreferredSize(); 144 } 145 146 149 public Dimension preferredLayoutSize(Container arg0) { 150 return this.getPreferredSize(); 151 } 152 153 156 public Dimension getPreferredSize() { 157 return new Dimension (m_nWidth, 20); 158 } 159 160 161 162 165 public boolean equals(Object obj) { 166 boolean bRetn = false; 167 if(obj instanceof PermissionsSelectionCell) { 168 PermissionsSelectionCell cell = (PermissionsSelectionCell)obj; 169 if(cell.getPath().trim().equals(this.m_sPath) && 170 cell.getVFS().getInitialPath().trim().equals(this.m_vfs.getInitialPath())) { 171 bRetn=true; 172 } 173 } 174 return bRetn; 175 } 176 177 183 public String getPath() { 184 return m_sPath; 185 } 186 187 193 public AbstractVirtualFileSystem getVFS() { 194 return m_vfs; 195 } 196 197 202 public boolean isSelected() { 203 return m_bSelected; 204 } 205 206 211 public void setSelected(boolean bSelected) { 212 m_bSelected = bSelected; 213 if(this.m_bSelected) { 214 this.setBackground( new Color (173, 169, 143)); 215 } else { 216 this.setBackground(Color.WHITE); 217 this.m_label.setBackground(Color.WHITE); 218 } 219 this.repaint(); 220 } 221 222 225 public void mouseClicked(MouseEvent me) { 226 MouseListener [] listeners = this.getMouseListeners(); 227 me.setSource(this); 228 for(int i=0; i<listeners.length; i++) { 229 listeners[i].mouseClicked(me); 230 } 231 } 232 233 236 public void mouseEntered(MouseEvent arg0) { 237 } 238 239 242 public void mouseExited(MouseEvent arg0) { 243 } 244 245 248 public void mousePressed(MouseEvent arg0) { 249 } 250 251 254 public void mouseReleased(MouseEvent arg0) { 255 } 256 257 } 258 | Popular Tags |