exceptionallsection.java
来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 303 行
JAVA
303 行
/*
* $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/exception/ExceptionAllSection.java,v 1.1.1.1 2004/07/01 09:07:45 wang_j Exp $
* $Revision: 1.1.1.1 $
* $Date: 2004/07/01 09:07:45 $
*
* ====================================================================
*
* 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.util.Vector;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.*;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.jface.wizard.WizardDialog;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;
import com.webpump.ui.exception.data.*;
import com.webpump.ui.base.data.*;
import com.webpump.ui.base.gui.*;
/**
* Class for the table part of the exception editor.
*
* @author zhao_f
* @version 2.0.0 2004-2-13
*/
public class ExceptionAllSection extends BaseTableSection {
public static String[] dialogParams = new String[6];
public static boolean enabled = true;
/**
* the constructor which define the content of this part
* @param page the page in which the part lies
*/
public ExceptionAllSection(BasePage page) {
//Define the layout of the part using the super class's constructor
super(page, new String[] {WebpumpIDEPlugin.getResourceString(MacroResource.ADDBUTTON),null, WebpumpIDEPlugin.getResourceString(MacroResource.EDITBUTTON), null, WebpumpIDEPlugin.getResourceString(MacroResource.DELBUTTON)});
//Set the head text of this part
this.setHeaderText(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONALLSECTION_EXCEPTION_LIST));
handleDefaultButton = false;
}
/**
* Initialize the layout of this part
* @param input the input in "exception.xml"
*/
public void initialize(Object input) {
BaseModel model = (BaseModel) input;
//Initialize this part by inputting the model's AllException in it
tableViewer.setInput(((ExceptionList)(model.getDataObject())).getExcetpions());
model.addModelChangedListener(this);
getTablePart().setButtonEnabled(2,false);
getTablePart().setButtonEnabled(4,false);
}
/**
* Define the action after the model has been changed
* @param event the changed event
*/
public void modelChanged(IModelChangedEvent event) {
if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
tableViewer.setInput(((ExceptionList)(((BaseModel)(getFormPage().getModel())).getDataObject())).getExcetpions());
tableViewer.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 ExceptionInfo
if (changeObject instanceof ExceptionInfo
&& event.getChangeType() == IModelChangedEvent.CHANGE) {
IStructuredSelection sel =
(IStructuredSelection) tableViewer.getSelection();
BaseObject extension =
(BaseObject) sel.getFirstElement();
tableViewer.refresh();
//tableViewer.setSelection(new StructuredSelection(extension));
return;
}
//Define the action to the table viewer if the changed object is an instance of AllException
if (changeObject instanceof AllException) {
AllException iimport = (AllException) changeObject;
//Add a new element in the tableViewer if the changed type is insert
if (event.getChangeType() == IModelChangedEvent.INSERT) {
AllException iobj = iimport;
imports.add(iobj);
tableViewer.add(iobj);
tableViewer.setSelection(new StructuredSelection(iobj), true);
tableViewer.getTable().setFocus();
} else
{
//Delete an element from the table viewer if the changed type is remove
AllException iobj = iimport;
if (iobj != null) {
if (event.getChangeType() == IModelChangedEvent.REMOVE) {
imports.remove(iobj);
tableViewer.remove(iobj);
} else {
tableViewer.update(iobj, null);
}
}
}
setDirty(true);
}
}
/**
* Define the action to the tableViewer after the selection is changed
* @param selection the selected item
*/
protected void selectionChanged(IStructuredSelection selection) {
//Get the selected element
Object item = selection.getFirstElement();
if (item == null) m_strSelectName=null;
else
m_strSelectName = item.toString();
//Get the object of ExceptionDetailSection
ExceptionDetailSection objExceptionDetailSection = ((ExceptionForm)(getFormPage().getForm())).getExceptionDetailSection();
//Set the button style on the ExceptionDetailSection
objExceptionDetailSection.setButtonStyle();
fireSelectionNotification(item);
getFormPage().setSelection(selection);
setButtonStyle(item);
}
/**
* Define what to do when selecting one of the botton
* @param index a param which indicates the botton which has been selected
*/
protected void buttonSelected(int index) {
if (index == 0)
handleAdd();
if (index == 2)
handleEdit();
if (index == 4)
handleRemove();
}
/**
* Define the action when having selected the "add" botton
*/
private void handleAdd(){
//Initiate the data in the dialog when having selected "add" button
for(int i=0; i<6; i++){
dialogParams[i] = "";
}
dialogParams[4] = "org.apache.struts.action.ExceptionHandler";
enabled = false;
//Show the dialog to customers
ExceptionTableDialog wizard = new ExceptionTableDialog();
wizard.init(WebpumpIDEPlugin.getDefault().getWorkbench(), null);
WizardDialog dialog = new WizardDialog(WebpumpIDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),wizard);
//Add the new ExceptionInfo in the exception model when selected "finish"
if(dialog.open() == WizardDialog.OK ){
ExceptionInfo objExceptionInfo = wizard.getExceptionInfo();
ExceptionInfo objExceptionInfo1 = new ExceptionInfo();
AllException objAllException =((ExceptionList)((BaseModel)getFormPage().getEditor().getModel()).getDataObject()).getExcetpions();
objAllException.addException(objExceptionInfo1);
objExceptionInfo1.setParamsInfo1((String [])objExceptionInfo.getParamsInfo());
this.update();
}
}
/**
* Define the action when having selected the "remove" botton
*/
private void handleRemove(){
//Get the selected item on the tableViewer
IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
BaseObject object = (BaseObject) sel.getFirstElement();
BaseObject objControl = null;
//If the selected item is an instance of ExceptionInfo, get its parent
if (object instanceof ExceptionInfo)
{
objControl = object.getParent() ;
}
if (objControl instanceof AllException)
{
//Define following params for counting the times of circulation and identifying whether all the circulations have been done.
int i = 0;
int k = 0;
int j = 0;
boolean openMessageDialog = true;
//Get the selected item's name in this section
String strSelectName = this.getSelectName();
//Get the present ExceptionModel
ExceptionModel model = (ExceptionModel) (getFormPage().getModel());
//Get GlobalExceptions in the present ExceptionModel
GlobalExceptions objGlobalExceptions = ((ExceptionList)(model.getDataObject())).getGlobalExcetpions();
Vector globalExceptionNames = objGlobalExceptions.getActionException();
//Identifying wheter the selected item has been added to GlobalExceptions during the circulation
for(i = 0; i<globalExceptionNames.size(); i++){
String name = ((ExceptionName)(globalExceptionNames.get(i))).toString();
if(strSelectName.equals(name)) {
//Open the message dialog
if(openMessageDialog){
openMessageDialog = false;
MessageDialog.openInformation(
this.getFormPage().getEditor().getEditorSite().getPage().getWorkbenchWindow().getShell(),
(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONALLSECTION_DEL_WARNING)),
(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONALLSECTION_DEL_WORDSA)));
}
break;
}
}
//Get ActionList in the present ExceptionModel
ActionList objActionList = ((ExceptionList)(model.getDataObject())).getActionExcetpions();
//Get ActionExceptions in the present ActionList
Object[] actionExceptions = objActionList.getChild();
//Get every actionException's exception names during the circulation
for(k = 0; k<actionExceptions.length; k++ ){
Object[] actionExceptionNames = ((ActionException)actionExceptions[k]).getChild();
//Get every exceptionName object's ExceptionName during the circulation
for(j = 0; j<actionExceptionNames.length; j++){
String name = ((ExceptionName)(actionExceptionNames[j])).toString();
if(strSelectName.equals(name)){
//Open the message dialog
if(openMessageDialog) {
openMessageDialog = false;
MessageDialog.openInformation(
this.getFormPage().getEditor().getEditorSite().getPage().getWorkbenchWindow().getShell(),
(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONALLSECTION_DEL_WARNING)),
(WebpumpIDEPlugin.getResourceString(MacroResource.EXCEPTIONALLSECTION_DEL_WORDSB)));
}
break;
}
}
if(j < actionExceptionNames.length) break;
}
//Remove the item from the exception model
if((i == globalExceptionNames.size()) && (k == actionExceptions.length)){
((AllException)objControl).remove((ExceptionInfo)object);
}
}
this.update();
}
/**
* Define the action when having selected the "edit" botton
*/
private void handleEdit(){
enabled = true;
//Get the selected item on the tableViewer
IStructuredSelection sel =
(IStructuredSelection) tableViewer.getSelection();
BaseObject object = (BaseObject) sel.getFirstElement();
//Send the params in the dialog to the static group
if(object instanceof ExceptionInfo){
dialogParams = ((ExceptionInfo)object).getParamsInfo();
}
//Show the dialog to customers
ExceptionTableDialog wizard = new ExceptionTableDialog();
wizard.init(WebpumpIDEPlugin.getDefault().getWorkbench(), null);
WizardDialog dialog = new WizardDialog(WebpumpIDEPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),wizard);
if(dialog.open() == WizardDialog.OK ){
if(object instanceof ExceptionInfo){
ExceptionInfo objExceptionInfo = wizard.getExceptionInfo();
((ExceptionInfo)object).setParamsInfo1((String [])objExceptionInfo.getParamsInfo());
}
this.update();
}
}
/**
* 用户双击列柄垓时弹出修改对话
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?