bindallerror.java
来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 94 行
JAVA
94 行
/*
* $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/bind/action/BindAllError.java,v 1.1.1.1 2004/07/01 09:07:40 wang_j Exp $
* $Revision: 1.1.1.1 $
* $Date: 2004/07/01 09:07:40 $
*
* ====================================================================
*
* The NanJing HopeRun(IT-FOREST) Software License, Version 2.0.0
*
* Copyright 2003-2004 by NanJing HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and
* IT Forest Corporation
* All rights reserved.
*
* This software is the confidential and proprietary information of
* HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
* You shall not disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into with
* HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
*/
package com.webpump.ui.bind.action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import com.webpump.ui.bind.editors.BindEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.IEditorInput;
import com.webpump.ui.bind.editors.XMLEditor;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;
/**
* Class for the action of BindAllError which is contributed to the BindEditor.
*
* @author zhang_tx
* @version 2.0.0 2004-2-13
*/
public class BindAllError implements IEditorActionDelegate{
/** the editor to which is this action contributed */
private BindEditor m_objeditor;
/**
* set the active BindEditor to which the action is now contributed
*
* @param IAction aciton the action object itself
* @param IEditorPart targetEditor the editor to which is this action contributed
*/
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
m_objeditor = (targetEditor instanceof BindEditor) ? (BindEditor) targetEditor : null;
}
/**
* method which will be called when the action's UI button is clicked by the user
*
* @param IAction aciton the action object itself
*/
public void run(IAction action) {
/** the member editor of the editor which is editted by the user */
XMLEditor xmleditor = null;
/** to get the xmleditor object */
if (m_objeditor!=null)
xmleditor = m_objeditor.getXMLEditor();
String fileName = m_objeditor.getHtmlIFile().getFullPath().lastSegment();
int index = fileName.indexOf(".");
fileName = fileName.substring(0,index);
if(xmleditor!=null){
/** to get the document of the xmleditor */
IDocumentProvider provider= ((ITextEditor) xmleditor).getDocumentProvider();
IEditorInput input = xmleditor.getEditorInput();
IDocument document = provider.getDocument(input);
/** to get the cursorposition in the xmleditor */
TextSelection selectedText =
(TextSelection)xmleditor.getEditorSite().getSelectionProvider().getSelection();
String strSelectedText = selectedText.getText();
//cursorposition
int cursorpos = selectedText.getOffset();
int sellen = strSelectedText.length();
/** the text which is now editted in the xmleditor */
String editorText =
xmleditor.getDocumentProvider().getDocument(m_objeditor.getEditorInput()).get();
/**判断是否可以插
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?