Interface ContentCompletionManager
-
@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface ContentCompletionManager
This class offers support for actions with content completion such as: insert element, surround with tags and rename element. For every action we have two methods: one that returns a list of proposals to be presented to the user and another one that performs the action based on the user choice. Users of the API will typically show a dialog with the proposals and after the user selects one of the call the second method to finish the action.- Since:
- 15.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
executeAction(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel)
Inserts an element from content completion which is provided from a custom content completion action.void
executeInsert(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel)
Executes the insert element action.void
executeInsertInvalid(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel)
Inserts an element from content completion which is invalid at the caret position.void
executeNewLine(AuthorSelectionAndCaretModel selectionModel)
Executes a new line insertion.void
executeRename(AuthorSelectionAndCaretModel selectionModel, CCItemProxy ccItem)
Executes the rename operation.void
executeSplit(AuthorSelectionAndCaretModel selectionModel)
Splits the element at current caret offset.void
executeSplit(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel)
Splits the element chosen by the user.void
executeSurround(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel)
Surrounds the current selection with an element that has the specified render string and type as chosen by the user/java.util.List<CCItemProxy>
getAllPossibleElementsForInsert()
Returns all possible elements defined by the schema, including those that are not valid to be inserted at the caret position.CCItemProxy
getNewLineProposal(AuthorSelectionAndCaretModel selectionModel)
If the selection/caret is inside a space preserve content it will return a proposal for inserting a new line.java.util.List<CCItemProxy>
getProposedElementsForInsert(AuthorSelectionAndCaretModel selectionModel)
Returns the proposals for element insertions at the current offset.java.util.List<CCItemProxy>
getProposedElementsForRename(AuthorSelectionAndCaretModel selectionModel)
Returns the proposals for renaming.java.util.List<CCItemProxy>
getProposedElementsForSurround(AuthorSelectionAndCaretModel selectionModel)
Returns the proposals for a tag to surround the current selection with.java.util.List<CCItemProxy>
getProposedElementsToSplit(AuthorSelectionAndCaretModel selectionModel)
Returns the block elements around the caret position that can be split.
-
-
-
Method Detail
-
getProposedElementsForInsert
java.util.List<CCItemProxy> getProposedElementsForInsert(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
Returns the proposals for element insertions at the current offset.- Parameters:
selectionModel
- The selection and caret model of the document.- Returns:
- The proposals for element insertions at the current offset.
- Throws:
javax.swing.text.BadLocationException
-
getAllPossibleElementsForInsert
java.util.List<CCItemProxy> getAllPossibleElementsForInsert()
Returns all possible elements defined by the schema, including those that are not valid to be inserted at the caret position.- Returns:
- The list of all possible elements.
-
executeInsert
void executeInsert(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException, ItemNotFoundException
Executes the insert element action.- Parameters:
ccItem
- The content completion item chosen by the user.selectionModel
- The selection and caret model of the document.- Throws:
javax.swing.text.BadLocationException
ItemNotFoundException
-
getProposedElementsForRename
java.util.List<CCItemProxy> getProposedElementsForRename(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
Returns the proposals for renaming.- Parameters:
selectionModel
- The selection and caret model of the document. The selection should be either collapsed, or an entire element should be selected.- Returns:
- The proposed elements for rename.
- Throws:
javax.swing.text.BadLocationException
- If the selection does not comply with the restrictions above.
-
executeRename
void executeRename(AuthorSelectionAndCaretModel selectionModel, CCItemProxy ccItem) throws javax.swing.text.BadLocationException
Executes the rename operation.- Parameters:
selectionModel
- The selection and caret model of the document.ccItem
- The content completion item chosen for rename.- Throws:
javax.swing.text.BadLocationException
-
executeNewLine
void executeNewLine(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
Executes a new line insertion.- Parameters:
selectionModel
- The selection and caret model of the document.- Throws:
javax.swing.text.BadLocationException
-
getProposedElementsForSurround
java.util.List<CCItemProxy> getProposedElementsForSurround(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
Returns the proposals for a tag to surround the current selection with.- Parameters:
selectionModel
- The selection and caret model of the document.- Returns:
- The list of proposals.
- Throws:
javax.swing.text.BadLocationException
-
executeSurround
void executeSurround(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException, ItemNotFoundException
Surrounds the current selection with an element that has the specified render string and type as chosen by the user/- Parameters:
ccItem
- The content completion item chosen by the user.selectionModel
- The selection and caret model of the document.- Throws:
javax.swing.text.BadLocationException
ItemNotFoundException
-
getProposedElementsToSplit
java.util.List<CCItemProxy> getProposedElementsToSplit(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
Returns the block elements around the caret position that can be split.- Parameters:
selectionModel
- The selection and caret model of the document.- Returns:
- The list of block elements that can be split.
- Throws:
javax.swing.text.BadLocationException
-
executeSplit
void executeSplit(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException, ItemNotFoundException
Splits the element chosen by the user.- Parameters:
ccItem
- The element chosen by the user.selectionModel
- The selection model of the document.- Throws:
javax.swing.text.BadLocationException
ItemNotFoundException
-
executeSplit
void executeSplit(AuthorSelectionAndCaretModel selectionModel)
Splits the element at current caret offset.- Parameters:
selectionModel
- The selection and caret model of the document.- Since:
- 19
-
getNewLineProposal
CCItemProxy getNewLineProposal(AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException
If the selection/caret is inside a space preserve content it will return a proposal for inserting a new line.- Parameters:
selectionModel
- Selection and caret model.- Returns:
- A new line insertion proposal or
null
if the caret is not in a space preserve context. - Throws:
javax.swing.text.BadLocationException
- Bad offsets.
-
executeInsertInvalid
void executeInsertInvalid(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException, ItemNotFoundException
Inserts an element from content completion which is invalid at the caret position. Some schema aware strategies will be employed to find a good position to insert the element.- Parameters:
ccItem
- The selected element.selectionModel
- The selection.- Throws:
javax.swing.text.BadLocationException
ItemNotFoundException
-
executeAction
void executeAction(CCItemProxy ccItem, AuthorSelectionAndCaretModel selectionModel) throws javax.swing.text.BadLocationException, ItemNotFoundException
Inserts an element from content completion which is provided from a custom content completion action.- Parameters:
ccItem
- The selected element.selectionModel
- The selection.- Throws:
javax.swing.text.BadLocationException
ItemNotFoundException
- Since:
- 19
-
-