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

The following examples show how to use com.google.gwt.user.client.ui.Label#addStyleName() . 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: SqlScriptFileConfigTable.java    From EasyML with Apache License 2.0 6 votes vote down vote up
public SqlScriptFileConfigTable(SqlProgramWidget widget, String name){
	this.widget = widget;
	this.name = name;
	this.insertRow(0);
	Label add = new Label();
	add.addStyleName("admin-user-edit");
	this.setWidget(0, 0, new Label(name));
	this.setWidget(0, 1, new Label());
	this.setWidget(0, 2, add);
	this.setWidget(0, 3, new Label());
	add.addClickHandler(new ClickHandler(){

		@Override
		public void onClick(ClickEvent event) {
			int i = 0;
			while( i < SqlScriptFileConfigTable.this.getRowCount() 
					&& SqlScriptFileConfigTable.this.getWidget(i, 2 ) != event.getSource() ) i ++ ;

			if( i < SqlScriptFileConfigTable.this.getRowCount() ){
				addRow( i, "");
			}

		}

	});
}
 
Example 2
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's title section
 * @param container   The container that title resides
 */
private void initAppTitle(Panel container) {
  if (newOrUpdateApp()) {
    // GUI for editable title container
    if (editStatus==NEWAPP) {
      // If it's new app, give a textual hint telling user this is title
      titleText.setText(app.getTitle());
    } else if (editStatus==UPDATEAPP) {
      // If it's not new, just set whatever's in the data field already
      titleText.setText(app.getTitle());
    }
    titleText.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setTitle(titleText.getText());
      }
    });
    titleText.addStyleName("app-desc-textarea");
    container.add(titleText);
    container.addStyleName("app-title-container");
  } else {
    Label title = new Label(app.getTitle());
    title.addStyleName("app-title");
    container.add(title);
  }
}
 
Example 3
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the salvage section
 * @param container   The container that salvage label reside
 */
private void initSalvageSection(Panel container) { //TODO: Update the location of this button
  if (!canSalvage()) {                              // Permitted to salvage?
    return;
  }

  final Label salvagePrompt = new Label("salvage");
  salvagePrompt.addStyleName("primary-link");
  container.add(salvagePrompt);

  salvagePrompt.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
      final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>(
          // failure message
          MESSAGES.galleryError()) {
            @Override
            public void onSuccess(Void bool) {
              salvagePrompt.setText("done");
            }
        };
      Ode.getInstance().getGalleryService().salvageGalleryApp(app.getGalleryAppId(), callback);
    }
  });
}
 
Example 4
Source File: TaskExecutionsTable.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected Widget getCell(final TaskExecutionInterface e, final TaskExecutionsTableColumn column, final int idx) {
	switch (column) {
	case DATE: return new Label(sDateFormatMeeting.format(e.getExecutionDate()));
	case TIME: return new Label(e.getExecutionTime(CONSTANTS));
	case QUEUED: return new Label(e.getQueued() == null ? "" : sDateFormatTS.format(e.getQueued()));
	case STARTED: return new Label(e.getStarted() == null ? "" : sDateFormatTS.format(e.getStarted()));
	case FINISHED: return new Label(e.getFinished() == null ? "" : sDateFormatTS.format(e.getFinished()));
	case STATUS: return new Label(CONSTANTS.taskStatus()[e.getStatus().ordinal()]);
	case MESSAGE:
		Label message = new Label(e.getStatusMessage() == null ? "" : e.getStatusMessage()); message.addStyleName("status-message");
		if (e.getStatusMessage() != null)
			message.setTitle(e.getStatusMessage());
		return message;
	case OUTPUT:
		if (e.getOutput() != null) return new Anchor(e.getOutput(), GWT.getHostPageBaseURL() + "taskfile?e=" + e.getId());
		return new Label("");
	default:
		return null;
	}
}
 
Example 5
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 6
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's comment area
 */
private void initAppComments() {
  // App details - comments
  appDetails.add(appComments);
  appComments.addStyleName("app-comments-wrapper");
  Label commentsHeader = new Label("Comments and Reviews");
  commentsHeader.addStyleName("app-comments-header");
  appComments.add(commentsHeader);
  final TextArea commentTextArea = new TextArea();
  commentTextArea.addStyleName("app-comments-textarea");
  appComments.add(commentTextArea);
  Button commentSubmit = new Button("Submit my comment");
  commentSubmit.addStyleName("app-comments-submit");
  commentSubmit.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final OdeAsyncCallback<Long> commentPublishCallback = new OdeAsyncCallback<Long>(
          // failure message
          MESSAGES.galleryError()) {
            @Override
            public void onSuccess(Long date) {
              // get the new comment list so gui updates
              //   note: we might modify the call to publishComment so it returns
              //   the list instead, this would save one server call
              gallery.GetComments(app.getGalleryAppId(), 0, 100);
            }
        };
      Ode.getInstance().getGalleryService().publishComment(app.getGalleryAppId(),
          commentTextArea.getText(), commentPublishCallback);
    }
  });
  appComments.add(commentSubmit);

  // Add list of comments
  gallery.GetComments(app.getGalleryAppId(), 0, 100);
  appComments.add(appCommentsList);
  appCommentsList.addStyleName("app-comments");

}
 
Example 7
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 8
Source File: ReportList.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the header row to the table.
 *
 */
private void setHeaderRow() {
  table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

  HorizontalPanel reportHeader = new HorizontalPanel();
  final Label reportHeaderLabel = new Label(MESSAGES.moderationReportTextHeader());
  reportHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  reportHeader.add(reportHeaderLabel);
  table.setWidget(0, 0, reportHeader);

  HorizontalPanel appHeader = new HorizontalPanel();
  final Label appHeaderLabel = new Label(MESSAGES.moderationAppHeader());
  appHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  appHeader.add(appHeaderLabel);
  table.setWidget(0, 1, appHeader);

  HorizontalPanel dateCreatedHeader = new HorizontalPanel();
  final Label dateCreatedHeaderLabel = new Label(MESSAGES.moderationReportDateCreatedHeader());
  dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  dateCreatedHeader.add(dateCreatedHeaderLabel);
  table.setWidget(0, 2, dateCreatedHeader);

  HorizontalPanel appAuthorHeader = new HorizontalPanel();
  final Label appAuthorHeaderLabel = new Label(MESSAGES.moderationAppAuthorHeader());
  appAuthorHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  appAuthorHeader.add(appAuthorHeaderLabel);
  table.setWidget(0, 3, appAuthorHeader);

  HorizontalPanel reporterHeader = new HorizontalPanel();
  final Label reporterHeaderLabel = new Label(MESSAGES.moderationReporterHeader());
  reporterHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  reporterHeader.add(reporterHeaderLabel);
  table.setWidget(0, 4, reporterHeader);

}
 
Example 9
Source File: ReportList.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor of ReportWidgets
 * @param report GalleryAppReport
 */
private ReportWidgets(final GalleryAppReport report) {

  reportTextLabel = new Label(report.getReportText());
  reportTextLabel.addStyleName("ode-ProjectNameLabel");
  reportTextLabel.setWordWrap(true);
  reportTextLabel.setWidth("200px");

  appLabel = new Label(report.getApp().getTitle());
  appLabel.addStyleName("primary-link");

  DateTimeFormat dateTimeFormat = DateTimeFormat.getMediumDateTimeFormat();
  Date dateCreated = new Date(report.getTimeStamp());
  dateCreatedLabel = new Label(dateTimeFormat.format(dateCreated));

  appAuthorlabel = new Label(report.getOffender().getUserName());
  appAuthorlabel.addStyleName("primary-link");

  reporterLabel = new Label(report.getReporter().getUserName());
  reporterLabel.addStyleName("primary-link");

  sendEmailButton = new Button(MESSAGES.buttonSendEmail());

  deactiveAppButton = new Button(MESSAGES.labelDeactivateApp());

  markAsResolvedButton = new Button(MESSAGES.labelmarkAsResolved());

  seeAllActions = new Button(MESSAGES.labelSeeAllActions());
}
 
Example 10
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 11
Source File: GuestSignaturePanel.java    From appengine-gwtguestbook-namespaces-java with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a guest signature panel, with components fully instantiated and
 * attached. 
 * 
 */
public GuestSignaturePanel() {
  entryUpdateHandlers = new ArrayList<EntryUpdateHandler>();
  guestSignaturePanel = new HorizontalPanel();

  // Create guest signature panel widgets
  guestNameBox = new TextBox();
  guestMessageBox = new TextBox();
  guestNameLabel = new Label("Your Name:");
  guestMessageLabel = new Label("Message:");
  signButton = new Button("Sign!");

  // Set up the widget guest signature panel widget styles (additional to
  // standard styles)
  guestNameLabel.addStyleName("gb-Label");
  guestMessageLabel.addStyleName("gb-Label");
  guestNameBox.addStyleName("gb-NameBox");
  guestMessageBox.addStyleName("gb-MessageBox");

  // Attach components together
  guestSignaturePanel.add(guestNameLabel);
  guestSignaturePanel.add(guestNameBox);
  guestSignaturePanel.add(guestMessageLabel);
  guestSignaturePanel.add(guestMessageBox);
  guestSignaturePanel.add(signButton);

  signButton.addClickHandler(this);

 /* The initWidget(Widget) method inherited from the Composite class must be
  * called exactly once in the constructor to declare the widget that this 
  * composite class is wrapping. */
  initWidget(guestSignaturePanel);
}
 
Example 12
Source File: ProjectList.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the header row to the table.
 *
 */
private void setHeaderRow() {
  table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

  HorizontalPanel nameHeader = new HorizontalPanel();
  final Label nameHeaderLabel = new Label(MESSAGES.projectNameHeader());
  nameHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  nameHeader.add(nameHeaderLabel);
  nameSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  nameHeader.add(nameSortIndicator);
  table.setWidget(0, 1, nameHeader);

  HorizontalPanel dateCreatedHeader = new HorizontalPanel();
  final Label dateCreatedHeaderLabel = new Label(MESSAGES.projectDateCreatedHeader());
  dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  dateCreatedHeader.add(dateCreatedHeaderLabel);
  dateCreatedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  dateCreatedHeader.add(dateCreatedSortIndicator);
  table.setWidget(0, 2, dateCreatedHeader);

  HorizontalPanel dateModifiedHeader = new HorizontalPanel();
  final Label dateModifiedHeaderLabel = new Label(MESSAGES.projectDateModifiedHeader());
  dateModifiedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  dateModifiedHeader.add(dateModifiedHeaderLabel);
  dateModifiedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  dateModifiedHeader.add(dateModifiedSortIndicator);
  table.setWidget(0, 3, dateModifiedHeader);

  HorizontalPanel publishedHeader = new HorizontalPanel();
  final Label publishedHeaderLabel = new Label(MESSAGES.projectPublishedHeader());
  publishedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  publishedHeader.add(publishedHeaderLabel);
  publishedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  publishedHeader.add(publishedSortIndicator);
  table.setWidget(0, 4, publishedHeader);

  MouseDownHandler mouseDownHandler = new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent e) {
      SortField clickedSortField;
      if (e.getSource() == nameHeaderLabel || e.getSource() == nameSortIndicator) {
        clickedSortField = SortField.NAME;
      } else if (e.getSource() == dateCreatedHeaderLabel || e.getSource() == dateCreatedSortIndicator) {
        clickedSortField = SortField.DATE_CREATED;
      } else if (e.getSource() == dateModifiedHeaderLabel || e.getSource() == dateModifiedSortIndicator){
        clickedSortField = SortField.DATE_MODIFIED;
      }else{
        clickedSortField = SortField.PUBLISHED;
      }
      changeSortOrder(clickedSortField);
    }
  };
  nameHeaderLabel.addMouseDownHandler(mouseDownHandler);
  nameSortIndicator.addMouseDownHandler(mouseDownHandler);
  dateCreatedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  dateCreatedSortIndicator.addMouseDownHandler(mouseDownHandler);
  dateModifiedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  dateModifiedSortIndicator.addMouseDownHandler(mouseDownHandler);
  publishedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  publishedSortIndicator.addMouseDownHandler(mouseDownHandler);
}
 
Example 13
Source File: TrashProjectList.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the header row to the table.
 *
 */
private void setHeaderRow() {
  table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

  HorizontalPanel nameHeader = new HorizontalPanel();
  final Label nameHeaderLabel = new Label(MESSAGES.projectNameHeader());
  nameHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  nameHeader.add(nameHeaderLabel);
  nameSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  nameHeader.add(nameSortIndicator);
  table.setWidget(0, 1, nameHeader);

  HorizontalPanel dateCreatedHeader = new HorizontalPanel();
  final Label dateCreatedHeaderLabel = new Label(MESSAGES.projectDateCreatedHeader());
  dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  dateCreatedHeader.add(dateCreatedHeaderLabel);
  dateCreatedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  dateCreatedHeader.add(dateCreatedSortIndicator);
  table.setWidget(0, 2, dateCreatedHeader);

  HorizontalPanel dateModifiedHeader = new HorizontalPanel();
  final Label dateModifiedHeaderLabel = new Label(MESSAGES.projectDateModifiedHeader());
  dateModifiedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  dateModifiedHeader.add(dateModifiedHeaderLabel);
  dateModifiedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  dateModifiedHeader.add(dateModifiedSortIndicator);
  table.setWidget(0, 3, dateModifiedHeader);

  HorizontalPanel publishedHeader = new HorizontalPanel();
  final Label publishedHeaderLabel = new Label(MESSAGES.projectPublishedHeader());
  publishedHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  publishedHeader.add(publishedHeaderLabel);
  publishedSortIndicator.addStyleName("ode-ProjectHeaderLabel");
  publishedHeader.add(publishedSortIndicator);
  table.setWidget(0, 4, publishedHeader);

  MouseDownHandler mouseDownHandler = new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent e) {
      SortField clickedSortField;
      if (e.getSource() == nameHeaderLabel || e.getSource() == nameSortIndicator) {
          clickedSortField = SortField.NAME;
      } else if (e.getSource() == dateCreatedHeaderLabel || e.getSource() == dateCreatedSortIndicator) {
          clickedSortField = SortField.DATE_CREATED;
      } else if (e.getSource() == dateModifiedHeaderLabel || e.getSource() == dateModifiedSortIndicator) {
          clickedSortField = SortField.DATE_MODIFIED;
      } else {
          clickedSortField = SortField.PUBLISHED;
      }
      changeSortOrder(clickedSortField);
    }
  };
  nameHeaderLabel.addMouseDownHandler(mouseDownHandler);
  nameSortIndicator.addMouseDownHandler(mouseDownHandler);
  dateCreatedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  dateCreatedSortIndicator.addMouseDownHandler(mouseDownHandler);
  dateModifiedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  dateModifiedSortIndicator.addMouseDownHandler(mouseDownHandler);
  publishedHeaderLabel.addMouseDownHandler(mouseDownHandler);
  publishedSortIndicator.addMouseDownHandler(mouseDownHandler);
}
 
Example 14
Source File: AdminUserList.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the header row to the table.
 *
 */
private void setHeaderRow() {

  if (galleryEnabledHolder.enabled) {
    table.resizeColumns(5); // Number of columns varies based on whether or not
                            // the Gallery is enabled
  } else {
    table.resizeColumns(4);
  }

  table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");

  HorizontalPanel emailHeader = new HorizontalPanel();
  final Label emailHeaderLabel = new Label("User Email");
  int column = 0;
  emailHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  emailHeader.add(emailHeaderLabel);
  emailHeader.add(nameSortIndicator);
  table.setWidget(0, column, emailHeader);
  column += 1;

  HorizontalPanel uidHeader = new HorizontalPanel();
  final Label uidHeaderLabel = new Label("UID");
  uidHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  uidHeader.add(uidHeaderLabel);
  table.setWidget(0, column++, uidHeader);

  HorizontalPanel adminHeader = new HorizontalPanel();
  final Label adminHeaderLabel = new Label("isAdmin?");
  adminHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
  adminHeader.add(adminHeaderLabel);
  table.setWidget(0, column++, adminHeader);

  if (galleryEnabledHolder.enabled) {
    HorizontalPanel moderatorHeader = new HorizontalPanel();
    final Label moderatorHeaderLabel = new Label("isModerator?");
    moderatorHeaderLabel.addStyleName("ode-ProjectHeaderLabel");
    moderatorHeader.add(moderatorHeaderLabel);
    table.setWidget(0, column++, moderatorHeader);
  }

  HorizontalPanel visitedHeader = new HorizontalPanel();
  final Label visitedLabel = new Label("Visited");
  visitedLabel.addStyleName("ode-ProjectHeaderLabel");
  visitedHeader.add(visitedLabel);
  visitedHeader.add(visitedSortIndicator);
  table.setWidget(0, column++, visitedHeader);

  MouseDownHandler mouseDownHandler = new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent e) {
      SortField clickedSortField;
      if (e.getSource() == emailHeaderLabel || e.getSource() == nameSortIndicator) {
        clickedSortField = SortField.NAME;
      } else if (e.getSource() == visitedLabel || e.getSource() == visitedSortIndicator) {
        clickedSortField = SortField.VISITED;
      } else {
        return;
      }
      changeSortOrder(clickedSortField);
    }
  };
  emailHeaderLabel.addMouseDownHandler(mouseDownHandler);
  nameSortIndicator.addMouseDownHandler(mouseDownHandler);
  visitedLabel.addMouseDownHandler(mouseDownHandler);
  visitedSortIndicator.addMouseDownHandler(mouseDownHandler);
}
 
Example 15
Source File: GalleryGuiFactory.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates list of comments in the app page.
 * @param comments: list of returned gallery comments from callback.
 * @param container: the GUI panel where comments will reside.
 */
public void generateAppPageComments(List<GalleryComment> comments, FlowPanel container) {
  container.clear();  // so don't show previous listing
  if (comments == null) {
    Label noComments = new Label("This app does not have any comments yet.");
    noComments.addStyleName("comment-nope");
    container.add(noComments);
    return;
  }

  for ( GalleryComment c : comments) {
    FlowPanel commentItem = new FlowPanel();
    FlowPanel commentPerson = new FlowPanel();
    FlowPanel commentMeta = new FlowPanel();
    FlowPanel commentContent = new FlowPanel();

    // Add commentPerson, default avatar for now
    Image cPerson = new Image();
    cPerson.setUrl(PERSON_URL);
    commentPerson.add(cPerson);
    commentPerson.addStyleName("comment-person");
    commentItem.add(commentPerson);

    // Add commentContent
    Label cAuthor = new Label(c.getUserName());
    cAuthor.addStyleName("comment-author");
    commentMeta.add(cAuthor);

    Date commentDate = new Date(c.getTimeStamp());
    DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd hh:mm:ss a");
    Label cDate = new Label(" on " + dateFormat.format(commentDate));
    cDate.addStyleName("comment-date");
    commentMeta.add(cDate);

    commentMeta.addStyleName("comment-meta");
    commentContent.add(commentMeta);

    Label cText = new Label(c.getComment());
    cText.addStyleName("comment-text");
    commentContent.add(cText);

    commentContent.addStyleName("comment-content");
    commentItem.add(commentContent);

    commentItem.addStyleName("comment-item");
    commentItem.addStyleName("clearfix");
    container.add(commentItem);
  }
}
 
Example 16
Source File: SimplePaletteItem.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new palette item.
 *
 * @param scd component descriptor for palette item
 * @param dropTargetProvider provider of targets that palette items can be dropped on
 */
public SimplePaletteItem(SimpleComponentDescriptor scd, DropTargetProvider dropTargetProvider) {
  this.dropTargetProvider = dropTargetProvider;
  this.scd = scd;

  componentPrototype = null;

  // Initialize palette item UI
  HorizontalPanel panel = new HorizontalPanel();
  panel.setStylePrimaryName("ode-SimplePaletteItem");

  Image image = scd.getImage();
  image.setStylePrimaryName("ode-SimplePaletteItem-icon");
  panel.add(image);
  panel.setCellHorizontalAlignment(image, HorizontalPanel.ALIGN_LEFT);
  panel.setCellWidth(image, "30px");

  Label label = new Label(ComponentsTranslation.getComponentName(scd.getName()));
  label.setHorizontalAlignment(Label.ALIGN_LEFT);
  label.addStyleName("ode-SimplePaletteItem-caption");
  panel.add(label);

  HorizontalPanel optPanel = new HorizontalPanel();

  ComponentHelpWidget helpImage = new ComponentHelpWidget(scd);
  optPanel.add(helpImage);
  optPanel.setCellHorizontalAlignment(helpImage, HorizontalPanel.ALIGN_LEFT);

  if (scd.getExternal()) {
    ComponentRemoveWidget deleteImage = new ComponentRemoveWidget(scd);
    optPanel.add(deleteImage);
    optPanel.setCellHorizontalAlignment(deleteImage, HorizontalPanel.ALIGN_RIGHT);
  }

  panel.add(optPanel);
  panel.setCellHorizontalAlignment(optPanel, HorizontalPanel.ALIGN_RIGHT);

  panel.setWidth("100%");
  add(panel);
  setWidth("100%");

  addHandlers();
}