Java Code Examples for com.google.gwt.user.client.ui.Label#setText()

The following examples show how to use com.google.gwt.user.client.ui.Label#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GalleryAppBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Creates new Gallery app box.
 */
private GalleryAppBox() {
  gContainer = new FlowPanel();
  final HorizontalPanel container = new HorizontalPanel();
  container.setWidth("100%");
  container.setSpacing(0);
  container.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  HorizontalPanel panel = new HorizontalPanel();
  Image image = new Image();
  image.setResource(Ode.getImageBundle().waitingIcon());
  panel.add(image);
  Label label = new Label();
  label.setText(Ode.getMessages().defaultRpcMessage());
  panel.add(label);
  gContainer.add(panel);
  this.add(gContainer);
}
 
Example 2
Source File: ChangeGradeModesDialog.java    From unitime with Apache License 2.0 6 votes vote down vote up
public GradeModeLabel(GradeModeChange change, SpecialRegistrationGradeModeChanges gradeMode) {
	super(null);
	iGradeMode = gradeMode;
	iLabel = new Label();
	iLabel.addStyleName("grade-mode-label");
	iLabel.setText(iGradeMode.getCurrentGradeMode() == null ? "" : iGradeMode.getCurrentGradeMode().getLabel());
	final ListBox box = (ListBox)change.getWidget(); 
	box.addChangeHandler(new ChangeHandler() {
		@Override
		public void onChange(ChangeEvent event) {
			if (box.getSelectedIndex() <= 0) {
				iLabel.setText(iGradeMode.getCurrentGradeMode() == null ? "" : iGradeMode.getCurrentGradeMode().getLabel());
			} else {
				SpecialRegistrationGradeMode m = iGradeMode.getAvailableChange(box.getValue(box.getSelectedIndex()));
				if (m == null) {
					iLabel.setText(iGradeMode.getCurrentGradeMode() == null ? "" : iGradeMode.getCurrentGradeMode().getLabel());
				} else {
					iLabel.setText(m.getLabel());
				}
			}
		}
	});
}
 
Example 3
Source File: PropertyTable.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public void addProperty(Property p, int row) {
	grid.setWidget(row, 0, new Label(p.getName()));

	Label box = new Label();
	box.setText(p.getValue());
	grid.setWidget(row, 1, box);
	box.setStyleName("propetybox");
	properties.put(p, box);
}
 
Example 4
Source File: SqlScriptFileConfigTable.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public void deleteRow(int row){
	this.removeRow(row);
	for( int i = row; i < this.getRowCount() - 1; ++ i ){
		Label label = (Label)this.getWidget(i,0);
		label.setText(name + " " + i);
	}
	active();
}
 
Example 5
Source File: ProfilePage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the GUI components for a regular app tab.
 * This method resides here because it needs access to global variables.
 * @param container: the FlowPanel that this app tab will reside.
 * @param content: the sub-panel that contains the actual app content.
 */
private void addGalleryAppTab(FlowPanel container, FlowPanel content, final String incomingUserId) {
  // Search specific
  generalTotalResultsLabel = new Label();
  container.add(generalTotalResultsLabel);

  final OdeAsyncCallback<GalleryAppListResult> byAuthorCallback = new OdeAsyncCallback<GalleryAppListResult>(
    // failure message
    MESSAGES.galleryError()) {
    @Override
    public void onSuccess(GalleryAppListResult appsResult) {
      refreshApps(appsResult,false);
    }
  };
  Ode.getInstance().getGalleryService().getDeveloperApps(userId,appCatalogCounter ,NUMAPPSTOSHOW, byAuthorCallback);
  container.add(content);

  buttonNext = new Label();
  buttonNext.setText(MESSAGES.galleryMoreApps());
  buttonNext.addStyleName("active");

  FlowPanel next = new FlowPanel();
  next.add(buttonNext);
  next.addStyleName("gallery-nav-next");
  container.add(next);
  buttonNext.addClickHandler(new ClickHandler() {
    //  @Override
    public void onClick(ClickEvent event) {
       if (!appCatalogExhausted) {
            // If the next page still has apps to retrieve, do it
            appCatalogCounter += NUMAPPSTOSHOW;
            Ode.getInstance().getGalleryService().getDeveloperApps(userId,appCatalogCounter ,NUMAPPSTOSHOW, byAuthorCallback);
          }
    }
  });
}
 
Example 6
Source File: ReportList.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Help method for Email Collapse Function
 * When the button(see more) is clicked, it will retrieve the whole email from database.
 * @param parent the parent container
 * @param emailId email id
 * @param preview email preview
 */
void createEmailCollapse(final FlowPanel parent, final long emailId, final String preview){
  final Label emailContent = new Label();
  emailContent.setText(preview);
  emailContent.addStyleName("inline-label");
  parent.add(emailContent);
  final Label actionButton = new Label();
  actionButton.setText(MESSAGES.seeMoreLink());
  actionButton.addStyleName("seemore-link");
  parent.add(actionButton);
  if(preview.length() <= MAX_EMAIL_PREVIEW_LENGTH){
    actionButton.setVisible(false);
  }
  actionButton.addClickHandler(new ClickHandler() {
    boolean ifPreview = true;
    @Override
    public void onClick(ClickEvent event) {
      if(ifPreview == true){
        OdeAsyncCallback<Email> callback = new OdeAsyncCallback<Email>(
            // failure message
            MESSAGES.serverUnavailable()) {
              @Override
              public void onSuccess(final Email email) {
                emailContent.setText(email.getBody());
                emailContent.addStyleName("inline");
                actionButton.setText(MESSAGES.hideLink());
                ifPreview = false;
              }
            };
        Ode.getInstance().getGalleryService().getEmail(emailId, callback);
      }else{
        emailContent.setText(preview);
        actionButton.setText(MESSAGES.seeMoreLink());
        ifPreview = true;
      }
    }
  });
}
 
Example 7
Source File: ConflictBasedStatisticsTree.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected TreeItem generate(final CBSNode node) {
	P widget = new P("cbs-node");
	Label counter = new Label(); counter.setText(node.getCount() + " \u00D7");
	widget.add(counter);
	if (node.getHTML() != null) {
		HTML html = new HTML(node.getHTML());
		widget.add(html);
	} else {
		Label name = new Label(); name.setText(node.getName());
		if (node.getPref() != null && iProperties != null) {
			PreferenceInterface pref = iProperties.getPreference(node.getPref());
			if (pref != null)
				name.getElement().getStyle().setColor(pref.getColor());
		}
		widget.add(name);
	}
	widget.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			ConflictBasedStatisticsTree.this.onClick(event, node);
		}
	});
	TreeItem item = new TreeItem(widget);
	if (node.hasNodes()) {
		for (CBSNode child: node.getNodes()) {
			item.addItem(generate(child));
		}
	}
	return item;
}
 
Example 8
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Helper method called by constructor to initialize the report section
 */
private void initReportSection() {
  final HTML reportPrompt = new HTML();
  reportPrompt.setHTML(MESSAGES.galleryReportPrompt());
  reportPrompt.addStyleName("primary-prompt");
  final TextArea reportText = new TextArea();
  reportText.addStyleName("action-textarea");
  final Button submitReport = new Button(MESSAGES.galleryReportButton());
  submitReport.addStyleName("action-button");
  final Label descriptionError = new Label();
  descriptionError.setText("Description required");
  descriptionError.setStyleName("ode-ErrorMessage");
  descriptionError.setVisible(false);
  appReportPanel.add(reportPrompt);
  appReportPanel.add(descriptionError);
  appReportPanel.add(reportText);
  appReportPanel.add(submitReport);

  final OdeAsyncCallback<Boolean> isReportdByUserCallback = new OdeAsyncCallback<Boolean>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(Boolean isAlreadyReported) {
          if(isAlreadyReported) { //already reported, cannot report again
            reportPrompt.setHTML(MESSAGES.galleryAlreadyReportedPrompt());
            reportText.setVisible(false);
            submitReport.setVisible(false);
            submitReport.setEnabled(false);
          } else {
            submitReport.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                final OdeAsyncCallback<Long> reportClickCallback = new OdeAsyncCallback<Long>(
                    // failure message
                    MESSAGES.galleryError()) {
                      @Override
                      public void onSuccess(Long id) {
                        reportPrompt.setHTML(MESSAGES.galleryReportCompletionPrompt());
                        reportText.setVisible(false);
                        submitReport.setVisible(false);
                        submitReport.setEnabled(false);
                      }
                  };
                if (!reportText.getText().trim().isEmpty()){
                  Ode.getInstance().getGalleryService().addAppReport(app, reportText.getText(),
                    reportClickCallback);
                  descriptionError.setVisible(false);
                } else {
                  descriptionError.setVisible(true);
                }
              }
            });
          }
        }
    };
  Ode.getInstance().getGalleryService().isReportedByUser(app.getGalleryAppId(),
      isReportdByUserCallback);
}
 
Example 9
Source File: Ode.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private Widget createLoadingWidget(final int pending) {
  final HorizontalPanel container = new HorizontalPanel();
  container.setWidth("100%");
  container.setSpacing(0);
  container.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  HorizontalPanel panel = new HorizontalPanel();
  Image image = new Image();
  image.setResource(IMAGES.waitingIcon());
  panel.add(image);
  Label label = new Label();
  label.setText(MESSAGES.defaultRpcMessage());
  panel.add(label);
  container.add(panel);
  GalleryClient.getInstance().addListener(new GalleryRequestListener() {
    volatile int count = pending;
    private void hideLoadingWidget() {
      if (container.getParent() != null) {
        container.clear();
        container.removeFromParent();
      }
    }
    @Override
    public boolean onAppListRequestCompleted(GalleryAppListResult appsResult, int requestID, boolean refreshable) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
    @Override
    public boolean onCommentsRequestCompleted(List<GalleryComment> comments) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
    @Override
    public boolean onSourceLoadCompleted(UserProject projectInfo) {
      if ((--count) <= 0) {
        hideLoadingWidget();
        return true;
      }
      return false;
    }
  });
  return container;
}
 
Example 10
Source File: HasFileStatInfoTablePage.java    From sc2gears with Apache License 2.0 4 votes vote down vote up
private void renderInfoRow( final FileStatInfo info, final FlexTable table, final ClickHandler googleAccountClickHandler ) {
	final CellFormatter cellFormatter = table.getCellFormatter();
	final RowFormatter  rowFormatter  = table.getRowFormatter();
	
	int column = 0;
	
	table.setWidget( row, column++, new Label( userCounter + "." ) );
	cellFormatter.setHorizontalAlignment( row, column-1, HasHorizontalAlignment.ALIGN_RIGHT );
	
	final VerticalPanel userPanel = new VerticalPanel();
	if ( info.getAddressedBy() != null )
		userPanel.add( ClientUtils.styledWidget( new Label( info.getAddressedBy() + ", "
			+ ( info.getCountry() == null ? "-" : info.getCountry() ) ), "explanation" ) );
	if ( googleAccountClickHandler == null || userCounter == 0 )
		userPanel.add( new Label( info.getGoogleAccount() ) );
	else {
		final Anchor googleAccountAnchor = new Anchor( info.getGoogleAccount() );
		googleAccountAnchor.setTitle( googleAccountClickHandler.toString() );
		googleAccountAnchor.addClickHandler( googleAccountClickHandler );
		userPanel.add( googleAccountAnchor );
	}
	userPanel.add( ClientUtils.styledWidget( ClientUtils.createTimestampWidget( "Updated: ", info.getUpdated() ), "explanation" ) );
	userPanel.add( ClientUtils.styledWidget( new Label(
		( info.getAccountCreated() == null ? "" : "Created: " + ClientUtils.DATE_FORMAT.format( info.getAccountCreated() ) + ", " )
		+ "Pkg: " + info.getDbPackageName() + ";" ), "explanation" ) );
	if ( info.getComment() != null ) {
		final Label commentLabel = new Label();
		if ( info.getComment().length() <= 40 )
			commentLabel.setText( info.getComment() );
		else {
			commentLabel.setText( info.getComment().substring( 0, 40 ) + "..." );
			commentLabel.setTitle( info.getComment() );
		}
		userPanel.add( ClientUtils.styledWidget( commentLabel, "explanation" ) );
	}
	table.setWidget( row, column++, userPanel );
	
	final Widget dbPackageWidget = info.getDbPackageIcon() == null ? new Label( info.getDbPackageName() ) : new Image( info.getDbPackageIcon() );
	dbPackageWidget.setTitle( "Available storage: " + NUMBER_FORMAT.format( info.getPaidStorage() ) + " bytes" );
	table.setWidget( row, column++, dbPackageWidget );
	int rowSpan = 1;
	if ( info.getRepCount  () > 0 ) rowSpan++;
	if ( info.getSmpdCount () > 0 ) rowSpan++;
	if ( info.getOtherCount() > 0 ) rowSpan++;
	if ( rowSpan > 1 )
		for ( int i = column - 1; i >= 0; i-- )
			table.getFlexCellFormatter().setRowSpan( row, i, rowSpan );
	userCounter++;
	
	for ( int type = 0; type < 4; type++ ) {
		String fileType = null;
		int    count    = 0;
		long   storage  = 0;
		switch ( type ) {
		case 0 : count = info.getAllCount(); storage = info.getAllStorage(); fileType = "<all>"; break;
		case 1 : if ( ( count = info.getRepCount  () ) == 0 ) continue; storage = info.getRepStorage  (); fileType = "rep"  ; column = 0; break;
		case 2 : if ( ( count = info.getSmpdCount () ) == 0 ) continue; storage = info.getSmpdStorage (); fileType = "smpd" ; column = 0; break;
		case 3 : if ( ( count = info.getOtherCount() ) == 0 ) continue; storage = info.getOtherStorage(); fileType = "other"; column = 0; break;
		}
		table.setWidget( row, column++, new Label( fileType ) );
		final int firstNumberColumn = column;
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count ) ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( storage ) + " bytes" ) );
		table.setWidget( row, column++, new Label( NUMBER_FORMAT.format( count == 0 ? 0 : storage / count ) + " bytes" ) );
		final int usedPercent = info.getPaidStorage() == 0 ? 0 : (int) ( storage * 100 / info.getPaidStorage() );
		table.setWidget( row, column++, new Label( usedPercent + "%" ) );
		
		for ( int i = column - 1; i >= firstNumberColumn; i-- )
			cellFormatter.setHorizontalAlignment( row, i, HasHorizontalAlignment.ALIGN_RIGHT );
		
		rowFormatter.addStyleName( row, userCounter == 1 ? "gold" : ( userCounter & 0x01 ) == 0 ? "row0" : "row1" );
		
		row++;
	}
}
 
Example 11
Source File: AssignmentDialog.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Widget asWidget() {
    ProvidesKey<Role> keyProvider = Role::getId;

    AbstractCell<Role> roleCell = new AbstractCell<Role>() {
        @Override
        public void render(final Context context, final Role value, final SafeHtmlBuilder sb) {
            sb.append(Templates.roleItem("navigation-column-item", value));
        }
    };
    DefaultCellList<Role> list = new DefaultCellList<>(roleCell, keyProvider);
    list.setPageSize(30);
    list.setKeyboardPagingPolicy(INCREASE_RANGE);
    list.setKeyboardSelectionPolicy(BOUND_TO_SELECTION);

    ListDataProvider<Role> dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.setList(
            Roles.orderedByType().compound(Roles.orderedByName()).immutableSortedCopy(unassignedRoles));
    dataProvider.addDataDisplay(list);

    SingleSelectionModel<Role> selectionModel = new SingleSelectionModel<>(keyProvider);
    list.setSelectionModel(selectionModel);
    selectionModel.setSelected(dataProvider.getList().get(0), true);
    Scheduler.get().scheduleDeferred(() -> list.setFocus(true));

    Label errorMessage = new Label();
    errorMessage.setVisible(false);
    errorMessage.getElement().getStyle().setColor("#c82e2e");
    errorMessage.getElement().getStyle().setPadding(7, PX);

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");
    layout.add(errorMessage);
    layout.add(list);

    DialogueOptions options = new DialogueOptions(
            event -> {
                if (selectionModel.getSelectedObject() == null) {
                    errorMessage.setText(Console.CONSTANTS.pleaseSelectRole());
                    errorMessage.setVisible(true);
                } else {
                    Assignment assignment = new Assignment(principal, selectionModel.getSelectedObject(),
                            include);
                    circuit.dispatch(new AddAssignment(assignment, PRINCIPAL_TO_ROLE));
                    presenter.closeWindow();
                }
            },
            event -> presenter.closeWindow()
    );

    return new WindowContentBuilder(layout, options).build();
}
 
Example 12
Source File: MemberDialog.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Widget asWidget() {
    ProvidesKey<Principal> keyProvider = Principal::getId;

    AbstractCell<Principal> roleCell = new AbstractCell<Principal>() {
        @Override
        public void render(final Context context, final Principal value, final SafeHtmlBuilder sb) {
            sb.append(Templates.memberItem("navigation-column-item", value));
        }
    };
    DefaultCellList<Principal> list = new DefaultCellList<>(roleCell, keyProvider);
    list.setPageSize(30);
    list.setKeyboardPagingPolicy(INCREASE_RANGE);
    list.setKeyboardSelectionPolicy(BOUND_TO_SELECTION);

    ListDataProvider<Principal> dataProvider = new ListDataProvider<>(keyProvider);
    dataProvider.setList(Principals.orderedByType()
            .compound(Principals.orderedByName())
            .immutableSortedCopy(unassignedPrincipals));
    dataProvider.addDataDisplay(list);

    SingleSelectionModel<Principal> selectionModel = new SingleSelectionModel<>(keyProvider);
    list.setSelectionModel(selectionModel);
    selectionModel.setSelected(dataProvider.getList().get(0), true);
    Scheduler.get().scheduleDeferred(() -> list.setFocus(true));

    Label errorMessage = new Label();
    errorMessage.setVisible(false);
    errorMessage.getElement().getStyle().setColor("#c82e2e");
    errorMessage.getElement().getStyle().setPadding(7, PX);

    VerticalPanel layout = new VerticalPanel();
    layout.setStyleName("window-content");
    layout.add(errorMessage);
    layout.add(list);

    DialogueOptions options = new DialogueOptions(
            event -> {
                if (selectionModel.getSelectedObject() == null) {
                    errorMessage.setText(Console.CONSTANTS.pleaseSelectPrincipal());
                    errorMessage.setVisible(true);
                } else {
                    Assignment assignment = new Assignment(selectionModel.getSelectedObject(), role,
                            include);
                    circuit.dispatch(new AddAssignment(assignment, ROLE_TO_PRINCIPAL));
                    presenter.closeWindow();
                }
            },
            event -> presenter.closeWindow()
    );

    return new WindowContentBuilder(layout, options).build();
}