Java Code Examples for com.google.gwt.user.client.ui.ListBox#setWidth()

The following examples show how to use com.google.gwt.user.client.ui.ListBox#setWidth() . 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: UTCDateTimeDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
public void onModuleLoad() {

    eventListBox = new ListBox(true);
    eventListBox.setVisibleItemCount(20);
    eventListBox.setWidth("800px");
    RootPanel.get("eventlog").add(eventListBox);

    startDate = createDateBox("start-date");
    startTime = createTimeBox("start-time");

    endDate = createDateBox("end-date");
    endTime = createTimeBox("end-time");
    
    allday = new CheckBox("All Day");
    
    // constructing this will bind all of the events
    new UTCDateTimeRangeController(startDate, startTime, endDate, endTime, allday);
    
    RootPanel startPanel = RootPanel.get("start");
    startPanel.add(startDate);
    startPanel.add(startTime);
    startPanel.add(allday);

    RootPanel endPanel = RootPanel.get("end");
    endPanel.add(endDate);
    endPanel.add(endTime);
    
    startDate.setValue(UTCDateBox.getValueForToday(), true);
    startTime.setValue(UTCTimeBox.getValueForNextHour(), true);
}
 
Example 2
Source File: DataTypeSelectPanel.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * UI initialization
 */
public void init()
{
	this.setSize("480px", "100px");

	//Dialog box title
	closeButton.setSize("10px", "10px");
	closeButton.setStyleName("closebtn");

	//Selection dialog
	HorizontalPanel typeListPanel = new HorizontalPanel();
	typeListPanel.setStyleName("popupDatatypeSelectPanel");
	typeListBox = new ListBox();
	typeListBox.setWidth("120px");
	typeListBox.addItem("----");
	typeListBox.addItem(DatasetType.GENERAL.getDesc());
	typeListBox.addItem(DatasetType.CSV.getDesc());
	typeListBox.addItem(DatasetType.TSV.getDesc());
	typeListBox.addItem(DatasetType.JSON.getDesc());
	if(dataset.getContenttype() == null || dataset.getContenttype() .equals(""))
		typeListBox.setSelectedIndex(0);
	else
	{
		for(int i = 0 ; i<typeListBox.getItemCount() ; i++)
		{
			if(typeListBox.getItemText(i).equals(dataset.getContenttype()))
			{
				typeListBox.setSelectedIndex(i);
				break;
			}
		}
	}
	Label selectLabel = new Label("Select data type: ");
	typeListPanel.add(selectLabel);
	typeListPanel.add(typeListBox);

	//Ok and cancel button
	HorizontalPanel buttonPanel = new HorizontalPanel();
	buttonPanel.setStyleName("popupDatatypeButtonPanel");
	okBtn = new Button("Ok");
	okBtn.setStyleName("button-style");
	cancelBtn = new Button("Cancel");
	cancelBtn.setStyleName("button-style");
	buttonPanel.add(okBtn);
	buttonPanel.add(cancelBtn);

	//Overall arrangement
	VerticalPanel topPanel = new VerticalPanel();
	topPanel.add(closeButton);
	topPanel.setCellHeight(closeButton, "13px");
	topPanel.setStyleName("vpanel");
	desc.setStyleName("popupDatatypeSelectTitle");
	topPanel.add(desc);
	topPanel.setCellHeight(desc, "30px");
	topPanel.add(typeListPanel);
	topPanel.add(buttonPanel);

	this.setGlassEnabled(true);
	this.setModal(true);
	this.add(topPanel);
	this.center();
	this.setStyleName("loading-panel");
}
 
Example 3
Source File: YoungAndroidAssetSelectorPropertyEditor.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new property editor for selecting a Young Android asset.
 *
 * @param editor the editor that this property editor belongs to
 */
public YoungAndroidAssetSelectorPropertyEditor(final YaFormEditor editor) {
  Project project = Ode.getInstance().getProjectManager().getProject(editor.getProjectId());
  assetsFolder = ((YoungAndroidProjectNode) project.getRootNode()).getAssetsFolder();
  project.addProjectChangeListener(this);

  VerticalPanel selectorPanel = new VerticalPanel();
  assetsList = new ListBox();
  assetsList.setVisibleItemCount(10);
  assetsList.setWidth("100%");
  selectorPanel.add(assetsList);

  choices = new ListWithNone(MESSAGES.noneCaption(), new ListWithNone.ListBoxWrapper() {
    @Override
    public void addItem(String item) {
      assetsList.addItem(item);
    }

    @Override
    public String getItem(int index) {
      return assetsList.getItemText(index);
    }

    @Override
    public void removeItem(int index) {
      assetsList.removeItem(index);
    }

    @Override
    public void setSelectedIndex(int index) {
      assetsList.setSelectedIndex(index);
    }
  });

  // Fill choices with the assets.
  if (assetsFolder != null) {
    for (ProjectNode node : assetsFolder.getChildren()) {
      choices.addItem(node.getName());
    }
  }

  Button addButton = new Button(MESSAGES.addButton());
  addButton.setWidth("100%");
  addButton.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      FileUploadedCallback callback = new FileUploadedCallback() {
        @Override
        public void onFileUploaded(FolderNode folderNode, FileNode fileNode) {
          // At this point, the asset has been uploaded to the server, and
          // has even been added to the assetsFolder. We are all set!
          choices.selectValue(fileNode.getName());
          closeAdditionalChoiceDialog(true);
        }
      };
      FileUploadWizard uploader = new FileUploadWizard(assetsFolder, callback);
      uploader.show();
    }
  });
  selectorPanel.add(addButton);
  selectorPanel.setWidth("100%");

  // At this point, the editor hasn't finished loading.
  // Use a DeferredCommand to finish the initialization after the editor has finished loading.
  DeferredCommand.addCommand(new Command() {
    @Override
    public void execute() {
      if (editor.isLoadComplete()) {
        finishInitialization();
      } else {
        // Editor still hasn't finished loading.
        DeferredCommand.addCommand(this);
      }
    }
  });

  initAdditionalChoicePanel(selectorPanel);
}
 
Example 4
Source File: YoungAndroidComponentSelectorPropertyEditor.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new property editor for selecting a component, where the
 * user chooses among components of one or more component types.
 *
 * @param editor the editor that this property editor belongs to
 * @param componentTypes types of component that can be selected, or null if
 *        all types of components can be selected.
 */
public YoungAndroidComponentSelectorPropertyEditor(final YaFormEditor editor,
    Set<String> componentTypes) {
  this.editor = editor;
  this.componentTypes = componentTypes;

  VerticalPanel selectorPanel = new VerticalPanel();
  componentsList = new ListBox();
  componentsList.setVisibleItemCount(10);
  componentsList.setWidth("100%");
  selectorPanel.add(componentsList);
  selectorPanel.setWidth("100%");

  choices = new ListWithNone(MESSAGES.noneCaption(), new ListWithNone.ListBoxWrapper() {
    @Override
    public void addItem(String item) {
      componentsList.addItem(item);
    }

    @Override
    public String getItem(int index) {
      return componentsList.getItemText(index);
    }

    @Override
    public void removeItem(int index) {
      componentsList.removeItem(index);
    }

    @Override
    public void setSelectedIndex(int index) {
      componentsList.setSelectedIndex(index);
    }
  });

  // At this point, the editor hasn't finished loading.
  // Use a DeferredCommand to finish the initialization after the editor has finished loading.
  DeferredCommand.addCommand(new Command() {
    @Override
    public void execute() {
      if (editor.isLoadComplete()) {
        finishInitialization();
      } else {
        // Editor still hasn't finished loading.
        DeferredCommand.addCommand(this);
      }
    }
  });

  initAdditionalChoicePanel(selectorPanel);
}