Search in sources :

Example 1 with CCBreadCrumbs

use of com.sun.web.ui.view.breadcrumb.CCBreadCrumbs in project OpenAM by OpenRock.

the class AgentsViewBean method createParentagePath.

private CCBreadCrumbs createParentagePath(String name) {
    CCBreadCrumbsModel model = null;
    AMModel ammodel = (AMModel) getModel();
    String curRealm = getCurrentRealm();
    if (curRealm.charAt(0) != '/') {
        curRealm = "/" + curRealm;
    }
    String startDN = ammodel.getStartDN();
    if (startDN.charAt(0) != '/') {
        startDN = "/" + startDN;
    }
    String startDNString = AMFormatUtils.DNToName(ammodel, ammodel.getStartDSDN());
    if (curRealm.equals(startDN)) {
        model = new CCBreadCrumbsModel();
        setDisplayFieldValue(TXT_ROOT, startDNString);
    } else {
        int idx = curRealm.indexOf(startDN);
        String subRealm = (idx == 0) ? curRealm.substring(startDN.length()) : curRealm;
        List list = reverseParentagePath(subRealm);
        if (!list.isEmpty()) {
            list.remove(list.size() - 1);
        }
        /*
             * The model is initialized with the name of the current realm.
             * This entry is not selectable, just displayed as a label.
             */
        idx = subRealm.lastIndexOf("/");
        if (idx != -1) {
            subRealm = subRealm.substring(idx + 1);
        }
        model = new CCBreadCrumbsModel(SMSSchema.unescapeName(subRealm));
        StringBuilder baseDN = new StringBuilder(200);
        baseDN.append(startDN);
        /*
             * each row added to the model is a selectable entry in the
             * parentage path
             */
        model.appendRow();
        model.setValue(CCBreadCrumbsModel.LABEL, SMSSchema.unescapeName(startDNString));
        model.setValue(CCBreadCrumbsModel.COMMANDFIELD, PARENTAGE_PATH_HREF);
        model.setValue(CCBreadCrumbsModel.HREF_VALUE, baseDN.toString());
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            String tok = (String) iter.next();
            if (!baseDN.toString().equals("/")) {
                baseDN.append("/").append(tok);
            } else {
                baseDN.append(tok);
            }
            model.appendRow();
            model.setValue(CCBreadCrumbsModel.LABEL, SMSSchema.unescapeName(tok));
            model.setValue(CCBreadCrumbsModel.COMMANDFIELD, PARENTAGE_PATH_HREF);
            model.setValue(CCBreadCrumbsModel.HREF_VALUE, baseDN.toString());
        }
    }
    return new CCBreadCrumbs(this, model, name);
}
Also used : AMModel(com.sun.identity.console.base.model.AMModel) CCBreadCrumbs(com.sun.web.ui.view.breadcrumb.CCBreadCrumbs) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) CCBreadCrumbsModel(com.sun.web.ui.model.CCBreadCrumbsModel)

Example 2 with CCBreadCrumbs

use of com.sun.web.ui.view.breadcrumb.CCBreadCrumbs in project OpenAM by OpenRock.

the class AMPrimaryMastHeadViewBean method createBreadCrumb.

private CCBreadCrumbs createBreadCrumb(String name) {
    PageTrail trail = getPageTrail();
    CCBreadCrumbsModel model = null;
    if (trail != null) {
        List markers = trail.getMarkers();
        int size = markers.size();
        if (size >= 1) {
            PageTrail.Marker marker = (PageTrail.Marker) markers.get(size - 1);
            model = new CCBreadCrumbsModel(marker.getDisplayName());
            model.setUseGrayBg("true");
            size--;
            for (int i = 0; i < size; i++) {
                marker = (PageTrail.Marker) markers.get(i);
                model.appendRow();
                model.setValue(CCBreadCrumbsModel.LABEL, marker.getDisplayName());
                model.setValue(CCBreadCrumbsModel.COMMANDFIELD, BREAD_CRUMB_HREF);
                model.setValue(CCBreadCrumbsModel.HREF_VALUE, Integer.toString(i));
            }
        } else {
            model = new CCBreadCrumbsModel("dummy");
        }
    } else {
        model = new CCBreadCrumbsModel("dummy");
    }
    return new CCBreadCrumbs(this, model, name);
}
Also used : CCBreadCrumbs(com.sun.web.ui.view.breadcrumb.CCBreadCrumbs) List(java.util.List) CCBreadCrumbsModel(com.sun.web.ui.model.CCBreadCrumbsModel)

Example 3 with CCBreadCrumbs

use of com.sun.web.ui.view.breadcrumb.CCBreadCrumbs in project OpenAM by OpenRock.

the class RMRealmViewBeanBase method createParentagePath.

private CCBreadCrumbs createParentagePath(String name) {
    CCBreadCrumbsModel model = null;
    AMModel ammodel = (AMModel) getModel();
    String curRealm = getCurrentRealm();
    if (curRealm.charAt(0) != '/') {
        curRealm = "/" + curRealm;
    }
    String startDN = ammodel.getStartDN();
    if (startDN.charAt(0) != '/') {
        startDN = "/" + startDN;
    }
    String startDNString = AMFormatUtils.DNToName(ammodel, ammodel.getStartDSDN());
    if (curRealm.equals(startDN)) {
        model = new CCBreadCrumbsModel();
        setDisplayFieldValue(TXT_ROOT, startDNString);
    } else {
        int idx = curRealm.indexOf(startDN);
        String subRealm = (idx == 0) ? curRealm.substring(startDN.length()) : curRealm;
        List list = reverseParentagePath(subRealm);
        if (!list.isEmpty()) {
            list.remove(list.size() - 1);
        }
        /*
             * The model is initialized with the name of the current realm.
             * This entry is not selectable, just displayed as a label.
             */
        idx = subRealm.lastIndexOf("/");
        if (idx != -1) {
            subRealm = subRealm.substring(idx + 1);
        }
        model = new CCBreadCrumbsModel(SMSSchema.unescapeName(subRealm));
        StringBuilder baseDN = new StringBuilder(200);
        baseDN.append(startDN);
        /*
             * each row added to the model is a selectable entry in the
             * parentage path
             */
        model.appendRow();
        model.setValue(CCBreadCrumbsModel.LABEL, SMSSchema.unescapeName(startDNString));
        model.setValue(CCBreadCrumbsModel.COMMANDFIELD, PARENTAGE_PATH_HREF);
        model.setValue(CCBreadCrumbsModel.HREF_VALUE, baseDN.toString());
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            String tok = (String) iter.next();
            if (!baseDN.toString().equals("/")) {
                baseDN.append("/").append(tok);
            } else {
                baseDN.append(tok);
            }
            model.appendRow();
            model.setValue(CCBreadCrumbsModel.LABEL, SMSSchema.unescapeName(tok));
            model.setValue(CCBreadCrumbsModel.COMMANDFIELD, PARENTAGE_PATH_HREF);
            model.setValue(CCBreadCrumbsModel.HREF_VALUE, baseDN.toString());
        }
    }
    return new CCBreadCrumbs(this, model, name);
}
Also used : AMModel(com.sun.identity.console.base.model.AMModel) CCBreadCrumbs(com.sun.web.ui.view.breadcrumb.CCBreadCrumbs) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CCBreadCrumbsModel(com.sun.web.ui.model.CCBreadCrumbsModel)

Aggregations

CCBreadCrumbsModel (com.sun.web.ui.model.CCBreadCrumbsModel)3 CCBreadCrumbs (com.sun.web.ui.view.breadcrumb.CCBreadCrumbs)3 List (java.util.List)3 AMModel (com.sun.identity.console.base.model.AMModel)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2