All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tcdng.unify.web.ui.widget.writer.control.AssignmentBoxWriter Maven / Gradle / Ivy

/*
 * Copyright 2018-2023 The Code Department.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.tcdng.unify.web.ui.widget.writer.control;

import com.tcdng.unify.core.UnifyException;
import com.tcdng.unify.core.annotation.Component;
import com.tcdng.unify.core.annotation.Writes;
import com.tcdng.unify.core.util.DataUtils;
import com.tcdng.unify.web.ui.widget.Control;
import com.tcdng.unify.web.ui.widget.ResponseWriter;
import com.tcdng.unify.web.ui.widget.Widget;
import com.tcdng.unify.web.ui.widget.control.AssignmentBox;
import com.tcdng.unify.web.ui.widget.writer.AbstractControlWriter;

/**
 * Assignment box writer.
 * 
 * @author The Code Department
 * @since 1.0
 */
@Writes(AssignmentBox.class)
@Component("assignmentbox-writer")
public class AssignmentBoxWriter extends AbstractControlWriter {

    @Override
    protected void doWriteStructureAndContent(ResponseWriter writer, Widget widget) throws UnifyException {
        AssignmentBox assignmentBox = (AssignmentBox) widget;
        writer.write("");

        writer.write("
"); writer.write("
"); writeFilter(writer, assignmentBox.getFilterSel1(), assignmentBox.getFilterCaption1()); writeFilter(writer, assignmentBox.getFilterSel2(), assignmentBox.getFilterCaption2()); writer.write("
"); writer.write("
"); writer.write("
"); // Assigned List writer.write("
") .write(assignmentBox.getAssignCaption()).write(":"); writer.writeStructureAndContent(assignmentBox.getAssignSel()); writer.write("
"); if (!assignmentBox.isShowAssignedOnly()) { // Action Buttons writer.write("
"); writer.writeStructureAndContent(assignmentBox.getAssignBtn()); writer.write("
"); writer.writeStructureAndContent(assignmentBox.getUnassignBtn()); writer.write("
"); if(assignmentBox.isAllowAssignAll()) { writer.write("
"); writer.writeStructureAndContent(assignmentBox.getAssignAllBtn()); writer.write("
"); writer.writeStructureAndContent(assignmentBox.getUnassignAllBtn()); writer.write("
"); } writer.write("
"); // Unassigned List writer.write("
") .write(assignmentBox.getUnassignCaption()).write(":"); writer.writeStructureAndContent(assignmentBox.getUnassignSel()); writer.write("
"); } writer.write("
"); writer.write("
"); } @Override protected void doWriteBehavior(ResponseWriter writer, Widget widget) throws UnifyException { super.doWriteBehavior(writer, widget); AssignmentBox assignmentBox = (AssignmentBox) widget; writer.writeBehavior(assignmentBox.getAssignSel()); writer.writeBehavior(assignmentBox.getUnassignSel()); Control filter1 = assignmentBox.getFilterSel1(); if (filter1 != null) { writer.writeBehavior(filter1); } Control filter2 = assignmentBox.getFilterSel2(); if (filter2 != null) { writer.writeBehavior(filter2); } // Append rigging writer.beginFunction("ux.rigAssignmentBox"); writer.writeParam("pId", assignmentBox.getId()); writer.writeCommandURLParam("pCmdURL"); writer.writeParam("pContId", assignmentBox.getContainerId()); if (assignmentBox.getFilterSel1() != null) { writer.writeParam("pFilterSel1Id", assignmentBox.getFilterSel1().getId()); } if (assignmentBox.getFilterSel2() != null) { writer.writeParam("pFilterSel2Id", assignmentBox.getFilterSel2().getId()); } writer.writeParam("pAssnSelId", assignmentBox.getAssignSel().getId()); writer.writeParam("pAssnOnly", assignmentBox.isShowAssignedOnly()); if (!assignmentBox.isShowAssignedOnly()) { writer.writeParam("pAssnAll", assignmentBox.isAllowAssignAll()); writer.writeParam("pUnassnSelId", assignmentBox.getUnassignSel().getId()); writer.writeParam("pAssnBtnId", assignmentBox.getAssignBtn().getId()); writer.writeParam("pAssnAllBtnId", assignmentBox.getAssignAllBtn().getId()); writer.writeParam("pUnassnBtnId", assignmentBox.getUnassignBtn().getId()); writer.writeParam("pUnassnAllBtnId", assignmentBox.getUnassignAllBtn().getId()); } writer.writeParam("pEditable", assignmentBox.isContainerEditable()); writer.writeParam("pRef", DataUtils.toArray(String.class, writer.getPostCommandRefs())); writer.endFunction(); } private void writeFilter(ResponseWriter writer, Control filter, String caption) throws UnifyException { if (filter != null) { writer.write("
"); writer.write(caption).write(":"); writer.writeStructureAndContent(filter); writer.write("
"); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy