Class CustomAttributeValueEditor

  • All Implemented Interfaces:
    Extension

    @API(type=EXTENDABLE,
         src=PUBLIC)
    public abstract class CustomAttributeValueEditor
    extends java.lang.Object
    implements Extension
    A custom editor which gets invoked to edit the value for an attribute.
    Since:
    15
    • Constructor Detail

      • CustomAttributeValueEditor

        public CustomAttributeValueEditor()
    • Method Detail

      • getAttributeValue

        public abstract java.lang.String getAttributeValue​(EditedAttribute attribute,
                                                           java.lang.Object parentComponent)
                                                    throws CancelledByUserException
        Get a value for the current attribute.
        Parameters:
        attribute - The attribute to be edited.
        parentComponent - The parent component, usually the table in which the user double clicked the value. Used for example to find the parent window/shell when creating dialogs.
        It is very important to set the parent of the dialog used as custom editor when showing it from oXygen's in-place attribute-editing dialog in the Author page. This needs to be done in order for oXygen's in-place attribute editor not to disappear when presenting the custom attribute value editor.
        The code that creates a simple input dialog as a custom editor, with the proper parent dialog, for the stand-alone oXygen, looks as following:
         public String getAttributeValue(EditedAttribute attribute, Object parentComponent)
             throws CancelledByUserException {
           String attrValue = null;
           PluginWorkspace pluginWorkspace = PluginWorkspaceProvider.getPluginWorkspace();
           Platform platform = pluginWorkspace.getPlatform();
           if (platform == Platform.STANDALONE) {
             // Find the parent window
             Component parent = (Component) parentComponent;
             while (!(parent instanceof Window)) {
               parent = parent.getParent();
             }
             attrValue = JOptionPane.showInputDialog(
                 parent,
                 "Set a new value for \"" + attribute.getAttributeQName() + "\":");
           }
           return attrValue;
         }
         
        For the Eclipse plug-in, the code changes into:
         public String getAttributeValue(EditedAttribute attribute, Object parentComponent)
             throws CancelledByUserException {
           String attrValue = null;
           PluginWorkspace pluginWorkspace = PluginWorkspaceProvider.getPluginWorkspace();
           Platform platform = pluginWorkspace.getPlatform();
           if (platform == Platform.ECLIPSE) {
             // Find the parent shell
             Control parent = (Control) parentComponent;
             while (!(parent instanceof Shell)) {
               parent = parent.getParent();
             }
             InputDialog inputDialog = new InputDialog(
                 (Shell) parent,
                 "Edit attribute",
                 "Set a new value for \"" + attribute.getAttributeQName() + "\":",
                 null,
                 null);
             if (inputDialog.open() == org.eclipse.jface.window.Window.OK) {
               // OK pressed. Get the value.
               attrValue = inputDialog.getValue();
             }
           }
           return attrValue;
         }
         
        Returns:
        The proposed value. Returning the empty string will commit it as a value, returning null will remove the attribute, while throwing a CancelledByUserException will cancel the editing.
        Throws:
        CancelledByUserException - When the user cancels the editing.
      • shouldHandleAttribute

        public abstract boolean shouldHandleAttribute​(EditedAttribute attribute)
        Ask the custom editor if it wants to handle editing for a certain attribute.
        Parameters:
        attribute - The attribute.
        Returns:
        true if this custom editor's "getAttributeValue" method should be invoked for that certain attribute.
      • getTooltipButtonInfo

        public TooltipIconInfo getTooltipButtonInfo​(EditedAttribute attribute)
        Get the information(tooltip and button) that describes the handle of the given attribute.
        Parameters:
        attribute - The attribute to be edited.
        Returns:
        The proposed information. Returning null if isn't a proposed info for the attribute.
        Since:
        21