/** * Instantiates a new user statistics. * * @param userId the user id * @param model the model * @param dateFrom the date from * @param dateTo the date to * @param segVal the seg val * @param dispatcher */ public UserStatisticsLayout( Record userRec, String model, Date dateFrom, Date dateTo, final String segVal, DispatchAsync dispatcher, LangConstants lang) { this.dispatcher = dispatcher; this.userId = userRec != null ? userRec.getAttributeAsString(Constants.ATTR_ID) : UNIFYING; this.chartsLayout = new HLayout(); this.lang = lang; this.userName = userRec != null ? (userRec.getAttributeAsString(Constants.ATTR_NAME) + " " + userRec.getAttribute(Constants.ATTR_SURNAME)) : lang.unifyingCharts(); HTMLFlow nameFlow = new HTMLFlow(HtmlCode.title(userName, 3)); nameFlow.setHeight(40); addMember(nameFlow); addMember(chartsLayout); setBackgroundColor("white"); htmlPieFlow = new HTMLFlow(html.replace("%s", PIE_CHART_NESTED_DIV_ID + userId)); htmlPieFlow.setWidth("40%"); htmlPieFlow.setHeight(250); htmlPieFlow.setExtraSpace((userRec != null) ? 10 : 50); chartsLayout.addMember(htmlPieFlow); htmlLineFlow = new HTMLFlow(html.replace("%s", LINE_CHART_NESTED_DIV_ID + userId)); htmlLineFlow.setWidth("*"); htmlLineFlow.setHeight(250); chartsLayout.addMember(htmlLineFlow); setShowEdges(true); setEdgeSize(3); setEdgeOpacity(60); setPadding(5); setExtraSpace(5); setHeight(280); final ModalWindow mw = new ModalWindow(chartsLayout); mw.setLoadingIcon("loadingAnimation.gif"); mw.show(true); setdata(model, dateFrom, dateTo, segVal, mw); }
private void setdata( String model, Date dateFrom, Date dateTo, final String segVal, final ModalWindow mw) { if (!UNIFYING.equals(userId)) { GetUserStatisticDataAction statisticDataAction = new GetUserStatisticDataAction(userId, model, dateFrom, dateTo, segVal); dispatcher.execute( statisticDataAction, new DispatchCallback<GetUserStatisticDataResult>() { @Override public void callback(GetUserStatisticDataResult result) { if (result.getData() != null) { setData(result.getData(), userName); } else { SC.warn("There is no data!!!"); } mw.hide(); afterDraw(); } /** {@inheritDoc} */ @Override public void callbackError(Throwable t) { super.callbackError(t); mw.hide(); afterDraw(); } }); } else { setData(null, null); mw.hide(); } }
private static void onRefresh(DispatchAsync dispatcher, final LangConstants lang) { if (ready) { synchronized (LOCK) { if (ready) { // double-lock idiom ready = false; final ModalWindow mw = new ModalWindow(inputQueueTree); mw.setLoadingIcon("loadingAnimation.gif"); mw.show(true); dispatcher.execute( new ScanInputQueueAction(null, true), new DispatchCallback<ScanInputQueueResult>() { @Override public void callback(ScanInputQueueResult result) { ServerActionResult serverActionResult = result.getServerActionResult(); if (serverActionResult.getServerActionResult() == SERVER_ACTION_RESULT.OK) { mw.hide(); refreshTree(); ready = true; } else if (serverActionResult.getServerActionResult() == SERVER_ACTION_RESULT.WRONG_FILE_NAME) { mw.hide(); SC.warn(lang.wrongDirName() + serverActionResult.getMessage()); } } @Override public void callbackError(final Throwable t) { mw.hide(); super.callbackError(t); ready = true; } }); } } } }
private void getIngestInfo( final String path, final DispatchAsync dispatcher, final EventBus eventBus) { final ModalWindow mw = new ModalWindow(InputQueueTree.this); mw.setLoadingIcon("loadingAnimation.gif"); mw.show(true); Timer timer = new Timer() { @Override public void run() { GetIngestInfoAction ingestInfoAction = new GetIngestInfoAction(path); DispatchCallback<GetIngestInfoResult> ingestInfoCallback = new DispatchCallback<GetIngestInfoResult>() { @Override public void callback(GetIngestInfoResult result) { mw.hide(); List<IngestInfo> ingestInfoList = result.getIngestInfo(); if (ingestInfoList.isEmpty()) { EditorSC.operationFailed(lang, lang.noIngestFile()); } else { IngestInfoWindow.setInstanceOf(ingestInfoList, lang, eventBus); } } @Override public void callbackError(Throwable t) { mw.hide(); super.callbackError(t); } }; dispatcher.execute(ingestInfoAction, ingestInfoCallback); } }; timer.schedule(25); }