Example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setEnabled

List of usage examples for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setEnabled

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setEnabled.

Prototype

public final Component setEnabled(final boolean enabled) 

Source Link

Document

Sets whether this component is enabled.

Usage

From source file:org.geoserver.taskmanager.web.BatchPage.java

License:Open Source License

@Override
public void onInitialize() {
    super.onInitialize();

    add(dialog = new GeoServerDialog("dialog"));

    add(new WebMarkupContainer("notvalidated").setVisible(batchModel.getObject().getConfiguration() != null
            && !batchModel.getObject().getConfiguration().isValidated()));

    Form<Batch> form = new Form<Batch>("batchForm", batchModel);
    add(form);/*  w  w w .j  a  v  a2  s .  c  om*/

    AjaxSubmitLink saveButton = saveButton();
    form.add(saveButton);

    form.add(new TextField<String>("name", new PropertyModel<String>(batchModel, "name")) {
        private static final long serialVersionUID = -3736209422699508894L;

        @Override
        public boolean isRequired() {
            return form.findSubmittingButton() == saveButton;
        }
    });

    List<String> workspaces = new ArrayList<String>();
    for (WorkspaceInfo wi : GeoServerApplication.get().getCatalog().getWorkspaces()) {
        if (wi.getName().equals(batchModel.getObject().getWorkspace())
                || TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(), wi)) {
            workspaces.add(wi.getName());
        }
    }
    boolean canBeNull = GeoServerApplication.get().getCatalog().getDefaultWorkspace() != null
            && TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(),
                    GeoServerApplication.get().getCatalog().getDefaultWorkspace());
    form.add(new DropDownChoice<String>("workspace", new PropertyModel<String>(batchModel, "workspace"),
            workspaces).setNullValid(canBeNull).setRequired(!canBeNull));

    form.add(new TextField<String>("description", new PropertyModel<String>(batchModel, "description")));

    form.add(new TextField<String>("configuration",
            new Model<String>(batchModel.getObject().getConfiguration() == null ? ""
                    : batchModel.getObject().getConfiguration().getName())).setEnabled(false));

    form.add(new FrequencyPanel("frequency", new PropertyModel<String>(batchModel, "frequency")));

    form.add(new CheckBox("enabled", new PropertyModel<Boolean>(batchModel, "enabled")));

    form.add(addButton());

    // the removal button
    form.add(remove = removeButton());
    remove.setOutputMarkupId(true);
    remove.setEnabled(false);

    //the tasks panel
    form.add(elementsPanel = elementsPanel());
    elementsPanel.setFilterVisible(false);
    elementsPanel.setPageable(false);
    elementsPanel.setSortable(false);
    elementsPanel.setOutputMarkupId(true);

    form.add(new AjaxLink<Object>("cancel") {
        private static final long serialVersionUID = -6892944747517089296L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            //restore elements
            batchModel.getObject().getElements().clear();
            batchModel.getObject().getElements().addAll(oldElements);
            doReturn();
        }
    });

    if (batchModel.getObject().getId() != null && !TaskManagerBeans.get().getSecUtil()
            .isAdminable(getSession().getAuthentication(), batchModel.getObject())) {
        form.get("name").setEnabled(false);
        form.get("workspace").setEnabled(false);
        form.get("description").setEnabled(false);
        form.get("configuration").setEnabled(false);
        form.get("frequency").setEnabled(false);
        form.get("enabled").setEnabled(false);
        form.get("addNew").setEnabled(false);
        remove.setEnabled(false);
        saveButton.setEnabled(false);
        elementsPanel.setEnabled(false);
    }

}

From source file:org.geoserver.taskmanager.web.ConfigurationPage.java

License:Open Source License

@Override
public void onInitialize() {
    super.onInitialize();

    add(dialog = new GeoServerDialog("dialog"));

    add(new WebMarkupContainer("init").setVisible(initMode));

    Form<Configuration> form = new Form<Configuration>("configurationForm", configurationModel);
    add(form);// w  w  w.ja  v a 2 s .  c om

    AjaxSubmitLink saveButton = saveOrApplyButton("save", true);
    saveButton.setOutputMarkupId(true);
    form.add(saveButton);
    AjaxSubmitLink applyButton = saveOrApplyButton("apply", false);
    form.add(applyButton);

    form.add(new TextField<String>("name", new PropertyModel<String>(configurationModel, "name")) {
        private static final long serialVersionUID = -3736209422699508894L;

        @Override
        public boolean isRequired() {
            return form.findSubmittingButton() == saveButton || form.findSubmittingButton() == applyButton;
        }
    });

    List<String> workspaces = new ArrayList<String>();
    for (WorkspaceInfo wi : GeoServerApplication.get().getCatalog().getWorkspaces()) {
        if (wi.getName().equals(configurationModel.getObject().getWorkspace())
                || TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(), wi)) {
            workspaces.add(wi.getName());
        }
    }
    boolean canBeNull = GeoServerApplication.get().getCatalog().getDefaultWorkspace() != null
            && TaskManagerBeans.get().getSecUtil().isAdminable(getSession().getAuthentication(),
                    GeoServerApplication.get().getCatalog().getDefaultWorkspace());
    form.add(new DropDownChoice<String>("workspace", new PropertyModel<String>(configurationModel, "workspace"),
            workspaces).setNullValid(canBeNull).setRequired(!canBeNull));

    TextField<String> name = new TextField<String>("description",
            new PropertyModel<String>(configurationModel, "description"));
    form.add(name);

    //the attributes panel
    attributesModel = new AttributesModel(configurationModel);
    form.add(attributesPanel = attributesPanel());
    attributesPanel.setFilterVisible(false);
    attributesPanel.setSelectable(false);
    attributesPanel.setPageable(false);
    attributesPanel.setSortable(false);
    attributesPanel.setOutputMarkupId(true);

    form.add(addButton().setOutputMarkupId(true));

    // the removal button
    form.add(remove = removeButton());
    remove.setOutputMarkupId(true);
    remove.setEnabled(false);

    //the tasks panel
    tasksModel = new TasksModel(configurationModel);
    form.add(tasksPanel = tasksPanel());
    tasksPanel.setFilterVisible(false);
    tasksPanel.setPageable(false);
    tasksPanel.setSortable(false);
    tasksPanel.setOutputMarkupId(true);

    //the batches panel
    form.add(batchesPanel = new BatchesPanel("batchesPanel", configurationModel));
    batchesPanel.setOutputMarkupId(true);

    form.add(new AjaxLink<Object>("cancel") {
        private static final long serialVersionUID = -6892944747517089296L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            //restore tasks
            configurationModel.getObject().getTasks().clear();
            configurationModel.getObject().getTasks().putAll(oldTasks);
            //restore batches
            configurationModel.getObject().getBatches().clear();
            configurationModel.getObject().getBatches().putAll(oldBatches);
            doReturn();
        }
    });

    if (initMode) {
        form.get("addNew").setEnabled(false);
        form.get("removeSelected").setEnabled(false);
        batchesPanel.get("addNew").setEnabled(false);
        batchesPanel.get("removeSelected").setEnabled(false);
        saveButton.setVisible(false);
    }

    if (configurationModel.getObject().getId() != null && !TaskManagerBeans.get().getSecUtil()
            .isAdminable(getSession().getAuthentication(), configurationModel.getObject())) {
        form.get("name").setEnabled(false);
        form.get("workspace").setEnabled(false);
        form.get("description").setEnabled(false);
        attributesPanel.setEnabled(false);
        form.get("addNew").setEnabled(false);
        form.get("removeSelected").setEnabled(false);
        tasksPanel.setEnabled(false);
        batchesPanel.get("addNew").setEnabled(false);
        batchesPanel.get("removeSelected").setEnabled(false);
        saveButton.setEnabled(false);
        applyButton.setEnabled(false);
    }

}

From source file:org.opengeo.data.importer.web.ImportDataPage.java

License:Open Source License

void resetNextButton(AjaxSubmitLink next, AjaxRequestTarget target) {
    next.add(new AttributeModifier("class", true, new Model("")));
    next.setEnabled(true);
    next.get(0).setDefaultModelObject("Next");
    target.addComponent(next);//from  ww w.j  a  v a  2s .  co m
}