Java Code Examples for com.smartgwt.client.widgets.form.fields.SelectItem#addChangedHandler()

The following examples show how to use com.smartgwt.client.widgets.form.fields.SelectItem#addChangedHandler() . 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: DigitalObjectPreview.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets widget to zoom image in the window.
 * @return
 */
public Canvas getWindowZoomer() {
    SelectItem zoomItem = createZoomForm();
    zoomItem.setHeight(15);
    zoomItem.setPickerIconSrc("[SKIN]/headerIcons/zoom.png");
    zoomItem.setPickerIconHeight(15);
    zoomItem.setPickerIconWidth(15);
    zoomItem.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            onZoomChange(event);
        }
    });
    DynamicForm form = new DynamicForm();
    form.setValuesManager(zoomValues);
    form.setFields(zoomItem);
    form.setLayoutAlign(Alignment.CENTER);
    return form;
}
 
Example 2
Source File: StationSelector.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createInformationFieldForSelectedStation() {
        VLayout layout = new VLayout();
        timeseriesInfoHTMLPane = new HTMLPane();
        phenomenonBox = new SelectItem(i18n.phenomenonLabel());
        phenomenonBox.addChangedHandler(new ChangedHandler() {
			@Override
			public void onChanged(ChangedEvent event) {
				String category = (String) event.getItem().getValue();
				controller.loadTimeseriesByCategory(category);
			}
		});
        DynamicForm form = new DynamicForm();
        form.setItems(phenomenonBox);
//        phenomenonInfoLabel = new Label();
//        phenomenonInfoLabel.setAutoHeight();
        stationInfoLabel = new Label();
        stationInfoLabel.setAutoHeight();
//        layout.addMember(phenomenonInfoLabel);
        layout.addMember(form);
        layout.addMember(stationInfoLabel);
        layout.addMember(timeseriesInfoHTMLPane);
        return layout;
    }
 
Example 3
Source File: SensorLossRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEditConditionCanvas() {
        StaticTextItem label = createLabelItem(i18n.sensorFailure());

        SelectItem unitItem = createUnitsItem();
        unitItem.addChangedHandler(createEntryUnitChangedHandler());
        unitItem.setValueMap(createTimeunitsMap());
        unitItem.setWidth(2 * EDIT_ITEMS_WIDTH);
        
        TextItem valueItem = createValueItem();
        valueItem.addChangedHandler(createValueChangedHandler());
        valueItem.setWidth(EDIT_ITEMS_WIDTH);
        valueItem.setRequired(true);
//        valueItem.setKeyPressFilter("[0-9]+(\\.|,)[0-9]+");
        
        FormItem[] formItems = new FormItem[] { label, unitItem, valueItem };
        conditionForm = assembleEditConditionForm(formItems);
        return alignVerticalCenter(conditionForm);
    }
 
Example 4
Source File: OverUndershootRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Canvas createEntryConditionEditCanvas() {
    StaticTextItem labelItem = createLabelItem(i18n.enterCondition());
    
    OverUndershootSelectionData data = controller.getOverUndershootEntryConditions();
    SelectItem entryOperatorItem = createOperatorItem(data, GREATER_THAN_INT);
    entryOperatorItem.addChangedHandler(createEntryOperatorChangedHandler());
    entryOperatorItem.setWidth(EDIT_ITEMS_WIDTH);

    TextItem entryValueItem = createValueItem();
    entryValueItem.addChangedHandler(createEntryValueChangedHandler());
    entryValueItem.setWidth(EDIT_ITEMS_WIDTH);
    declareAsRequired(entryValueItem);
    
    StaticTextItem entryUnitItem = createStaticUnitItem(data);
    entryUnitItem.setWidth(EDIT_ITEMS_WIDTH);
    
    FormItem[] items = new FormItem[] { labelItem, entryOperatorItem, entryValueItem, entryUnitItem };
    entryConditionForm = assembleEditConditionForm(items);
    return alignVerticalCenter(entryConditionForm);
}
 
Example 5
Source File: DigitalObjectPreview.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets widget to zoom image in the preview panel.
 * @return
 */
public Canvas getPreviewZoomer() {
    SelectItem zoomItem = createZoomForm();
    zoomItem.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            onZoomChange(event);
        }
    });
    DynamicForm form = new DynamicForm();
    form.setValuesManager(zoomValues);
    form.setFields(zoomItem);
    form.setLayoutAlign(Alignment.CENTER);
    return form;
}
 
Example 6
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static SelectItem newEventSelector(String name, String title, final ChangedHandler handler, boolean folder,
		boolean workflow, boolean user) {
	final SelectItem select = newSelectItem(filterItemName(name), title);
	select.setWidth(350);
	select.setMultiple(false);
	select.setOptionDataSource(new EventsDS(folder, workflow, user));
	select.setValueField("code");
	select.setDisplayField("label");
	if (handler != null)
		select.addChangedHandler(handler);

	PickerIcon clear = new PickerIcon(PickerIcon.CLEAR, new FormItemClickHandler() {
		@Override
		public void onFormItemClick(FormItemIconClickEvent event) {
			select.clearValue();
			select.setValue((String) null);
			if (handler != null)
				handler.onChanged(null);
		}
	});
	select.setIcons(clear);
	select.setIconVAlign(VerticalAlignment.TOP);

	return select;
}
 
Example 7
Source File: ImportSettingsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ImportSettingsPanel(GUIArchive archive, ChangedHandler changedHandler) {
	this.archive = archive;

	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.TOP);

	TextItem description = ItemFactory.newTextItem("description", "description", archive.getDescription());
	description.addChangedHandler(changedHandler);
	description.setDisabled(archive.getStatus() != GUIArchive.STATUS_OPENED);

	RadioGroupItem importTemplates = ItemFactory.newBooleanSelector("importtemplates", "importtemplates");
	importTemplates.setValue(archive.getImportTemplate() == 1 ? "yes" : "no");
	importTemplates.addChangedHandler(changedHandler);
	importTemplates.setDisabled(archive.getStatus() != GUIArchive.STATUS_OPENED);

	SelectItem options = ItemFactory.newImportCustomIds();
	options.setWidth(200);
	options.setValue(Integer.toString(archive.getImportCustomId()));
	options.addChangedHandler(changedHandler);
	options.setDisabled(archive.getStatus() != GUIArchive.STATUS_OPENED);

	form.setFields(description, importTemplates, options);

	addMember(form);
}
 
Example 8
Source File: MainMenu.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private SelectItem getDensitySelector() {
	SelectItem density = ItemFactory.newDensitySelector();
	density.setShowTitle(false);
	String dens = Session.get().getInfo().getConfig("gui.density");
	if (CookiesManager.get(CookiesManager.COOKIE_DENSITY) != null)
		dens = CookiesManager.get(CookiesManager.COOKIE_DENSITY);
	density.setValue(dens);
	density.addChangedHandler(new ChangedHandler() {

		@Override
		public void onChanged(ChangedEvent event) {
			String newDensity = event.getValue().toString();
			Session.get().getInfo().setConfig(Session.get().getTenantName() + ".gui.density", newDensity);
			CookiesManager.save(CookiesManager.COOKIE_DENSITY, newDensity);
			Util.setupDensity(Session.get().getInfo());
			com.google.gwt.user.client.Window.Location.reload();
		}
	});
	return density;
}
 
Example 9
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newEventsSelector(String name, String title, final ChangedHandler handler, boolean folder,
		boolean workflow, boolean user) {
	final SelectItem select = newMultipleSelector(filterItemName(name), title);
	select.setWidth(350);
	select.setHeight(250);
	select.setMultipleAppearance(MultipleAppearance.GRID);
	select.setMultiple(true);
	select.setOptionDataSource(new EventsDS(folder, workflow, user));
	select.setValueField("code");
	select.setDisplayField("label");
	if (handler != null)
		select.addChangedHandler(handler);

	PickerIcon clear = new PickerIcon(PickerIcon.CLEAR, new FormItemClickHandler() {
		@Override
		public void onFormItemClick(FormItemIconClickEvent event) {
			select.clearValue();
			select.setValue((String) null);
			if (handler != null)
				handler.onChanged(null);
		}
	});
	select.setIcons(clear);
	select.setIconVAlign(VerticalAlignment.TOP);

	return select;
}
 
Example 10
Source File: ItemFactory.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static SelectItem newAutomationRoutineSelector(String name, Long value, final ChangedHandler handler,
		boolean showEmpty) {
	final SelectItem select = newSelectItem(filterItemName(name), "routine");
	select.setValueField("id");
	select.setDisplayField("name");
	select.setEmptyDisplayValue(I18N.message("customcode"));

	ListGridField id = new ListGridField("id", I18N.message("id"));
	id.setHidden(true);
	ListGridField _name = new ListGridField("name", I18N.message("name"));
	ListGridField description = new ListGridField("description", I18N.message("description"));
	select.setPickListFields(id, _name, description);
	select.setPickListWidth(250);
	select.setOptionDataSource(new AutomationRoutinesDS(showEmpty));
	select.setValue(value);

	ChangedHandler setNullOnEmpty = new ChangedHandler() {

		@Override
		public void onChanged(ChangedEvent event) {
			if (event != null && event.getValue().equals("")) {
				select.setValue((String) null);
				select.clearValue();
			}
		}
	};
	select.addChangedHandler(setNullOnEmpty);
	if (handler != null)
		select.addChangedHandler(handler);

	return select;
}
 
Example 11
Source File: OverUndershootRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
protected SelectItem createUnitsItem() {
    SelectItem unitSelectItem = new SelectItem();
    unitSelectItem.setTitle(i18n.unit());
    unitSelectItem.setTitleOrientation(TOP);
    unitSelectItem.addChangedHandler(createUnitSelectionChangedHandler());
    return unitSelectItem;
}
 
Example 12
Source File: SensorLossRuleTemplate.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
private SelectItem createUnitsItem() {
    SelectItem unitSelectItem = new SelectItem();
    unitSelectItem.setTitle(i18n.unit());
    unitSelectItem.setTitleOrientation(TOP);
    unitSelectItem.addChangedHandler(createUnitSelectionChangedHandler());
    return unitSelectItem;
}
 
Example 13
Source File: TwoFactorsAuthenticationPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TwoFactorsAuthenticationPanel(GUIUser user, boolean withNotify) {
	super();
	this.user = user;

	DynamicForm form = new DynamicForm();
	form.setWidth100();
	form.setValuesManager(vm);
	form.setTitleOrientation(TitleOrientation.LEFT);

	notify = ItemFactory.newCheckbox("notify", "notifyuser");
	notify.setValue(false);
	notify.setDisabled(true);

	SelectItem method = ItemFactory.new2AFMethodSelector("factor", user.getSecondFactor());
	method.setWidth(250);
	method.addChangedHandler(new ChangedHandler() {

		@Override
		public void onChanged(ChangedEvent event) {
			removeMember(setupPanel);
			if (event.getValue() == null || event.getValue().toString().isEmpty()) {
				setupPanel = new TwoFactorsAuthenticationSetup();
				TwoFactorsAuthenticationPanel.this.user.setKey(null);
				TwoFactorsAuthenticationPanel.this.user.setSecondFactor(null);
				notify.setValue(false);
				notify.setDisabled(true);
			} else if (Constants.TWOFA_GOOGLE_AUTHENTICATOR.equals(event.getValue().toString())) {
				setupPanel = new GoogleAuthenticatorSetup(TwoFactorsAuthenticationPanel.this.user);
				notify.setValue(true);
				notify.setDisabled(false);
			} else if (Constants.TWOFA_YUBIKEY.equals(event.getValue().toString())) {
				setupPanel = new YubiKeySetup(TwoFactorsAuthenticationPanel.this.user);
				notify.setValue(false);
				notify.setDisabled(true);
			}
			addMember(setupPanel);
		}
	});

	if (withNotify)
		form.setItems(method, notify);
	else
		form.setItems(method);
	setMembers(form);
}
 
Example 14
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private Widget createForm() {
    taskForm = new DynamicForm();
    taskForm.setDataSource(WorkflowTaskDataSource.getInstance());
    taskForm.setNumCols(3);
    taskForm.setColWidths("*", "*", "*");
    taskForm.setTitleOrientation(TitleOrientation.TOP);
    taskForm.setItemHoverWidth(300);

    StaticTextItem jobLabel = new StaticTextItem(WorkflowTaskDataSource.FIELD_JOB_LABEL);
    jobLabel.setColSpan("*");
    jobLabel.setWidth("*");
    jobLabel.setShowTitle(false);
    jobLabel.setReadOnlyTextBoxStyle(Editor.CSS_HEADER_INSIDE_FORM);
    jobLabel.setTextBoxStyle(Editor.CSS_HEADER_INSIDE_FORM);

    final SelectItem owner = new SelectItem(WorkflowTaskDataSource.FIELD_OWNER);
    owner.setOptionDataSource(UserDataSource.getInstance());
    owner.setValueField(UserDataSource.FIELD_ID);
    owner.setDisplayField(UserDataSource.FIELD_USERNAME);
    owner.setWidth("*");
   // owner.setValidators(new RequiredIfValidator(requiredFunc));

    TextAreaItem note = new TextAreaItem(WorkflowTaskDataSource.FIELD_NOTE);
    note.setStartRow(true);
    note.setColSpan("*");
    note.setWidth("*");

    // title tooltip is broken in SmartGWT 4.0
    final FormItemIcon taskHelpIcon = new FormItemIcon();
    taskHelpIcon.setSrc("[SKIN]/actions/help.png");
    taskHelpIcon.setTabIndex(-1);
    taskHelpIcon.setNeverDisable(true);
    taskHelpIcon.setShowIfCondition(new FormItemIfFunction() {

        @Override
        public boolean execute(FormItem item, Object value, DynamicForm form) {
            String hint = taskForm.getValueAsString(WorkflowTaskDataSource.FIELD_HINT);
            taskHelpIcon.setPrompt(hint);
            return hint != null;
        }
    });
    TextItem label = new TextItem(WorkflowTaskDataSource.FIELD_LABEL);
    label.setWidth("*");
    label.setIcons(taskHelpIcon);

    stateItem = new SelectItem(WorkflowTaskDataSource.FIELD_STATE);
    stateItem.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            owner.redraw();
            paramForm.markForRedraw();
        }
    });

    taskForm.setFields(jobLabel,
            label,
            owner,
            stateItem,
            new TextItem(WorkflowTaskDataSource.FIELD_CREATED),
            new TextItem(WorkflowTaskDataSource.FIELD_MODIFIED),
            new SelectItem(WorkflowTaskDataSource.FIELD_PRIORITY),
            note);
    return taskForm;
}
 
Example 15
Source File: WorkflowNewJobView.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private Widget createOptionForm() {
        final SelectItem profile = createProfileSelector();
        profile.addChangedHandler(changedEvent -> fetchModelMenu(changedEvent.getItem().getSelectedRecord()));

        TextItem metadata = new TextItem(WorkflowResourceApi.NEWJOB_METADATA, "Metadata");
        metadata.setShowTitle(false);
        metadata.setCanEdit(false);
        metadata.setStartRow(true);
        metadata.setReadOnlyDisplay(ReadOnlyDisplayAppearance.STATIC);
        // show empty value instead of XML
        metadata.setEditorValueFormatter(new FormItemValueFormatter() {

            @Override
            public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
                return "";
            }
        });

//        HiddenItem catalog = new HiddenItem(WorkflowResourceApi.NEWJOB_CATALOGID);
//        catalog.setRequired(true);
//        catalog.setRequiredMessage("Nejsou vybrána žádná metadata!");

        optionForm = new DynamicForm();
        optionForm.setAutoWidth();
        optionForm.setWrapItemTitles(false);
        optionForm.setTitleOrientation(TitleOrientation.TOP);
        optionForm.setItems(profile, metadata);
        // XXX HiddenValidationErrorsHandler does not work in smartgwt 4.0
//        optionForm.addHiddenValidationErrorsHandler(new HiddenValidationErrorsHandler() {
//
//            @Override
//            public void onHiddenValidationErrors(HiddenValidationErrorsEvent event) {
//                event.cancel();
//                String[] profileErrors = optionForm.getFieldErrors(profile.getName());
//                ArrayList<String> result = new ArrayList<String>();
//                result.addAll(Arrays.asList(profileErrors));
//                Map<?,?> errors = event.getErrors();
//                for (Entry<? extends Object, ? extends Object> entrySet : errors.entrySet()) {
//                    StringBuilder sb = new StringBuilder();
//                    Object key = entrySet.getKey();
//                    Object value = entrySet.getValue();
//                    result.add(String.valueOf(key) + " - " + String.valueOf(value));
//                }
//                System.out.println("## onHiddenValidationErrors. origErr: " + profileErrors +
//                        "\n event.err: " + errors + "\n result: " + result);
//                optionForm.setFieldErrors(profile.getName(), result.toArray(new String[result.size()]), true);
//            }
//        });
        return optionForm;
    }
 
Example 16
Source File: ImportSourceChooser.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private DynamicForm createOptionsForm() {
    DynamicForm form = new DynamicForm();
    form.setNumCols(10);
    form.setGroupTitle(i18n.ImportSourceChooser_Options_Title());
    form.setIsGroup(true);
    form.setWrapItemTitles(false);

    final CheckboxItem cbiPageIndexes = new CheckboxItem(ImportBatchDataSource.FIELD_INDICES,
            i18n.ImportSourceChooser_OptionPageIndices_Title());
    cbiPageIndexes.setValue(true);

    final SelectItem selectScanner = createScannerSelection();
    final SelectItem selectProfile = ProfileChooser.createProfileSelection(ProfileGroup.IMPORTS, i18n);
    selectProfile.setName(ImportBatchDataSource.FIELD_PROFILE_ID);
    selectProfile.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            String profile = getImportProfile();
            Criteria criteria = new Criteria();
            if (profile != null) {
                criteria.addCriteria(ImportTreeDataSource.FIELD_PROFILE, profile);
            }
            treeGrid.setCriteria(criteria);
            boolean isArchive= BatchRecord.isArchive(profile);
            boolean isKramerius = BatchRecord.isKramerius(profile);
            selectScanner.setRequired(!isArchive);
            if (isKramerius) {
                selectScanner.show();
                cbiPageIndexes.hide();
            } else if (isArchive) {
                selectScanner.hide();
                cbiPageIndexes.hide();
            } else {
                selectScanner.show();
                cbiPageIndexes.show();
            }
        }
    });

    form.setFields(selectProfile, selectScanner, cbiPageIndexes);
    return form;
}
 
Example 17
Source File: PageMetadataEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void createPageNumberUi() {
    formPageNumber = createForm();

    allowPageNumbers = new CheckboxItem("fillPageNumbers", i18n.PageMetadataEditor_CheckboxPageNubers_Title());
    allowPageNumbers.setStartRow(true);
    allowPageNumbers.setColSpan("*");
    allowPageNumbers.setShowTitle(false);

    PageNumberChangeHandler pageNumberChangeHandler = new PageNumberChangeHandler();

    integerStartValidator = new IntegerRangeValidator();
    integerStartValidator.setMin(0);
    integerStartValidator.setMax(1000000);
    romanStartValidator = new RegExpValidator(
            "^[1-9][0-9]{0,6}$"
            + "|^[mM]{0,6}([cC][mM]|[cC][dD]|[dD]?[cC]{0,3})([xX][cC]|[xX][lL]|[lL]?[xX]{0,3})([iI][xX]|[iI][vV]|[vV]?[iI]{0,3})$");
    alphabetStartValidator = new RegExpValidator("^[a-zA-Z]{0,6}$");
    numberStartRequired = new RequiredIfValidator(new RequiredIfFunction() {

        @Override
        public boolean execute(FormItem formItem, Object value) {
            return true;
        }
    });
    numberStart = new TextItem("numberStart", i18n.PageMetadataEditor_NumberStartValue_Title());
    numberStart.addChangedHandler(pageNumberChangeHandler);

    prefix = new TextItem("prefix", i18n.PageMetadataEditor_NumberPrefix_Title());
    prefix.setLength(20);
    prefix.addChangedHandler(pageNumberChangeHandler);

    suffix = new TextItem("suffix", i18n.PageMetadataEditor_NumberSuffix_Title());
    suffix.setLength(20);
    suffix.addChangedHandler(pageNumberChangeHandler);

    integerIncrementValidator = new IntegerRangeValidator();
    integerIncrementValidator.setMin(-1000);
    integerIncrementValidator.setMax(1000);
    numberIncrement = new IntegerItem("numberIncrement", i18n.PageMetadataEditor_NumberIncrement_Title());
    numberIncrement.addChangedHandler(pageNumberChangeHandler);
    numberIncrement.setRequired(true);
    numberIncrement.setValidators(integerIncrementValidator);

    numberExample = new StaticTextItem("numberExample", i18n.PageMetadataEditor_NumberPreview_Title());
    numberExample.setClipValue(true);
    numberExample.setWidth(120); // enforce clip value

    seriesType = new SelectItem("seriesType", i18n.PageMetadataEditor_NumberSeriesType_Title());
    seriesType.setValueMap(ARABIC_SERIES, ROMAN_UPPER_SERIES,
            ROMAN_LOWER_SERIES, ALPHABET_UPPER_SERIES, ALPHABET_LOWER_SERIES);
    seriesType.setDefaultValue(ARABIC_SERIES);
    seriesType.setValue(ARABIC_SERIES);
    seriesType.addChangedHandler(new ChangedHandler() {

        @Override
        public void onChanged(ChangedEvent event) {
            setSequenceType(seriesType.getValueAsString());
        }
    });

    allowPageNumbers.addChangedHandler(new DisableStateHandler(
            prefix, numberStart, numberIncrement, suffix, seriesType, numberExample));
}
 
Example 18
Source File: AutomationTriggerProperties.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void refresh() {
	vm.clearValues();
	vm.clearErrors(false);

	if (formsContainer.getMembers() != null)
		formsContainer.removeMembers(formsContainer.getMembers());

	DynamicForm form2 = new DynamicForm();
	form2.setWidth100();
	form2.setTitleOrientation(TitleOrientation.TOP);
	form2.setValuesManager(vm);
	form2.setNumCols(1);

	final TextAreaItem automation = ItemFactory.newTextAreaItemForAutomation("automation", "automation",
			trigger.getAutomation(), changedHandler, false);
	automation.setStartRow(false);
	automation.setWidth("*");
	automation.setDisabled(trigger.getRoutine()!=null);
	
	form2.setItems(automation);
	
	DynamicForm form1 = new DynamicForm();
	form1.setNumCols(2);
	form1.setTitleOrientation(TitleOrientation.TOP);
	form1.setValuesManager(vm);
	form1.setHeight100();

	SelectItem events = ItemFactory.newEventsSelector("events", I18N.message("triggeron"), changedHandler, true, true,
			true);
	events.setRowSpan(3);
	events.setValues(trigger.getEventsArray());

	SpacerItem spacer = new SpacerItem();
	spacer.setHeight(100);

	SelectItem routine = ItemFactory.newAutomationRoutineSelector("routine",
			trigger.getRoutine() != null ? trigger.getRoutine().getId() : null, changedHandler, true);
	routine.setEndRow(true);
	routine.addChangedHandler(changedHandler);
	ChangedHandler cngHandler = new ChangedHandler() {
		@Override
		public void onChanged(ChangedEvent event) {
			if (event == null) {
				automation.setDisabled(false);
			} else {
				automation.setDisabled(event.getValue() != null && !event.getValue().toString().isEmpty());
			}
		}
	};
	routine.addChangedHandler(cngHandler);
	
	form1.setItems(events, folderSelector, routine, spacer);

	formsContainer.setMembers(form1, form2);
}
 
Example 19
Source File: RetentionPolicyDetailsPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void refresh() {

		/*
		 * Prepare the standard properties tab
		 */
		if (tabSet != null) {
			tabSet.hideSave();
			removeMember(tabSet);
		}

		tabSet = new EditingTabSet(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				onSave();
			}
		}, new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				if (policy.getId() != 0) {
					RetentionPoliciesService.Instance.get().getPolicy(policy.getId(),
							new AsyncCallback<GUIRetentionPolicy>() {
								@Override
								public void onFailure(Throwable caught) {
									Log.serverError(caught);
								}

								@Override
								public void onSuccess(GUIRetentionPolicy policy) {
									setPolicy(policy);
								}
							});
				} else {
					GUIRetentionPolicy newsPolicy = new GUIRetentionPolicy();
					setPolicy(newsPolicy);
				}
				tabSet.hideSave();
			}
		});

		Tab propertiesTab = new Tab(I18N.message("properties"));
		propertiesTabPanel = new HLayout();
		propertiesTabPanel.setWidth100();
		propertiesTabPanel.setHeight100();
		propertiesTab.setPane(propertiesTabPanel);
		tabSet.addTab(propertiesTab);

		addMember(tabSet);

		ChangedHandler changedHandler = new ChangedHandler() {
			@Override
			public void onChanged(ChangedEvent event) {
				onModified();
			}
		};

		form = new DynamicForm();
		form.setNumCols(2);
		form.setTitleOrientation(TitleOrientation.TOP);

		TextItem name = ItemFactory.newSimpleTextItem("name", "name", policy.getName());
		name.addChangedHandler(changedHandler);
		name.setWidth(200);
		name.setRequired(true);

		IntegerItem days = ItemFactory.newIntegerItem("days", "retentiondays", policy.getRetentionDays());
		days.addChangedHandler(changedHandler);
		days.setWidth(100);
		days.setRequired(true);

		SelectItem dateOption = ItemFactory.newRetentionDateOption(policy.getDateOption());
		dateOption.addChangedHandler(changedHandler);

		SelectItem template = ItemFactory.newTemplateSelector(true, policy.getTemplateId());
		template.addChangedHandler(changedHandler);

		folder = new FolderSelector(null, true);
		folder.setFolder(policy.getFolderId(), policy.getFolderName());
		folder.addFolderChangeListener(RetentionPolicyDetailsPanel.this);

		SelectItem action = ItemFactory.newRetentionAction(policy.getAction());
		action.addChangedHandler(changedHandler);

		form.setItems(name, days, dateOption, template, action, folder);

		propertiesTab.setPane(form);
	}