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.Ejb; 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 BeanDetailsPanel extends EjbDetailForm { 35 36 private final Ejb ejb; 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 ejb.getLargeIcon(); 47 } 48 49 protected void setValue(String value) { 50 ejb.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 ejb.getSmallIcon(); 62 } 63 64 protected void setValue(String value) { 65 ejb.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 ejb.getDefaultDescription(); 77 } 78 79 protected void setValue(String value) { 80 ejb.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 ejb.getDefaultDisplayName(); 92 } 93 94 protected void setValue(String value) { 95 ejb.setDisplayName(value); 96 } 97 } 98 99 public BeanDetailsPanel(SectionNodeView sectionNodeView, final Ejb ejb) { 100 super(sectionNodeView); 101 this.dataObject = (EjbJarMultiViewDataObject) sectionNodeView.getDataObject(); 102 XmlMultiViewDataSynchronizer synchronizer = dataObject.getModelSynchronizer(); 103 this.ejb = ejb; 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 public void dataModelPropertyChange(Object source, String propertyName, Object oldValue, Object newValue) { 127 if(source == ejb || source instanceof Icon) { 128 scheduleRefreshView(); 129 } 130 } 131 } 132 | Popular Tags |