Package org.brixcms.web.model

Examples of org.brixcms.web.model.ModelBuffer$NodeModel


        form.add(new TextField<String>("fileName", new PropertyModel<String>(this, "fileName"))
                .setRequired(true).add(NodeNameValidator.getInstance()).setLabel(
                        new ResourceModel("fileName")));

        final ModelBuffer model = new ModelBuffer();

        form.add(new TextResourceEditor("editor", model));

        form.add(new SubmitLink("save") {
            @Override
            public void onSubmit() {
                if (getContainer().hasNode(fileName)) {
                    error(getString("fileExists", Model.ofMap(new MicroMap<String, String>(
                            "fileName", fileName))));
                    return;
                }

                // create initial node skeleton
                BrixNode node = (BrixNode) getContainer().addNode(fileName, "nt:file");
                BrixFileNode file = BrixFileNode.initialize(node, "text"); // temp-mime

                // save the node so brix assigns the correct jcr type to it
                getContainer().save();

                // populate node
                ResourceNode resource = (ResourceNode) getContainer().getSession().getItem(
                        node.getPath());
                model.setObject(new BrixNodeModel(resource));
                model.apply();

                getContainer().save();

                // done
                getSession().info(getString("saved"));
View Full Code Here


    public EditPropertiesPanel(String id, final IModel<BrixNode> nodeModel) {
        super(id, nodeModel);

        List<Protocol> protocols = Arrays.asList(Protocol.values());

        final ModelBuffer model = new ModelBuffer(nodeModel);
        Form<?> form = new Form<Void>("form");

        IChoiceRenderer<Protocol> renderer = new IChoiceRenderer<Protocol>() {
            public Object getDisplayValue(Protocol object) {
                return getString(object.toString());
            }

            public String getIdValue(Protocol object, int index) {
                return object.toString();
            }
        };
        IModel<Protocol> protocolModel = model.forProperty("requiredProtocol");
        form.add(new DropDownChoice<Protocol>("requiredProtocol", protocolModel, protocols,
                renderer).setNullValid(false));

        IModel<String> mimeTypeModel = model.forProperty("mimeType");
        form.add(new TextField<String>("mimeType", mimeTypeModel));

        form.add(new SubmitLink("save") {
            @Override
            public void onSubmit() {
                BrixNode node = nodeModel.getObject();
                model.apply();
                node.save();
                getSession().info(getString("propertiesSaved"));
                goBack();
            }
        });
View Full Code Here

        add(new FeedbackPanel("feedback"));

        Form<?> form = new Form<Void>("form");
        add(form);

        final ModelBuffer model = new ModelBuffer(node);

        form.add(new TextResourceEditor("editor", model));

        form.add(new SubmitLink("save") {
            @Override
            public void onSubmit() {
                model.apply();
                getNode().save();
                // done
                getSession().info(getString("saved"));
                done();
            }
View Full Code Here

        Brix brix = getModelObject().getBrix();
        Form<Void> form = new Form<Void>("form");
        add(form);

        final ModelBuffer adapter = new ModelBuffer(nodeModel);
        IModel<String> stringModel = adapter.forProperty("title");

        form.add(new TextField<String>("title", stringModel));

        String workspace = nodeModel.getObject().getSession().getWorkspace().getName();
        NodeFilter filter = new NodeTypeFilter(TemplateSiteNodePlugin.TYPE);

        IModel<BrixNode> model = adapter.forNodeProperty("template");

        form.add(new SiteNodePickerPanel("templatePicker", model, workspace, filter));

        IModel<Boolean> booleanModel = adapter.forProperty("requiresSSL");
        form.add(new ProtocolSelector("requiresSSL", booleanModel));

        IModel<String> mimeTypeModel = adapter.forProperty("mimeType");
        form.add(new TextField<String>("mimeType", mimeTypeModel));

        // set up markup editor

        contentEditorModel = adapter.forProperty("dataAsString");
        contentEditorParent = form;

        Collection<MarkupEditorFactory> editorFactories = brix.getConfig().getRegistry()
                .lookupCollection(MarkupEditorFactory.POINT);

        setupEditor(editorFactories.iterator().next().getClass().getName());

        // set up buttons to control editor switching

        RepeatingView editors = new RepeatingView("editors") {
            @Override
            public boolean isVisible() {
                return size() > 1;
            }
        };
        form.add(editors);

        for (MarkupEditorFactory factory : editorFactories) {
            final String cn = factory.getClass().getName();
            editors.add(new Button(editors.newChildId(), factory.newLabel()) {
                public void onSubmit() {
                    setupEditor(cn);
                }

                @Override
                public boolean isEnabled() {
                    return !cn.equals(currentEditorFactory);
                }
            });
        }


        form.add(new ContainerFeedbackPanel("feedback", this));

        form.add(new Button("save") {
            @Override
            public void onSubmit() {
                JcrNode node = nodeModel.getObject();
                node.checkout();
                adapter.apply();
                node.save();
                node.checkin();

                getSession().info(getString("status.saved"));
                goBack();
View Full Code Here

public class PropertiesTab extends BrixGenericPanel<BrixNode> {
    public PropertiesTab(String id, final IModel<BrixNode> folderNodeModel) {
        super(id, folderNodeModel);

        final ModelBuffer buffer = new ModelBuffer(folderNodeModel);

        Form<Void> form = new Form<Void>("form");

        form.add(new SubmitLink("submit") {
            @Override
            public void onSubmit() {
                buffer.apply();
                folderNodeModel.getObject().save();
                getSession().info(PropertiesTab.this.getString("propertiesSaved"));
            }
        });
        add(form);

        add(new ContainerFeedbackPanel("feedback", this));

        ReferenceEditorConfiguration conf = new ReferenceEditorConfiguration();

        conf.setDisplayFiles(true);
        conf.setWorkspaceName(folderNodeModel);

        IModel<Reference> model = buffer.forProperty("redirectReference");
        form.add(new ReferenceEditorPanel("redirectReference", model).setConfiguration(conf));
    }
View Full Code Here

TOP

Related Classes of org.brixcms.web.model.ModelBuffer$NodeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.