📄 clearresultsadapter.java
字号:
package com.esri.solutions.jitk.web.tasks.mapcomp;
import java.util.ArrayList;
import java.util.List;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.query.QueryResult;
import com.esri.adf.web.data.results.ResultNode;
import com.esri.adf.web.data.results.WebResults;
import com.esri.solutions.jitk.web.tasks.IWebContextAware;
/**
* Clears the Results when a Map Composition is created. This object
* will observe the <code>created</code> event that is fired by the
* Map Composition tasks. In order to clear the Results, the Graphics will
* be cleared from the WebQuery, and WebResults object will be cleared.
*/
public class ClearResultsAdapter implements IMapCompositionEventObserver {
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#created(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
*/
public void created(MapCompositionEvent event) {
if (event.getSource() instanceof IWebContextAware) {
IWebContextAware ctxAware = (IWebContextAware) event.getSource();
WebContext ctx = ctxAware.getContext();
clearResults(ctx);
}
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#deleted(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
*/
public void deleted(MapCompositionEvent event) {
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#opened(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
*/
public void opened(MapCompositionEvent event) {
}
/*
* (non-Javadoc)
* @see com.esri.solutions.jitk.web.tasks.mapcomp.IMapCompositionEventObserver#saved(com.esri.solutions.jitk.web.tasks.mapcomp.MapCompositionEvent)
*/
public void saved(MapCompositionEvent event) {
}
/**
* Clears the Results within the WebContext. The Graphics in the
* WebQuery are cleared and the WebResults object is cleared.
*
* @param ctx Contains references to WebQuery and WebResults.
*/
private void clearResults (WebContext ctx) {
ctx.getWebQuery().clearGraphics();
WebResults results = ctx.getWebResults();
if (results == null) {
return;
}
List<ResultNode> resultNodes = new ArrayList<ResultNode>(results.getResultNodes());
for (ResultNode node : resultNodes) {
if (node == null) {
continue;
}
clearResultNode(node);
results.removeResultNode(node);
}
}
/**
* Clears the specified Result Node and all of its children,
* recursively. If a Result Node contains a Query Result,
* then {@link #clearQueryResult(QueryResult)}
* is invoked.
*
* @param node Result Node to clear.
*/
private void clearResultNode (ResultNode node) {
assert(node != null);
Object result = node.getResult();
if (result instanceof QueryResult) {
clearQueryResult((QueryResult) result);
}
for (ResultNode child : node.getChildren()) {
if (child == null) {
continue;
}
clearResultNode(child);
}
}
/**
* Clears the specified Query Result. The Graphics of the
* Result will be cleared via {@link QueryResult#clearGraphic()}.
*
* @param result Query Result to clear.
*/
private void clearQueryResult (QueryResult result) {
assert(result != null);
result.clearGraphic();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -