Java Code Examples for com.google.gwt.user.client.ui.Button#addClickHandler()

The following examples show how to use com.google.gwt.user.client.ui.Button#addClickHandler() . 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: VButtonValueRenderer.java    From vaadin-grid-util with MIT License 6 votes vote down vote up
private Button genButton(final int bitm) {
	Button btn = GWT.create(Button.class);
	btn.setStylePrimaryName("v-nativebutton");
	switch (bitm) {
		case VIEW_BITM:
			btn.addStyleName("v-view");
			break;
		case EDIT_BITM:
			btn.addStyleName("v-edit");
			break;
		case DELETE_BITM:
			btn.addStyleName("v-delete");
			break;

	}
	btn.setHTML("<span></span>");
	btn.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(final ClickEvent event) {
			VButtonValueRenderer.this.clickedBITM = bitm;
			VButtonValueRenderer.super.onClick(event);
		}
	});
	return btn;
}
 
Example 2
Source File: HelloWorld.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
public HelloWorld() {
	HTML html = new HTML("Hello Word");
	refresh = new Button("refresh UI");
	refresh.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			GeneralComunicator.refreshUI();
		}
	});

	vPanel = new VerticalPanel();
	vPanel.add(html);
	vPanel.add(refresh);

	refresh.setStyleName("okm-Input");

	initWidget(vPanel);
}
 
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 cancel button
 */
private void initCancelButton() {
  cancelButton = new Button(MESSAGES.galleryCancelText());
  cancelButton.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      if (editStatus==NEWAPP) {
        Ode.getInstance().switchToProjectsView();
      }else if(editStatus==UPDATEAPP){
        Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP);
      }
    }
  });
  cancelButton.addStyleName("app-action-button");
  appAction.add(cancelButton);
}
 
Example 4
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 edit it button
 * Only seen by app owner.
 */
private void initEdititButton() {
  final User currentUser = Ode.getInstance().getUser();
  if(app.getDeveloperId().equals(currentUser.getUserId())){
    editButton = new Button(MESSAGES.galleryEditText());
    editButton.addClickHandler(new ClickHandler() {
      // Open up source file if clicked the action button
      public void onClick(ClickEvent event) {
        editButton.setEnabled(false);
        Ode.getInstance().switchToGalleryAppView(app, GalleryPage.UPDATEAPP);
      }
    });
    editButton.addStyleName("app-action-button");
    appAction.add(editButton);
  }
}
 
Example 5
Source File: DominoRestEntryPoint.java    From gwt-boot-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onModuleLoad() {
   	DominoRestConfig.initDefaults();

	DominoRestConfig.getInstance().setDefaultServiceRoot("http://localhost:9090/server");
	
	PersonDto coolPerson = new PersonDto();
	coolPerson.setDate(new Date());
	coolPerson.setName("Lofi");
	coolPerson.setPersonType(PersonType.COOL);

	Button personListButton = new Button("Click me: " + coolPerson.getPersonType().name());

	personListButton.addClickHandler(clickEvent -> {
		logger.info("Hello World: executePersonList");

		PersonClientFactory.INSTANCE.getPersons().onSuccess(response -> {
			response.forEach(p -> logger
					.info("Person: " + p.getName() + " - Date: " + p.getDate() + " - Type: " + p.getPersonType()));
		}).onFailed(failedResponse -> {
			logger.info(
					"Error: " + failedResponse.getStatusCode() + "\nMessages: " + failedResponse.getStatusText());
		}).send();
	});

   }
 
Example 6
Source File: GroupedListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

groupedListBox1 = new GroupedListBox(false);
groupedListBox2 = new GroupedListBox(true);
RootPanel.get("select1").add(groupedListBox1);
RootPanel.get("select2").add(groupedListBox2);

addItem("Fruits|Apples");
addItem("Fruits|Bananas");
addItem("Fruits|Oranges");
addItem("Fruits|Pears");	
addItem("Vegetables|Tomatoes");	
addItem("Vegetables|Carrots");		

Panel controls = RootPanel.get("controls");
controls.add(createAddButton("Fruits|Blueberries"));
controls.add(createAddButton("Vegetables|Broccoli"));
controls.add(createAddButton("Meats|Chicken"));
controls.add(createAddButton("Meats|Turkey"));

Button remove = new Button("Remove Selected");
remove.addClickHandler(new ClickHandler() {
           
           @Override
           public void onClick(ClickEvent event) {
               removeSelected();
           }
       });

controls.add(remove);
   }
 
Example 7
Source File: SingleListBoxDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
private Button createSetAddMissingValue(final boolean addMissingValue) {
    Button ret = new Button("setAddMissingValue(" + addMissingValue + ")");
    ret.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            singleListBox.setAddMissingValue(addMissingValue);
        }
    });
    return ret;
}
 
Example 8
Source File: GridButtonRenderer.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Button createWidget() {
    Button b = GWT.create(Button.class);
    b.addClickHandler(this);
    b.setStylePrimaryName("v-nativebutton");
    return b;
}
 
Example 9
Source File: DialogBox.java    From swellrt with Apache License 2.0 5 votes vote down vote up
void link(Button button) {
  this.button = button;
  button.setText(title);
  button.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event) {
      execute();
    }
  });
}
 
Example 10
Source File: OpacityDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

Panel controls = RootPanel.get("controls");

startOpacity = createTextBox("1.0");
endOpacity = createTextBox("0.1");
duration = createTextBox("5000");

addTextBox(controls, "Start Opacity", startOpacity);
addTextBox(controls, "End Opacity", endOpacity);
addTextBox(controls, "Duration", duration);

Button start = new Button("Start");
start.addClickHandler(new ClickHandler() {
    @Override
           public void onClick(ClickEvent event) {
        OpacityAnimation animation = new OpacityAnimation(new Element[] {
							      Document.get().getElementById("box1"),
							      Document.get().getElementById("box2"),
							      Document.get().getElementById("box3")
							  },
							  Float.parseFloat(startOpacity.getText()),
							  Float.parseFloat(endOpacity.getText()));
        animation.run(Integer.parseInt(duration.getText()));
    }
});

controls.add(start);
   }
 
Example 11
Source File: WordCloudDetailApp.java    From swcv with MIT License 5 votes vote down vote up
private void createRandomWordCloudButton()
{
    Button sendButton = Button.wrap(Document.get().getElementById("btn_create_random_wc"));
    sendButton.removeStyleName("invisible");
    sendButton.addClickHandler(new ClickHandler()
    {
        public void onClick(ClickEvent event)
        {
            updateWordCloud(true);
        }
    });
}
 
Example 12
Source File: ColorDemo.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
   public void onModuleLoad() {

Panel controls = RootPanel.get("controls");

startColor = createTextBox("rgba(255,255,0,1)");
endColor = createTextBox("rgba(255,0,255,0)");
duration = createTextBox("5000");

addTextBox(controls, "Start Color", startColor);
addTextBox(controls, "End Color", endColor);
addTextBox(controls, "Duration", duration);

Button start = new Button("Start");
start.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
        ColorAnimation animation = new ColorAnimation(new Element[] {
							      Document.get().getElementById("box1"),
							      Document.get().getElementById("box2"),
							      Document.get().getElementById("box3")
							  },
							  "backgroundColor",
							  RgbaColor.from(startColor.getText()),
							  RgbaColor.from(endColor.getText()));
        animation.run(Integer.parseInt(duration.getText()));
    }
});

controls.add(start);
   }
 
Example 13
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 14
Source File: StreamingProgress.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public StreamingProgress(final LogStore logStore, int timeout) {
    super(false, true);
    this.timeout = timeout;

    setWidth(WIDTH + "px");
    setHeight(HEIGHT + "px");
    setGlassEnabled(true);
    setId(getElement(), WINDOW, BASE_ID, "stream_in_progress");
    setStyleName("default-window");

    FlowPanel content = new FlowPanel();
    content.addStyleName("stream-log-file-pending");
    content.add(new Pending(Console.CONSTANTS.downloadInProgress()));
    cancel = new Button(Console.CONSTANTS.common_label_cancel());
    setId(cancel.getElement(), BUTTON, BASE_ID, "cancel_stream");
    cancel.addStyleName("cancel");
    cancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PendingStreamingRequest request = logStore.getPendingStreamingRequest();
            if (request != null) {
                request.cancel();
                done();
            }
        }
    });
    content.add(cancel);
    setWidget(content);
}
 
Example 15
Source File: JobDescPopupPanel.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public JobDescPopupPanel(String title) {

		Label label = new Label(title);
		label.setStyleName("bda-newjob-head");
		verticalPanel.add(label);
		verticalPanel.add(createGrid());
		HorizontalPanel hpanel = new HorizontalPanel();

		hpanel.setStyleName("bda-newjob-hpanel");
		verticalPanel.add(errorLabel);
		Button cancelBtn = new Button(Constants.studioUIMsg.cancel());
		cancelBtn.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				JobDescPopupPanel.this.hide();
			}

		});

		hpanel.add(submitBtn);
		hpanel.add(cancelBtn);
		submitBtn.removeStyleName("gwt-Button");
		cancelBtn.removeStyleName("gwt-Button");
		submitBtn.addStyleName("button-style");
		cancelBtn.addStyleName("button-style");
		errorLabel.setStyleName("error-label");
		verticalPanel.add(hpanel);
		verticalPanel.addStyleName("bda-newjob");
		this.setCloseEnable(false);
	}
 
Example 16
Source File: BasicGwtEntryPoint.java    From gwt-boot-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onModuleLoad() {
	Button button = new Button("Click me");
	button.addClickHandler(clickEvent -> {
		Window.alert("Hello World!");
		logger.info("Hello World!");
	});

	RootPanel.get("helloButton").add(button);
}
 
Example 17
Source File: BasicGwtEntryPoint.java    From gwt-boot-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onModuleLoad() {
	Button button = new Button("Click me");
	button.addClickHandler(clickEvent -> {
		Window.alert("Hello World!");
		logger.info("Hello World!");
	});

	RootPanel.get("helloButton").add(button);
}
 
Example 18
Source File: PreviewFileCommand.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(final ProjectNode node) {
  final DialogBox dialogBox = new DialogBox();
  dialogBox.setText(node.getName());
  dialogBox.setStylePrimaryName("ode-DialogBox");

  //setting position of dialog box
  dialogBox.center();
  dialogBox.setAnimationEnabled(true);

  //button element
  final Button closeButton = new Button(MESSAGES.closeFilePreview());
  closeButton.getElement().setId("closeButton");
  closeButton.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        dialogBox.hide();
      }
    });

  HorizontalPanel buttonPanel = new HorizontalPanel();
  buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
  buttonPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
  buttonPanel.add(closeButton);

  VerticalPanel dialogPanel = new VerticalPanel();
  dialogPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
  dialogPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);

  Widget filePreview = generateFilePreview(node);
  dialogPanel.clear();
  dialogPanel.add(filePreview);

  dialogPanel.add(buttonPanel);
  dialogPanel.setWidth("300px");

  dialogBox.setGlassEnabled(false);
  dialogBox.setModal(false);

  // Set the contents of the Widget
  dialogBox.setWidget(dialogPanel);
  dialogBox.center();
  dialogBox.show();
}
 
Example 19
Source File: ShowBarcodeCommand.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
BarcodeDialogBox(String projectName, String appInstallUrl) {
      super(false, true);
      setStylePrimaryName("ode-DialogBox");
      setText(MESSAGES.barcodeTitle(projectName));

      ClickHandler buttonHandler = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
          hide();
        }
      };

      Button cancelButton = new Button(MESSAGES.cancelButton());
      cancelButton.addClickHandler(buttonHandler);
      Button okButton = new Button(MESSAGES.okButton());
      okButton.addClickHandler(buttonHandler);
      HTML barcodeQrcode = new HTML("<center>" + BlocklyPanel.getQRCode(appInstallUrl) + "</center>");
      HTML linkQrcode = new HTML("<center><a href=\"" + appInstallUrl + "\" target=\"_blank\">" + appInstallUrl + "</a></center>");
      HorizontalPanel buttonPanel = new HorizontalPanel();
      buttonPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
      HTML warningLabel = new HTML(MESSAGES.barcodeWarning(
          "<a href=\"" + "http://appinventor.mit.edu/explore/ai2/share.html" +
          "\" target=\"_blank\">",
          "</a>"));
      warningLabel.setWordWrap(true);
      warningLabel.setWidth("200px");  // set width to get the text to wrap
      HorizontalPanel warningPanel = new HorizontalPanel();
      warningPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
      warningPanel.add(warningLabel);

      // The cancel button is removed from the panel since it has no meaning in this
      // context.  But the logic is still here in case we want to restore it, and as
      // an example of how to code this stuff in GWT.
      // buttonPanel.add(cancelButton);
      buttonPanel.add(okButton);
      buttonPanel.setSize("100%", "24px");
      VerticalPanel contentPanel = new VerticalPanel();
      contentPanel.add(barcodeQrcode);
      contentPanel.add(linkQrcode);
      contentPanel.add(buttonPanel);
      contentPanel.add(warningPanel);
//      contentPanel.setSize("320px", "100%");
      add(contentPanel);
    }
 
Example 20
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);
}