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

📄 validationdetailsection.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/validation/ValidationDetailSection.java,v 1.1.1.1 2004/07/01 09:07:53 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:53 $
 *
 * ====================================================================
 *
 * 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.validation;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
import org.eclipse.pde.internal.ui.parts.TreePart;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;

import com.webpump.ui.base.data.BaseDataObject;
import com.webpump.ui.base.data.BaseObject;
import com.webpump.ui.base.gui.*;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for the table part of the validation editor which shows the tree of the fields.
 * 
 * @author zhao_f
 * @version 2.0.0 2004-1-13
 */
public class ValidationDetailSection extends BaseTreeSection{
	
	/**
	 * Class for providing the content of the tree part
	 */	
	class TreeContentProvider
		extends DefaultContentProvider
		implements ITreeContentProvider {
	
		/**
		 * Get the Children of the node
		 * @param parent the node who owns the children
		 */	
		public Object[] getChildren(Object parent) {
			Object[] children = null;
			if ((parent instanceof BaseObject)
				&&(!(parent instanceof ValidationFields))
				) {
				return ((BaseDataObject)parent).getChild();
			}

			if (children == null)
				children = new Object[0];
			return children;
		}
		
		/**
		 * Identify whether the node has children
		 */
		public boolean hasChildren(Object parent) {
			return getChildren(parent).length > 0;
		}
		
		/**
		 * Get the parent of the node
		 * @param child the node who has a parent
		 */
		public Object getParent(Object child) {
			if (child instanceof BaseObject)
				return ((BaseObject) child).getParent();
			return null;
		}
		
		/**
		 * Get all the children of the node in the form of Object group
		 * @param parent the node who owns children
		 */
		public Object[] getElements(Object parent) {
			return getChildren(parent);
		}
	}
	
	/**
	 * the constructor
	 * @param page
	 */
	public ValidationDetailSection(BasePage page) {
			super(page);
			this.setHeaderText(WebpumpIDEPlugin.getResourceString(MacroResource.VALIDATIONDETAILSECTION_HEADER_TEXT));
			handleDefaultButton = false;
	}
	
	/**
	 * Initialize the content of the part
	 */
	public void initialize(Object input) {
		ValidationModel model = (ValidationModel) input;

		//Initialize this part by inputting the model's ValidationFromset in it  
		exceptionTree.setInput(((ValidationList)(model.getDataObject())).getValidationFormset());
		boolean editable = model.isEditable();
		setReadOnly(!editable);
		TreePart treePart = getTreePart();
		model.addModelChangedListener(this);
		ValidationAllSection objValidationAllSection = ((ValidationEditorForm)(getFormPage().getForm())).getValidationAllSection();
		objValidationAllSection.setInitButtonStyle();
	}
	
	/**
	 * Dispose this part
	 */
	public void dispose() {
			//Get the model on this part
			ValidationModel model = (ValidationModel) getFormPage().getModel();
			//Remove the Model Changed Listener on this model
			model.removeModelChangedListener(this);
			super.dispose();
	}
	
	/**
	 * Define the action after the model has been changed
	 */	
	public void modelChanged(IModelChangedEvent event) {
		if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
			ValidationModel model = (ValidationModel) getFormPage().getModel();
			exceptionTree.setInput(((ValidationList)(model.getDataObject())).getValidationFormset());
			exceptionTree.refresh();
			return;
		}
		//Get the changed object
		Object changeObject = event.getChangedObjects()[0];
		//Define the action to the tableViewer if the changed object is an instance of ExceptionName
		if (changeObject instanceof ValidationFields
			&& event.getChangeType() == IModelChangedEvent.CHANGE) {
			IStructuredSelection sel =
				(IStructuredSelection) exceptionTree.getSelection();
			BaseObject extension =
				(BaseObject) sel.getFirstElement();
				exceptionTree.refresh();
				exceptionTree.setSelection(new StructuredSelection(extension));
			return;
		}
		//Define the action to the tableViewer if the changed object is an instance of ExceptionList
		if (!(changeObject instanceof ValidationList)) {
			BaseObject pobj = (BaseObject) changeObject;
			BaseObject parent = pobj.getParent();
			
			//Add a new element in the tableViewer if the changed type is insert
			if (event.getChangeType() == IModelChangedEvent.INSERT) {
				exceptionTree.add(parent, pobj);

			}
			//Delete an element from the table viewer if the changed type is remove
			 else if (event.getChangeType() == IModelChangedEvent.REMOVE) {
				exceptionTree.remove(pobj);		 
				IStructuredSelection sel =
					(IStructuredSelection) exceptionTree.getSelection();
				BaseObject extension =
					(BaseObject) sel.getFirstElement();
					exceptionTree.refresh();
					exceptionTree.setSelection(new StructuredSelection(extension));
			}
		}
	}		
	
	/**
	 * Define the action after the selection has been changed
	 */
	protected void selectionChanged(IStructuredSelection selection) {
        //清空参

⌨️ 快捷键说明

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