1 19 package org.netbeans.modules.j2ee.ddloaders.multiview; 20 21 import org.netbeans.modules.j2ee.dd.api.common.Icon; 22 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 23 import org.netbeans.modules.j2ee.ddloaders.multiview.ui.EjbDetailForm; 24 import org.netbeans.modules.xml.multiview.ItemEditorHelper; 25 import org.netbeans.modules.xml.multiview.XmlMultiViewDataSynchronizer; 26 import org.netbeans.modules.xml.multiview.ui.SectionNodeView; 27 28 import java.awt.event.ActionEvent ; 29 import java.awt.event.ActionListener ; 30 31 34 public class EjbJarDetailsPanel extends EjbDetailForm { 35 36 private final EjbJar ejbJar; 37 private EjbJarMultiViewDataObject dataObject; 38 39 private class LargeIconEditorModel extends TextItemEditorModel { 40 41 public LargeIconEditorModel(XmlMultiViewDataSynchronizer synchronizer) { 42 super(synchronizer, true, true); 43 } 44 45 protected String getValue() { 46 return ejbJar.getLargeIcon(); 47 } 48 49 protected void setValue(String value) { 50 ejbJar.setLargeIcon(value); 51 } 52 } 53 54 private class SmallIconEditorModel extends TextItemEditorModel { 55 56 public SmallIconEditorModel(XmlMultiViewDataSynchronizer synchronizer) { 57 super(synchronizer, true, true); 58 } 59 60 protected String getValue() { 61 return ejbJar.getSmallIcon(); 62 } 63 64 protected void setValue(String value) { 65 ejbJar.setSmallIcon(value); 66 } 67 } 68 69 private class DescriptionEditorModel extends TextItemEditorModel { 70 71 public DescriptionEditorModel(XmlMultiViewDataSynchronizer synchronizer) { 72 super(synchronizer, true, true); 73 } 74 75 protected String getValue() { 76 return ejbJar.getDefaultDescription(); 77 } 78 79 protected void setValue(String value) { 80 ejbJar.setDescription(value); 81 } 82 } 83 84 private class DisplayNameEditorModel extends TextItemEditorModel { 85 86 public DisplayNameEditorModel(XmlMultiViewDataSynchronizer synchronizer) { 87 super(synchronizer, true, true); 88 } 89 90 protected String getValue() { 91 return ejbJar.getDefaultDisplayName(); 92 } 93 94 protected void setValue(String value) { 95 ejbJar.setDisplayName(value); 96 } 97 } 98 99 public EjbJarDetailsPanel(SectionNodeView sectionNodeView, final EjbJar ejbJar) { 100 super(sectionNodeView); 101 this.dataObject = (EjbJarMultiViewDataObject) sectionNodeView.getDataObject(); 102 this.ejbJar = ejbJar; 103 XmlMultiViewDataSynchronizer synchronizer = dataObject.getModelSynchronizer(); 104 addRefreshable(new ItemEditorHelper(getDisplayNameTextField(), new DisplayNameEditorModel(synchronizer))); 105 addRefreshable(new ItemEditorHelper(getDescriptionTextArea(), new DescriptionEditorModel(synchronizer))); 106 addRefreshable(new ItemEditorHelper(getSmallIconTextField(), new SmallIconEditorModel(synchronizer))); 107 addRefreshable(new ItemEditorHelper(getLargeIconTextField(), new LargeIconEditorModel(synchronizer))); 108 getBrowseLargeIconButton().addActionListener(new ActionListener () { 109 public void actionPerformed(ActionEvent e) { 110 String relativePath = Utils.browseIcon(dataObject); 111 if (relativePath != null) { 112 getLargeIconTextField().setText(relativePath); 113 } 114 } 115 }); 116 getBrowseSmallIconButton().addActionListener(new ActionListener () { 117 public void actionPerformed(ActionEvent e) { 118 String relativePath = Utils.browseIcon(dataObject); 119 if (relativePath != null) { 120 getSmallIconTextField().setText(relativePath); 121 } 122 } 123 }); 124 125 } 126 127 public void dataModelPropertyChange(Object source, String propertyName, Object oldValue, Object newValue) { 128 if (source instanceof EjbJar || source instanceof Icon) { 129 scheduleRefreshView(); 130 } 131 } 132 } 133 | Popular Tags |