⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moduleeditor.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/module/editor/ModuleEditor.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.module.editor;

import java.io.*;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.pde.internal.ui.editor.IModelUndoManager;
import org.eclipse.pde.internal.ui.editor.IPDEEditorPage;
import org.eclipse.ui.IEditorInput;

import com.webpump.ui.base.data.BaseModel;
import com.webpump.ui.base.gui.BaseEditor;
import com.webpump.ui.base.gui.BaseSourcePage;
import com.webpump.ui.base.gui.BaseUndoManager;
import com.webpump.ui.module.model.Model;
import com.webpump.ui.perspective.WebpumpIDEPlugin;
import com.webpump.ui.perspective.MacroResource;

/**
 * Class for Module Editor
 * 
 * @author shi_l
 * @version 2.0.0 2004-2-12
 */
public class ModuleEditor extends BaseEditor {

	/**The id of the modeling page*/
	public static String MODULE_PAGE_ID = WebpumpIDEPlugin.getResourceString(MacroResource.MODULEEDITOR_MODULE_PAGE_NAME);

	/**The id of the XML source page*/
	public static String SOURCE_PAGE_ID = WebpumpIDEPlugin.getResourceString(MacroResource.MODULEEDITOR_SOURCE_PAGE_NAME);

	/**
	 * create undo manager
	 * @return new BaseUndoManager IModelUndoManager
	 */
	protected IModelUndoManager createModelUndoManager() {
		return new BaseUndoManager(this);
	}

	/**
	 * Create resource model
	 * @param file
	 * @return model BaseModel
	 */
	protected BaseModel createResourceModel(IFile file) throws CoreException {
		
		this.m_objFile = file;
		Model model = WebpumpIDEPlugin.getModel(file, true);
		IEditorInput eInput = this.getEditorInput();
		//返回创建的Model
		return model;
	}

	/**
	 * Create storage model
	 * @param stroage
	 * @return model BaseModel
	 */
	protected BaseModel createStorageModel(IStorage storage) {
		InputStream stream = null;
		try {
			stream = storage.getContents();
		} catch (Exception e) {
			WebpumpIDEPlugin.log(e);
		}
		Model model = new Model();

		try {
			//载?,解析XML文?
			model.load(stream, false);
		} catch (Exception e) {
			WebpumpIDEPlugin.log(e);
		}
		try {
			stream.close();
		} catch (IOException e) {
			WebpumpIDEPlugin.log(e);
		}
		//返回创建的Model
		return model;
	}

	/**
	 * Create pages
	 */
	protected void createPages() {
		//创建建模页面和XML源代?页?
		firstPageId = MODULE_PAGE_ID;
		//设置首页的ID
		formWorkbook.setFirstPageSelected(false);
		//得到建模页面名称
		String modulePageName =
			WebpumpIDEPlugin.getResourceString(
				MacroResource.MODULEEDITOR_MODULE_PAGE_NAME);
		//得到源代?页面名称
		String sourcePageName =
			WebpumpIDEPlugin.getResourceString(
				MacroResource.MODULEEDITOR_SOURCE_PAGE_NAME);

		//将建模页面铁赜到编辑器中
		addPage(modulePageName, new ModulePage(this, modulePageName));
		//将源代?页面铁赜到编辑器中
		addPage(sourcePageName, new BaseSourcePage(this, sourcePageName));
	}

	/**
	 * Get home page
	 * @return module page IPDEEditorPage
	 */
	public IPDEEditorPage getHomePage() {
		//返回首页
		return getPage(MODULE_PAGE_ID);

	}

	/**
	 * Get source page id
	 * @return source page id String
	 */
	protected String getSourcePageId() {
		//返回源代?页面名称
		return SOURCE_PAGE_ID;

	}

	/**
	 * Get source page
	 * @return source page IPDEEditorPage
	 */
	protected IPDEEditorPage getSourcePage() {
		//返回源代?页?
		return getPage(MODULE_PAGE_ID);

	}

	/**
	 * set selection
	 * @param objArray
	 */
	public void setSelection(Object[] objArray) {
		IStructuredSelection selection = new StructuredSelection(objArray);
		super.setSelection(selection);
		getContributor().updateSelectableActions(selection);
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -