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

The following examples show how to use com.smartgwt.client.widgets.IButton#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: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createPublishRuleButton(final ListGridRecord ruleRecord) {
    IButton publishButton = new IButton(i18n.publishButton());
    publishButton.setShowDown(false);
    publishButton.setShowRollOver(false);
    publishButton.setLayoutAlign(Alignment.CENTER);
    publishButton.setHeight(16);
    publishButton.setAutoFit(true);

    final boolean published = ruleRecord.getAttributeAsBoolean(PUBLISHED);
    if (published) {
        publishButton.setTitle(i18n.unpublishButton());
        publishButton.setPrompt(i18n.cancelPublication());
    } else {
        publishButton.setTitle(i18n.publishButton());
        publishButton.setPrompt(i18n.publishThisRule());
    }

    publishButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String ruleName = ruleRecord.getAttribute(NAME);
            EventBus.getMainEventBus().fireEvent(new PublishRuleEvent(currentSession(), ruleName, !published, "USER"));
        }
    });

    return publishButton;
}
 
Example 2
Source File: AllRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected Canvas createEditRuleButton(final ListGridRecord ruleRecord) {
    String userID = getLoggedInUser();
    String ruleOwnerID = ruleRecord.getAttribute(OWNERID);
    if (ruleOwnerID.equals(userID)) {
        IButton editButton = new IButton(i18n.edit());
        editButton.setShowDown(false);
        editButton.setShowRollOver(false);
        editButton.setLayoutAlign(Alignment.CENTER);
        editButton.setPrompt(i18n.editThisRule());
        editButton.setHeight(16);
        editButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String name = ruleRecord.getAttribute(NAME);
                EventBus.getMainEventBus().fireEvent(new EditRuleEvent(name));
            }
        });
        return editButton;
    } else {
        return null;
    }
}
 
Example 3
Source File: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createDeleteRuleButtonm(final ListGridRecord ruleRecord) {
    IButton deleteButton = new IButton(i18n.delete());
    deleteButton.setShowDown(false);
    deleteButton.setShowRollOver(false);
    deleteButton.setLayoutAlign(Alignment.CENTER);
    deleteButton.setPrompt(i18n.deleteThisRule());
    deleteButton.setHeight(16);
    deleteButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() {
                public void execute(Boolean value) {
                    if (value) {
                        String uuid = ruleRecord.getAttribute(UUID);
                        String userRole = getLoggedInUserRole();
                        EventBus.getMainEventBus().fireEvent(new DeleteRuleEvent(currentSession(), uuid, userRole));
                    }
                }
            });
        }
    });
    return deleteButton;
}
 
Example 4
Source File: BrandingPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initGUI() {
	tenantBranding = new TenantBrandingPanel(tenant, new ChangedHandler() {

		@Override
		public void onChanged(ChangedEvent event) {

		}
	});

	IButton save = new IButton(I18N.message("save"));
	save.setMinWidth(80);
	save.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent event) {
			if (tenantBranding.validate())
				onSave();
		}
	});

	body.setMembers(tenantBranding);
	addMember(save);
}
 
Example 5
Source File: AllRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
protected Canvas createDeleteRuleButton(final ListGridRecord record) {
    IButton deleteButton = new IButton(i18n.delete());
    deleteButton.setShowDown(false);
    deleteButton.setShowRollOver(false);
    deleteButton.setLayoutAlign(CENTER);
    deleteButton.setPrompt(i18n.deleteThisRule());
    deleteButton.setHeight(16);
    deleteButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            SC.ask(i18n.reallyDeleteRule(), new BooleanCallback() {
                public void execute(Boolean value) {
                    if (value) {
                        String uuid = record.getAttribute(UUID);
                        String userRole = getLoggedInUser();
                        DeleteRuleEvent deleteRuleEvent = new DeleteRuleEvent(currentSession(), uuid, userRole);
                        EventBus.getMainEventBus().fireEvent(deleteRuleEvent);
                    }
                }
            });
        }
    });

    return deleteButton;
}
 
Example 6
Source File: OwnRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEditRuleButton(final ListGridRecord ruleRecord) {
    // subscribe button
    IButton editButton = new IButton(i18n.edit());
    editButton.setShowDown(false);
    editButton.setShowRollOver(false);
    editButton.setLayoutAlign(Alignment.CENTER);
    editButton.setPrompt(i18n.editThisRule());
    editButton.setHeight(16);
    editButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String name = ruleRecord.getAttribute(NAME);
            EventBus.getMainEventBus().fireEvent(new GetAllPublishedRulesEvent(currentSession(), 1));
            EventBus.getMainEventBus().fireEvent(new EditRuleEvent(name));
        }
    });

    return editButton;
}
 
Example 7
Source File: WorkflowUploader.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowUploader(WorkflowDesigner designer) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	this.designer = designer;
	setTitle(I18N.message("uploadworkflow"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();
	
	layout.setMembersMargin(2);
	layout.setMargin(2);

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

	// Add a finish handler which will load the image once the upload
	// finishes
	uploader.addOnFinishUploadHandler(onFinishUploaderHandler);

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

		@Override
		public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
			onSend();
		}
	});

	layout.addMember(uploader);
	layout.addMember(sendButton);
	addItem(layout);
}
 
Example 8
Source File: BarcodeTemplateSettings.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BarcodeTemplateSettings(BarcodeTemplatesPanel panel, GUIBarcodeTemplate template) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("barcodetemplate"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	this.panel = panel;
	this.template = template;

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

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

	prepareForm();

	VLayout layout = new VLayout();
	layout.setMembersMargin(5);
	layout.setWidth100();

	layout.addMember(form);
	layout.addMember(save);

	addItem(layout);
}
 
Example 9
Source File: FillForm.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public FillForm(GUIDocument frm) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);

	setTitle(I18N.message("form") + " - " + Util.getBaseName(frm.getFileName()));
	setWidth(500);
	setHeight(400);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	
	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.setAutoFit(true);
	save.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
		@Override
		public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
			onSave();
		}
	});

	HLayout buttonsBar = new HLayout();
	buttonsBar.setWidth100();
	buttonsBar.setHeight(25);
	buttonsBar.setMembers(save);
	
	
	propertiesPanel = new ExtendedPropertiesPanel(frm, null, true, true, false);
	
	VLayout layout = new VLayout();
	layout.setMargin(3);
	layout.setMembersMargin(3);
	layout.setMembers(propertiesPanel, buttonsBar);
	
	addItem(layout);
}
 
Example 10
Source File: OtherUserRulesListGrid.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {

    if (record != null) {
        String fieldName = this.getFieldName(colNum);

       if (fieldName.equals(EditRulesLayout.EDIT_RULES_COPY)) {
            // Copy button
            IButton copyButton = new IButton(i18n.copy());
            copyButton.setShowDown(false);
            copyButton.setShowRollOver(false);
            copyButton.setHeight(17);
            copyButton.setLayoutAlign(Alignment.CENTER);
            copyButton.setAlign(Alignment.CENTER);
            copyButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    System.out.println("copy " + record.getAttribute("name"));
                    String userID = getLoggedInUserId();
                    EventBus.getMainEventBus().fireEvent(new CopyEvent(userID, record.getAttribute("name")));
                }
            });
            return copyButton;
        }
    return null;
    }
    return null;
}
 
Example 11
Source File: TwoFactorsAuthenticationSettings.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void init(GUIParameter[] parameters) {
	DynamicForm form = new DynamicForm();
	form.setWidth(1);
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.LEFT);
	form.setNumCols(1);

	Map<String, String> settings = Util.convertToMap(parameters);
	final RadioGroupItem enable2fa = ItemFactory.newBooleanSelector("enable2fa", I18N.message("enable2fa"));
	enable2fa.setValue("true".equals(settings.get("enabled")) ? "yes" : "no");
	enable2fa.setWrapTitle(false);
	enable2fa.setWrap(false);
	enable2fa.setRequired(true);
	enable2fa.setDisabled(Session.get().isDemo());
	form.setFields(enable2fa);

	/*
	 * GoogleAuthenticator section
	 */
	DynamicForm googleForm = new DynamicForm();
	googleForm.setValuesManager(vm);
	googleForm.setTitleOrientation(TitleOrientation.TOP);
	googleForm.setIsGroup(true);
	googleForm.setGroupTitle("Google Authenticator");
	googleForm.setNumCols(1);

	final RadioGroupItem enableGoolge = ItemFactory.newBooleanSelector("enableGoolge",
			I18N.message("enablegoogleauthenticator"));
	enableGoolge.setValue("true".equals(settings.get(Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled")) ? "yes"
			: "no");
	enableGoolge.setWrapTitle(false);
	enableGoolge.setWrap(false);
	enableGoolge.setRequired(true);
	enableGoolge.setDisabled(Session.get().isDemo());
	googleForm.setFields(enableGoolge);

	/*
	 * Yubikey section
	 */
	DynamicForm yubikeyForm = new DynamicForm();
	yubikeyForm.setValuesManager(vm);
	yubikeyForm.setTitleOrientation(TitleOrientation.TOP);
	yubikeyForm.setIsGroup(true);
	yubikeyForm.setGroupTitle("YubiKey");
	yubikeyForm.setNumCols(1);

	final RadioGroupItem enableYubikey = ItemFactory.newBooleanSelector("enableYubikey",
			I18N.message("enableyubikey"));
	enableYubikey.setValue("true".equals(settings.get("yubikey.enabled")) ? "yes" : "no");
	enableYubikey.setWrapTitle(false);
	enableYubikey.setWrap(false);
	enableYubikey.setRequired(true);
	enableYubikey.setDisabled(Session.get().isDemo());
	yubikeyForm.setFields(enableYubikey);

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			if (vm.validate()) {
				String tenant = Session.get().getTenantName();
				final List<GUIParameter> params = new ArrayList<GUIParameter>();
				params.add(new GUIParameter(tenant + ".2fa.enabled",
						vm.getValueAsString("enable2fa").equals("yes") ? "true" : "false"));
				params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_GOOGLE_AUTHENTICATOR + ".enabled",
						vm.getValueAsString("enableGoolge").equals("yes") ? "true" : "false"));
				params.add(new GUIParameter(tenant + ".2fa." + Constants.TWOFA_YUBIKEY + ".enabled",
						vm.getValueAsString("enableYubikey").equals("yes") ? "true" : "false"));
				SettingService.Instance.get().saveSettings(params.toArray(new GUIParameter[0]),
						new AsyncCallback<Void>() {

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

							@Override
							public void onSuccess(Void arg) {
								Session.get().updateConfig(params);
								Log.info(I18N.message("settingssaved"), null);
							}
						});
			}
		}
	});

	VLayout panel = new VLayout();
	panel.setWidth100();
	panel.setMembers(form, googleForm, yubikeyForm);

	body.setMembers(panel);
	addMember(save);
}
 
Example 12
Source File: ZoneEditor.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ZoneEditor(GUIZone zone) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("zone") + " - " + zone.getName());
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	this.zone = zone;

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

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

	prepareForm();

	ImageWithCanvases sample = new ImageWithCanvases(zone.getSampleUrl(), 300, null, null);

	HLayout body = new HLayout();
	body.setMembers(form, sample);

	VLayout layout = new VLayout();
	layout.setMembersMargin(5);
	layout.setWidth100();
	layout.setMembers(body, save);

	addItem(layout);

	// Just to clean the upload folder
	DocumentService.Instance.get().cleanUploadedFileFolder(new AsyncCallback<Void>() {

		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(Void result) {
		}
	});
}
 
Example 13
Source File: TagsSettingsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onDraw() {
	DynamicForm parametersForm = new DynamicForm();
	parametersForm.setValuesManager(vm);
	parametersForm.setTitleOrientation(TitleOrientation.LEFT);
	parametersForm.setNumCols(2);
	parametersForm.setColWidths(1, "*");
	parametersForm.setPadding(5);

	SelectItem mode = ItemFactory.newTagInputMode("mode", "inputmode");

	SpinnerItem maxsize = ItemFactory.newSpinnerItem("maxsize", I18N.message("maxsize"), (Long) null);
	maxsize.setRequired(true);

	SpinnerItem minsize = ItemFactory.newSpinnerItem("minsize", I18N.message("minsize"), (Long) null);
	minsize.setRequired(true);

	SpinnerItem cloudElements = ItemFactory.newSpinnerItem("cloudElements", I18N.message("tagcloudelements"),
			(Long) null);
	cloudElements.setRequired(true);
	cloudElements.setWrapTitle(false);

	TextItem vocabulary = ItemFactory.newTextItem("vocabulary", I18N.message("vocabulary"), null);
	vocabulary.setRequired(true);
	vocabulary.setWidth(300);

	parametersForm.setItems(mode, maxsize, minsize, cloudElements, vocabulary);
	addMember(parametersForm);

	for (GUIParameter p : settings) {
		if (p.getName().endsWith("tag.mode"))
			mode.setValue(p.getValue());
		if (p.getName().endsWith("tag.maxsize"))
			maxsize.setValue(p.getValue());
		if (p.getName().endsWith("tag.minsize"))
			minsize.setValue(p.getValue());
		if (p.getName().endsWith("tag.vocabulary"))
			vocabulary.setValue(p.getValue());
		if (p.getName().endsWith("tagcloud.maxtags"))
			cloudElements.setValue(p.getValue());
	}

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

			if (vm.validate()) {
				List<GUIParameter> params = new ArrayList<GUIParameter>();

				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.mode", values.get("mode")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.maxsize", values.get("maxsize")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.minsize", values.get("minsize")
						.toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tag.vocabulary", values.get(
						"vocabulary").toString()));
				params.add(new GUIParameter(Session.get().getTenantName() + ".tagcloud.maxtags", values.get(
						"cloudElements").toString()));

				SettingService.Instance.get().saveSettings(params.toArray(new GUIParameter[0]),
						new AsyncCallback<Void>() {

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

							@Override
							public void onSuccess(Void ret) {
								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.mode",
												values.get("mode").toString());
								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.maxsize",
												values.get("maxsize").toString());

								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tag.minsize",
												values.get("minsize").toString());

								Session.get()
										.getInfo()
										.setConfig(Session.get().getTenantName() + ".tagcloud.maxtags",
												values.get("cloudElements").toString());

								Log.info(I18N.message("settingssaved"), null);
							}
						});
			}
		}
	});

	addMember(save);
}
 
Example 14
Source File: KeystoreUploader.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public KeystoreUploader(TenantKeystorePanel keystorePanel) {
	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	this.keystorePanel = keystorePanel;
	setTitle(I18N.message("uploadkeystore"));
	setWidth(420);
	setHeight(190);
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();

	layout.setMembersMargin(2);
	layout.setMargin(2);

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

	// Add a finish handler which will load the image once the upload
	// finishes
	uploader.addOnFinishUploadHandler(onFinishUploaderHandler);

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

		@Override
		public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
			onSend();
		}
	});

	prepareForm();

	layout.addMember(form);
	layout.addMember(uploader);
	layout.addMember(sendButton);
	addItem(layout);

	// Cleanup the upload folder
	DocumentService.Instance.get().cleanUploadedFileFolder(new AsyncCallback<Void>() {

		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(Void result) {
		}
	});
}
 
Example 15
Source File: TwoFactorsAuthenticationDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TwoFactorsAuthenticationDialog(final GUIUser user, boolean allowNotify) {
	super();

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("twofactorsauth"));
	setIsModal(true);
	setShowModalMask(true);
	centerInPage();
	setAutoSize(true);

	final TwoFactorsAuthenticationPanel panel = new TwoFactorsAuthenticationPanel(user, allowNotify);
	panel.setWidth(350);

	IButton save = new IButton(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {

		@Override
		public void onClick(ClickEvent event) {
			if (panel.validate()) {
				TwoFactorsAuthenticationService.Instance.get().changeTwoFactorsAuthentication(user.getId(),
						panel.getFactor(), panel.getKey(), panel.getAccount(), panel.isNotify(),
						new AsyncCallback<Void>() {
							@Override
							public void onFailure(Throwable caught) {
								Log.serverError(caught);
							}

							@Override
							public void onSuccess(Void arg) {
								user.setSecondFactor(panel.getFactor());
								user.setKey(panel.getKey());
								TwoFactorsAuthenticationDialog.this.destroy();
							}
						});
			}
		}
	});

	VLayout body = new VLayout();
	body.setMembers(panel, save);
	addItem(body);
}
 
Example 16
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 17
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 18
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));
	}
}
 
Example 19
Source File: SignatureDialog.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public SignatureDialog(long[] docIds) {
	super();

	this.docIds = docIds;

	setHeaderControls(HeaderControls.HEADER_LABEL, HeaderControls.CLOSE_BUTTON);
	setTitle(I18N.message("signature"));
	setCanDragResize(true);
	setIsModal(true);
	setShowModalMask(true);
	setAutoSize(true);
	centerInPage();

	VLayout layout = new VLayout();
	layout.setWidth100();
	layout.setHeight(40);

	form.setValuesManager(vm);
	form.setWrapItemTitles(false);
	form.setTitleOrientation(TitleOrientation.TOP);
	form.setNumCols(2);

	TextItem reason = ItemFactory.newTextItem("reason", "reason", null);
	reason.setRequired(true);
	reason.setWrapTitle(false);
	reason.setWidth(250);
	reason.setAutoComplete(AutoComplete.NONE);

	visualPositioning = new CheckboxItem();
	visualPositioning.setName("visualpositioning");
	visualPositioning.setTitle(I18N.message("visualpositioning"));
	visualPositioning.setDisabled(true);

	form.setItems(reason, visualPositioning);

	IButton sign = new IButton(I18N.message("sign"));
	sign.setAutoFit(true);
	sign.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			onSign();
		}
	});

	HLayout buttons = new HLayout();
	buttons.setMembersMargin(5);
	buttons.setMargin(3);
	buttons.addMember(sign);

	layout.addMember(form);
	layout.addMember(buttons);

	addItem(layout);

	SignService.Instance.get().isVisualSignatureEnabled(new AsyncCallback<Boolean>() {

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

		@Override
		public void onSuccess(Boolean enabled) {
			visualPositioning.setDisabled(!enabled);
		}
	});
}
 
Example 20
Source File: AntivirusPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void initGUI(GUIParameter[] settings) {
	final DynamicForm form = new DynamicForm();
	form.setTitleOrientation(TitleOrientation.LEFT);
	form.setAlign(Alignment.LEFT);

	RadioGroupItem enabled = ItemFactory.newBooleanSelector("enabled", I18N.message("enabled"));
	enabled.setWrapTitle(false);
	enabled.setRequired(true);

	TextItem command = ItemFactory.newTextItem("command", "ClamAV", null);
	command.setWidth(400);

	TextItem includes = ItemFactory.newTextItem("includes", "include", null);
	includes.setWidth(400);

	TextItem excludes = ItemFactory.newTextItem("excludes", "exclude", null);
	excludes.setWidth(400);

	TextItem timeout = ItemFactory.newSpinnerItem("timeout", "timeout", (Integer) null);
	timeout.setHint(I18N.message("seconds"));

	for (GUIParameter setting : settings) {
		if ((Session.get().getTenantName() + ".antivirus.enabled").equals(setting.getName()))
			enabled.setValue("true".equals(setting.getValue()) ? "yes" : "no");
		else if ("antivirus.command".equals(setting.getName()))
			command.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.excludes").equals(setting.getName()))
			excludes.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.includes").equals(setting.getName()))
			includes.setValue(setting.getValue());
		else if ((Session.get().getTenantName() + ".antivirus.timeout").equals(setting.getName()))
			timeout.setValue(Integer.parseInt(setting.getValue()));
	}

	IButton save = new IButton();
	save.setTitle(I18N.message("save"));
	save.addClickHandler(new ClickHandler() {
		public void onClick(ClickEvent event) {
			if (form.validate()) {
				GUIParameter[] params = new GUIParameter[Session.get().isDefaultTenant() ? 4 : 3];
				params[0] = new GUIParameter(Session.get().getTenantName() + ".antivirus.enabled",
						"" + ("yes".equals(form.getValueAsString("enabled"))));
				params[1] = new GUIParameter(Session.get().getTenantName() + ".antivirus.excludes",
						form.getValueAsString("excludes").trim());
				params[2] = new GUIParameter(Session.get().getTenantName() + ".antivirus.includes",
						form.getValueAsString("includes").trim());
				params[3] = new GUIParameter(Session.get().getTenantName() + ".antivirus.timeout",
						form.getValueAsString("timeout").trim());

				if (Session.get().isDefaultTenant())
					params[4] = new GUIParameter("antivirus.command", form.getValueAsString("command").trim());

				SettingService.Instance.get().saveSettings(params, new AsyncCallback<Void>() {

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

					@Override
					public void onSuccess(Void ret) {
						Log.info(I18N.message("settingssaved"), null);
					}
				});
			}
		}
	});
	if (Session.get().isDefaultTenant())
		form.setFields(enabled, command, includes, excludes, timeout);
	else
		form.setFields(enabled, includes, excludes, timeout);

	Tab tab = new Tab();
	tab.setTitle(I18N.message("antivirus"));
	tab.setPane(form);

	TabSet tabs = new TabSet();
	tabs.setWidth100();
	tabs.setHeight100();
	tabs.setTabs(tab);

	setMembers(tabs, save);
}