1 19 20 package org.netbeans.modules.dbschema.nodes; 21 22 import java.text.MessageFormat ; 23 24 import org.openide.util.NbBundle; 25 import org.openide.nodes.*; 26 27 import org.netbeans.modules.dbschema.*; 28 29 32 public class TableElementNode extends DBElementNode { 33 34 private static final String [] ICON_AFFECTING_PROPERTIES = new String [] { 35 PROP_TABLE_OR_VIEW 36 }; 37 38 43 public TableElementNode(TableElement element, Children children, boolean writeable) { 44 super(element, children, writeable); 45 setDisplayName(MessageFormat.format((element.isTable() ? NbBundle.getBundle("org.netbeans.modules.dbschema.nodes.Bundle_noi18n").getString("SHORT_tableElement") : NbBundle.getBundle("org.netbeans.modules.dbschema.nodes.Bundle_noi18n").getString("SHORT_viewElement")), new Object []{super.getDisplayName()})); } 47 48 51 protected String resolveIconBase() { 52 return ((TableElement)element).isView() ? VIEW : TABLE; 53 } 54 55 59 protected String [] getIconAffectingProperties() { 60 return ICON_AFFECTING_PROPERTIES; 61 } 62 63 64 protected Sheet createSheet () { 65 Sheet sheet = Sheet.createDefault(); 66 Sheet.Set ps = sheet.get(Sheet.PROPERTIES); 67 ps.put(createNameProperty(writeable)); 68 ps.put(createTableOrViewProperty(writeable)); 69 70 return sheet; 71 } 72 73 77 protected Node.Property createNameProperty (boolean canW) { 78 return new ElementProp(Node.PROP_NAME, String .class,canW) { 79 80 public Object getValue () { 81 String name = ((TableElement) element).getName().getFullName(); 82 int pos; 83 84 pos = name.lastIndexOf("."); if (pos != -1) 86 name = name.substring(pos + 1); 87 88 return name; 89 } 90 }; 91 } 92 93 97 protected Node.Property createTableOrViewProperty (boolean canW) { 98 return new ElementProp(PROP_TABLE_OR_VIEW, String .class, canW) { 99 100 public Object getValue () { 101 if (((TableElement)element).isTableOrView()) 102 return NbBundle.getMessage(TableElementNode.class, "Table"); else 104 return NbBundle.getMessage(TableElementNode.class, "View"); } 106 }; 107 } 108 } 109 | Popular Tags |