--- openide.explorer/apichanges.xml +++ openide.explorer/apichanges.xml @@ -50,6 +50,21 @@ Explorer API + + + PropertySheet extensions + + + + + + PropertySheet class has new methods which allow subclasses to provide custom + popup menu, check expansion state, expand/collapse property categories, + retrieve the selected property. + + + + setPropertyColumnAttribute() method added to OutlineView --- openide.explorer/manifest.mf +++ openide.explorer/manifest.mf @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.explorer OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 6.46 +OpenIDE-Module-Specification-Version: 6.47 --- openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java +++ openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java @@ -859,12 +859,16 @@ final void showPopup(Point p) { if( !popupEnabled ) return; + + JPopupMenu popup = createPopupMenu(); + + if( null == popup ) { JMenuItem helpItem = new JMenuItem(); JRadioButtonMenuItem sortNamesItem = new JRadioButtonMenuItem(); JRadioButtonMenuItem unsortedItem = new JRadioButtonMenuItem(); JCheckBoxMenuItem descriptionItem = new JCheckBoxMenuItem(); JMenuItem defaultValueItem = new JMenuItem(); - JPopupMenu popup = new JPopupMenu(); + popup = new JPopupMenu(); unsortedItem.setSelected(getSortingMode() == UNSORTED); sortNamesItem.setSelected(getSortingMode() == SORTED_BY_NAMES); @@ -887,9 +891,53 @@ popup.add(defaultValueItem); popup.add(new JSeparator()); popup.add(helpItem); + } popup.show(psheet, p.x, p.y); } + /** + * Subclasses may override this method to create a custom popup menu that will + * show on right-click in the property sheet. + * @return Custom popup menu or null to use the default popup menu provided + * by this class. + * @since 6.47 + */ + protected JPopupMenu createPopupMenu() { + return null; + } + + /** + * Check if the PropertySet the given property belongs to is expanded or not. + * @param fd Property or PropertySet to check. + * @return True if the PropertySet the given property belongs is expanded. + * @since 6.47 + */ + protected final boolean isExpanded( FeatureDescriptor fd ) { + return table.getPropertySetModel().isExpanded( fd ); + } + + /** + * Expand or collapse the PropertySet the given property belongs to. + * @param fd + * @since 6.47 + */ + protected final void toggleExpanded( FeatureDescriptor fd ) { + int index = table.getPropertySetModel().indexOf( fd ); + if( index >= 0 ) { + table.getPropertySetModel().toggleExpanded( WIDTH ); + } + } + + /** + * Retrieve currently selected property or PropertySet. + * @return Selected property or PropertySet or null if there is no selection. + * @since 6.47 + */ + protected final FeatureDescriptor getSelection() { + return table.getSelection(); + } + + Node[] getCurrentNodes() { Node n = pclistener.getNode();