| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.common.ui.client.mvc; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.HashMap; |
| 20 |
|
import java.util.Iterator; |
| 21 |
|
import java.util.Map; |
| 22 |
|
|
| 23 |
|
import org.kuali.student.common.assembly.data.Data; |
| 24 |
|
import org.kuali.student.common.rice.authorization.PermissionType; |
| 25 |
|
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
| 26 |
|
import org.kuali.student.common.ui.client.application.ViewContext; |
| 27 |
|
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
| 28 |
|
import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView; |
| 29 |
|
import org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbSupport; |
| 30 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
| 31 |
|
import org.kuali.student.common.ui.client.mvc.history.HistorySupport; |
| 32 |
|
import org.kuali.student.common.ui.client.mvc.history.NavigationEvent; |
| 33 |
|
import org.kuali.student.common.ui.client.reporting.ReportExport; |
| 34 |
|
import org.kuali.student.common.ui.client.security.AuthorizationCallback; |
| 35 |
|
import org.kuali.student.common.ui.client.security.RequiresAuthorization; |
| 36 |
|
import org.kuali.student.common.ui.client.service.GwtExportRpcService; |
| 37 |
|
import org.kuali.student.common.ui.client.service.GwtExportRpcServiceAsync; |
| 38 |
|
import org.kuali.student.common.ui.client.util.ExportElement; |
| 39 |
|
import org.kuali.student.common.ui.client.util.ExportUtils; |
| 40 |
|
import org.kuali.student.common.ui.client.widgets.progress.BlockingTask; |
| 41 |
|
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
| 42 |
|
|
| 43 |
|
import com.google.gwt.core.client.GWT; |
| 44 |
|
import com.google.gwt.event.shared.GwtEvent.Type; |
| 45 |
|
import com.google.gwt.event.shared.HandlerManager; |
| 46 |
|
import com.google.gwt.event.shared.HandlerRegistration; |
| 47 |
|
import com.google.gwt.user.client.Window; |
| 48 |
|
import com.google.gwt.user.client.ui.Composite; |
| 49 |
|
import com.google.gwt.user.client.ui.Widget; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@author |
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 288 (288) |
Complexity: 95 |
Complexity Density: 0.59 |
|
| 57 |
|
public abstract class Controller extends Composite implements HistorySupport, BreadcrumbSupport, ReportExport{ |
| 58 |
|
public static final Callback<Boolean> NO_OP_CALLBACK = new Callback<Boolean>() { |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 59 |
0
|
@Override... |
| 60 |
|
public void exec(Boolean result) { |
| 61 |
|
|
| 62 |
|
} |
| 63 |
|
}; |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
protected Controller parentController = null; |
| 68 |
|
private View currentView = null; |
| 69 |
|
private Enum<?> currentViewEnum = null; |
| 70 |
|
private String defaultModelId = null; |
| 71 |
|
protected ViewContext context = new ViewContext(); |
| 72 |
|
private final Map<String, ModelProvider<? extends Model>> models = new HashMap<String, ModelProvider<? extends Model>>(); |
| 73 |
|
private boolean fireNavEvents = true; |
| 74 |
|
private HandlerManager applicationEventHandlers = new HandlerManager(this); |
| 75 |
|
private GwtExportRpcServiceAsync reportExportRpcService = GWT.create(GwtExportRpcService.class); |
| 76 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 77 |
0
|
protected Controller() {... |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@param |
| 83 |
|
|
| 84 |
|
@param |
| 85 |
|
|
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0
|
public <V extends Enum<?>> void showView(final V viewType){... |
| 88 |
0
|
this.showView(viewType, NO_OP_CALLBACK); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
@param |
| 105 |
|
|
| 106 |
|
@param |
| 107 |
|
|
| 108 |
|
@param |
| 109 |
|
@return |
| 110 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 111 |
0
|
public <V extends Enum<?>> void showView(final V viewType, final Callback<Boolean> onReadyCallback) {... |
| 112 |
0
|
GWT.log("showView " + viewType.toString(), null); |
| 113 |
0
|
getView(viewType, new Callback<View>(){ |
| 114 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 115 |
0
|
@Override... |
| 116 |
|
public void exec(View result) { |
| 117 |
0
|
View view = result; |
| 118 |
0
|
if (view == null) { |
| 119 |
0
|
onReadyCallback.exec(false); |
| 120 |
|
|
| 121 |
|
} |
| 122 |
0
|
beginShowView(view, viewType, onReadyCallback); |
| 123 |
|
|
| 124 |
|
}}); |
| 125 |
|
} |
| 126 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
0
|
private <V extends Enum<?>> void beginShowView(final View view, final V viewType, final Callback<Boolean> onReadyCallback){... |
| 128 |
0
|
beforeViewChange(viewType, new Callback<Boolean>(){ |
| 129 |
|
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 130 |
0
|
@Override... |
| 131 |
|
public void exec(Boolean result) { |
| 132 |
0
|
if(result){ |
| 133 |
0
|
boolean requiresAuthz = (view instanceof RequiresAuthorization) && ((RequiresAuthorization)view).isAuthorizationRequired(); |
| 134 |
|
|
| 135 |
0
|
if (requiresAuthz){ |
| 136 |
0
|
ViewContext tempContext = new ViewContext(); |
| 137 |
0
|
if(view instanceof LayoutController){ |
| 138 |
0
|
tempContext = ((LayoutController) view).getViewContext(); |
| 139 |
|
} |
| 140 |
|
else{ |
| 141 |
0
|
tempContext = view.getController().getViewContext(); |
| 142 |
|
} |
| 143 |
|
|
| 144 |
0
|
PermissionType permType = (tempContext != null) ? tempContext.getPermissionType() : null; |
| 145 |
0
|
if (permType != null) { |
| 146 |
0
|
GWT.log("Checking permission type '" + permType.getPermissionTemplateName() + "' for view '" + view.toString() + "'", null); |
| 147 |
|
|
| 148 |
0
|
((RequiresAuthorization)view).checkAuthorization(permType, new AuthorizationCallback(){ |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 149 |
0
|
public void isAuthorized() {... |
| 150 |
0
|
finalizeShowView(view, viewType, onReadyCallback); |
| 151 |
|
} |
| 152 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 153 |
0
|
public void isNotAuthorized(String msg) {... |
| 154 |
0
|
Window.alert(msg); |
| 155 |
0
|
onReadyCallback.exec(false); |
| 156 |
|
} |
| 157 |
|
}); |
| 158 |
|
} |
| 159 |
|
else { |
| 160 |
0
|
GWT.log("Cannot find PermissionType for view '" + view.toString() + "' which requires authorization", null); |
| 161 |
0
|
finalizeShowView(view, viewType, onReadyCallback); |
| 162 |
|
} |
| 163 |
|
} else { |
| 164 |
0
|
GWT.log("Not Requiring Auth.", null); |
| 165 |
0
|
finalizeShowView(view, viewType, onReadyCallback); |
| 166 |
|
} |
| 167 |
|
} |
| 168 |
|
else{ |
| 169 |
0
|
onReadyCallback.exec(false); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
} |
| 173 |
|
}); |
| 174 |
|
} |
| 175 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 176 |
0
|
private <V extends Enum<?>> void finalizeShowView(final View view, final V viewType, final Callback<Boolean> onReadyCallback){... |
| 177 |
0
|
if ((currentView == null) || currentView.beforeHide()) { |
| 178 |
0
|
view.beforeShow(new Callback<Boolean>() { |
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 179 |
0
|
@Override... |
| 180 |
|
public void exec(Boolean result) { |
| 181 |
0
|
if (!result) { |
| 182 |
0
|
GWT.log("showView: beforeShow yielded false " + viewType, null); |
| 183 |
0
|
onReadyCallback.exec(false); |
| 184 |
|
} else { |
| 185 |
0
|
if (currentView != null) { |
| 186 |
0
|
hideView(currentView); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
0
|
currentViewEnum = viewType; |
| 190 |
0
|
currentView = view; |
| 191 |
0
|
GWT.log("renderView " + viewType.toString(), null); |
| 192 |
0
|
if(fireNavEvents){ |
| 193 |
0
|
fireNavigationEvent(); |
| 194 |
|
} |
| 195 |
0
|
renderView(view); |
| 196 |
0
|
onReadyCallback.exec(true); |
| 197 |
|
|
| 198 |
|
} |
| 199 |
|
} |
| 200 |
|
}); |
| 201 |
|
} else { |
| 202 |
0
|
onReadyCallback.exec(false); |
| 203 |
0
|
GWT.log("Current view canceled hide action", null); |
| 204 |
|
} |
| 205 |
|
} |
| 206 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 207 |
0
|
protected void fireNavigationEvent() {... |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
0
|
fireApplicationEvent(new NavigationEvent(Controller.this)); |
| 212 |
|
|
| 213 |
|
|
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
@return |
| 220 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 221 |
0
|
public View getCurrentView() {... |
| 222 |
0
|
return currentView; |
| 223 |
|
} |
| 224 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 225 |
0
|
public Enum<?> getCurrentViewEnum() {... |
| 226 |
0
|
return currentViewEnum; |
| 227 |
|
} |
| 228 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 229 |
0
|
public void setCurrentViewEnum(Enum<?> currentViewEnum) {... |
| 230 |
0
|
this.currentViewEnum = currentViewEnum; |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
@param |
| 240 |
|
|
| 241 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 242 |
0
|
public void setParentController(Controller controller) {... |
| 243 |
0
|
parentController = controller; |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
@return |
| 251 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 252 |
0
|
public Controller getParentController() {... |
| 253 |
0
|
if (parentController == null) { |
| 254 |
0
|
parentController = Controller.findController(this); |
| 255 |
|
} |
| 256 |
0
|
return parentController; |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
@param |
| 263 |
|
|
| 264 |
|
@return |
| 265 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 266 |
0
|
public static Controller findController(Widget w) {... |
| 267 |
0
|
Controller result = null; |
| 268 |
0
|
while (true) { |
| 269 |
0
|
w = w.getParent(); |
| 270 |
0
|
if (w == null) { |
| 271 |
0
|
break; |
| 272 |
0
|
} else if (w instanceof Controller) { |
| 273 |
0
|
result = (Controller) w; |
| 274 |
0
|
break; |
| 275 |
0
|
} else if (w instanceof View) { |
| 276 |
|
|
| 277 |
|
|
| 278 |
0
|
result = ((View) w).getController(); |
| 279 |
0
|
break; |
| 280 |
|
} |
| 281 |
|
} |
| 282 |
0
|
return result; |
| 283 |
|
} |
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
@param |
| 295 |
|
@param |
| 296 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 297 |
0
|
@SuppressWarnings("unchecked")... |
| 298 |
|
public void requestModel(final Class modelType, final ModelRequestCallback callback) { |
| 299 |
0
|
requestModel((modelType == null) ? null : modelType.getName(), callback); |
| 300 |
|
} |
| 301 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 302 |
0
|
@SuppressWarnings("unchecked")... |
| 303 |
|
public void requestModel(final String modelId, final ModelRequestCallback callback) { |
| 304 |
0
|
String id = (modelId == null) ? defaultModelId : modelId; |
| 305 |
|
|
| 306 |
0
|
ModelProvider<? extends Model> p = models.get(id); |
| 307 |
0
|
if (p != null) { |
| 308 |
0
|
p.requestModel(callback); |
| 309 |
0
|
} else if (getParentController() != null) { |
| 310 |
0
|
parentController.requestModel(modelId, callback); |
| 311 |
|
} else { |
| 312 |
0
|
if (callback != null) { |
| 313 |
0
|
callback.onRequestFail(new RuntimeException("The requested model was not found: " + modelId)); |
| 314 |
|
} |
| 315 |
|
} |
| 316 |
|
} |
| 317 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 318 |
0
|
@SuppressWarnings("unchecked")... |
| 319 |
|
public void requestModel(final ModelRequestCallback callback) { |
| 320 |
0
|
requestModel((String)null, callback); |
| 321 |
|
} |
| 322 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 323 |
0
|
public <T extends Model> void registerModel(String modelId, ModelProvider<T> provider) {... |
| 324 |
0
|
models.put(modelId, provider); |
| 325 |
|
} |
| 326 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 327 |
0
|
public String getDefaultModelId() {... |
| 328 |
0
|
return defaultModelId; |
| 329 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 330 |
0
|
public void setDefaultModelId(String defaultModelId) {... |
| 331 |
0
|
this.defaultModelId = defaultModelId; |
| 332 |
|
} |
| 333 |
|
|
| 334 |
|
|
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
@param |
| 340 |
|
@param |
| 341 |
|
@return |
| 342 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 343 |
0
|
@SuppressWarnings("unchecked")... |
| 344 |
|
public HandlerRegistration addApplicationEventHandler(Type type, ApplicationEventHandler handler) { |
| 345 |
0
|
if ((handler instanceof UncheckedApplicationEventHandler) && (getParentController() != null)) { |
| 346 |
0
|
return parentController.addApplicationEventHandler(type, handler); |
| 347 |
|
} |
| 348 |
0
|
return applicationEventHandlers.addHandler(type, handler); |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
@param |
| 355 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 356 |
0
|
@SuppressWarnings("unchecked")... |
| 357 |
|
public void fireApplicationEvent(ApplicationEvent event) { |
| 358 |
|
|
| 359 |
|
|
| 360 |
0
|
if ((event instanceof UncheckedApplicationEvent) && (getParentController() != null)) { |
| 361 |
0
|
parentController.fireApplicationEvent(event); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
0
|
applicationEventHandlers.fireEvent(event); |
| 365 |
|
|
| 366 |
|
} |
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
| 370 |
|
|
| 371 |
|
@param |
| 372 |
|
|
| 373 |
|
protected abstract void renderView(View view); |
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
@param |
| 379 |
|
|
| 380 |
|
protected abstract void hideView(View view); |
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
@param |
| 386 |
|
@param |
| 387 |
|
@return |
| 388 |
|
|
| 389 |
|
protected abstract <V extends Enum<?>> void getView(V viewType, Callback<View> callback); |
| 390 |
|
|
| 391 |
|
|
| 392 |
|
|
| 393 |
|
|
| 394 |
|
|
| 395 |
|
@param |
| 396 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 397 |
0
|
public void beforeViewChange(Enum<?> viewChangingTo, Callback<Boolean> okToChangeCallback) {... |
| 398 |
0
|
okToChangeCallback.exec(true); |
| 399 |
|
} |
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
|
| 404 |
|
public abstract void showDefaultView(Callback<Boolean> onReadyCallback); |
| 405 |
|
|
| 406 |
|
public abstract Enum<?> getViewEnumValue(String enumValue); |
| 407 |
|
|
| 408 |
|
|
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
@see |
| 413 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 414 |
0
|
@Override... |
| 415 |
|
public String collectHistory(String historyStack) { |
| 416 |
0
|
String token = getHistoryToken(); |
| 417 |
0
|
historyStack = historyStack + "/" + token; |
| 418 |
|
|
| 419 |
0
|
if(currentView != null){ |
| 420 |
0
|
String tempHistoryStack = historyStack; |
| 421 |
0
|
historyStack = currentView.collectHistory(historyStack); |
| 422 |
|
|
| 423 |
|
|
| 424 |
0
|
if(historyStack == null){ |
| 425 |
0
|
historyStack = tempHistoryStack; |
| 426 |
|
} |
| 427 |
0
|
else if(historyStack != null && historyStack.isEmpty()){ |
| 428 |
0
|
historyStack = tempHistoryStack; |
| 429 |
|
} |
| 430 |
|
} |
| 431 |
0
|
return historyStack; |
| 432 |
|
} |
| 433 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.71 |
|
| 434 |
0
|
protected String getHistoryToken() {... |
| 435 |
0
|
String historyToken = ""; |
| 436 |
0
|
if (currentViewEnum != null) { |
| 437 |
0
|
historyToken = currentViewEnum.toString(); |
| 438 |
0
|
if(currentView != null && currentView instanceof Controller |
| 439 |
|
&& ((Controller)currentView).getViewContext() != null){ |
| 440 |
0
|
ViewContext context = ((Controller) currentView).getViewContext(); |
| 441 |
0
|
historyToken = HistoryManager.appendContext(historyToken, context); |
| 442 |
|
} |
| 443 |
|
|
| 444 |
|
} |
| 445 |
0
|
return historyToken; |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
|
|
| 456 |
|
|
| 457 |
|
|
| 458 |
|
@see |
| 459 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 460 |
0
|
@Override... |
| 461 |
|
public void onHistoryEvent(String historyStack) { |
| 462 |
0
|
final String nextHistoryStack = HistoryManager.nextHistoryStack(historyStack); |
| 463 |
0
|
String[] tokens = HistoryManager.splitHistoryStack(nextHistoryStack); |
| 464 |
0
|
if (tokens.length >= 1 && tokens[0] != null && !tokens[0].isEmpty()) { |
| 465 |
0
|
final Map<String, String> tokenMap = HistoryManager.getTokenMap(tokens[0]); |
| 466 |
|
|
| 467 |
0
|
String viewEnumString = tokenMap.get("view"); |
| 468 |
0
|
if (viewEnumString != null) { |
| 469 |
0
|
final Enum<?> viewEnum = getViewEnumValue(viewEnumString); |
| 470 |
|
|
| 471 |
0
|
if (viewEnum != null) { |
| 472 |
0
|
getView(viewEnum, new Callback<View>(){ |
| 473 |
|
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 11 |
Complexity Density: 0.52 |
|
| 474 |
0
|
@Override... |
| 475 |
|
public void exec(View result) { |
| 476 |
0
|
View theView = result; |
| 477 |
0
|
boolean sameContext = true; |
| 478 |
0
|
if(theView instanceof Controller){ |
| 479 |
|
|
| 480 |
0
|
ViewContext newContext = new ViewContext(); |
| 481 |
0
|
Iterator<String> tokenIt = tokenMap.keySet().iterator(); |
| 482 |
0
|
while(tokenIt.hasNext()){ |
| 483 |
0
|
String key = tokenIt.next(); |
| 484 |
0
|
if(key.equals(ViewContext.ID_ATR)){ |
| 485 |
0
|
newContext.setId(tokenMap.get(ViewContext.ID_ATR)); |
| 486 |
|
} |
| 487 |
0
|
else if(key.equals(ViewContext.ID_TYPE_ATR)){ |
| 488 |
0
|
newContext.setIdType(tokenMap.get(ViewContext.ID_TYPE_ATR)); |
| 489 |
|
} |
| 490 |
|
|
| 491 |
0
|
else if(!key.equals("view")){ |
| 492 |
0
|
newContext.setAttribute(key, tokenMap.get(key)); |
| 493 |
|
} |
| 494 |
|
} |
| 495 |
|
|
| 496 |
0
|
ViewContext viewContext = ((Controller) theView).getViewContext(); |
| 497 |
0
|
if(viewContext.compareTo(newContext) != 0){ |
| 498 |
0
|
((Controller) theView).setViewContext(newContext); |
| 499 |
0
|
sameContext = false; |
| 500 |
|
} |
| 501 |
|
} |
| 502 |
0
|
if (currentViewEnum == null || !viewEnum.equals(currentViewEnum) |
| 503 |
|
|| !sameContext) { |
| 504 |
0
|
beginShowView(theView, viewEnum, new Callback<Boolean>() { |
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 505 |
0
|
@Override... |
| 506 |
|
public void exec(Boolean result) { |
| 507 |
0
|
if (result) { |
| 508 |
0
|
currentView.onHistoryEvent(nextHistoryStack); |
| 509 |
|
} |
| 510 |
|
} |
| 511 |
|
}); |
| 512 |
0
|
} else if (currentView != null) { |
| 513 |
0
|
currentView.onHistoryEvent(nextHistoryStack); |
| 514 |
|
} |
| 515 |
|
} |
| 516 |
|
}); |
| 517 |
|
|
| 518 |
|
} |
| 519 |
|
} |
| 520 |
|
} |
| 521 |
|
else{ |
| 522 |
0
|
this.showDefaultView(new Callback<Boolean>(){ |
| 523 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 524 |
0
|
@Override... |
| 525 |
|
public void exec(Boolean result) { |
| 526 |
0
|
if(result){ |
| 527 |
0
|
currentView.onHistoryEvent(nextHistoryStack); |
| 528 |
|
} |
| 529 |
|
|
| 530 |
|
} |
| 531 |
|
}); |
| 532 |
|
} |
| 533 |
|
|
| 534 |
|
} |
| 535 |
|
|
| 536 |
|
|
| 537 |
|
|
| 538 |
|
|
| 539 |
|
|
| 540 |
|
|
| 541 |
|
@param |
| 542 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 543 |
0
|
public void setViewContext(ViewContext viewContext){... |
| 544 |
0
|
this.context = viewContext; |
| 545 |
|
} |
| 546 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 547 |
0
|
public ViewContext getViewContext() {... |
| 548 |
0
|
return this.context; |
| 549 |
|
} |
| 550 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 551 |
0
|
public void resetCurrentView(){... |
| 552 |
0
|
currentView = null; |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
|
| 559 |
|
|
| 560 |
|
@see |
| 561 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 562 |
0
|
@Override... |
| 563 |
|
public void doReportExport(ArrayList<ExportElement> exportElements, final String format, final String reportTitle) { |
| 564 |
|
|
| 565 |
0
|
final BlockingTask loadDataTask = new BlockingTask("Generating Export File"); |
| 566 |
|
|
| 567 |
0
|
DataModel dataModel = getExportDataModel(); |
| 568 |
0
|
Data modelDataObject = null; |
| 569 |
0
|
if (dataModel != null) { |
| 570 |
0
|
modelDataObject = dataModel.getRoot(); |
| 571 |
|
} |
| 572 |
|
|
| 573 |
|
|
| 574 |
|
|
| 575 |
0
|
KSBlockingProgressIndicator.addTask(loadDataTask); |
| 576 |
|
|
| 577 |
0
|
reportExportRpcService.reportExport(exportElements, modelDataObject, getExportTemplateName(), format, reportTitle, new KSAsyncCallback<String>() { |
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 578 |
0
|
@Override... |
| 579 |
|
public void onSuccess(String result) { |
| 580 |
|
|
| 581 |
|
|
| 582 |
|
|
| 583 |
0
|
String baseUrl = GWT.getHostPageBaseURL(); |
| 584 |
0
|
baseUrl = baseUrl.replaceFirst(GWT.getModuleName() + "/", ""); |
| 585 |
|
|
| 586 |
0
|
KSBlockingProgressIndicator.removeTask(loadDataTask); |
| 587 |
|
|
| 588 |
0
|
Window.open(baseUrl + "exportDownloadHTTPServlet?exportId="+result + "&format=" + format, "", ""); |
| 589 |
|
} |
| 590 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 591 |
0
|
@Override... |
| 592 |
|
public void handleFailure(Throwable caught) { |
| 593 |
0
|
KSBlockingProgressIndicator.removeTask(loadDataTask); |
| 594 |
0
|
super.handleFailure(caught); |
| 595 |
|
} |
| 596 |
|
|
| 597 |
|
}); |
| 598 |
|
|
| 599 |
|
|
| 600 |
|
|
| 601 |
|
} |
| 602 |
|
|
| 603 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 604 |
0
|
@Override... |
| 605 |
|
public DataModel getExportDataModel() { |
| 606 |
0
|
return null; |
| 607 |
|
} |
| 608 |
|
|
| 609 |
|
|
| 610 |
|
|
| 611 |
|
@see |
| 612 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 613 |
0
|
@Override... |
| 614 |
|
public String getExportTemplateName() { |
| 615 |
0
|
return exportTemplateName; |
| 616 |
|
} |
| 617 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 618 |
0
|
@Override... |
| 619 |
|
public ArrayList<ExportElement> getExportElementsFromView() { |
| 620 |
0
|
String viewName = null; |
| 621 |
0
|
View currentView = this.getCurrentView(); |
| 622 |
0
|
if (currentView != null) { |
| 623 |
|
|
| 624 |
0
|
ArrayList<ExportElement> exportElements = null; |
| 625 |
|
|
| 626 |
0
|
if (currentView != null && currentView instanceof SectionView) { |
| 627 |
0
|
viewName = currentView.getName(); |
| 628 |
0
|
exportElements = ExportUtils.getExportElementsFromView((SectionView)currentView, exportElements, viewName, "Sectionname"); |
| 629 |
0
|
return exportElements; |
| 630 |
|
} else { |
| 631 |
|
|
| 632 |
|
} |
| 633 |
|
} else { |
| 634 |
|
|
| 635 |
|
} |
| 636 |
0
|
return null; |
| 637 |
|
} |
| 638 |
|
} |