Package ro.sync.ecss.extensions.api
Class CustomAttributeValueEditor
- java.lang.Object
-
- ro.sync.ecss.extensions.api.CustomAttributeValueEditor
-
-
Constructor Summary
Constructors Constructor Description CustomAttributeValueEditor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
getAttributeValue(EditedAttribute attribute, java.lang.Object parentComponent)
Get a value for the current attribute.TooltipIconInfo
getTooltipButtonInfo(EditedAttribute attribute)
Get the information(tooltip and button) that describes the handle of the given attribute.abstract boolean
shouldHandleAttribute(EditedAttribute attribute)
Ask the custom editor if it wants to handle editing for a certain attribute.boolean
shouldHandleAttribute(EditedAttribute attribute, CustomAttributeValueEditingContext editContext)
Ask the custom editor if it wants to handle editing for a certain attribute in a certain context.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ro.sync.ecss.extensions.api.Extension
getDescription
-
-
-
-
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 aCancelledByUserException
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.
-
shouldHandleAttribute
public boolean shouldHandleAttribute(EditedAttribute attribute, CustomAttributeValueEditingContext editContext)
Ask the custom editor if it wants to handle editing for a certain attribute in a certain context.- Parameters:
attribute
- The attribute.editContext
- The context from the editing is invoked. Can beCustomAttributeValueEditingContext.ATTRIBUTES_TABLE_CELL_CONTEXT
orCustomAttributeValueEditingContext.CUSTOM_EDIT_BUTTON_CONTEXT
- Returns:
true
if this custom editor's "getAttributeValue" method should be invoked for that certain attribute.- Since:
- 21
-
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
-
-