exceptioneditor.java

来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 184 行

JAVA
184
字号
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/exception/ExceptionEditor.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.exception;



import java.io.*;

import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.pde.internal.ui.PDEPlugin;
import org.eclipse.pde.internal.ui.editor.*;

import com.webpump.ui.exception.data.*;
import com.webpump.ui.module.model.Model;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;
import com.webpump.ui.base.gui.*;
import com.webpump.ui.base.data.*;

/**
 * Class for the exception editor.
 * 
 * @author zhao_f
 * @version 2.0.0 2004-2-13
 */
public class ExceptionEditor extends BaseEditor
{
	/** A project which contains the resource file*/
	private IProject m_objProject;
	private String m_strPrefix;
	
	/**
	 * The Constructor which initiate this editor using the constructor of its parent.
	 */
	public ExceptionEditor() {
			super();
	}

    /**
     * Create file system model
     * @param file
     */
	private ExceptionModel createFileSystemModel(File file) {
		
		InputStream stream = null;
		//Open the input file stream
		try {
			stream = new FileInputStream(file);
		} catch (FileNotFoundException e) {
			PDEPlugin.logException(e);
			return null;
		}
		//Indicate a new object of ExceptionModel
		ExceptionModel model = new ExceptionModel();
		
        //Get the parent path of the input file
		String parentPath = file.getParentFile().getAbsolutePath();
		//Load the file stream to the model
		try {
			model.load(stream, false);
		} catch (CoreException e) {
			// Errors in the file
			return null;
		}
		//Close the input file stream
		try {
			stream.close();
		} catch (IOException e) {
		}
		return model;
	}
	
    /**
     * Create the resource model for the file.
     * @param file
     */
    protected BaseModel createResourceModel(IFile file)
		throws CoreException
	{
		InputStream stream = null;
		//Return the contents of the file in the form of stream
		stream = file.getContents(false);
		//Retrun the project which contains the resource file
		m_objProject = file.getProject();
		
		Model objModel = WebpumpIDEPlugin.getModel(file,false); 
		
		ExceptionModel objExceptionModel = new ExceptionModel(file);
		objExceptionModel.setModuleModel(objModel);
        //Load the input stream to the exception model
		try
		{
			this.m_objFile = file;
			objExceptionModel.load(stream, false);
		}
		catch(Exception e)
		{

		}
		try
		{
			stream.close();
		}
		catch(IOException e)
		{
	
		}
		return objExceptionModel;
	}

	/**
	 * Create the model for the input file
	 * @param input
	 */
    protected Object createModel(Object input) throws CoreException {
	
		//Create the resource model if the input is an instance of IFile
		if(input instanceof IFile)
			return createResourceModel((IFile)input);
		//Create the storage model if the input is an instance of IStorage
		if (input instanceof IStorage)
			return createStorageModel((IStorage) input);
		//Create the file system model if the input is an instance of File
		if (input instanceof File)
			return createFileSystemModel((File) input);				
		else
		    return null;
			
	}

	/**
	 * Create pages on this editor
	 */
	protected void createPages() {
		firstPageId = WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONEDITOR_EXCEPTION_PAGE_ID);
		formWorkbook.setFirstPageSelected(false);
		//Create an object of the ExceptionPage whose name is "?明式?常编辑?"
		ExceptionPage exceptionPage =
			new ExceptionPage(this, WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONEDITOR_EXCEPTION_PAGE_ID));
			
		//Add the exception page to the editor, whose ID is "?常定?"			
		addPage(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONDETAILSECTION_EXCEPTION_DEFINITION), exceptionPage);
		//Add a new page of SoucePage on this editor, whose ID is "源代?"
		addPage(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONEDITOR_SOURCE_PAGE_ID), new BaseSourcePage(this,WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONEDITOR_SOURCE_PAGE_ID)));

	}

	/**
	 * Get the Page whose ID is "?明式?常编辑?"
	 */
	public IPDEEditorPage getHomePage() {

		return getPage(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONDETAILSECTION_EXCEPTION_DEFINITION));
	}

	/**
	 * Get the Source Page ID "源代?"
	 */
	protected String getSourcePageId() {

		return WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONEDITOR_SOURCE_PAGE_ID);
	}
	
}

⌨️ 快捷键说明

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