📄 elevationtaskinfo.java
字号:
package com.esri.solutions.jitk.web.tasks.elevation;
import java.util.ArrayList;
import java.util.List;
import com.esri.adf.web.data.tasks.SimpleTaskInfo;
import com.esri.adf.web.data.tasks.TaskActionDescriptor;
import com.esri.adf.web.data.tasks.TaskActionDescriptorModel;
import com.esri.adf.web.data.tasks.TaskDescriptor;
import com.esri.adf.web.data.tasks.TaskParamDescriptor;
import com.esri.adf.web.data.tasks.TaskParamDescriptorModel;
import com.esri.adf.web.data.tasks.TaskToolDescriptor;
import com.esri.adf.web.data.tasks.TaskToolDescriptorModel;
import com.esri.adf.web.faces.event.ClientActions;
import com.esri.solutions.jitk.common.resources.TextResources;
import com.esri.solutions.jitk.web.tasks.RenderAwareTaskDescription;
/**
* Describes the actions, parameters, tools, and the task for
* the Elevation task. This object will also maintain the state
* of all the UI components for the Elevation Task as the user progresses
* through the workflow of the task.
*/
public class ElevationTaskInfo extends SimpleTaskInfo {
/**
* Serialization ID.
*/
private static final long serialVersionUID = -8618134883630045890L;
/**
* Maintains a list of all the parameter descriptors.
*/
private final List<TaskParamDescriptor> m_paramDescList;
/**
* Maintains a list of all the tool descriptors.
*/
private final List<TaskToolDescriptor> m_taskToolDescList;
/**
* Maintains a list of all the action descriptors.
*/
private final List<TaskActionDescriptor> m_actionDescList;
/**
* Descriptor for the location pick tool.
*/
private TaskToolDescriptor m_pickTool;
/**
* Descriptor for the Calculate Elevation action.
*/
private TaskActionDescriptor m_calculateAction;
/**
* Descriptor for the Clear action.
*/
private TaskActionDescriptor m_clearAction;
/**
* Descriptor for the Show Marker parameter
*/
private TaskParamDescriptor m_showMarkerParam;
/**
* Descriptor for the X parameter
*/
private TaskParamDescriptor m_xParam;
/**
* Descriptor for Y parameter
*/
private TaskParamDescriptor m_yParam;
/**
* Descriptor for elevation feet parameter
*/
private TaskParamDescriptor m_elevFeetParam;
/**
* Descriptor for elevation meters parameter.
*/
private TaskParamDescriptor m_elevMeterParam;
/**
* Descriptor for executed parameter.
*/
private TaskParamDescriptor m_executedParam;
/**
* Descriptor for error occurred parameter.
*/
private TaskParamDescriptor m_errorOccurredParam;
/**
* Descriptor for error parameter.
*/
private TaskParamDescriptor m_errorParam;
/**
* Descriptor for task.
*/
private TaskDescriptor m_taskDesc;
/**
* Reference to task bean.
*/
private ElevationTask m_task;
/**
* Constructs a new <code>ElevationTaskInfo</code> object.
*
* @param task Reference to {@link ElevationTask} object.
*/
public ElevationTaskInfo (ElevationTask task) {
m_paramDescList = new ArrayList<TaskParamDescriptor>();
m_taskToolDescList = new ArrayList<TaskToolDescriptor>();
m_actionDescList = new ArrayList<TaskActionDescriptor>();
m_taskDesc = new RenderAwareTaskDescription(ElevationTask.class, ResourceProps.TASK_WINDOW_TITLE, ResourceProps.TASK_WINDOW_TITLE);
this.m_task = task;
init(task);
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.tasks.SimpleTaskInfo#getTaskDescriptor()
*/
public TaskDescriptor getTaskDescriptor() {
return m_taskDesc;
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.tasks.SimpleTaskInfo#getToolDescriptors()
*/
public TaskToolDescriptorModel[] getToolDescriptors() {
return this.m_taskToolDescList.toArray(new TaskToolDescriptor[0]);
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.tasks.SimpleTaskInfo#getParamDescriptors()
*/
public TaskParamDescriptorModel[] getParamDescriptors() {
return this.m_paramDescList.toArray(new TaskParamDescriptor[0]);
}
/*
* (non-Javadoc)
* @see com.esri.adf.web.data.tasks.SimpleTaskInfo#getActionDescriptors()
*/
public TaskActionDescriptorModel[] getActionDescriptors() {
return this.m_actionDescList.toArray(new TaskActionDescriptor[0]);
}
/**
* Puts the UI in a start state. This forces the user to enter
* coordinates or choose a location on the map.
*/
public void startState () {
m_pickTool.setDisabled(false);
m_showMarkerParam.setDisabled(false);
m_showMarkerParam.setParamValue(m_task, "false");
m_xParam.setDisabled(false);
m_xParam.setParamValue(m_task, "");
m_yParam.setDisabled(false);
m_yParam.setParamValue(m_task, "");
m_calculateAction.setDisabled(false);
m_clearAction.setDisabled(true);
m_elevFeetParam.setDisabled(true);
m_elevFeetParam.setParamValue(m_task, "");
m_elevMeterParam.setDisabled(true);
m_elevMeterParam.setParamValue(m_task, "");
m_errorOccurredParam.setParamValue(m_task, "false");
m_errorParam.setParamValue(m_task, "");
m_task.setErrorOccurred(false);
m_task.setError("");
}
/**
* Puts the UI in a Location Picked state. Currently this
* state has no implementation.
*/
public void locationPickedState () {
}
/**
* Puts the UI in a elevation calculated state. This occurs
* after the elevation has been successfully calculated and
* can be displayed in the UI.
*/
public void elevationCalculatedState () {
m_executedParam.setParamValue(m_task, "true");
m_pickTool.setDisabled(true);
m_showMarkerParam.setDisabled(true);
m_xParam.setDisabled(true);
m_yParam.setDisabled(true);
m_calculateAction.setDisabled(true);
m_clearAction.setDisabled(false);
m_errorOccurredParam.setParamValue(m_task, "false");
m_errorParam.setParamValue(m_task, "");
}
/**
* Puts the UI in an Elevation Not Found Error state.
*/
public void elevationNotFoundErrorState () {
m_executedParam.setParamValue(m_task, "false");
m_errorOccurredParam.setParamValue(m_task, "true");
m_errorParam.setParamValue(m_task, TextResources.getResourceString(ResourceProps.MSG_ERROR_ELEVATION_CANNOT_BE_FOUND));
m_task.setErrorOccurred(true);
m_task.setError(TextResources.getResourceString(ResourceProps.MSG_ERROR_ELEVATION_CANNOT_BE_FOUND));
m_pickTool.setDisabled(false);
m_showMarkerParam.setDisabled(false);
m_xParam.setDisabled(false);
m_yParam.setDisabled(false);
m_calculateAction.setDisabled(false);
m_clearAction.setDisabled(false);
}
/**
* Puts the UI in a general error state.
* @param errCode
*/
public void generalErrorState (String errCode) {
m_executedParam.setParamValue(m_task, "false");
m_errorOccurredParam.setParamValue(m_task, "true");
m_errorParam.setParamValue(m_task, TextResources.getResourceString("jitk.task.getPointElevation.msg.error." + errCode));
m_task.setErrorOccurred(true);
m_task.setError(TextResources.getResourceString("jitk.task.getPointElevation.msg.error." + errCode));
m_pickTool.setDisabled(false);
m_showMarkerParam.setDisabled(false);
m_xParam.setDisabled(false);
m_yParam.setDisabled(false);
m_calculateAction.setDisabled(false);
m_clearAction.setDisabled(false);
}
/**
* Initializes the descriptors for the task.
*
* @param task Reference to task object.
*/
private void init (ElevationTask task) {
m_taskDesc.setDisplayName(TextResources.getResourceString(ResourceProps.TASK_WINDOW_TITLE));
m_pickTool = new TaskToolDescriptor(ElevationTask.class, "pickLocation", "PickLocation", ClientActions.MAP_POINT);
m_pickTool.setDefaultImage("WebResource/com/esri/solutions/jitk/web/tasks/images/gpPoint.gif");
m_pickTool.setDisabledImage("WebResource/com/esri/solutions/jitk/web/tasks/images/gpPointX.gif");
m_pickTool.setHoverImage("WebResource/com/esri/solutions/jitk/web/tasks/images/gpPointU.gif");
m_pickTool.setSelectedImage("WebResource/com/esri/solutions/jitk/web/tasks/images/gpPointD.gif");
m_pickTool.setRendererType(TaskToolDescriptor.IMAGE_RENDERER_TYPE);
m_pickTool.setDisplayName(TextResources.getResourceString(ResourceProps.TOOL_PICK_LOCATION));
m_pickTool.setToolTip(TextResources.getResourceString(ResourceProps.TOOL_PICK_LOCATION_TIP));
m_taskToolDescList.add(m_pickTool);
m_showMarkerParam = new TaskParamDescriptor(ElevationTask.class, "showMarker", TextResources.getResourceString(ResourceProps.LABEL_SHOW_MARKER));
m_showMarkerParam.setRendererType(TaskParamDescriptor.CHECKBOX_RENDERER_TYPE);
this.m_paramDescList.add(m_showMarkerParam);
m_xParam = new TaskParamDescriptor(ElevationTask.class, "X", TextResources.getResourceString(ResourceProps.LABEL_LONGITUDE));
m_yParam = new TaskParamDescriptor(ElevationTask.class, "Y", TextResources.getResourceString(ResourceProps.LABEL_LATITUDE));
this.m_paramDescList.add(m_xParam);
this.m_paramDescList.add(m_yParam);
m_calculateAction = new TaskActionDescriptor(ElevationTask.class, "calculateElevation", TextResources.getResourceString(ResourceProps.BUTTON_CALCULATE_ELEVATION));
this.m_actionDescList.add(m_calculateAction);
m_elevFeetParam = new TaskParamDescriptor(ElevationTask.class, "elevationFeet", TextResources.getResourceString(ResourceProps.LABEL_ELEVATION_FEET));
m_elevMeterParam = new TaskParamDescriptor(ElevationTask.class, "elevationMeters", TextResources.getResourceString(ResourceProps.LABEL_ELEVATION_METERS));
this.m_paramDescList.add(m_elevFeetParam);
this.m_paramDescList.add(m_elevMeterParam);
m_clearAction = new TaskActionDescriptor(ElevationTask.class, "clear", TextResources.getResourceString(ResourceProps.BUTTON_CLEAR));
this.m_actionDescList.add(m_clearAction);
m_executedParam = new TaskParamDescriptor(ElevationTask.class, "executed", TextResources.getResourceString(ResourceProps.MSG_EXECUTED));
this.m_paramDescList.add(m_executedParam);
m_errorOccurredParam = new TaskParamDescriptor (ElevationTask.class, "errorOccurred", TextResources.getResourceString(ResourceProps.MSG_ERROR_GENERAL));
this.m_paramDescList.add(m_errorOccurredParam);
m_errorParam = new TaskParamDescriptor (ElevationTask.class, "error", TextResources.getResourceString(ResourceProps.MSG_ERROR));
this.m_paramDescList.add(m_errorParam);
m_errorParam = new TaskParamDescriptor (ElevationTask.class, "legendLocation", TextResources.getResourceString(ResourceProps.LEGEND_LOCATION));
this.m_paramDescList.add(m_errorParam);
m_errorParam = new TaskParamDescriptor (ElevationTask.class, "legendElevation", TextResources.getResourceString(ResourceProps.LEGEND_ELEVATION));
this.m_paramDescList.add(m_errorParam);
m_errorParam = new TaskParamDescriptor (ElevationTask.class, "footerNote", TextResources.getResourceString(ResourceProps.FOOTER_NOTE));
this.m_paramDescList.add(m_errorParam);
startState();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -