Java Code Examples for com.smartgwt.client.widgets.IButton#setDisabled()

The following examples show how to use com.smartgwt.client.widgets.IButton#setDisabled() . 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: ParametersPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ParametersPanel(GUIParameter[] settings) {
	super("parameters");
	this.settings = settings;

	setWidth100();
	setHeight100();
	setMembersMargin(5);
	setMargin(5);

	DynamicForm form = new DynamicForm();
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setNumCols(4);
	form.setColWidths(100, 100, 100, 100);

	TextItem[] items = new TextItem[settings.length];

	int i = 0;
	for (GUIParameter parameter : settings) {
		TextItem item = ItemFactory.newTextItem(parameter.getName(), parameter.getName(), parameter.getValue());
		items[i] = item;
		i++;
	}

	form.setItems(items);

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		@SuppressWarnings("unchecked")
		public void onClick(ClickEvent event) {
			Map<String, Object> values = (Map<String, Object>) vm.getValues();

			if (vm.validate()) {
				for (GUIParameter param : ParametersPanel.this.settings) {
					param.setValue((String) values.get(ItemFactory.filterItemName(param.getName())));
					Session.get().getInfo().setConfig(param.getName(), param.getValue());
				}

				SettingService.Instance.get().saveSettings(ParametersPanel.this.settings,
						new AsyncCallback<Void>() {

							@Override
							public void onFailure(Throwable caught) {
								Log.serverError(caught);
							}

							@Override
							public void onSuccess(Void ret) {
								Log.info(I18N.message("settingssaved"), null);
							}
						});
			}
		}
	});
	save.setDisabled(Session.get().isDemo() && Session.get().getUser().getId() == 1);

	body.setMembers(form);
	addMember(save);
}
 
Example 2
Source File: ReplaceVersionFile.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ReplaceVersionFile(GUIDocument document, String fileVersion) {
	this.document = document;
	this.fileVersion = fileVersion;
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("replacefile"));
	setWidth(420);
	
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	DynamicForm form = new DynamicForm();
	vm = new ValuesManager();
	form.setValuesManager(vm);

	TextItem commentItem = ItemFactory.newTextItem("comment", "comment", null);
	commentItem.setRequired(true);
	commentItem.setWidth(250);

	form.setItems(commentItem);

	// Create a new uploader panel and attach it to the window
	multiUploader = new MultiUploader();
	multiUploader.setStyleName("upload");
	multiUploader.setWidth("300px");
	multiUploader.setHeight("60px");
	multiUploader.setFileInputPrefix("LDOC");
	multiUploader.setMaximumFiles(1);
	multiUploader.addOnFinishUploadHandler(onFinishUploaderHandler);
	multiUploader.reset();

	saveButton = new IButton(I18N.message("save"));
	saveButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {

		@Override
		public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
			onSave();
		}
	});
	saveButton.setDisabled(true);

	VLayout layout = new VLayout();
	layout.setMembersMargin(5);
	layout.setMargin(2);

	layout.addMember(form);
	layout.addMember(multiUploader);
	layout.addMember(saveButton);

	addItem(layout);
}
 
Example 3
Source File: MetadataDiff.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public MetadataDiff(final GUIVersion version1, final GUIVersion version2) {
	super();

	setTitle(I18N.message("compare") + " " + version1.getVersion() + " > " + version2.getVersion());
	setWidth(450);
	setHeight(350);
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.MAXIMIZE_BUTTON, HeaderControls.MINIMIZE_BUTTON,
			HeaderControls.CLOSE_BUTTON);
	setCanDragReposition(true);
	setCanDragResize(true);
	centerInPage();

	// Prepare the records, each one is related to a version's attribute
	ArrayList<DiffRecord> records = new ArrayList<DiffRecord>();
	records.add(new DiffRecord(I18N.message("versiondate"), I18N.message("versiondate"),
			I18N.formatDate(version1.getVersionDate()), I18N.formatDate(version2.getVersionDate()), 0));
	records.add(new DiffRecord(I18N.message("fileversion"), I18N.message("fileversion"), version1.getFileVersion(),
			version2.getFileVersion(), 0));
	records.add(new DiffRecord(I18N.message("filename"), I18N.message("filename"), version1.getFileName(),
			version2.getFileName(), 0));
	records.add(new DiffRecord(I18N.message("username"), I18N.message("username"), version1.getUsername(),
			version2.getUsername(), 0));
	records.add(new DiffRecord(I18N.message("comment"), I18N.message("comment"), version1.getComment(),
			version2.getComment(), 0));
	records.add(new DiffRecord(I18N.message("customid"), I18N.message("customid"), version1.getCustomId(),
			version2.getCustomId(), 0));
	records.add(new DiffRecord(I18N.message("language"), I18N.message("language"), version1.getLanguage(),
			version2.getLanguage(), 0));
	records.add(new DiffRecord(I18N.message("createdon"), I18N.message("createdon"),
			I18N.formatDate(version1.getCreation()), I18N.formatDate(version2.getCreation()), 0));
	records.add(new DiffRecord(I18N.message("creator"), I18N.message("creator"), version1.getCreator(),
			version2.getCreator(), 0));
	records.add(new DiffRecord(I18N.message("publishedon"), I18N.message("publishedon"),
			I18N.formatDate(version1.getDate()), I18N.formatDate(version2.getDate()), 0));
	records.add(new DiffRecord(I18N.message("publisher"), I18N.message("publisher"), version1.getPublisher(),
			version2.getPublisher(), 0));
	records.add(new DiffRecord(I18N.message("size"), I18N.message("size"),
			Util.formatSizeBytes((double) version1.getFileSize()),
			Util.formatSizeBytes((double) version2.getFileSize()), 0));
	records.add(new DiffRecord(I18N.message("folder"), I18N.message("folder"),
			version1.getFolder().getId() == Constants.DOCUMENTS_FOLDERID ? "/" : version1.getFolder().getName(),
			version2.getFolder().getId() == Constants.DOCUMENTS_FOLDERID ? "/" : version2.getFolder().getName(),
			0));

	records.add(new DiffRecord(I18N.message("tags"), I18N.message("tags"), version1.getTagsString(),
			version2.getTagsString(), 0));

	records.add(new DiffRecord(I18N.message("published"), I18N.message("published"),
			version1.getPublished() == 1 ? I18N.message("yes") : I18N.message("no"),
			version2.getPublished() == 1 ? I18N.message("yes") : I18N.message("no"), 0));

	records.add(new DiffRecord(I18N.message("startpublishing"), I18N.message("startpublishing"),
			version1.getStartPublishing() != null ? I18N.formatDate(version1.getStartPublishing()) : null,
			version2.getStartPublishing() != null ? I18N.formatDate(version2.getStartPublishing()) : null, 0));

	records.add(new DiffRecord(I18N.message("stoppublishing"), I18N.message("stoppublishing"),
			version1.getStopPublishing() != null ? I18N.formatDate(version1.getStopPublishing()) : null,
			version2.getStopPublishing() != null ? I18N.formatDate(version2.getStopPublishing()) : null, 0));

	records.add(new DiffRecord(I18N.message("template"), I18N.message("template"), version1.getTemplate(),
			version2.getTemplate(), 0));
	printExtendedAttributes(records, version1, version2);

	ListGridField label = new ListGridField("label", " ");
	ListGridField val1 = new ListGridField("val1", version1.getVersion());
	ListGridField val2 = new ListGridField("val2", version2.getVersion());

	ListGrid listGrid = new ListGrid();
	listGrid.setEmptyMessage(I18N.message("notitemstoshow"));
	listGrid.setCanFreezeFields(false);
	listGrid.setCanGroupBy(false);
	listGrid.setAutoFetchData(true);
	listGrid.setCanReorderFields(false);
	listGrid.setCanSort(false);
	listGrid.setData(records.toArray(new ListGridRecord[0]));
	listGrid.setFields(label, val1, val2);
	addItem(listGrid);

	IButton compareContent = new IButton(I18N.message("comparecontent"));
	compareContent.setWidth100();
	compareContent.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent event) {
			ComparisonWindow diff = new ComparisonWindow(version1, version2);
			diff.show();
		}
	});
	if (Feature.visible(Feature.COMPARISON)) {
		addItem(compareContent);
		compareContent.setDisabled(!Feature.enabled(Feature.COMPARISON));
	}
}