1 19 package org.openharmonise.him.configuration.preview; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 24 import javax.swing.*; 25 26 import org.openharmonise.him.*; 27 import org.openharmonise.him.configuration.*; 28 import org.openharmonise.him.swing.resourcetree.*; 29 import org.openharmonise.vfs.*; 30 import org.openharmonise.vfs.gui.*; 31 import org.openharmonise.vfs.servers.*; 32 33 34 41 public class PreviewOptions 42 extends JPanel 43 implements LayoutManager, ActionListener, ApplyChangesListener { 44 45 48 private ConfigDialog m_dialog = null; 49 50 53 private ResourceTree m_tree = null; 54 55 58 private JButton m_addButton = null; 59 60 63 private JButton m_removeButton = null; 64 65 68 private JTextField m_textField = null; 69 70 73 private boolean m_bChanged = false; 74 75 private String DOC_PREVIEW_PAGE = "DOC_PREVIEW_PAGE"; 76 private String m_sPage = null; 77 78 83 public PreviewOptions(ConfigDialog dialog) { 84 super(); 85 this.m_dialog = dialog; 86 this.setup(); 87 } 88 89 93 private void setup() { 94 this.m_dialog.addApplyChangesListener(this); 95 96 this.setLayout(this); 97 98 m_tree = new ResourceTree(); 99 m_tree.setShowLeafNodes(true); 100 m_tree.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 101 102 this.m_addButton = new JButton(); 103 this.m_addButton.setIcon( 104 IconManager.getInstance().getIcon("16-command-right.png")); 105 this.m_addButton.setActionCommand("ADD"); 106 this.m_addButton.setToolTipText("Add"); 107 this.m_addButton.addActionListener(this); 108 this.add(this.m_addButton); 109 this.m_removeButton = new JButton(); 110 this.m_removeButton.setIcon( 111 IconManager.getInstance().getIcon("16-command-left.png")); 112 this.m_removeButton.setActionCommand("REMOVE"); 113 this.m_removeButton.setToolTipText("Remove"); 114 this.m_removeButton.addActionListener(this); 115 this.add(this.m_removeButton); 116 117 m_sPage = ConfigStore.getInstance().getPropertyValue(DOC_PREVIEW_PAGE); 118 Server server = ServerList.getInstance().getHarmoniseServer(); 119 120 this.m_textField = new JTextField(m_sPage); 121 m_textField.setBorder(BorderFactory.createLineBorder(Color.BLACK)); 122 this.add(this.m_textField); 123 124 this.add(m_tree); 125 126 String fontName = "Dialog"; 127 int fontSize = 11; 128 Font font = new Font(fontName, Font.PLAIN, fontSize); 129 130 VirtualFile vfFile = 131 server.getVFS().getVirtualFile( 132 "/webdav/Website/Page Definition").getResource(); 133 this.m_tree.addCollection(vfFile); 134 } 135 136 139 public Dimension getPreferredSize() { 140 return new Dimension(this.getParent().getSize().width, 200); 141 } 142 143 146 public void actionPerformed(ActionEvent ae) { 147 if(ae.getActionCommand().equals("ADD")) { 148 VirtualFile vfFile = this.m_tree.getSelectedResource(); 149 if(vfFile.isDirectory() == false){ 150 m_sPage = vfFile.getFullPath(); 151 this.m_textField.setText(vfFile.getFileName()); 152 } 153 154 this.revalidate(); 155 this.m_bChanged = true; 156 this.m_dialog.changesMade(); 157 } else if(ae.getActionCommand().equals("REMOVE")) { 158 this.m_textField.setText(""); 159 this.revalidate(); 161 this.m_bChanged = true; 162 this.m_dialog.changesMade(); 163 } 164 } 165 166 169 public boolean applyChanges() { 170 if(this.m_bChanged) { 171 ConfigStore.getInstance().setProperty(DOC_PREVIEW_PAGE, m_sPage); 172 173 this.m_bChanged = false; 174 } 175 return true; 176 } 177 178 181 public void layoutContainer(Container arg0) { 182 int nHeight = 0; 183 184 this.m_tree.setSize(150, 200); 185 this.m_tree.setLocation(10, nHeight + 20); 186 187 this.m_addButton.setSize(this.m_addButton.getPreferredSize()); 188 this.m_addButton.setLocation(170, nHeight + 40); 189 this.m_removeButton.setSize(this.m_addButton.getPreferredSize()); 190 this.m_removeButton.setLocation(170, nHeight + 70); 191 192 this.m_textField.setSize(120, 20); 193 this.m_textField.setLocation(240, nHeight + 20); 194 this.m_textField.setEditable(false); 195 this.m_textField.setBackground(Color.WHITE); 196 } 197 198 201 public Dimension minimumLayoutSize(Container arg0) { 202 return this.getPreferredSize(); 203 } 204 205 208 public Dimension preferredLayoutSize(Container arg0) { 209 return this.getPreferredSize(); 210 } 211 212 215 public void removeLayoutComponent(Component arg0) { 216 } 217 218 221 public void addLayoutComponent(String arg0, Component arg1) { 222 } 223 224 227 private PreviewOptions(boolean arg0) { 228 super(arg0); 229 } 230 231 234 private PreviewOptions(LayoutManager arg0) { 235 super(arg0); 236 } 237 238 242 private PreviewOptions(LayoutManager arg0, boolean arg1) { 243 super(arg0, arg1); 244 } 245 246 249 public void discardChanges() { 250 251 } 252 253 } 254 | Popular Tags |