本文整理汇总了Java中ro.sync.exml.workspace.api.editor.WSEditor.getCurrentPage方法的典型用法代码示例。如果您正苦于以下问题:Java WSEditor.getCurrentPage方法的具体用法?Java WSEditor.getCurrentPage怎么用?Java WSEditor.getCurrentPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ro.sync.exml.workspace.api.editor.WSEditor
的用法示例。
在下文中一共展示了WSEditor.getCurrentPage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editorStringEncoding
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
/**
* Extracts encoding from XML prologue in editor string content and the String content as second element,
* returns empty string as first element if no prologue is found.
* @param editorAccess editor handle
* @return encoding encoding and editor content as String array, empty if no encoding could be extracted
*/
private static String[] editorStringEncoding(WSEditor editorAccess) {
String encodingString[] = new String[2];
String pageID = editorAccess.getCurrentPageID();
if (!pageID.equals(EditorPageConstants.PAGE_TEXT))
editorAccess.changePage(EditorPageConstants.PAGE_TEXT);
WSTextEditorPage textPage = (WSTextEditorPage)editorAccess.getCurrentPage();
Document doc = textPage.getDocument();
if (!pageID.equals(EditorPageConstants.PAGE_TEXT))
editorAccess.changePage(pageID);
try {
encodingString[1] = doc.getText(0, doc.getLength());
encodingString[0] = XMLUtils.encodingFromPrologue(encodingString[1]);
} catch (BadLocationException ex) {
logger.error(ex);
encodingString[0] = "";
}
return encodingString;
}
示例2: actionPerformed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
@Override
public void actionPerformed(@NotNull ActionEvent event) {
WSEditor editorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
WSAuthorEditorPage authorPageAccess = (WSAuthorEditorPage) editorAccess.getCurrentPage();
AuthorDocumentController controller = authorPageAccess.getDocumentController();
controller.beginCompoundEdit();
try {
boolean deleted = controller.delete(match.getOxygenOffsetStart(), match.getOxygenOffsetEnd());
if (!deleted) {
System.err.println("Could not delete text for match " + match);
} else {
AuthorHighlighter highlighter = authorAccess.getEditorAccess().getHighlighter();
highlighter.removeAllHighlights();
controller.insertText(match.getOxygenOffsetStart(), event.getActionCommand());
checkTextInBackground(highlighter, authorPageAccess);
}
} finally {
controller.endCompoundEdit();
}
}
示例3: insertFragment
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
/**
* Inserts a text fragment into a text or author editor pane.
*
* @param workspace oXygen's plugin workspace
* @param d the glyph definition
*/
private void insertFragment(StandalonePluginWorkspace workspace,
GlyphDefinition d) {
WSEditor editorAccess = workspace.getCurrentEditorAccess(
PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
WSEditorPage currentPage = editorAccess.getCurrentPage();
if (currentPage instanceof WSTextEditorPage) {
insertIntoTextEditorPage(d.getXmlString(), (WSTextEditorPage) currentPage);
transferFocus();
return;
} else if (currentPage instanceof WSAuthorEditorPage) {
insertIntoAuthorPage(d.getXmlString(), (WSAuthorEditorPage) currentPage);
transferFocus();
return;
}
}
workspace.showErrorMessage(getI18n().getString("GlyphPickerPluginExtension.noEditorFound"));
}
示例4: getDocumentFromEditor
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
public static Document getDocumentFromEditor(WSEditor editorAccess) {
boolean editorInAuthorMode = false;
if (editorAccess.getCurrentPageID().equals(EditorPageConstants.PAGE_AUTHOR)) {
editorInAuthorMode = true;
editorAccess.changePage(EditorPageConstants.PAGE_TEXT);
}
WSTextEditorPage textPage = (WSTextEditorPage)editorAccess.getCurrentPage();
Document doc = textPage.getDocument();
if (editorInAuthorMode) {
editorAccess.changePage(EditorPageConstants.PAGE_AUTHOR);
}
return doc;
}
示例5: actionPerformed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
String selection = "";
WSEditor editorAccess = workspace.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess.getCurrentPageID().equals(EditorPageConstants.PAGE_AUTHOR)) {
WSEditorPage editorPage = editorAccess.getCurrentPage();
AuthorAccess authorAccess = ((WSAuthorEditorPage) editorPage).getAuthorAccess();
//selection = authorAccess.getEditorAccess().getSelectedText();
WSAuthorEditorPageBase baseAccess = authorAccess.getEditorAccess();
int[] nodeSelection = baseAccess.
getBalancedSelection(baseAccess.getBalancedSelectionStart(), baseAccess.getBalancedSelectionEnd());
AuthorParentNode selectedNode = (AuthorParentNode) baseAccess.
getFullySelectedNode(nodeSelection[0], nodeSelection[1]);
try {
selection = getAuthorText(((WSAuthorEditorPage) editorPage).getDocumentController(), selectedNode, 0);
} catch (BadLocationException ble) {
logger.error("Error while parsing XML from AuthorPage selection: ", ble.getMessage());
}
} else if (editorAccess.getCurrentPageID().equals(EditorPageConstants.PAGE_TEXT)) {
WSTextEditorPage textPage = (WSTextEditorPage)editorAccess.getCurrentPage();
selection = textPage.getSelectedText();
} else return;
String[] buttons = {Lang.get(Lang.Keys.cm_tofile), Lang.get(Lang.Keys.cm_todb), Lang.get(Lang.Keys.cm_cancel)};
int[] responseIDs = { 0, 1, -1};
int saveTo = workspace.showConfirmDialog(Lang.get(Lang.Keys.dlg_snippet), Lang.get(Lang.Keys.lbl_snippet), buttons, responseIDs, 0);
if (saveTo == -1)
return;
if (saveTo == 0)
saveToFile(selection);
else
saveToArgon(selection);
}
示例6: customizeEditorPopupMenu
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
private void customizeEditorPopupMenu() {
WSEditor editorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.DITA_MAPS_EDITING_AREA);
if (editorAccess != null) {
if (EditorPageConstants.PAGE_DITA_MAP.equals(editorAccess.getCurrentPageID())) {
WSDITAMapEditorPage currentCustomizedDitaPageAccess;
currentCustomizedDitaPageAccess = (WSDITAMapEditorPage) editorAccess.getCurrentPage();
currentCustomizedDitaPageAccess.setPopUpMenuCustomizer(new ArgonDitaPopupMenuCustomizer(currentCustomizedDitaPageAccess));
}
}
}
示例7: getAuthorAccess
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
private static AuthorAccess getAuthorAccess() {
WSEditor editorAccess = PluginWorkspaceProvider.getPluginWorkspace().getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
WSEditorPage currentPage = editorAccess.getCurrentPage();
if (currentPage instanceof WSAuthorEditorPage) {
return ((WSAuthorEditorPage)currentPage).getAuthorAccess();
}
}
return null;
}
示例8: createShowSelectionAction
import ro.sync.exml.workspace.api.editor.WSEditor; //导入方法依赖的package包/类
/**
* Create the Swing action which shows the current selection.
*
* @param pluginWorkspaceAccess The plugin workspace access.
* @return The "Show Selection" action
*/
@SuppressWarnings("serial")
private AbstractAction createShowSelectionAction(
final StandalonePluginWorkspace pluginWorkspaceAccess) {
return new AbstractAction("Show Selection") {
@Override
public void actionPerformed(ActionEvent actionevent) {
//Get the current opened XML document
WSEditor editorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
// The action is available only in Author mode.
if(editorAccess != null){
if (EditorPageConstants.PAGE_AUTHOR.equals(editorAccess.getCurrentPageID())) {
WSAuthorEditorPage authorPageAccess = (WSAuthorEditorPage) editorAccess.getCurrentPage();
AuthorDocumentController controller = authorPageAccess.getDocumentController();
if (authorPageAccess.hasSelection()) {
AuthorDocumentFragment selectionFragment;
try {
// Create fragment from selection
selectionFragment = controller.createDocumentFragment(
authorPageAccess.getSelectionStart(),
authorPageAccess.getSelectionEnd() - 1
);
// Serialize
String serializeFragmentToXML = controller.serializeFragmentToXML(selectionFragment);
// Show fragment
pluginWorkspaceAccess.showInformationMessage(serializeFragmentToXML);
} catch (BadLocationException e) {
pluginWorkspaceAccess.showErrorMessage("Show Selection Source operation failed: " + e.getMessage());
}
} else {
// No selection
pluginWorkspaceAccess.showInformationMessage("No selection available.");
}
} else if (EditorPageConstants.PAGE_TEXT.equals(editorAccess.getCurrentPageID())) {
WSTextEditorPage textPage = (WSTextEditorPage) editorAccess.getCurrentPage();
if (textPage.hasSelection()) {
pluginWorkspaceAccess.showInformationMessage(textPage.getSelectedText());
} else {
// No selection
pluginWorkspaceAccess.showInformationMessage("No selection available.");
}
}
}
}
};
}
开发者ID:oxygenxml,项目名称:sample-plugin-workspace-access,代码行数:52,代码来源:CustomWorkspaceAccessPluginExtension.java