当前位置: 首页>>代码示例>>Java>>正文


Java WSEditor类代码示例

本文整理汇总了Java中ro.sync.exml.workspace.api.editor.WSEditor的典型用法代码示例。如果您正苦于以下问题:Java WSEditor类的具体用法?Java WSEditor怎么用?Java WSEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WSEditor类属于ro.sync.exml.workspace.api.editor包,在下文中一共展示了WSEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ro.sync.exml.workspace.api.editor.WSEditor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。