bindeditor.java
来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 1,701 行 · 第 1/5 页
JAVA
1,701 行
/*
* $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/bind/editors/BindEditor.java,v 1.2 2004/12/29 09:45:30 wang_j Exp $
* $Revision: 1.2 $
* $Date: 2004/12/29 09:45:30 $
*
* ====================================================================
*
* 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.editors;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.*;
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Vector;
import com.webpump.ui.module.model.Model;
import com.webpump.ui.module.model.Modules;
import com.webpump.ui.module.model.Page;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;
import com.webpump.ui.project.ProjectModel;
import com.webpump.ui.project.ProjectInfo;
import com.webpump.ui.project.SiteConfig;
import com.webpump.ui.wizard.FileUtil;
import com.webpump.ui.bind.data.*;
import com.webpump.ui.bind.listeners.*;
import com.webpump.ui.bind.action.*;
/**
* Class of the Bind Html Editor
* This editor has 4 pages:
* <ul>
* <li>page 0 contains a nested text editor: the HTML Editor.
* <li>page 1 contains a Table to deal with the bind paramter
* <li>page 2 to preview the document editted in page 0 in JSP style
* <li>page 3 to preview the bind parameters in the BindParameters.xml in a FORMBEAN style
* </ul>
* @author zhang_tx
* @version 2.0.0 2004-2-13
*/
public class BindEditor extends MultiPageEditorPart {
/** The text editor used in page 0. */
private XMLEditor editor;
/** The editor widget used in page 2. */
private StyledText jspeditor1;
private Text jsptext;
/** The editor widget used in page 2. */
private StyledText formbeaneditor1;
private Text formbeantext;
/** a action for binding all*/
private BindingAllAction m_objBindingAllAction;
/** a action for clearing all*/
private ClearAllAction m_objClearAllAction;
/** a action for removing a binding*/
private RemoveABindingAction m_objRemoveABindingAction;
/** a action for binding a mark*/
private BindingAMarkAction m_objBindingAMarkAction;
/** a menu manager of the m_objTable's pop up menus*/
private MenuManager contextMenu;
/** The temp content of JSPFilecontent used for JSP Preview and for writing the JSP files */
private String m_strJSPFileContent = "";
/** The head part of the jsp files which is used to contribute the jsp file's content */
private String m_strJSP_htmlheader = "";
/** The script part of the jsp files which is used to contribute the jsp file's content */
private String m_strJSP_htmlscript = "";
/** The style part of the jsp files which is used to contribute the jsp file's content */
private String m_strJSP_htmlstyle = "";
/** The body part of the jsp files which is used to contribute the jsp file's content */
private String m_strJSP_htmlbody = "";
/** The tailscript part of the jsp files which is used to contribute the jsp file's content */
private String m_strJSP_htmltail = "";
/** The part of customer bind method in the end of the jsp files which is used to contribute the jsp file's content */
private String m_strCustomBindMethod = "";
private String m_strCustomBindMethod_2 = "";
private String m_strCustomBindMethod_3 = "";
private String m_strCustomBindMethod_4 = "";
private String m_strCustomBindMethod_5 = "";
/** The temp content of FORMBEANFilecontent used for FORMBEAN Preview and for writing the FORMBEAN files */
private String m_strFORMFileContent = "";
/** The parameter define part of the formbean files which is used to contribute the formbean file's content */
private String m_strParamDefine = "";
/** The get method define part of the formbean files which is used to contribute the formbean file's content */
private String m_strGetMethod = "";
/** The set method define part of the formbean files which is used to contribute the formbean file's content */
private String m_strSetMethod = "";
/** The parameter reset define part of the formbean files which is used to contribute the formbean file's content */
private String m_strResetDefine = "";
private String m_strPageName = "";
/** the file of the document which is editted in the editor of page 0 */
private IFile m_objhtmlfile;
private String m_strModuleFolder = "";
private IProject m_objproject;
private Table m_objTable;
/** the file of the ParametersBind.xml which contains all the binded parameters */
public File m_objxmlfile;
/** data model of all htmlpages */
private BindParaModel m_objBindParaModel;
/** the data object of this htmlpage */
private HtmlPage m_objHtmlPage = null;
private IPath m_objProjectPath = null;
private String m_Charset = "";
/**
* Creates a multi-page editor example.
*/
public BindEditor() {
super();
}
/**
* create page 0 of the BindEditor
*
*/
void createPage0() {
try {
editor = new XMLEditor();
int index = addPage(editor, getEditorInput());
setPageText(index, WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_PAGE0_NAME));
IEditorInput input = editor.getEditorInput();
editor.getDocumentProvider().getDocument(input).addDocumentListener(new HTMLDocumentAdapter(this));
// editor.getSourceView().getTextWidget().addKeyListener(new DelKeyListener(this));
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested text editor",
null,
e.getStatus());
}
}
/**
* create page 1 of the BindEditor
* which allows user to deal with the bind paramters in the document of page 0
*
*/
void createPage1() {
Composite composite = new Composite(getContainer(), SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.marginHeight = 0;
composite.setLayout(gridLayout_1);
{
m_objTable = new Table(composite, SWT.FULL_SELECTION|SWT.V_SCROLL|SWT.BORDER);
final GridData gridData = new GridData(GridData.FILL_BOTH);
m_objTable.setLayoutData(gridData);
m_objTable.setLinesVisible(true);
m_objTable.setHeaderVisible(true);
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_RANGE_NAME));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_OBJECT_NAME));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_TYPE));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_VARIABLE_NAME));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_MODIFIER));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_VARIABLE_TYPE));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_DEFAULT_VALUE));
}
{
final TableColumn tableColumn = new TableColumn(m_objTable, SWT.NONE);
tableColumn.setWidth(80);
tableColumn.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_DESCRIPTION));
}
}
m_objTable.addMouseListener(new TableMouseAdapter(this));
makeActions();
//add a pop up menu to the table
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fillContextMenu(manager);
}
});
Menu menu = menuMgr.createContextMenu(m_objTable);
m_objTable.setMenu(menu);
int index = addPage(composite);
setPageText(index, WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_PAGE1_NAME));
}
/**
* Add the actions to the menu
* @param menu
*/
public void fillContextMenu(IMenuManager menu) {
menu.add(m_objBindingAMarkAction);
menu.add(m_objRemoveABindingAction);
menu.add(m_objBindingAllAction);
menu.add(m_objClearAllAction);
}
/**
* Make actions
*
*/
public void makeActions() {
//binding all action
m_objBindingAllAction = new BindingAllAction(this, MacroResource.BINDEDITOR_BINDING_ALL_ID);
m_objBindingAllAction.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_BINDING_ALL));
m_objBindingAllAction.setToolTipText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_BINDING_ALL));
m_objBindingAllAction.setEnabled(true);
// clear all action
m_objClearAllAction = new ClearAllAction(this, MacroResource.BINDEDITOR_CLEAR_ALL_ID);
m_objClearAllAction.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_CLEAR_ALL));
m_objClearAllAction.setToolTipText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_CLEAR_ALL));
m_objClearAllAction.setEnabled(true);
//remove a binding action
m_objRemoveABindingAction = new RemoveABindingAction(this, MacroResource.BINDEDITOR_REMOVE_A_BINDING_ID);
m_objRemoveABindingAction.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_REMOVE_A_BINDING));
m_objRemoveABindingAction.setToolTipText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_REMOVE_A_BINDING));
m_objRemoveABindingAction.setEnabled(true);
// binding a mark action
m_objBindingAMarkAction = new BindingAMarkAction(this, MacroResource.BINDEDITOR_BINDING_A_MARK_ID);
m_objBindingAMarkAction.setText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_BINDING_A_MARK));
m_objBindingAMarkAction.setToolTipText(WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_BINDING_A_MARK));
m_objBindingAMarkAction.setEnabled(true);
}
/**
* create page 2 of the BindEditor
* which will display the information of page 0 in the jsp file style
*
*/
void createPage2() {
Composite composite = new Composite(getContainer(), SWT.NONE);
FillLayout layout = new FillLayout();
composite.setLayout(layout);
jsptext = new Text(composite, SWT.BORDER | SWT.MULTI|SWT.V_SCROLL|SWT.FLAT);
int index = addPage(composite);
setPageText(index, WebpumpIDEPlugin.getResourceString(MacroResource.BINDEDITOR_PAGE2_NAME));
}
/**
* create page 3 of the BindEditor
* which will display the information of page 0 in the formbean file style
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?