当前位置: 首页>>代码示例>>Java>>正文


Java Button.addSelectionListener方法代码示例

本文整理汇总了Java中com.extjs.gxt.ui.client.widget.button.Button.addSelectionListener方法的典型用法代码示例。如果您正苦于以下问题:Java Button.addSelectionListener方法的具体用法?Java Button.addSelectionListener怎么用?Java Button.addSelectionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.extjs.gxt.ui.client.widget.button.Button的用法示例。


在下文中一共展示了Button.addSelectionListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createToolbar

import com.extjs.gxt.ui.client.widget.button.Button; //导入方法依赖的package包/类
/**
 * Creates the toolbar of this component.
 * 
 * @param enabled
 *          <code>true</code> to enable the buttons of this toolbar, <code>false</code> to disable them.
 * @return A new toolbar.
 */
private ToolBar createToolbar(final ListStore<ReportReference> store) {
	final ToolBar toolbar = new ToolBar();

	// Creating buttons
	final Button createReportButton = new Button(I18N.CONSTANTS.reportCreateReport(), IconImageBundle.ICONS.add());

	// "Create" button action
	createReportButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

		@Override
		public void componentSelected(ButtonEvent ce) {
			MessageBox.prompt(I18N.CONSTANTS.reportCreateReport(), I18N.CONSTANTS.reportName(), new Listener<MessageBoxEvent>() {

				@Override
				public void handleEvent(MessageBoxEvent be) {
					if (Dialog.OK.equals(be.getButtonClicked().getItemId())) {
						final String name = be.getValue();

						final HashMap<String, Serializable> properties = new HashMap<String, Serializable>();
						properties.put("name", name);
						properties.put("flexibleElementId", getId());
						properties.put("reportModelId", getModelId());
						properties.put("containerId", currentContainerDTO.getId());
						if (currentContainerDTO instanceof ProjectDTO)
							properties.put("projectId", currentContainerDTO.getId());

						if (currentContainerDTO instanceof OrgUnitDTO)
							properties.put("orgUnitId", currentContainerDTO.getId());

						properties.put("multiple", true);

						if (currentContainerDTO instanceof ProjectDTO)
							properties.put("phaseName", ((ProjectDTO) currentContainerDTO).getCurrentPhase().getPhaseModel().getName());

						if (currentContainerDTO instanceof OrgUnitDTO)
							properties.put("phaseName", null);

						dispatch.execute(new CreateEntity(ProjectReportDTO.ENTITY_NAME, properties), new CommandResultHandler<CreateResult>() {

							@Override
							public void onCommandFailure(final Throwable caught) {
								N10N.error(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportCreateError());
							}

							@Override
							public void onCommandSuccess(final CreateResult result) {

								final ProjectReportDTO createdProjetReport = (ProjectReportDTO) result.getEntity();

								final ReportReference reference = new ReportReference();
								reference.setId(createdProjetReport.getId());
								reference.setName(name);
								reference.setLastEditDate(new Date());
								reference.setEditorName(auth().getUserShortName());
								store.add(reference);

								N10N.validNotif(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportCreateSuccess());
							}

						});
					}
				}
			});
		}
	});

	// Adding buttons to the toolbar
	toolbar.add(createReportButton);

	return toolbar;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:79,代码来源:ReportListElementDTO.java

示例2: getDialog

import com.extjs.gxt.ui.client.widget.button.Button; //导入方法依赖的package包/类
public static Dialog getDialog(final KeyQuestionDTO keyQuestion, final RichTextArea textArea, final FoldPanel panel, final int toolButtonIndex,
		final KeyQuestionState keyQuestionState, boolean enabled) {
	final Dialog dialog = getDialog();
	dialog.setHeadingHtml(I18N.MESSAGES.reportKeyQuestionDialogTitle(Integer.toString(keyQuestion.getNumber())));

	// Question label
	final Label question = (Label) dialog.getWidget(0);
	question.setTitle(keyQuestion.getLabel());

	// Rich text editor
	final RichTextArea dialogTextArea = (RichTextArea) dialog.getWidget(1);
	dialogTextArea.setHTML(textArea.getHTML());

	final boolean wasValid = !"".equals(textArea.getText());

	// OK Button
	final Button okButton = dialog.getButtonById(Dialog.OK);

	okButton.removeAllListeners();

	if (enabled) {

		dialog.getTopComponent().enable();
		dialogTextArea.setEnabled(true);

		okButton.setVisible(true);
		okButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

			@Override
			public void componentSelected(ButtonEvent ce) {
				dialog.hide();
				textArea.setHTML(dialogTextArea.getHTML());

				final boolean isValid = !"".equals(dialogTextArea.getText());

				final ToolbarImages images = GWT.create(ToolbarImages.class);
				if (isValid) {
					panel.setToolButtonImage(toolButtonIndex, images.compasGreen());

					if (!wasValid)
						keyQuestionState.increaseValids();

				} else {
					panel.setToolButtonImage(toolButtonIndex, images.compasRed());

					if (wasValid)
						keyQuestionState.decreaseValids();
				}
			}
		});

	} else {

		okButton.setVisible(false);

		dialog.getTopComponent().disable();
		dialogTextArea.setEnabled(false);
	}

	return dialog;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:62,代码来源:KeyQuestionDialog.java

示例3: getDialog

import com.extjs.gxt.ui.client.widget.button.Button; //导入方法依赖的package包/类
/**
 * Dialog used to <b>create</b> a report from outside the "Report & Documents" page.
 * 
 * @param properties
 *          Base properties of the new report (should contain the report model id).
 * @param reportButton
 * @param registrations
 * @param eventBus
 *          The application event bus.
 * @param dispatch
 *          The application command dispatcher.
 * @return The create report dialog.
 */
public static Dialog getDialog(final Map<String, Serializable> properties, final com.google.gwt.user.client.ui.Button reportButton,
		final HandlerRegistration[] registrations, final EventBus eventBus, final DispatchAsync dispatch) {

	final Dialog dialog = getDialog();

	// OK Button
	final Button okButton = dialog.getButtonById(Dialog.OK);

	okButton.removeAllListeners();
	okButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

		@SuppressWarnings("unchecked")
		@Override
		public void componentSelected(ButtonEvent ce) {
			final String name = ((TextField<String>) dialog.getWidget(0)).getValue();

			properties.put("name", name);

			dispatch.execute(new CreateEntity(ProjectReportDTO.ENTITY_NAME, properties), new CommandResultHandler<CreateResult>() {

				@Override
				public void onCommandFailure(Throwable caught) {
					N10N.error(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportCreateError());
				}

				@Override
				public void onCommandSuccess(final CreateResult result) {

					final ProjectReportDTO createdProjetReport = (ProjectReportDTO) result.getEntity();

					reportButton.setText(I18N.MESSAGES.reportOpenReport(name));
					registrations[0].removeHandler();

					reportButton.addClickHandler(new ClickHandler() {

						@Override
						public void onClick(ClickEvent event) {
							final PageRequest request = new PageRequest(Page.PROJECT_REPORTS);
							request.addParameter(RequestParameter.ID, properties.get("projectId"));
							request.addParameter(RequestParameter.REPORT_ID, createdProjetReport.getId());
							eventBus.navigateRequest(request);
						}
					});

					N10N.validNotif(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportCreateSuccess());
				}
			});

			dialog.hide();
		}

	});

	return dialog;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:69,代码来源:EditReportDialog.java


注:本文中的com.extjs.gxt.ui.client.widget.button.Button.addSelectionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。