org.apache.wicket.markup.html.form.Form Java Examples

The following examples show how to use org.apache.wicket.markup.html.form.Form. 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: FunctionBoxesPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public FunctionBoxesPanel(String id) {
  super(id);
  
  Form<Object> form = new Form<Object>("functionBoxesForm");
  add(form);
  
  List<Component> list = getFunctionBoxesList("functionBox"); 
  ListView<Component> functionBoxes = new ListView<Component>("functionBoxesList", list) {
    @Override
    protected void populateItem(ListItem<Component> item) {
      item.add(item.getModelObject());
    }
  };
  functionBoxes.setVisible(!list.isEmpty());
  form.add(functionBoxes);
}
 
Example #2
Source File: StatementsPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
private void setUpDetailPreference(StatementDetailPreference aDetailPreference)
{
    StatementDetailPreference defaultPreference = StatementDetailPreference.BASIC;
    
    boolean isDetailPreferenceUserDefinable = aDetailPreference == null;
    detailPreference = Model.of(isDetailPreferenceUserDefinable
            ? defaultPreference : aDetailPreference);        
    
    // the form for setting the detail preference (and its radio group) is only shown if the
    // detail preference is user-definable
    Form<StatementDetailPreference> form = new Form<StatementDetailPreference>(
            "detailPreferenceForm");
    form.add(LambdaBehavior
            .onConfigure(_this -> _this.setVisible(isDetailPreferenceUserDefinable)));
    add(form);
    
    // radio choice for statement detail preference
    BootstrapRadioGroup<StatementDetailPreference> choice = new BootstrapRadioGroup<>(
            "detailPreferenceChoice", Arrays.asList(StatementDetailPreference.values()));
    choice.setModel(detailPreference);
    choice.setChoiceRenderer(new EnumRadioChoiceRenderer<>(Buttons.Type.Default, this));
    choice.add(new LambdaAjaxFormSubmittingBehavior("change",
            this::actionStatementDetailPreferencesChanged));
    form.add(choice);
}
 
Example #3
Source File: StatementEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
private void actionSave(AjaxRequestTarget aTarget, Form<KBStatement> aForm) {
    KBStatement modifiedStatement = aForm.getModelObject();
    try {
        String language = aForm.getModelObject().getLanguage() != null
            ? aForm.getModelObject().getLanguage()
            : kbModel.getObject().getDefaultLanguage();
        modifiedStatement.setLanguage(language);

        // persist the modified statement and replace the original, unchanged model
        kbService.upsertStatement(kbModel.getObject(), modifiedStatement);
        statement.setObject(modifiedStatement);
        // switch back to ViewMode and send notification to listeners
        actionCancelExistingStatement(aTarget);
        send(getPage(), Broadcast.BREADTH,
                new AjaxStatementChangedEvent(aTarget, statement.getObject()));
    }
    catch (RepositoryException e) {
        error("Unable to update statement: " + e.getLocalizedMessage());
        LOG.error("Unable to update statement.", e);
        aTarget.addChildren(getPage(), IFeedback.class);
    }
}
 
Example #4
Source File: ColoringRulesConfigurationPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
public ColoringRulesConfigurationPanel(String aId, IModel<AnnotationLayer> aModel,
        IModel<List<ColoringRule>> aColoringRules)
{
    super(aId, aModel);
    
    coloringRules = aColoringRules;
    
    Form<ColoringRule> coloringRulesForm = new Form<>("coloringRulesForm",
            CompoundPropertyModel.of(new ColoringRule()));
    add(coloringRulesForm);

    coloringRulesContainer = new WebMarkupContainer("coloringRulesContainer");
    coloringRulesContainer.setOutputMarkupPlaceholderTag(true);
    coloringRulesForm.add(coloringRulesContainer);

    coloringRulesContainer.add(new TextField<String>("pattern"));
    // We cannot make the color field a required one here because then we'd get a message
    // about color not being set when saving the entire feature details form!
    coloringRulesContainer.add(new ColorPickerTextField("color")
            .add(new PatternValidator("#[0-9a-fA-F]{6}")));
    coloringRulesContainer
            .add(new LambdaAjaxSubmitLink<>("addColoringRule", this::addColoringRule));
            
    coloringRulesContainer.add(createKeyBindingsList("coloringRules", coloringRules));
}
 
Example #5
Source File: ColorPickerPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();
  final Form<Void> colorForm = new Form<Void>("colorForm");
  add(colorForm);
  final TextField<String> colorField = new TextField<String>("color", new PropertyModel<String>(this, "selectedColor"));
  colorField.add(new AjaxFormComponentUpdatingBehavior("onChange") {
    private static final long serialVersionUID = 1L;

    /**
     * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget)
     */
    @Override
    protected void onUpdate(final AjaxRequestTarget target)
    {
      onColorUpdate(selectedColor);
    }
  });
  colorForm.add(colorField);
  // colorpicker js
  final JavaScriptTemplate jsTemplate = new JavaScriptTemplate(new PackageTextTemplate(ColorPickerPanel.class, "ColorPicker.js.template"));
  final String javaScript = jsTemplate.asString(new MicroMap<String, String>("markupId", colorField.getMarkupId()));
  add(new Label("template", javaScript).setEscapeModelStrings(false));
}
 
Example #6
Source File: LogsITCase.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Test
public void updateCoreLogs() {
    TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:0:link");
    TESTER.assertComponent(CONTAINER_PATH, WebMarkupContainer.class);

    Component result = searchLog(KEY, CONTAINER_PATH, "io.swagger");
    assertNotNull(result);

    TESTER.getRequest().setMethod(Form.METHOD_GET);
    TESTER.getRequest().addParameter(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", "6");
    TESTER.assertComponent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", DropDownChoice.class);
    TESTER.executeAjaxEvent(
            result.getPageRelativePath() + ":fields:1:field:dropDownChoiceField", Constants.ON_CHANGE);

    assertSuccessMessage();
}
 
Example #7
Source File: DaysValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
	// we have a choice to validate the type converted values or the raw
	// input values, we validate the raw input
	final FormComponent formComponent1 = components[0];
	final FormComponent formComponent2 = components[1];

       String s1 = formComponent1.getInput();
       String s2 = formComponent2.getInput();

       // disabled components
       if ( (s1 == null) && (s2 == null)) {
          return; 
       }

       // must have one and only one selected
       if ("".equals(s1) && "".equals(s2)) {
           error(formComponent2, resourceKey() + "." + "bothnull");
       }  else if (!"".equals(s1) && !"".equals(s2)) {
           error(formComponent2, resourceKey() + "." + "bothnotnull");
       }
}
 
Example #8
Source File: CheckTablePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public CheckTablePanel(String id, List<IColumn<T, String>> columns, ISortableDataProvider<T, String> provider, int rows) {
    super(id);

    group = new CheckGroup<T>("group", marked);

    this.dataTable = new BaseTable<T>("table", createTableColumns(columns), provider, rows) {

        @Override
        protected Item<T> newRowItem(String s, int i, IModel<T> entityIModel) {
            Item<T> item = super.newRowItem(s, i, entityIModel);
            return newRowTableItem(entityIModel, item);
        }

    };
    
    Form<T> form = new Form<T>("form");
    group.add(dataTable);
    form.add(group);
    add(form);
}
 
Example #9
Source File: DefaultRestorePasswordPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    Form<?> form = new Form<>("form");

    TextField<String> passwordField = new PasswordTextField("password", passwordModel);
    TextField<String> confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
    form.add(createRestoreButton("restoreButton"));

    add(createFeedbackPanel("feedback"));
    add(form);

    setOutputMarkupPlaceholderTag(true);
}
 
Example #10
Source File: ActiveLearningSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private void actionStartSession(AjaxRequestTarget target, Form<?> form)
{
    ActiveLearningUserState alState = alStateModel.getObject();
    AnnotatorState state = getModelObject();
    
    // Start new session
    alState.setSessionActive(true);

    refreshSuggestions();

    moveToNextRecommendation(target, false);

    String userName = state.getUser().getUsername();
    Project project = state.getProject();
    recommendationService.setPredictForAllDocuments(userName, project, true);
    applicationEventPublisherHolder.get().publishEvent(new ActiveLearningSessionStartedEvent(
            this, project, userName));
}
 
Example #11
Source File: NextFeedbackPanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public NextFeedbackPanel(String s, final Form<?> form) {
    super(s);
    
    if (form != null) {
        setFilter(new IFeedbackMessageFilter() {
        	
private static final long serialVersionUID = 1L;

public boolean accept(FeedbackMessage message) {
                final List<FormComponent<?>> components = getFormComponents(form);
                return !components.contains(message.getReporter());
            }

        });
    }
}
 
Example #12
Source File: CurationSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private void merge(AjaxRequestTarget aTarget, Form<Void> aForm)
{
    AnnotatorState state = getModelObject();
    User currentUser = userRepository.getCurrentUser();
    updateCurator(state, currentUser);
    // update selected users
    updateUsers(state);
    long projectId = state.getProject().getId();
    Collection<User> users = selectedUsers.getModelObject();
    curationService.updateMergeStrategy(currentUser.getUsername(), projectId,
            autoMergeStrat);
    mergeConfirm.setConfirmAction((target, form) -> {
        boolean mergeIncomplete = form.getModelObject().isMergeIncompleteAnnotations();
        doMerge(state, state.getUser().getUsername(), users, mergeIncomplete);
        target.add(annoPage);
    });
    mergeConfirm.show(aTarget);
}
 
Example #13
Source File: AbstractFormWidget.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public AbstractFormWidget(String id, IModel<ODocument> model, IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);
	formKey = obtainFormKey();
	String formKeyStr = formKey.toString();
	add(new Label("formKey", formKeyStr));
	setVisible(formKey.isValid());
	formDocumentModel = new ODocumentModel(resolveODocument(formKey));
	
	Form<ODocument> form = new Form<ODocument>("form", getModel());
	IModel<List<OProperty>> propertiesModel = new LoadableDetachableModel<List<OProperty>>() {
		@Override
		protected List<OProperty> load() {
			return oClassIntrospector.listProperties(formDocumentModel.getObject().getSchemaClass(), IOClassIntrospector.DEFAULT_TAB, false);
		}
	};
	propertiesStructureTable = new OrienteerStructureTable<ODocument, OProperty>("properties", formDocumentModel, propertiesModel){

				@Override
				protected Component getValueComponent(String id,
						IModel<OProperty> rowModel) {
					return new ODocumentMetaPanel<Object>(id, getModeModel(), formDocumentModel, rowModel);
				}
	};
	form.add(propertiesStructureTable);
	add(form);
}
 
Example #14
Source File: OPropertyConfigurationWidget.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public OPropertyConfigurationWidget(String id, IModel<OProperty> model,
		IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);
	
	Form<OProperty> form = new Form<OProperty>("form");
	structureTable  = new OrienteerStructureTable<OProperty, String>("attributes", getModel(), OPropertyMetaPanel.OPROPERTY_ATTRS) {

		@Override
		protected Component getValueComponent(String id, final IModel<String> rowModel) {
			return new OPropertyMetaPanel<Object>(id, getModeModel(), OPropertyConfigurationWidget.this.getModel(), rowModel);
		}
	};

	form.add(structureTable);
	
	add(form);
}
 
Example #15
Source File: AnalysisPanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public AnalysisPanel(String id) {
super(id, new SelectedAnalysisModel());				
setOutputMarkupId(true);    
addToolbar();            

Form<Void> submitForm = new Form<Void>("submitForm");
add(submitForm);

dataProvider = new AnalysisDataProvider(getModel());
xlsResource = new XlsResource(dataProvider);
xlsxResource = new XlsxResource(dataProvider);
csvResource = new CsvResource(dataProvider);
submitForm.add(createTablePanel(dataProvider));   
      
      addLinks(submitForm);
  }
 
Example #16
Source File: GalleryImageEdit.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private AjaxFallbackButton createSetProfileImageCancelButton(Form imageEditForm) {
	AjaxFallbackButton removeCancelButton = new AjaxFallbackButton(
			"gallerySetProfileImageCancelButton", new ResourceModel(
					"button.cancel"), imageEditForm) {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			target.appendJavaScript("$('#"
					+ setProfileImageConfirmContainer.getMarkupId() + "').hide();");

			imageOptionsContainer.setVisible(true);
			target.add(imageOptionsContainer);

			target.appendJavaScript("setMainFrameHeight(window.name);");
		}

	};
	return removeCancelButton;
}
 
Example #17
Source File: ProjectVersionFormPopupPanel.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, ProjectVersionFormPopupPanel.class);
	
	form = new Form<ProjectVersion>("form", getModel());
	body.add(form);
	
	TextField<String> versionField = new TextField<String>("version", BindingModel.of(getModel(), Binding.projectVersion().version())) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(ProjectVersionFormPopupPanel.this.isAddMode());
		}
	};
	versionField.setLabel(new ResourceModel("project.version.field.version"));
	versionField.setRequired(isAddMode());
	versionField.add(new ProjectVersionPatternValidator());
	form.add(versionField);
	
	form.add(new VersionAdditionalInformationFormComponentPanel("additionalInformationPanel",
			BindingModel.of(getModel(), Binding.projectVersion().additionalInformation())));
	
	return body;
}
 
Example #18
Source File: MinMaxPoolSizeValidator.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void validate(Form form) {
	// we have a choice to validate the type converted values or the raw
	// input values, we validate the raw input
	final FormComponent formComponent1 = components[0];
	final FormComponent formComponent2 = components[1];

       String s1 = formComponent1.getInput();
       String s2 = formComponent2.getInput();

       // disabled components
       if ( (s1 == null) || s1.trim().equals("") || (s2 == null) || s2.trim().equals("")) {
       	error(formComponent2, resourceKey() + "." + "notnull"); 
       }  else  {
       	Integer i1 = Integer.parseInt(s1);
       	Integer i2 = Integer.parseInt(s2);
       	if (i1.intValue() > i2.intValue()) {
       		error(formComponent2, resourceKey() + "." + "invalid");
       	}           
       }
}
 
Example #19
Source File: TeamCalFilterDialog.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.projectforge.web.dialog.ModalDialog#init()
 */
@SuppressWarnings("serial")
@Override
public void init()
{
  init(new Form<String>(getFormId()));
  calendarPageSupport = new CalendarPageSupport((ISelectCallerPage) getPage());
  timesheetsCalendar.setTitle(getString("plugins.teamcal.timeSheetCalendar"));
  timesheetsCalendar.setId(TIMESHEET_CALENDAR_ID);
  // confirm
  setCloseButtonTooltip(null, new ResourceModel("plugins.teamcal.calendar.filterDialog.closeButton.tooltip"));
  insertNewAjaxActionButton(new AjaxCallback() {
    @Override
    public void callback(final AjaxRequestTarget target)
    {
      filter.remove(filter.getActiveTemplateEntry());
      close(target);
      onClose(target);
    }
  }, 1, getString("delete"), SingleButtonPanel.DELETE);
}
 
Example #20
Source File: MySocialNetworkingEdit.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private boolean save(Form form) {
	
	// get the backing model
	UserProfile userProfile = (UserProfile) form.getModelObject();
	
	// save social networking information
	SocialNetworkingInfo socialNetworkingInfo = new SocialNetworkingInfo(userProfile.getUserUuid());
	
	String tFacebook = ProfileUtils.truncate(userProfile.getSocialInfo().getFacebookUrl(), 255, false);
	String tLinkedin = ProfileUtils.truncate(userProfile.getSocialInfo().getLinkedinUrl(), 255, false);
	String tMyspace = ProfileUtils.truncate(userProfile.getSocialInfo().getMyspaceUrl(), 255, false);
	String tSkype = ProfileUtils.truncate(userProfile.getSocialInfo().getSkypeUsername(), 255, false);
	String tTwitter = ProfileUtils.truncate(userProfile.getSocialInfo().getTwitterUrl(), 255, false);

	socialNetworkingInfo.setFacebookUrl(tFacebook);
	socialNetworkingInfo.setLinkedinUrl(tLinkedin);
	socialNetworkingInfo.setMyspaceUrl(tMyspace);
	socialNetworkingInfo.setSkypeUsername(tSkype);
	socialNetworkingInfo.setTwitterUrl(tTwitter);
	
	return profileLogic.saveSocialNetworkingInfo(socialNetworkingInfo);
	
}
 
Example #21
Source File: OClassSearchPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    setOutputMarkupPlaceholderTag(true);
    if ((selectedClassModel == null || selectedClassModel.getObject() == null) && !classesGetter.get().isEmpty())
        selectedClassModel = new OClassModel(classesGetter.get().get(0));

    Form<String> form = new Form<>("form", getModel());
    TextField<String> field = new TextField<>("query", getModel());
    field.setOutputMarkupId(true);
    field.add(AttributeModifier.replace("placeholder", new ResourceModel("page.search.placeholder").getObject()));
    form.add(field);
    form.add(createSearchButton("search"));
    form.add(createTabsPanel("tabs"));
    form.add(resultsContainer = createResultsContainer("resultsContainer"));
    add(form);
    resultsContainer.add(createEmptyLabel("resultsLabel"));
    prepareResults();
}
 
Example #22
Source File: ConfirmationDialog.java    From webanno with Apache License 2.0 6 votes vote down vote up
protected void onConfirmInternal(AjaxRequestTarget aTarget, Form<State> aForm)
{
    State state = aForm.getModelObject();
    
    boolean closeOk = true;
    
    // Invoke callback if one is defined
    if (confirmAction != null) {
        try {
            confirmAction.accept(aTarget);
        }
        catch (Exception e) {
            LoggerFactory.getLogger(getPage().getClass()).error("Error: " + e.getMessage(), e);
            state.feedback = "Error: " + e.getMessage();
            aTarget.add(aForm);
            closeOk = false;
        }
    }
    
    if (closeOk) {
        close(aTarget);
    }
}
 
Example #23
Source File: RoomForm.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
	Room r = getModelObject();
	if (r.getId() != null) {
		r = roomDao.get(r.getId());
	} else {
		r = newRoom();
	}
	setModelObject(r);
	updateView(target);
}
 
Example #24
Source File: CurationSidebar.java    From inception with Apache License 2.0 5 votes vote down vote up
private Form<List<User>> createUserSelection()
{
    Form<List<User>> usersForm = new Form<List<User>>("usersForm",
            LoadableDetachableModel.of(this::listSelectedUsers));
    LambdaAjaxButton<Void> clearButton = new LambdaAjaxButton<>("clear", this::clearUsers);
    LambdaAjaxButton<Void> mergeButton = new LambdaAjaxButton<>("merge", this::merge);
    LambdaAjaxButton<Void> showButton = new LambdaAjaxButton<>("show", this::selectAndShow);
    usersForm.add(clearButton);
    usersForm.add(showButton);
    usersForm.add(mergeButton);
    selectedUsers = new CheckGroup<User>("selectedUsers", usersForm.getModelObject());
    users = new ListView<User>("users",
            LoadableDetachableModel.of(this::listUsers))
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<User> aItem)
        {
            aItem.add(new Check<User>("user", aItem.getModel()));
            aItem.add(new Label("name", aItem.getModelObject().getUsername()));

        }
    };
    selectedUsers.add(users);
    usersForm.add(selectedUsers);
    return usersForm;
}
 
Example #25
Source File: DefaultPagingNavigator.java    From webanno with Apache License 2.0 5 votes vote down vote up
public DefaultPagingNavigator(String aId, AnnotationPageBase aPage)
{
    super(aId);
    
    setOutputMarkupPlaceholderTag(true);
    
    page = aPage;
    
    Form<Void> form = new Form<>("form");
    gotoPageTextField = new NumberTextField<>("gotoPageText", Model.of(1), Integer.class);
    // Using a LambdaModel here because the model object in the page may change and we want to
    // always get the right one
    gotoPageTextField.setModel(
            PropertyModel.of(LambdaModel.of(() -> aPage.getModel()), "firstVisibleUnitIndex"));
    // FIXME minimum and maximum should be obtained from the annotator state
    gotoPageTextField.setMinimum(1);
    //gotoPageTextField.setMaximum(LambdaModel.of(() -> aPage.getModelObject().getUnitCount()));
    gotoPageTextField.setOutputMarkupId(true); 
    form.add(gotoPageTextField);
    LambdaAjaxSubmitLink gotoPageLink = new LambdaAjaxSubmitLink("gotoPageLink",
            form, this::actionGotoPage);
    form.setDefaultButton(gotoPageLink);
    form.add(gotoPageLink);
    add(form);
    
    form.add(new LambdaAjaxLink("showNext", t -> actionShowNextPage(t))
            .add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click)));

    form.add(new LambdaAjaxLink("showPrevious", t -> actionShowPreviousPage(t))
            .add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click)));

    form.add(new LambdaAjaxLink("showFirst", t -> actionShowFirstPage(t))
            .add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click)));

    form.add(new LambdaAjaxLink("showLast", t -> actionShowLastPage(t))
            .add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click)));
}
 
Example #26
Source File: OAuthForm.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
	OAuthServer server = this.getModelObject();
	if (server.getId() != null) {
		server = oauthDao.get(getModelObject().getId());
	} else {
		server = new OAuthServer();
	}
	this.setModelObject(server);
	target.add(this);
}
 
Example #27
Source File: MilestoneEditPage.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	Milestone milestone = milestoneModel.getObject();
	BeanEditor editor = BeanContext.edit("editor", milestone);
	Form<?> form = new Form<Void>("form") {

		@Override
		protected void onSubmit() {
			super.onSubmit();

			MilestoneManager milestoneManager = OneDev.getInstance(MilestoneManager.class);
			Milestone milestoneWithSameName = milestoneManager.find(getProject(), milestone.getName());
			if (milestoneWithSameName != null && !milestoneWithSameName.equals(milestone)) {
				editor.error(new Path(new PathNode.Named("name")),
						"This name has already been used by another milestone in the project");
			} 
			if (editor.isValid()){
				editor.getDescriptor().copyProperties(milestone, milestoneModel.getObject());
				milestoneManager.save(milestoneModel.getObject());
				Session.get().success("Milestone saved");
				setResponsePage(MilestoneDetailPage.class, MilestoneDetailPage.paramsOf(milestoneModel.getObject(), null));
			}
			
		}
		
	};
	form.add(editor);
	add(form);
}
 
Example #28
Source File: TagSetEditorPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private void actionSave(AjaxRequestTarget aTarget, Form<Tag> aForm) {
    if (isNull(selectedTagSet.getObject().getId())) {
        if (annotationSchemaService.existsTagSet(selectedTagSet.getObject()
                .getName(), selectedProject.getObject())) {
            error("Only one tagset per project is allowed!");
        }
    }
    
    selectedTagSet.getObject().setProject(selectedProject.getObject());
    annotationSchemaService.createTagSet(selectedTagSet.getObject());
    
    // Reload whole page because master panel also needs to be reloaded.
    aTarget.add(getPage());
}
 
Example #29
Source File: LayerTraitsEditor_ImplBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
public LayerTraitsEditor_ImplBase(String aId, LayerSupport<?, ?> aLayerSupport,
        IModel<AnnotationLayer> aLayerModel)
{
    super(aId, aLayerModel);

    layerSupportId = aLayerSupport.getId();
    
    traitsModel = CompoundPropertyModel
            .of(getLayerSupport().readTraits(aLayerModel.getObject()));
    layerModel = CompoundPropertyModel.of(aLayerModel);
    
    form = new Form<T>(MID_FORM, getTraitsModel())
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            
            LayerTraitsEditor_ImplBase.this.onSubmit();

            getLayerSupport().writeTraits(aLayerModel.getObject(), getTraitsModelObject());
        }
    };
    
    initializeForm(form);
    
    form.setOutputMarkupPlaceholderTag(true);
    add(form);
}
 
Example #30
Source File: IntegrationSettingsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void addComponents(Form<Settings> form) {
	final TextField<String> drillUrl = new TextField<String>("integration.drillUrl");		
    form.add(drillUrl);
    
    final TextField<String> notifyUrl = new TextField<String>("integration.notifyUrl");		
    form.add(notifyUrl);

    final TextField<String> secretKey = new TextField<String>("integration.secretKey");		
    form.add(secretKey);

    final TextField<String> whiteList = new TextField<String>("integration.whiteIp");		
    form.add(whiteList);
}