ManageBean

mail@pastecode.io avatar
unknown
java
a year ago
2.2 kB
1
Indexable
Never
package HrApp.view;

import java.util.ArrayList;
import java.util.List;

import javax.faces.event.ActionEvent;

import oracle.adf.controller.TaskFlowId;
import oracle.adf.controller.binding.TaskFlowBindingAttributes;
import oracle.adf.view.rich.component.rich.layout.RichPanelGroupLayout;
import oracle.adf.view.rich.component.rich.layout.RichPanelTabbed;
import oracle.adf.view.rich.component.rich.layout.RichShowDetailItem;
import oracle.adf.view.rich.event.ItemEvent;

public class MultiBean {
    private List<TaskFlowBindingAttributes> mTaskFlowBindingAttrs = new ArrayList<TaskFlowBindingAttributes>();
    private RichPanelTabbed panelTabbed;
    private String tabSelected;
    private RichPanelGroupLayout rootTabComp;
    
    public MultiBean() {}
    
    public void  addRegion(ActionEvent actionEvent) {
        TaskFlowBindingAttributes  tfAttr = new TaskFlowBindingAttributes();
        tfAttr.setId("tf" + Integer.toString(mTaskFlowBindingAttrs.size()));
        tfAttr.setTaskFlowId(new TaskFlowId("/WEB-INF/emp-detail-tf", "emp-detail-tf"));
        mTaskFlowBindingAttrs.add(tfAttr);
        if (this.panelTabbed.getChildCount() > 0) {
            this.tabSelected = tfAttr.getId();        
        }
    }
    
    public List<TaskFlowBindingAttributes> getTaskFlowList() {
        return mTaskFlowBindingAttrs;
    }
    
    public int getTabSize() {
        return mTaskFlowBindingAttrs.size();
    }
    
    public void handleClosedTabItem(ItemEvent itemEvent) {
        if (itemEvent.getType().equals(ItemEvent.Type.remove)) {
            Object item = itemEvent.getSource();
            if (item instanceof RichShowDetailItem) {
                RichShowDetailItem tabItem = (RichShowDetailItem) item;
                String tfName = (String)tabItem.getAttributes().get("tfName");
                
                for (int i = 0; i < mTaskFlowBindingAttrs.size(); i++) {
                    TaskFlowBindingAttributes tf = mTaskFlowBindingAttrs.get(i);
                    if (tf.getId().equals(tfName)) {
                        mTaskFlowBindingAttrs.remove(tf);
                        break;
                    }
                }
            }
        }
    }
}