本文整理汇总了Java中ro.sync.exml.workspace.api.editor.WSEditor类的典型用法代码示例。如果您正苦于以下问题:Java WSEditor类的具体用法?Java WSEditor怎么用?Java WSEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WSEditor类属于ro.sync.exml.workspace.api.editor包,在下文中一共展示了WSEditor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:axxepta,项目名称:project-argon,代码行数:25,代码来源:WorkspaceUtils.java
示例2: saveEditorToBaseXURL
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
/**
* Store the content of an editor editorAccess to a BaseX resource url. Checks for encoding in prologue and byte code,
* if none can be obtained assumes UTF-8 encoding.
* @param editorAccess editor handle
* @param url BaseX target url
* @throws IOException BaseX connection can return exception
*/
public static void saveEditorToBaseXURL(WSEditor editorAccess, URL url) throws IOException {
byte[] content = WorkspaceUtils.getEditorContent(editorAccess);
String[] encodingString = WorkspaceUtils.editorStringEncoding(editorAccess);
if (encodingString[0].equals(""))
encodingString[0] = XMLUtils.encodingFromBytes(content);
if (!URLUtils.isXML(url) && (URLUtils.isBinary(url) || !IOUtils.isXML(content))) {
ConnectionWrapper.save(true, url, content);
} else {
switch (encodingString[0]) {
case "": {
ConnectionWrapper.save(url, IOUtils.returnUTF8Array(encodingString[1]), "UTF-8");
break;
}
case "UTF-8": {
ConnectionWrapper.save(url, content, "UTF-8");
break;
}
default:
ConnectionWrapper.save(url, IOUtils.convertToUTF8(content, encodingString[0]), encodingString[0]);
}
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:30,代码来源:WorkspaceUtils.java
示例3: selectURLs
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
private URL[] selectURLs() {
final URL[] urls = new URL[2];
int[] selection = table.getSelectedRows();
// if only one revision row is selected, it is compared to the last (current) one
if (selection.length == 1) {
int rows = table.getModel().getRowCount();
urls[0] = ((VersionHistoryTableModel) table.getModel()).getURL(0);
urls[1] = ((VersionHistoryTableModel) table.getModel()).getURL(selection[0]);
WSEditor editorAccess = PluginWorkspaceProvider.getPluginWorkspace().
getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
/* if (editorAccess.isModified())
JOptionPane.showMessageDialog(null, "The content in the editor was changed.\n" +
"Save first to compare with current content.", "Compare File Revisions", JOptionPane.PLAIN_MESSAGE);*/
if (editorAccess.isModified()) { // take current version editor instead
editorAccess.save();
urls[0] = editorAccess.getEditorLocation();
}
} else {
urls[0] = ((VersionHistoryTableModel) table.getModel()).getURL(selection[1]);
urls[1] = ((VersionHistoryTableModel) table.getModel()).getURL(selection[0]);
}
return urls;
}
开发者ID:axxepta,项目名称:project-argon,代码行数:24,代码来源:CompareVersionsAction.java
示例4: getContentAndExtractExtVars
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
private static String[] getContentAndExtractExtVars(WSEditor editorAccess, StringBuilder content) {
List<String> extVars = new ArrayList<>();
MutableBoolean inComment = new MutableBoolean(false);
try (InputStream editorStream = editorAccess.createContentInputStream()) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(editorStream))) {
String line;
while ((line = reader.readLine()) != null) {
extractVarFromLine(extVars, line, inComment);
content.append(line).append("\n");
}
}
} catch (IOException ioe) {
logger.error("Failed extracting editor content: ", ioe.getMessage());
}
return extVars.toArray(new String[extVars.size()]);
}
开发者ID:axxepta,项目名称:project-argon,代码行数:17,代码来源:BaseXRunQueryAction.java
示例5: actionPerformed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
WSEditor editorAccess = workspace.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
URL url = editorAccess.getEditorLocation();
if (url.toString().startsWith(ArgonConst.ARGON)) {
String protocol = CustomProtocolURLHandlerExtension.protocolFromURL(url);
CustomProtocolURLHandlerExtension handlerExtension = new CustomProtocolURLHandlerExtension();
if (handlerExtension.canCheckReadOnly(protocol) && !handlerExtension.isReadOnly(url)) {
byte[] outputArray = WorkspaceUtils.getEditorByteContent(editorAccess);
WorkspaceUtils.setCursor(WorkspaceUtils.WAIT_CURSOR);
String encoding = ArgonEditorsWatchMap.getInstance().getEncoding(url);
if (!encoding.equals("UTF-8"))
outputArray = IOUtils.convertToUTF8(outputArray, encoding);
updateFile(url, outputArray, encoding);
WorkspaceUtils.setCursor(WorkspaceUtils.DEFAULT_CURSOR);
} else {
workspace.showInformationMessage(Lang.get(Lang.Keys.msg_noupdate1) + " " + url.toString() + ".\n" +
Lang.get(Lang.Keys.msg_noupdate2));
}
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:22,代码来源:NewVersionAction.java
示例6: checkIn
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
static void checkIn(URL url) {
BaseXSource source = CustomProtocolURLHandlerExtension.sourceFromURL(url);
String path = CustomProtocolURLHandlerExtension.pathFromURL(url);
try (Connection connection = BaseXConnectionWrapper.getConnection()) {
if (connection.lockedByUser(source, path)) {
WSEditor editorAccess = PluginWorkspaceProvider.getPluginWorkspace().
getEditorAccess(url, StandalonePluginWorkspace.MAIN_EDITING_AREA);
ArgonEditorsWatchMap.getInstance().setAskedForCheckIn(url, true);
if (editorAccess != null)
editorAccess.close(true);
connection.unlock(source, path);
}
} catch (IOException ex) {
logger.debug(ex);
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:17,代码来源:CheckInAction.java
示例7: editorOpened
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void editorOpened(URL editorLocation) {
logger.debug("editor opened: " + editorLocation.toString());
if (editorLocation.toString().startsWith(ArgonConst.ARGON))
ArgonEditorsWatchMap.getInstance().addURL(editorLocation);
checkEditorDependentMenuButtonStatus(pluginWorkspaceAccess);
TopicHolder.changedEditorStatus.postMessage(VersionHistoryUpdater.checkVersionHistory(editorLocation));
customizeEditorPopupMenu();
final WSEditor editorAccess = pluginWorkspaceAccess.getEditorAccess(editorLocation, PluginWorkspace.MAIN_EDITING_AREA);
boolean isArgon = URLUtils.isArgon(editorLocation);
if (isArgon)
editorAccess.addEditorListener(new ArgonEditorListener(pluginWorkspaceAccess));
if (isArgon && URLUtils.isQuery(editorLocation))
editorAccess.addValidationProblemsFilter(new ArgonValidationProblemsFilter(editorAccess));
}
开发者ID:axxepta,项目名称:project-argon,代码行数:20,代码来源:ArgonEditorChangeListener.java
示例8: checkEditorDependentMenuButtonStatus
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
private void checkEditorDependentMenuButtonStatus(PluginWorkspace pluginWorkspaceAccess){
WSEditor currentEditor = pluginWorkspaceAccess.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if(currentEditor == null) {
runQueryButton.setEnabled(false);
newVersionButton.setEnabled(false);
saveToArgonButton.setEnabled(false);
} else {
saveToArgonButton.setEnabled(true);
URL url = currentEditor.getEditorLocation();
if (URLUtils.isArgon(url)) {
newVersionButton.setEnabled(true);
} else {
newVersionButton.setEnabled(false);
}
if (URLUtils.isQuery(currentEditor.getEditorLocation())) {
runQueryButton.setEnabled(true);
} else {
runQueryButton.setEnabled(false);
}
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:23,代码来源:ArgonEditorChangeListener.java
示例9: editorClosed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void editorClosed(URL path) {
// TODO Auto-generated method stub
super.editorClosed(path);
if (path != null) {
editors.remove(path);
openOrderMap.remove(path);
if(editorByUrl.containsKey(path)){
WSEditor editor = editorByUrl.get(path);
this.closedEditor.add(editor);
if(closedEditor.size() > 50){
closedEditor.remove(0);
}
}
updateEditors();
}
}
开发者ID:nkutsche,项目名称:opendocs,代码行数:18,代码来源:DocViewer.java
示例10: customizePopUpMenu
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void customizePopUpMenu(Object popUp, WSTextEditorPage textPage) {
Object textComponent = textPage.getTextComponent();
if (textComponent instanceof JTextArea) {
int caretOffset = textPage.getCaretOffset();
WSEditor editorAccess = pluginWorkspaceAccess.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
HighlightData highlightData = perEditorHighlightData.get(editorAccess);
HighlightInfo hInfo = highlightData.getInfoForCaretOrNull(caretOffset);
if (hInfo != null) {
RuleMatch match = hInfo.ruleMatch;
replaceMenuItems((JPopupMenu) popUp, match, new TextModeApplyReplacementAction(match, textPage, highlightData, editorAccess));
}
} else {
System.err.println("textComponent not of type JTextArea: " + textComponent.getClass().getName());
}
}
开发者ID:danielnaber,项目名称:oxygen-languagetool-plugin,代码行数:17,代码来源:LanguageToolPluginExtension.java
示例11: 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();
}
}
开发者ID:danielnaber,项目名称:oxygen-languagetool-plugin,代码行数:21,代码来源:LanguageToolPluginExtension.java
示例12: 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"));
}
开发者ID:richard-strauss-werke,项目名称:glyphpicker,代码行数:26,代码来源:GlyphPickerPluginExtension.java
示例13: getEditorContent
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
private static byte[] getEditorContent(WSEditor editorAccess) throws IOException {
byte[] content;
try (InputStream contentStream = editorAccess.createContentInputStream()) {
content = IOUtils.getBytesFromInputStream(contentStream);
} catch (IOException ie) {
logger.error(ie);
content = new byte[0];
}
return content;
}
开发者ID:axxepta,项目名称:project-argon,代码行数:11,代码来源:WorkspaceUtils.java
示例14: 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;
}
开发者ID:axxepta,项目名称:project-argon,代码行数:14,代码来源:WorkspaceUtils.java
示例15: actionPerformed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent arg0) {
WSEditor editorAccess = workspace.getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
if (URLUtils.isQuery(editorAccess.getEditorLocation())) {
StringBuilder contentBuilder = new StringBuilder();
String[] parameterNames = getContentAndExtractExtVars(editorAccess, contentBuilder);
String editorContent = contentBuilder.toString();
String[] arguments;
if (parameterNames.length > 0) {
List<String> argumentList = askForArguments(parameterNames);
if (argumentList.size() == 0)
return;
arguments = argumentList.toArray(new String[argumentList.size()]);
} else
arguments = new String[0];
String queryRes;
try {
queryRes = ConnectionWrapper.query(editorContent, arguments);
} catch (Exception er) {
logger.error("query to BaseX failed");
queryRes = "";
}
workspace.createNewEditor("xml", ContentTypes.XML_CONTENT_TYPE, queryRes);
} else {
workspace.showInformationMessage(Lang.get(Lang.Keys.msg_noquery));
}
} else {
workspace.showInformationMessage(Lang.get(Lang.Keys.msg_noeditor));
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:39,代码来源:BaseXRunQueryAction.java
示例16: actionPerformed
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
ArgonChooserDialog urlChooser = new ArgonChooserDialog((Frame)workspace.getParentFrame(),
Lang.get(Lang.Keys.dlg_saveas), ArgonChooserDialog.Type.SAVE);
URL[] url = urlChooser.selectURLs();
WSEditor editorAccess = workspace.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (url != null) {
BaseXSource source = CustomProtocolURLHandlerExtension.sourceFromURL(url[0]);
String path = CustomProtocolURLHandlerExtension.pathFromURL(url[0]);
if (WorkspaceUtils.newResourceOrOverwrite(source, path)) {
if (!ConnectionWrapper.isLocked(source, path)) {
try {
WorkspaceUtils.setCursor(WorkspaceUtils.WAIT_CURSOR);
ConnectionWrapper.lock(source, path);
WorkspaceUtils.saveEditorToBaseXURL(editorAccess, url[0]);
editorAccess.close(false);
workspace.open(url[0]);
WorkspaceUtils.setCursor(WorkspaceUtils.DEFAULT_CURSOR);
} catch (IOException ioe) {
WorkspaceUtils.setCursor(WorkspaceUtils.DEFAULT_CURSOR);
workspace.showErrorMessage(Lang.get(Lang.Keys.warn_resource) + " " + url[0].toString()
+ " " + Lang.get(Lang.Keys.warn_storing) + ": " + ioe.getMessage());
}
} else {
workspace.showInformationMessage(Lang.get(Lang.Keys.warn_resource) + " " + url[0].toString() +
" " + Lang.get(Lang.Keys.warn_locked));
}
}
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:33,代码来源:SaveFileToArgonAction.java
示例17: 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);
}
开发者ID:axxepta,项目名称:project-argon,代码行数:34,代码来源:StoreSnippetSelectionAction.java
示例18: 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));
}
}
}
开发者ID:axxepta,项目名称:project-argon,代码行数:11,代码来源:DitaMapManagerChangeListener.java
示例19: 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;
}
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:11,代码来源:ConbatStylesFilter.java
示例20: getCloseAL
import ro.sync.exml.workspace.api.editor.WSEditor; //导入依赖的package包/类
public ActionListener getCloseAL(final int askForSave){
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
for (EditorItem item : EditorPanel.this.getSelectedItem()) {
if(!item.isClosed()){
WSEditor wse = EditorPanel.this.spw.getEditorAccess(item.getEditorNode().getUrl(), StandalonePluginWorkspace.MAIN_EDITING_AREA);
if(wse == null){
continue;
}
switch (askForSave) {
case CLOSE_WITH_SAVE:
wse.save();
wse.close(true);
break;
case CLOSE_WO_SAVE:
wse.close(false);
break;
default:
wse.close(true);
break;
}
}
// EditorPanel.this.spw.getEditorAccess(item.getEditorNode().getUrl(), 0).cl
}
}
};
}
开发者ID:nkutsche,项目名称:opendocs,代码行数:29,代码来源:EditorPanel.java
注:本文中的ro.sync.exml.workspace.api.editor.WSEditor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论