List of usage examples for com.google.gwt.user.client.ui Label Label
protected Label(Element element)
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
void dbLog(String msg) { dbLogConsole.add(new Label(msg)); }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
public void execute(Asset a, Sell s) { //Carteira curr = CarteiraInveste.carteiraAtual; int assetType = s.getAssetType(); ///* www .j a va 2 s .c om*/ // Calculate per-asset sales profit // if (assetType != Asset.ASSET_ACAO) return; // Average buy cost for stock double taxAvgBuyCostCents = a.getTaxAverageAcquisitionCostCents(); long taxCostCents = Math.round(s.sellAmount * taxAvgBuyCostCents); long sellProfitCents = s.sellNetRevenueCents - taxCostCents; // // Find monthly accumulation -- only for stocks // Date opDate = s.sellDate; int sellMon = DateUtil.linearMonth(opDate); int monIndex = sellMon - firstSaleMonth; Sales monthSales = monthlyTaxTable.get(monIndex); debugPanel.add(new Label("DBG AccumulateSales: " + DateTimeFormat.getFormat("yyyy-MM-dd").format(opDate) + " " + a.assetName + " amtAcq=" + a.getAcquiredAmount() + " amtSold=" + s.sellAmount + " amtCurr=" + a.getCurrentAmount() + " buyAvgCost=" + CurrencyUtil.formatDouble(taxAvgBuyCostCents / 100) + " buyGrossCost=" + CurrencyUtil.format(taxCostCents) + " saleNetGain=" + CurrencyUtil.format(s.sellNetRevenueCents) + " netResult=" + CurrencyUtil.format(sellProfitCents))); // Update monthly profits if (monthSales == null) debugPanel.add(new Label("ugh AccumulateSales.execute: " + DateTimeFormat.getFormat("yyyy-MM-dd").format(opDate) + a.assetName + " sellMon=" + sellMon + " monIndex=" + monIndex + " monthSales=" + monthSales)); else monthSales.monthSalesNetProfitsCents += sellProfitCents; }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
public void execute(Asset a, DayTrade dt) { ///* w w w . j a v a2 s. c om*/ // Calculate per-asset sales profit // // // Find monthly accumulation // Date opDate = dt.dtDate; int sellMon = DateUtil.linearMonth(opDate); int monIndex = sellMon - firstSaleMonth; Sales monthSales = monthlyTaxTable.get(monIndex); debugPanel.add(new Label("DBG AccumulateDT: " + DateTimeFormat.getFormat("yyyy-MM-dd").format(opDate) + " " + a.assetName + " amt=" + dt.dtAmount + " buyGross=" + CurrencyUtil.format(dt.dtBuyGrossValueCents) + " sellGross=" + CurrencyUtil.format(dt.dtSellGrossValueCents) + " sellNet=" + CurrencyUtil.format(dt.dtSellNetValueCents) + " result=" + CurrencyUtil.format(dt.getNetResultCents()))); // Update monthly profits if (monthSales == null) debugPanel.add(new Label("ugh AccumulateDT.execute: " + DateTimeFormat.getFormat("yyyy-MM-dd").format(opDate) + a.assetName + " sellMon=" + sellMon + " monIndex=" + monIndex + " monthSales=" + monthSales)); else monthSales.dayTradeMonthlyNetResultCents += dt.getNetResultCents(); }
From source file:cc.alcina.framework.gwt.client.ClientNotificationsImpl.java
License:Apache License
@Override public void confirm(String msg, final OkCallback callback) { new OkCancelDialogBox("Confirmation", new Label(msg), new PermissibleActionListener() { @Override// w w w.ja v a 2 s .c o m public void vetoableAction(PermissibleActionEvent evt) { if (evt.getAction() == OkAction.INSTANCE) { callback.ok(); } } }).show(); }
From source file:cc.alcina.framework.gwt.client.ide.Workspace.java
License:Apache License
@SuppressWarnings("unchecked") public void vetoableAction(final PermissibleActionEvent evt) { lastEvent = evt;/*ww w .j ava 2 s .c o m*/ if (evt.getAction().getClass() == CancelAction.class) { visualiser.setContentWidget(new Label("Action cancelled")); fireVetoableActionEvent(evt); return; } Object obj = evt.getSource(); Collection colln = null; Object singleObj = null; Class clazz = null; if (obj instanceof HasVisibleCollection) { colln = ((HasVisibleCollection) obj).getVisibleCollection(); clazz = ((HasVisibleCollection) obj).getCollectionMemberClass(); } else if (obj instanceof DomainNode) { singleObj = ((DomainNode) obj).getUserObject(); clazz = singleObj.getClass(); } else if (obj instanceof ActionDisplayNode) { singleObj = ((ActionDisplayNode) obj).getAction(); } else if (obj != null && (obj instanceof Collection)) { Collection c = (Collection) obj; if (c.size() == 1) { singleObj = c.iterator().next(); // quite possibly a provisional object // if (singleObj instanceof HasIdAndLocalId) { // HasIdAndLocalId hili = (HasIdAndLocalId) singleObj; // singleObj = TransformManager.get().getObject(hili); // } // but provisionalobj.equals(domain)=true TreeItem item = visualiser.selectNodeForObject(singleObj, true); if (item != null) { clazz = singleObj.getClass(); } } } if (colln != null && colln.size() == 1) { singleObj = colln.iterator().next(); } boolean autoSave = ClientBase.getGeneralProperties().isAutoSave(); if (singleObj instanceof PermissibleAction) { Widget view = getViewForAction((PermissibleAction) singleObj); visualiser.setContentWidget(view); fireVetoableActionEvent(evt); return; } if (singleObj instanceof HasIdAndLocalId) { HasIdAndLocalId hili = (HasIdAndLocalId) singleObj; singleObj = TransformManager.get().getObject(hili); } Class<? extends WorkspaceActionHandler> handlerClass = null; if (singleObj != null) { if (evt.getAction().getClass() == ViewAction.class) { handlerClass = ViewActionHandler.class; } else if (evt.getAction().getClass() == EditAction.class) { handlerClass = EditActionHandler.class; } else if (evt.getAction().getClass() == DeleteAction.class) { handlerClass = DeleteActionHandler.class; } else if (evt.getAction().getClass() == CloneAction.class) { handlerClass = CloneActionHandler.class; } else if (evt.getAction().getClass() == CreateAction.class) { handlerClass = CreateActionHandler.class; } } else if (colln != null) { if (evt.getAction().getClass() == ViewAction.class) { handlerClass = ViewActionHandler.class; } else if (evt.getAction().getClass() == EditAction.class) { handlerClass = EditActionHandler.class; } else if (evt.getAction().getClass() == CreateAction.class) { handlerClass = CreateActionHandler.class; } } WorkspaceActionHandler handler = (WorkspaceActionHandler) Registry.get().instantiateSingleOrNull( handlerClass, singleObj == null ? clazz == null ? Object.class : clazz : singleObj.getClass()); handler.performAction(evt, obj, singleObj != null ? singleObj : colln, this, clazz); }
From source file:cc.alcina.framework.gwt.client.objecttree.ObjectTreeRenderer.java
License:Apache License
@SuppressWarnings("unchecked") protected void renderToPanel(TreeRenderable renderable, ComplexPanel cp, int depth, boolean soleChild, RenderContext renderContext, TreeRenderer parent) { if (renderable instanceof Permissible) { Permissible permissible = (Permissible) renderable; if (!PermissionsManager.get().isPermissible(permissible)) { return; }/* w w w . jav a 2 s . c o m*/ } TreeRenderer node = TreeRenderingInfoProvider.get().getForRenderable(renderable, renderContext); if (parent != null) { parent.childRenderers().add(node); } else { renderContext.setRootRenderer(node); } if (depth == 0 && node.renderCss() != null) { cp.setStyleName(node.renderCss()); } node.parentBinding(op.binding); boolean widgetsAdded = false; Collection<? extends TreeRenderer> children = node.renderableChildren(); // title AbstractBoundWidget customiserWidget = null; RenderInstruction renderInstruction = node.renderInstruction(); IsRenderableFilter renderableFilter = renderContext.getRenderableFilter(); if (renderableFilter != null && !renderableFilter.isRenderable(renderable, node)) { renderInstruction = RenderInstruction.NO_RENDER; } if (renderInstruction != RenderInstruction.NO_RENDER) { customiserWidget = node.renderCustomiser() == null ? null : (AbstractBoundWidget) node.renderCustomiser().get(); } level1ContentRendererMap.put(customiserWidget, node); switch (renderInstruction) { case NO_RENDER: return; case AS_WIDGET_WITH_TITLE_IF_MORE_THAN_ONE_CHILD: if (customiserWidget == null && soleChild) { break; } case AS_TITLE: case AS_WIDGET: String displayName = renderable.getDisplayName(); if (CommonUtils.isNotNullOrEmpty(displayName) && !node.isNoTitle()) { Label label = TextProvider.get() .getInlineLabel(TextProvider.get().getUiObjectText(node.getClass(), TextProvider.DISPLAY_NAME + "-" + displayName, CommonUtils.upperCaseFirstLetterOnly(displayName) + ": ")); label.setStyleName("level-" + ((soleChild) ? Math.max(1, depth - 1) : depth)); cp.add(label); if (depth == 1) { level1LabelMap.put(label, node); } widgetsAdded = true; } default: break; } if (customiserWidget != null) { // note - must be responsible for own detach - cleanup customiserWidget.setModel(renderable); node.setBoundWidget(customiserWidget); if (node.renderCss() != null) { customiserWidget.addStyleName(node.renderCss()); } String customiserStyleName = node.isSingleLineCustomiser() ? "single-line-customiser" : "customiser"; String title = node.title(); if (title != null) { customiserWidget.setTitle(title); title = null; } String hint = node.hint(); if (hint != null) { FlowPanel fp2 = new FlowPanel(); Label label = new Label(hint); label.setStyleName("hint"); fp2.add(customiserWidget); fp2.add(label); fp2.addStyleName(customiserStyleName); cp.add(fp2); } else { customiserWidget.addStyleName(customiserStyleName); cp.add(customiserWidget); } return; } if (node.renderInstruction() == RenderInstruction.AS_WIDGET_WITH_TITLE_IF_MORE_THAN_ONE_CHILD || node.renderInstruction() == RenderInstruction.AS_WIDGET) { AbstractBoundWidget bw = new ObjectTreeBoundWidgetCreator().createBoundWidget(renderable, depth, soleChild, node, op.getBinding()); node.setBoundWidget(bw); cp.add(bw); widgetsAdded = true; } if (children != null && children.size() != 0) { ComplexPanel childPanel = cp; if (depth != 0) { if (node.renderChildrenHorizontally()) { HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); childPanel = hp; } else { childPanel = new FlowPanel(); } } if (childPanel != cp) { level1ContentRendererMap.put(childPanel, node); cp.add(childPanel); } List<? extends TreeRenderable> childRenderables = new ArrayList<TreeRenderable>( node.renderableChildren()); maybeSortChildRenderables(childRenderables, renderContext); for (TreeRenderable child : childRenderables) { renderToPanel(child, childPanel, depth + 1, node.renderableChildren().size() == 1, renderContext, node); } } return; }
From source file:cc.alcina.framework.gwt.client.widget.complex.EmailPreviewDisplayer.java
License:Apache License
public EmailPreviewDisplayer(EmailPreview model) { FlowPanel fp = new FlowPanel(); Grid g = new Grid(2, 2); g.setWidget(0, 0, UsefulWidgetFactory.boldInline("To:")); g.setWidget(0, 1, new Label(model.getToAddresses())); g.setWidget(1, 0, UsefulWidgetFactory.boldInline("Subject:")); g.setWidget(1, 1, new Label(model.getSubject())); fp.add(g);// ww w . j a v a 2 s . c o m fp.add(new HTML("<hr />")); frame = new Frame(); frame.setUrl(model.getBody()); fp.add(frame); initWidget(fp); }
From source file:cc.alcina.framework.gwt.client.widget.dialog.CancellableRemoteDialog.java
License:Apache License
public CancellableRemoteDialog(String msg, PermissibleActionListener l, boolean autoShow) { if (l == null) { l = new PermissibleActionListener() { public void vetoableAction(PermissibleActionEvent evt) { CancellableRemoteDialog.this.hide(); }//w ww .ja va 2 s . co m }; } final PermissibleActionListener lCopy = l; setText("Please wait..."); setAnimationEnabled(initialAnimationEnabled()); Grid grr = new Grid(2, 1); status = msg; statusLabel = new Label(msg); grr.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER); grr.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); grr.setCellPadding(4); cancelButton = new Button("Cancel"); setRetryButton(new Button("Retry")); cancelButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { PermissibleAction action = new PermissibleAction(); action.setActionName(CANCEL_ACTION); lCopy.vetoableAction(new PermissibleActionEvent(this, action)); } }); grr.setWidget(0, 0, statusLabel); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(0); hp.add(cancelButton); hp.add(getRetryButton()); getRetryButton().setVisible(false); grr.setWidget(1, 0, hp); setWidget(grr); if (autoShow) { centerAndShow(); } }
From source file:cc.alcina.framework.gwt.client.widget.dialog.LoginDisplayer.java
License:Apache License
public LoginDisplayer() { dialogBox = new GlassDialogBox(); dialogBox.setText("Login"); dialogBox.setAnimationEnabled(true); mainPanel = new FlowPanel(); mainPanel.setStyleName("alcina-Login"); mainPanel.ensureDebugId(AlcinaDebugIds.LOGIN_FORM); this.introWidget = new FlowPanel(); introWidget.setVisible(false);// w ww. j a v a 2 s .co m mainPanel.add(introWidget); introWidget.setStyleName("intro"); cancelButton = new Button("Cancel"); okButton = new Button("Login"); okButton.ensureDebugId(AlcinaDebugIds.LOGIN_SUBMIT); table = new FlexTable(); table.setWidth("100%"); table.setCellSpacing(2); this.usernameLabel = new Label("Username: "); table.setWidget(0, 0, usernameLabel); nameBox = new TextBox(); WidgetUtils.disableTextBoxHelpers(nameBox); nameBox.ensureDebugId(AlcinaDebugIds.LOGIN_USERNAME); table.setWidget(0, 1, nameBox); table.setWidget(1, 0, new Label("Password: ")); pwdBox = new PasswordTextBox(); WidgetUtils.disableTextBoxHelpers(pwdBox); pwdBox.ensureDebugId(AlcinaDebugIds.LOGIN_PASSWORD); table.setWidget(1, 1, pwdBox); pwdBox.addKeyPressHandler(new EnterAsClickKeyboardListener(pwdBox, okButton)); nameBox.addKeyPressHandler(new EnterAsClickKeyboardListener(nameBox, okButton)); rememberMeBox = new CheckBox(); rememberMeBox.setValue(true); table.setWidget(2, 0, rememberMeBox); table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); table.setWidget(2, 1, new Label("Remember me on this computer")); statusLabel = new Label("Logging in"); statusLabel.setVisible(false); table.setWidget(4, 1, statusLabel); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER); hPanel.setSpacing(5); hPanel.add(okButton); okButton.addStyleName("marginRight10"); hPanel.add(cancelButton); table.setWidget(3, 1, hPanel); mainPanel.add(table); dialogBox.setWidget(mainPanel); }
From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java
License:Apache License
public void insertCaption(String text, String className, boolean separator) { if (separator) { Label label = new Label("\u00A0"); label.setStyleName("flowTabBar-separator"); panel2.add(label);/*from www . j a va2s . c o m*/ } Label label = new Label(text); if (className != null) { label.addStyleName(className); } panel2.add(label); }