List of usage examples for com.google.gwt.user.client.ui Label Label
protected Label(Element element)
From source file:bwbv.rlt.client.ui.HeaderPane.java
License:Apache License
/** * Constructs a new HeaderPane that displays the given text. * /*w ww . java 2 s . co m*/ * @param titleText * The text this header should show as a title. */ public HeaderPane(ClientState clientState, ClientController clientController) { this.clientState = clientState; this.clientController = clientController; clientState.addChangeListener(ClientState.ChangeListener.USERCHANGED_EVENT, this); main = new DockPanel(); main.add(new Label("BWBV RLT Online"), DockPanel.CENTER); reset(); initWidget(main); setStyleName("HeaderPane"); }
From source file:bwbv.rlt.client.ui.HeaderPane.java
License:Apache License
/** * Build this conditionally based on isLoggedIn * @param isLoggedIn/*from ww w .j a v a 2 s. c om*/ * @return */ private HorizontalPanel buildHeaderPanel(boolean isLoggedIn) { HorizontalPanel panel = new HorizontalPanel(); panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); if (isLoggedIn) { panel.setSpacing(10); panel.add(new Label("Welcome " + clientState.getUserName())); Button logoutButton = new Button("Logout"); logoutButton.setStyleName("LogoutButton"); logoutButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { logout(); } }); panel.add(logoutButton); } else { Button loginButon = new Button("Login"); loginButon.setStyleName("LoginButton"); loginButon.addClickListener(new ClickListener() { public void onClick(Widget sender) { showNewUserNameRequestPopupPanel(); } }); panel.add(loginButon); } return panel; }
From source file:ca.farez.sortsomething.client.Sortsomething.java
License:Apache License
public void onModuleLoad() { // Boundary panel message on startup callNumsHere = new Label("Call Numbers will display here!"); callNumsHere.addStyleName("callNumsHere"); // Boundary panel setup boundaryPanel.setPixelSize(1000, 200); boundaryPanel.addStyleName("boundaryPanel"); boundaryPanel.getElement().getStyle().setProperty("position", "relative"); boundaryPanel.add(callNumsHere);/*from w w w . j a v a 2 s .c o m*/ // Call number panel setup cnPanel.addStyleName("cnPanel"); // Setting up widget drag controller final PickupDragController widgetDragController = new PickupDragController(boundaryPanel, false); widgetDragController.setBehaviorMultipleSelection(false); //widgetDragController.addDragHandler(demoDragHandler); // Setting up HP drag controller HorizontalPanelDropController widgetDropController = new HorizontalPanelDropController(cnPanel); widgetDragController.registerDropController(widgetDropController); // scoreMe button setup scoreMeButton.setPixelSize(120, 60); scoreMeButton.setVisible(false); scoreMeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Clear all of Quiz's data structures to avoid null pointers and index out of bounds newQuiz.clean(); // Finds the position on buttons/callnumbers as arranged by users int numOfButtons = cnPanel.getWidgetCount(); setUserOrder(numOfButtons); // Compute our inter-sorted buckets newQuiz.builtInSortQuiz(); // Set the bucket indices for fine sorting later newQuiz.fillBucketCollection(newQuiz.callNums.size()); newQuiz.printBucketCollection(); // Compute our and intra-sorted buckets newQuiz.callNumberIntraBucketSorting(); // Compare the two and find mistakes (if any) //System.out.println("Mistakes BEFORE compare() = " + newQuiz.getMistakes()); int mistakes = newQuiz.compare(); //System.out.println("Mistakes AFTER compare() = " + mistakes); if (mistakes > 0) { if (mistakes == 1) { mistakeLabel = new Label(mistakes + " mistake"); } else mistakeLabel = new Label(mistakes + " mistakes!"); mistakeLabel.addStyleName("yesMistakes"); } else { mistakeLabel = new Label("Correct Solution!"); mistakeLabel.addStyleName("noMistakes"); } if (bottomPanel.getWidgetCount() == 4) { bottomPanel.remove(3); } bottomPanel.add(mistakeLabel); } }); // startQuiz button setup startQuizButton.setPixelSize(120, 60); startQuizButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { scoreMeButton.setVisible(true); String input = inputArea.getText().toUpperCase(); if (input == null || input.trim().equals("")) { // Checking for empty strings Window.alert("Please type something in the text box!"); } else { int newCallNums = newQuiz.populate(input); // Reassemble call number panel only if there are NEW call numbers! if (newCallNums > 0) { cnPanel.clear(); AsyncCallback<Void> callback = autoQuizVoidSetup(); // TODO figure out how to switch to next panel if we've reached the right most side Button cnb; for (int i = 0; i < newQuiz.callNums.size(); i++) { // Storing string in db asynchronously autoQuizSvc.addString(newQuiz.callNums.get(i), callback); // Adding call number to the UI cnb = new Button(newQuiz.callNums.get(i)); cnb.addStyleName("gwt-Button"); cnPanel.add(cnb); cnb.setPixelSize(60, 90); widgetDragController.makeDraggable(cnb); } } callNumsHere.removeFromParent(); if (bottomPanel.getWidgetCount() == 4) mistakeLabel.removeFromParent(); if (scoreMeButton.getParent() != bottomPanel) bottomPanel.add(scoreMeButton); } } }); // generateQuizButton setup generateQuizButton.setPixelSize(120, 60); generateQuizButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String input = generateQuizTextBox.getText(); if (input == null || input.trim().equals("")) { // Checking for empty strings Window.alert("Please type something in the text box!"); } else { int size = Integer.parseInt(input); if (size <= 0) { // Checking for invalid size Window.alert("Please enter a valid quiz size!"); } else { AsyncCallback<String> callback = autoQuizStringSetup(); // Making the call to the auto quiz generation service autoQuizSvc.getQuiz(size, callback); String randomQuiz = generateRandomQuiz(size); inputArea.setText(randomQuiz); } } } }); // newQuizButton Setup newQuizButton.setPixelSize(120, 60); newQuizButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { cnPanel.clear(); newQuiz.clean(); inputArea.setText(""); newQuiz.callNums.clear(); // The clean() call above doesn't clear the entered call number list if (boundaryPanel.getWidgetCount() > 1) { boundaryPanel.remove(1); } boundaryPanel.add(callNumsHere); if (bottomPanel.getWidgetCount() == 4) mistakeLabel.removeFromParent(); scoreMeButton.removeFromParent(); } }); // inputBox text box setup inputArea.setFocus(true); inputArea.setText("Enter one call number per line. For example,\n\n" + "A100 TA2 2006\n" + "PC2600 Z68 2012\n" + "G53 XN1 2011\n"); inputArea.addStyleName("inputArea"); inputArea.setHeight("200px"); inputArea.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (inputAreaOnClickCount == 0) { inputArea.setText(""); } inputAreaOnClickCount++; } }); // Populating Boundary Panel boundaryPanel.add(cnPanel); // Top panel setup topPanel.add(inputArea); topPanel.add(boundaryPanel); // Bottom panel setup bottomPanel.add(startQuizButton); bottomPanel.add(newQuizButton); bottomPanel.add(scoreMeButton); bottomPanel.addStyleName("bottomPanel"); // Populating Manual Quiz Panel manualQuizPanel.add(topPanel); manualQuizPanel.add(bottomPanel); manualQuizPanel.addStyleName("manualQuizPanel"); // Generate Quiz setup generateQuizTextBox.getElement().setPropertyString("placeholder", "Enter the size of the quiz"); // Populating Generated Quiz Panel autoQuizPanel.add(generateQuizTextBox); autoQuizPanel.add(generateQuizButton); // Populating Main Panel tabPanel.add(autoQuizPanel, "Generate Quiz Automatically"); tabPanel.add(manualQuizPanel, "Create Quiz Manually"); tabPanel.selectTab(1); // Adding panels & buttons to Root RootPanel.get().add(tabPanel); }
From source file:ca.nanometrics.gflot.client.example.MarkingsExample.java
License:Open Source License
public Widget createExample() { final Label selectedPointLabel = new Label(INSTRUCTION); PlotWithOverviewModel model = new PlotWithOverviewModel(PlotModelStrategy.defaultStrategy()); PlotOptions plotOptions = new PlotOptions(); plotOptions.setDefaultLineSeriesOptions(new LineSeriesOptions().setLineWidth(1).setShow(true)); plotOptions.setDefaultPointsOptions(new PointsSeriesOptions().setRadius(2).setShow(true)); plotOptions.setDefaultShadowSize(1); plotOptions.setLegendOptions(new LegendOptions().setShow(false)); plotOptions.setSelectionOptions(new SelectionOptions().setDragging(true).setMode("x")); final PlotWithOverview plot = new PlotWithOverview(model, plotOptions); // add hover listener plot.addHoverListener(new PlotHoverListener() { public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) { if (item != null) { selectedPointLabel//from w ww . ja v a2s. com .setText("x: " + item.getDataPoint().getX() + ", y: " + item.getDataPoint().getY()); } else { selectedPointLabel.setText(INSTRUCTION); } } }, false); plot.addSelectionListener(new SelectionListener() { public void selected(double x1, double y1, double x2, double y2) { plot.setLinearSelection(x1, x2); } }); SeriesHandler s = plot.getModel().addSeries("Series 1"); s.add(new DataPoint(1, 2)); s.add(new DataPoint(2, 5)); s.add(new DataPoint(3, 7)); s.add(new DataPoint(4, 5)); s.add(new DataPoint(5, 3)); s.add(new DataPoint(6, 2)); s.add(new DataPoint(7, 5)); s.add(new DataPoint(8, 7)); s.add(new DataPoint(9, 5)); s.add(new DataPoint(10, 3)); // Start of Marking Code Marking m = new Marking(); m.setX(new Range(2, 4)); m.setColor("#3BEFc3"); Marking m2 = new Marking(); m2.setX(new Range(5, 7)); m2.setColor("#cccccc"); Marking m3 = new Marking(); Range a = new Range(); a.setFrom(8); m3.setX(a); m3.setColor("#000000"); Markings ms = new Markings(); ms.addMarking(m); ms.addMarking(m2); ms.addMarking(m3); // End of Marking Code // Add Markings Objects to Grid Options plotOptions.setGridOptions(new GridOptions().setHoverable(true).setMarkings(ms)); plot.setHeight(250); plot.setOverviewHeight(60); FlowPanel panel = new FlowPanel() { @Override protected void onLoad() { super.onLoad(); plot.setLinearSelection(0, 10); plot.redraw(); } }; panel.add(selectedPointLabel); panel.add(plot); return panel; }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:// w w w . j a v a2 s . c o m return new Label(Preference.dateFormat.format(quoteDate)); case 1: return new Label(quoteAssetName); case 2: return new Label(Preference.amountFormat.format(quoteAssetAmount)); case 3: return new Label(Preference.quoteFormat.format(quoteValue)); case 4: return new Label(Preference.unitaryQuoteFormat.format(getUnitValue())); default: return new Label("Quote.getCol error col=" + col); } }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:/*from w w w . j a va2 s. c om*/ return new Label(String.valueOf(id)); case 1: return new Label(yieldTypeName[yieldType]); case 2: return new Label(Preference.dateFormat.format(yieldDate)); //case 3: return new Label(String.valueOf(yieldTaxYear)); case 3: return new Label(yieldAsset); case 4: return new Label(String.valueOf(yieldAssetAmount)); case 5: return new Label(CurrencyUtil.format(yieldGrossCents)); case 6: return new Label(CurrencyUtil.format(yieldNetCents)); case 7: return new Label(yieldAccount == null ? "Nenhuma" : yieldAccount); default: return new Label("Yield.getCol error col=" + col); } }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:// w w w. ja v a 2 s. c o m return new Label(Preference.dateFormat.format(getDate())); case 1: return new Label(getAsset()); case 2: return new Label(String.valueOf(splitFrom)); case 3: return new Label(String.valueOf(splitTo)); default: return new Label("Split.getCol error col=" + col); } }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:/*from ww w . ja v a 2 s. co m*/ return new Label(String.valueOf(id)); case 1: return new Label(Preference.dateFormat.format(buyDate)); case 2: return new Label(operationName[Operation.TRADE_BUY]); case 3: return new Label(Asset.assetTypeName[buyAssetType]); case 4: return new Label(buyAssetName); case 5: return new Label(String.valueOf(buyAmount)); case 6: return new Label("--"); case 7: return new Label(CurrencyUtil.format(buyCostCents)); case 8: return new Label(CurrencyUtil.format(buyExpenseCents)); case 9: return new Label("--"); case 10: return new Label(buyAccount == null ? "Nenhuma" : buyAccount); case 11: return new Label(CurrencyUtil.format((long) ((double) (buyExpenseCents + buyCostCents) / buyAmount))); default: return new Label("Buy.getCol error col=" + col); } }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:/*from w ww . j av a 2 s. c om*/ return new Label(String.valueOf(id)); case 1: return new Label(Preference.dateFormat.format(sellDate)); case 2: return new Label(operationName[Operation.TRADE_SELL]); case 3: return new Label(Asset.assetTypeName[sellAssetType]); case 4: return new Label(sellAssetName); case 5: return new Label(String.valueOf(sellAmount)); case 6: return new Label(CurrencyUtil.format(sellGrossValueCents)); case 7: return new Label(CurrencyUtil.format(sellNetRevenueCents)); case 8: return new Label("--"); case 9: return new Label(CurrencyUtil.format(sellRetainedTaxCents)); case 10: return new Label(sellAccount == null ? "Nenhuma" : sellAccount); case 11: return new Label(CurrencyUtil.format((long) ((double) sellNetRevenueCents / sellAmount))); default: return new Label("Sell.getCol error col=" + col); } }
From source file:carteirainveste.client.DateUtil.java
License:Creative Commons License
Widget getCol(int col) { switch (col) { case 0:/*from w w w. jav a2 s . c om*/ return new Label(String.valueOf(id)); case 1: return new Label(Preference.dateFormat.format(dtDate)); case 2: return new Label(operationName[Operation.TRADE_DAYTRADE]); case 3: return new Label(Asset.assetTypeName[getAssetType()]); case 4: return new Label(dtAssetName); case 5: return new Label(String.valueOf(dtAmount)); case 6: return new Label(CurrencyUtil.format(dtBuyGrossValueCents)); case 7: return new Label(CurrencyUtil.format(dtSellNetValueCents)); case 8: return new Label("--"); case 9: return new Label(CurrencyUtil.format(dtRetainedTaxCents)); case 10: return new Label(dtAccount == null ? "Nenhuma" : dtAccount); case 11: return new Label(CurrencyUtil.format(dtSellNetValueCents - dtBuyGrossValueCents)); default: return new Label("Sell.getCol error col=" + col); } }