1 19 package org.openide.explorer.propertysheet; 20 21 import org.openide.nodes.Node; 22 import org.openide.util.NbBundle; 23 24 import java.awt.Color ; 25 import java.awt.Component ; 26 import java.awt.Container ; 27 import java.awt.Dimension ; 28 import java.awt.Graphics ; 29 import java.awt.KeyboardFocusManager ; 30 import java.awt.LayoutManager ; 31 import java.awt.Toolkit ; 32 import java.awt.event.ActionEvent ; 33 import java.awt.event.FocusEvent ; 34 import java.awt.event.KeyEvent ; 35 36 import java.beans.FeatureDescriptor ; 37 import java.beans.PropertyChangeEvent ; 38 import java.beans.PropertyChangeListener ; 39 import java.beans.PropertyEditor ; 40 import java.beans.PropertyVetoException ; 41 import java.beans.VetoableChangeListener ; 42 43 import javax.swing.*; 44 import javax.swing.event.ChangeListener ; 45 46 import org.netbeans.modules.openide.explorer.TTVEnvBridge; 47 48 49 92 public class PropertyPanel extends JComponent implements javax.accessibility.Accessible { 93 96 public static final int PREF_READ_ONLY = 0x0001; 97 98 101 public static final int PREF_CUSTOM_EDITOR = 0x0002; 102 103 106 public static final int PREF_INPUT_STATE = 0x0004; 107 108 110 public static final int PREF_TABLEUI = 0x0008; 111 112 113 public static final String PROP_PREFERENCES = "preferences"; 115 116 public static final String PROP_MODEL = "model"; 118 123 public static final @Deprecated String PROP_PROPERTY_EDITOR = "propertyEditor"; 125 128 public static final String PROP_STATE = PropertyEnv.PROP_STATE; 129 130 131 private int preferences; 132 133 134 private PropertyModel model; 135 136 140 private boolean changeImmediate = true; 141 142 144 Component inner = null; 145 146 147 private Listener listener = null; 148 149 150 private Node.Property prop; 151 152 153 private boolean settingModel = false; 154 private boolean initializing = false; 155 private PropertyDisplayer displayer = null; 156 Object [] beans = null; 157 private ReusablePropertyEnv reusableEnv = new ReusablePropertyEnv(); 158 private ReusablePropertyModel reusableModel = new ReusablePropertyModel(reusableEnv); 159 private final boolean isGtk = "GTK".equals(UIManager.getLookAndFeel().getID()) || (UIManager.getLookAndFeel().getClass().getSuperclass().getName().indexOf("Synth") != -1); 162 163 public PropertyPanel() { 164 this(ModelProperty.toProperty(null), 0, null); 165 } 166 167 174 public PropertyPanel(Object bean, String propertyName, int preferences) { 175 this( 177 ModelProperty.toProperty(new DefaultPropertyModel(bean, propertyName)), preferences, 178 179 new DefaultPropertyModel(bean, propertyName) 181 ); 182 } 183 184 191 public PropertyPanel(PropertyModel model, int preferences) { 192 this(null, preferences, model); 193 } 194 195 201 public PropertyPanel(Node.Property p, int preferences) { 202 this(p, preferences, null); 203 } 204 205 211 public PropertyPanel(Node.Property p) { 212 this(p, 0, null); 213 } 214 215 235 PropertyPanel(Node[] nodes, String propertyName) throws ClassCastException , NullPointerException { 236 this( 238 (nodes.length == 1) ? ModelProperty.findProperty(nodes[0], propertyName) 239 : ModelProperty.toProperty(nodes, propertyName) 240 ); 241 } 242 243 244 private PropertyPanel(Node.Property p, int preferences, PropertyModel mdl) { 245 if (p == null) { 246 prop = ModelProperty.toProperty(mdl); 247 } else { 248 prop = p; 249 } 250 251 this.preferences = preferences; 252 initializing = true; 253 setModel(mdl); 254 initializing = false; 255 setOpaque(true); 256 257 getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 259 KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "dump" 260 ); 261 getActionMap().put( 262 "dump", 263 new AbstractAction() { public void actionPerformed(ActionEvent ae) { 265 System.err.println(""); System.err.println(PropertyPanel.this); 267 System.err.println(""); } 269 } 270 ); 271 272 getActionMap().put("invokeCustomEditor", new CustomEditorProxyAction()); } 279 280 public void setBackground(Color c) { 281 if (inner != null) { 282 inner.setBackground(c); 283 } 284 285 super.setBackground(c); 286 } 287 288 public void setForeground(Color c) { 289 if (inner != null) { 290 inner.setForeground(c); 291 } 292 293 super.setForeground(c); 294 } 295 296 299 private PropertyDisplayer findPropertyDisplayer() { 300 PropertyDisplayer result; 301 Node.Property prop = getProperty(); 302 303 if (((preferences & PREF_CUSTOM_EDITOR) == 0) && (((preferences & PREF_READ_ONLY) != 0) || !isEnabled())) { 304 return getRendererComponent(prop); 306 } 307 308 switch (preferences) { 309 case 9: 310 case 1: result = getRendererComponent(prop); 312 313 break; 314 315 case 10: 316 case 2: result = new CustomEditorDisplayer(prop, model); 318 319 break; 320 321 case 11: 322 case 3: result = new CustomEditorDisplayer(prop, model); 324 325 break; 327 328 case 12: 329 case 4: result = new EditablePropertyDisplayer(prop, model); 331 332 break; 333 334 case 13: 335 case 5: result = getRendererComponent(prop); 337 338 break; 339 340 case 14: 341 case 6: result = new CustomEditorDisplayer(prop, model); 343 344 break; 347 348 case 15: 349 case 7: result = new CustomEditorDisplayer(prop, model); 351 352 break; 353 354 case 0: 355 case 8:default: 356 result = new EditablePropertyDisplayer(prop, model); 357 358 break; 359 } 360 361 if (result instanceof PropertyDisplayer_Inline) { 362 PropertyDisplayer_Inline inline = (PropertyDisplayer_Inline) result; 363 boolean tableUI = ((preferences & PREF_TABLEUI) != 0) || Boolean.TRUE.equals(getClientProperty("flat")); inline.setTableUI(tableUI); 366 if (inline.isTableUI()) { 367 inline.setUseLabels(!tableUI); 368 } 369 } 370 371 boolean isTableUI = (preferences & PREF_TABLEUI) != 0; 372 373 if (result instanceof CustomEditorDisplayer) { 374 ((PropertyDisplayer_Editable) result).setUpdatePolicy( 375 changeImmediate ? PropertyDisplayer.UPDATE_ON_FOCUS_LOST : PropertyDisplayer.UPDATE_ON_EXPLICIT_REQUEST 376 ); 377 } else if (result instanceof PropertyDisplayer_Editable) { 378 ((PropertyDisplayer_Editable) result).setUpdatePolicy( 379 isTableUI ? PropertyDisplayer.UPDATE_ON_CONFIRMATION : PropertyDisplayer.UPDATE_ON_FOCUS_LOST 380 ); 381 } 382 383 if (((preferences & PREF_READ_ONLY) != 0) && result instanceof CustomEditorDisplayer) { 384 ((CustomEditorDisplayer) result).setEnabled(false); 385 } else if (result instanceof PropertyDisplayer_Editable) { 386 if (!isEnabled()) { 387 ((PropertyDisplayer_Editable) result).setEnabled(isEnabled()); 388 } 389 } 390 391 return result; 392 } 393 394 397 private RendererPropertyDisplayer getRendererComponent(Node.Property prop) { 398 RendererPropertyDisplayer result; 399 400 if (inner instanceof RendererPropertyDisplayer) { 401 ((RendererPropertyDisplayer) inner).setProperty(prop); 403 result = (RendererPropertyDisplayer) inner; 404 } else { 405 result = new RendererPropertyDisplayer(prop); 406 } 407 408 return result; 409 } 410 411 413 private PropertyDisplayer getPropertyDisplayer() { 414 if (displayer == null) { 415 setDisplayer(findPropertyDisplayer()); 416 } 417 418 return displayer; 419 } 420 421 422 private void installDisplayerComponent() { 423 PropertyDisplayer displayer = getPropertyDisplayer(); 427 428 Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner(); 431 432 boolean hadFocus = (focusOwner == this) || isAncestorOf(focusOwner); 433 434 if (hadFocus) { 435 KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); 439 } 440 441 Component newInner = displayer.getComponent(); 443 444 if (!(displayer instanceof PropertyDisplayer_Editable)) { 448 newInner.setEnabled(isEnabled() && getProperty().canWrite()); 450 } 451 452 newInner.setForeground(getForeground()); 453 newInner.setBackground(getBackground()); 454 455 if (newInner != inner) { 457 synchronized (getTreeLock()) { 458 if (inner != null) { 460 remove(inner); 461 } 462 463 if (newInner != null) { 465 add(newInner); 466 467 newInner.invalidate(); 469 inner = newInner; 470 } 471 } 472 } 473 474 if (isShowing() && !(getParent() instanceof javax.swing.CellRendererPane )) { 476 validate(); 477 } 478 479 if (hadFocus && isEnabled() && ((preferences & PREF_READ_ONLY) == 0)) { 481 requestFocus(); 482 } 483 484 if (!isEnabled() || ((preferences & PREF_READ_ONLY) != 0)) { 490 Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 491 492 if ((focus == inner) || ((inner instanceof Container ) && ((Container ) inner).isAncestorOf(focus))) { 493 this.transferFocusUpCycle(); 494 } 495 } 496 } 497 498 public void doLayout() { 499 layout(); 500 } 501 502 @SuppressWarnings ("deprecation") 503 public void layout() { 504 if (inner != null) { 505 inner.setBounds(0, 0, getWidth(), getHeight()); 506 } 507 } 508 509 public Dimension getMinimumSize() { 510 return getPreferredSize(); 511 } 512 513 public Dimension getPreferredSize() { 514 Dimension result; 515 516 if (!isDisplayable() && ((preferences & PREF_CUSTOM_EDITOR) == 0)) { 517 result = getRendererComponent(getProperty()).getComponent().getPreferredSize(); 520 } else if (inner != null) { 521 result = inner.getPreferredSize(); 522 } else { 523 result = PropUtils.getMinimumPanelSize(); 524 } 525 526 return result; 527 } 528 529 531 private void setDisplayer(PropertyDisplayer nue) { 532 if (displayer != null) { 533 detachFromDisplayer(displayer); 534 } 535 536 displayer = nue; 537 538 if (nue != null) { 539 attachToDisplayer(displayer); 540 } 541 } 542 543 544 private void attachToDisplayer(PropertyDisplayer displayer) { 545 if (displayer instanceof PropertyDisplayer_Inline) { 546 updateDisplayerFromClientProps(); 547 } 548 549 if (displayer instanceof CustomEditorDisplayer) { 550 ((CustomEditorDisplayer) displayer).setRemoteEnvListener(getListener()); 551 ((CustomEditorDisplayer) displayer).setRemoteEnvVetoListener(getListener()); 552 } 553 554 if (displayer instanceof EditablePropertyDisplayer) { 555 ((EditablePropertyDisplayer) displayer).setRemoteEnvListener(getListener()); 556 ((EditablePropertyDisplayer) displayer).setRemoteEnvVetoListener(getListener()); 557 558 PropertyEnv env = ((EditablePropertyDisplayer) displayer).getPropertyEnv(); 559 560 if (env != null) { 561 env.setFeatureDescriptor(getProperty()); 562 } 563 } 564 } 565 566 568 private void detachFromDisplayer(PropertyDisplayer displayer) { 569 if (displayer instanceof CustomEditorDisplayer) { 570 ((CustomEditorDisplayer) displayer).setRemoteEnvVetoListener(null); 571 } 572 573 if (displayer instanceof EditablePropertyDisplayer) { 574 ((EditablePropertyDisplayer) displayer).setRemoteEnvVetoListener(null); 575 } 576 } 577 578 580 protected void firePropertyChange(String nm, Object old, Object nue) { 581 if ( 582 ("flat".equals(nm) || "radioButtonMax".equals(nm) || "suppressCustomEditor".equals(nm) || 583 "useLabels".equals(nm)) && (displayer != null) && displayer instanceof PropertyDisplayer_Inline 584 ) { updateDisplayerFromClientProp(nm, nue); 586 } 587 588 super.firePropertyChange(nm, old, nue); 589 } 590 591 593 private void updateDisplayerFromClientProp(String nm, Object val) { 594 PropertyDisplayer displayer = getPropertyDisplayer(); 595 596 if (displayer instanceof PropertyDisplayer_Inline) { 597 PropertyDisplayer_Inline inline = (PropertyDisplayer_Inline) displayer; 598 599 if ("flat".equals(nm)) { inline.setTableUI(Boolean.TRUE.equals(val)); 601 602 if (Boolean.TRUE.equals(val)) { 603 inline.setUseLabels(false); 604 } else if (Boolean.FALSE.equals(val) && (getClientProperty("useLabels") == null)) { inline.setUseLabels(true); 606 } 607 } else if ("radioButtonMax".equals(nm)) { 609 int max = (val instanceof Integer ) ? ((Integer ) val).intValue() : 0; 610 inline.setRadioButtonMax(max); 611 } else if ("suppressCustomEditor".equals(nm)) { inline.setShowCustomEditorButton(!Boolean.TRUE.equals(val)); 613 } else if ("useLabels".equals(nm)) { inline.setUseLabels(Boolean.TRUE.equals(val)); 615 } 616 } 617 } 618 619 621 public boolean isFocusable() { 622 return super.isFocusable() && isEnabled() && ((preferences & PREF_READ_ONLY) == 0); 623 } 624 625 629 public void requestFocus() { 630 if (!isEnabled() || ((preferences & PREF_READ_ONLY) != 0)) { 633 return; 634 } else if ((inner != null) && inner.isEnabled()) { 635 super.requestFocus(); 636 inner.requestFocus(); 637 } 638 } 639 640 642 private void updateDisplayerFromClientProps() { 643 String [] props = new String [] { "flat", "radioButtonMax", "suppressCustomEditor", "useLabels" }; 645 for (int i = 0; i < props.length; i++) { 646 Object o = getClientProperty(props[i]); 647 648 if (o != null) { 649 updateDisplayerFromClientProp(props[i], o); 650 } 651 } 652 } 653 654 protected void processFocusEvent(FocusEvent fe) { 655 super.processFocusEvent(fe); 656 657 if (fe.getID() == fe.FOCUS_GAINED) { 658 if ((inner != null) && inner.isEnabled() && inner.isFocusTraversable()) { 659 inner.requestFocus(); 660 } 661 } 662 } 663 664 666 private Listener getListener() { 667 if (listener == null) { 668 listener = new Listener (); 669 } 670 671 return listener; 672 } 673 674 675 public void addNotify() { 676 attachToModel(); 677 678 if (displayer != null) { 679 attachToDisplayer(displayer); 680 } 681 682 if (inner == null) { 683 installDisplayerComponent(); 684 } 685 686 super.addNotify(); 687 } 688 689 691 public void removeNotify() { 692 super.removeNotify(); 693 detachFromModel(); 694 695 if ((displayer != null) && (!(displayer instanceof RendererPropertyDisplayer))) { 696 detachFromDisplayer(displayer); 697 displayer = null; 698 } 699 700 if (null != inner && !(inner instanceof RendererPropertyDisplayer)) { 701 remove(inner); 705 inner = null; 706 } 707 } 708 709 729 730 735 public int getPreferences() { 736 return preferences; 737 } 738 739 743 public void setPreferences(int preferences) { 744 if (preferences != this.preferences) { 745 int oldPreferences = this.preferences; 746 this.preferences = preferences; 747 hardReset(); 748 firePropertyChange(PROP_PREFERENCES, oldPreferences, preferences); 749 } 750 } 751 752 772 public PropertyModel getModel() { 773 if (model == null) { 774 return new NodePropertyModel(getProperty(), null); 775 } 776 777 return model; 778 } 779 780 792 public void setModel(PropertyModel model) { 793 if (model != this.model) { 794 settingModel = true; 795 796 if ((this.model != null) && (listener != null)) { 797 detachFromModel(); 798 } 799 800 try { 801 if (!initializing) { 802 setProperty(ModelProperty.toProperty(model)); 803 this.model = model; 804 805 if (model != null) { 806 if (isDisplayable()) { 807 attachToModel(); 808 } 809 } 810 } else { 811 this.model = model; 812 attachToModel(); 813 } 814 } finally { 815 settingModel = false; 816 } 817 } 818 } 819 820 821 private final void attachToModel() { 822 if (model != null) { 823 model.addPropertyChangeListener(getListener()); 824 } 825 } 826 827 828 private final void detachFromModel() { 829 if (model != null) { 830 model.removePropertyChangeListener(getListener()); 831 } 832 } 833 834 Object [] getBeans() { 835 return beans; 836 } 837 838 841 public final void setProperty(Node.Property p) { 842 Object bridgeID = getClientProperty("beanBridgeIdentifier"); 843 844 if (bridgeID != null) { 845 TTVEnvBridge bridge = TTVEnvBridge.findInstance(bridgeID); 846 847 if (bridge != null) { 848 beans = bridge.getCurrentBeans(); 849 bridge.clear(); 850 } 851 } 852 853 if (p != prop) { 854 prop = p; 855 856 if (!settingModel) { 857 model = null; 859 } 860 861 if (displayer != null) { 862 if (displayer instanceof PropertyDisplayer_Mutable) { 863 ((PropertyDisplayer_Mutable) displayer).setProperty(p); 864 } else { 865 hardReset(); 866 } 867 } 868 } 869 } 870 871 875 final void reset() { 876 if ((preferences & PREF_CUSTOM_EDITOR) != 0) { 877 getPropertyDisplayer().refresh(); 878 } else { 879 hardReset(); 880 } 881 } 882 883 884 final void hardReset() { 885 setDisplayer(findPropertyDisplayer()); 886 887 if (isDisplayable()) { installDisplayerComponent(); 889 } 890 } 891 892 898 public final Node.Property getProperty() { 899 if ((prop == null) && (model != null)) { 900 prop = ModelProperty.toProperty(model); 901 } 902 903 return prop; 904 } 905 906 915 public final Object getState() { 916 if ((displayer != null) && displayer instanceof PropertyDisplayer_Editable) { 917 return ((PropertyDisplayer_Editable) displayer).getPropertyEnv().getState(); 918 } else { 919 PropertyEditor ed = propertyEditor(); 920 921 if (ed instanceof ExPropertyEditor) { 922 ReusablePropertyEnv env = reusableEnv; 924 reusableModel.setProperty(prop); 925 ((ExPropertyEditor) ed).attachEnv(env); 926 927 return env.getState(); 928 } 929 } 930 931 return PropertyEnv.STATE_VALID; 932 } 933 934 944 public void updateValue() { 945 if ((displayer != null) && displayer instanceof PropertyDisplayer_Editable) { 946 PropertyEnv env = ((PropertyDisplayer_Editable) displayer).getPropertyEnv(); 947 948 if (PropertyEnv.STATE_NEEDS_VALIDATION.equals(env.getState())) { 949 env.setState(PropertyEnv.STATE_VALID); 950 } 951 952 if (!changeImmediate) { 953 try { 954 ((PropertyDisplayer_Editable) displayer).commit(); 955 } catch (IllegalArgumentException iae) { 956 PropertyDialogManager.notify(iae); 957 } 958 } 959 } 960 } 961 962 982 public @Deprecated PropertyEditor getPropertyEditor() { 983 return propertyEditor(); 984 } 985 986 987 private PropertyEditor propertyEditor() { 988 PropertyEditor result = null; 989 990 if (displayer != null) { 991 if (displayer instanceof CustomEditorDisplayer) { 994 result = ((CustomEditorDisplayer) displayer).getPropertyEditor(); 995 } else if (displayer instanceof EditablePropertyDisplayer) { 996 result = ((EditablePropertyDisplayer) displayer).getPropertyEditor(); 997 } 998 } 999 1000 if (result == null) { 1001 result = PropUtils.getPropertyEditor(getProperty()); 1005 } 1006 1007 return result; 1008 } 1009 1010 1015 public void setEnabled(boolean enabled) { 1016 super.setEnabled(enabled); 1018 1019 if (inner != null) { 1020 PropertyDisplayer displayer = getPropertyDisplayer(); 1021 1022 if (displayer instanceof PropertyDisplayer_Editable) { 1023 ((PropertyDisplayer_Editable) displayer).setEnabled(enabled); 1027 } else { 1028 hardReset(); 1031 } 1032 } 1033 } 1034 1035 1042 public boolean isChangeImmediate() { 1043 return changeImmediate; 1044 } 1045 1046 1052 public void setChangeImmediate(boolean changeImmediate) { 1053 if (this.changeImmediate == changeImmediate) { 1054 return; 1055 } 1056 1057 this.changeImmediate = changeImmediate; 1058 1059 if (isShowing()) { 1060 PropertyDisplayer displayer = getPropertyDisplayer(); 1061 1062 if (displayer instanceof PropertyDisplayer_Editable) { 1063 ((PropertyDisplayer_Editable) displayer).setUpdatePolicy( 1064 changeImmediate ? PropertyDisplayer.UPDATE_ON_FOCUS_LOST 1065 : PropertyDisplayer.UPDATE_ON_EXPLICIT_REQUEST 1066 ); 1067 } 1068 } 1069 1070 firePropertyChange( 1071 PropertyEnv.PROP_CHANGE_IMMEDIATE, changeImmediate ? Boolean.FALSE : Boolean.TRUE, 1072 changeImmediate ? Boolean.TRUE : Boolean.FALSE 1073 ); 1074 } 1075 1076 1078 public String toString() { 1079 if ((preferences & PREF_CUSTOM_EDITOR) != 0) { 1080 return super.toString() + " - " + prefsToString(getPreferences()); } else { 1083 return getClass().getName() + System.identityHashCode(this) + prefsToString(getPreferences()) + 1084 " propertyRenderer: " + ((inner == null) ? " null " : inner.toString()); } 1086 } 1087 1088 1090 private static String prefsToString(int prefs) { 1091 StringBuffer sb = new StringBuffer (" prefs:"); int[] vals = new int[] { PREF_CUSTOM_EDITOR, PREF_INPUT_STATE, PREF_READ_ONLY }; 1093 String [] s = new String [] { "PREF_CUSTOM_EDITOR", "PREF_INPUT_STATE", "PREF_READ_ONLY" }; boolean found = false; 1095 1096 for (int i = 0; i < vals.length; i++) { 1097 if ((vals[i] & prefs) != 0) { 1098 sb.append(s[i]); 1099 } 1100 1101 if (found && (i != (vals.length - 1))) { 1102 sb.append(","); } 1104 1105 found = true; 1106 } 1107 1108 return sb.toString(); 1109 } 1110 1111 1116 public void paint(Graphics g) { 1117 if (isGtk) { 1118 Color c = getBackground(); 1120 1121 if (c == null) { 1122 c = UIManager.getColor("control"); } 1124 1125 if (c == null) { 1126 c = Color.LIGHT_GRAY; 1127 } 1128 1129 g.setColor(c); 1130 g.fillRect(0, 0, getWidth(), getHeight()); 1131 } 1132 1133 super.paint(g); 1134 } 1135 1136 public javax.accessibility.AccessibleContext getAccessibleContext() { 1138 if (accessibleContext == null) { 1139 accessibleContext = new AccessiblePropertyPanel(); 1140 } 1141 1142 return accessibleContext; 1143 } 1144 1145 1148 private class CustomEditorProxyAction extends AbstractAction { 1149 public void actionPerformed(ActionEvent e) { 1150 Action wrapped = getWrapped(); 1151 1152 if (wrapped != null) { 1153 wrapped.actionPerformed(e); 1154 } else { 1155 Toolkit.getDefaultToolkit().beep(); 1156 } 1157 } 1158 1159 private Action getWrapped() { 1160 Node.Property p = getProperty(); 1161 EditablePropertyDisplayer pd = (getPropertyDisplayer() instanceof EditablePropertyDisplayer) 1162 ? (EditablePropertyDisplayer) getPropertyDisplayer() : new EditablePropertyDisplayer(p); 1163 1164 return pd.getCustomEditorAction(); 1165 } 1166 1167 public boolean isEnabled() { 1168 Action wrapped = getWrapped(); 1169 1170 if (wrapped != null) { 1171 return wrapped.isEnabled(); 1172 } else { 1173 return getProperty() != null; 1174 } 1175 } 1176 } 1177 1178 private class AccessiblePropertyPanel extends AccessibleJComponent { 1179 AccessiblePropertyPanel() { 1180 } 1181 1182 public javax.accessibility.AccessibleRole getAccessibleRole() { 1183 return javax.accessibility.AccessibleRole.PANEL; 1184 } 1185 1186 public String getAccessibleName() { 1187 String name = super.getAccessibleName(); 1188 1189 if ((name == null) && model instanceof ExPropertyModel) { 1190 FeatureDescriptor fd = ((ExPropertyModel) model).getFeatureDescriptor(); 1191 name = NbBundle.getMessage(PropertyPanel.class, "ACS_PropertyPanel", fd.getDisplayName()); } 1193 1194 return name; 1195 } 1196 1197 public String getAccessibleDescription() { 1198 String description = super.getAccessibleDescription(); 1199 1200 if ((description == null) && model instanceof ExPropertyModel) { 1201 FeatureDescriptor fd = ((ExPropertyModel) model).getFeatureDescriptor(); 1202 description = NbBundle.getMessage(PropertyPanel.class, "ACSD_PropertyPanel", fd.getShortDescription()); } 1204 1205 return description; 1206 } 1207 } 1208 1209 private class Listener implements PropertyChangeListener , VetoableChangeListener , ChangeListener { 1210 public void propertyChange(PropertyChangeEvent evt) { 1211 if (evt.getSource() instanceof PropertyEnv) { 1212 firePropertyChange(PropertyPanel.PROP_STATE, evt.getOldValue(), evt.getNewValue()); 1213 } 1214 1215 if (evt.getSource() instanceof PropertyModel) { 1216 if ((evt.getOldValue() == null) && (evt.getNewValue() == null)) { 1217 hardReset(); 1220 } else { 1221 reset(); 1224 } 1225 } 1226 } 1227 1228 public void vetoableChange(PropertyChangeEvent evt) 1229 throws PropertyVetoException { 1230 } 1232 1233 public void stateChanged(javax.swing.event.ChangeEvent e) { 1234 } 1236 } 1237} 1238 | Popular Tags |