Example usage for org.apache.wicket.extensions.breadcrumb IBreadCrumbModel getActive

List of usage examples for org.apache.wicket.extensions.breadcrumb IBreadCrumbModel getActive

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.breadcrumb IBreadCrumbModel getActive.

Prototype

IBreadCrumbParticipant getActive();

Source Link

Document

Gets the currently active participant, if any.

Usage

From source file:gr.abiss.calipso.util.BreadCrumbUtils.java

License:Open Source License

/**
 * Returns the first panel of path to active panel
 * @param breadCrumbModel The given BreadCrumb Model
 * *//*from ww w .j a  v  a 2  s  . c o  m*/
public static BreadCrumbPanel moveToRootPanel(IBreadCrumbModel breadCrumbModel) {
    int participantsSize = breadCrumbModel.allBreadCrumbParticipants().size();

    if (participantsSize > 0) {
        breadCrumbModel.setActive((IBreadCrumbParticipant) breadCrumbModel.allBreadCrumbParticipants().get(0));
    }

    return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
}

From source file:gr.abiss.calipso.util.BreadCrumbUtils.java

License:Open Source License

/**
 * Returns a BreadCrumbPanel of a given breadCrumbModel according to the panelIndex
 * @param breadCrumbModel  The BreadCrumbModel
 * @param panelIndex Panel index//from   w  w w . ja  v a 2s  . c  o m
 * @return 
 * */
public static BreadCrumbPanel moveToPanel(IBreadCrumbModel breadCrumbModel, int panelIndex) {
    int participantsSize = breadCrumbModel.allBreadCrumbParticipants().size();

    if (panelIndex < participantsSize && panelIndex > 0) {
        breadCrumbModel.setActive(
                (IBreadCrumbParticipant) breadCrumbModel.allBreadCrumbParticipants().get(panelIndex));
        return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
    }

    return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
}

From source file:gr.abiss.calipso.util.BreadCrumbUtils.java

License:Open Source License

/**
 * @param breadCrumbModel/*www .  ja va  2s.c om*/
 * @param panelClassName
 * @return 
 * 
 * */
public static BreadCrumbPanel moveToPanel(IBreadCrumbModel breadCrumbModel, String panelClassName) {
    int participantsSize = breadCrumbModel.allBreadCrumbParticipants().size();

    for (int i = 0; i < participantsSize; i++) {
        IBreadCrumbParticipant breadCrumbParticipant = (IBreadCrumbParticipant) breadCrumbModel
                .allBreadCrumbParticipants().get(i);
        if (breadCrumbParticipant.getClass().getName().equals(panelClassName)) {
            breadCrumbModel
                    .setActive((IBreadCrumbParticipant) breadCrumbModel.allBreadCrumbParticipants().get(i));
            return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
        } //if

    } //for

    return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
}

From source file:gr.abiss.calipso.util.BreadCrumbUtils.java

License:Open Source License

/**
 * @param breadCrumbModel//from  ww  w.ja  v  a2  s. c o m
 * @param 
 * @return 
 * 
 * */
public static BreadCrumbPanel moveToPanel(IBreadCrumbModel breadCrumbModel, Class panelClass) {
    int participantsSize = breadCrumbModel.allBreadCrumbParticipants().size();

    for (int i = 0; i < participantsSize; i++) {
        IBreadCrumbParticipant breadCrumbParticipant = (IBreadCrumbParticipant) breadCrumbModel
                .allBreadCrumbParticipants().get(i);
        if (breadCrumbParticipant.getClass().equals(panelClass)) {
            breadCrumbModel
                    .setActive((IBreadCrumbParticipant) breadCrumbModel.allBreadCrumbParticipants().get(i));
            return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
        } //if

    } //for

    return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
}

From source file:gr.abiss.calipso.util.BreadCrumbUtils.java

License:Open Source License

public static BreadCrumbPanel moveToPanelForRelod(IBreadCrumbModel breadCrumbModel, Class panelClass) {
    int participantsSize = breadCrumbModel.allBreadCrumbParticipants().size();

    for (int i = 0; i < participantsSize; i++) {
        IBreadCrumbParticipant breadCrumbParticipant = (IBreadCrumbParticipant) breadCrumbModel
                .allBreadCrumbParticipants().get(i);
        if (breadCrumbParticipant.getClass().equals(panelClass)) {
            if (i >= 1) {
                breadCrumbModel.setActive(
                        (IBreadCrumbParticipant) breadCrumbModel.allBreadCrumbParticipants().get(i - 1));
            }/*from  ww w. ja  v  a 2s  .c  o m*/
            return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
        } //if

    } //for

    return (BreadCrumbPanel) breadCrumbModel.getActive().getComponent();
}

From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributeFormPagePanel.java

License:Open Source License

private void deleteLink() {
    //hide link if: admin, user==null, try to delete self or new user
    if (canBeDeleted == false || assetTypeCustomAttribute == null || assetTypeCustomAttribute.getId() == null
            || !Boolean.parseBoolean(((CalipsoApplication) Application.get())
                    .getCalipsoPropertyValue("allow.delete.assetTypeCustomAttribute"))) {
        add(new WebMarkupContainer("delete").setVisible(false));
    } else {//if edit
        add(new Link("delete") {
            @Override//from w  w w.  ja v  a2 s. c  o  m
            public void onClick() {

                final String line1 = localize("asset.customAttributes.deleteConfirmMessage");
                final String line2 = new String(
                        "\"" + localize(assetTypeCustomAttribute.getNameTranslationResourceKey()) + "\"");
                final String heading = new String(localize("asset.customAttributes.deleteConfirmHeading"));
                final String warning = new String("");

                activate(new IBreadCrumbPanelFactory() {
                    @Override
                    public BreadCrumbPanel create(String componentId, IBreadCrumbModel breadCrumbModel) {
                        ConfirmPanel confirm = new ConfirmPanel(componentId, breadCrumbModel, heading, warning,
                                new String[] { line1 }) {
                            @Override
                            public void onConfirm() {
                                //Delete Custom Attribute
                                getCalipso().removeCustomAttribute(assetTypeCustomAttribute);

                                BreadCrumbUtils.removePreviousBreadCrumbPanel(getBreadCrumbModel());

                                activate(new IBreadCrumbPanelFactory() {
                                    @Override
                                    public BreadCrumbPanel create(String componentId,
                                            IBreadCrumbModel breadCrumbModel) {
                                        return (BreadCrumbPanel) breadCrumbModel.getActive();
                                    }
                                });
                            }
                        };
                        return confirm;
                    }
                });
            }//onclick
        });//add, new Link
    }
}

From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributeLookupValuesFormPanel.java

License:Open Source License

/**
 * Renders User Interface components/*from  ww w  .j  a v a  2 s  .  c  o m*/
 * */
private void addComponents() {

    if (this.assetTypeCustomAttribute.getAllowedLookupValues() == null) {
        lookupValues = new ArrayList<CustomAttributeLookupValue>();
    } //if
    else {
        lookupValues = new ArrayList<CustomAttributeLookupValue>(
                this.assetTypeCustomAttribute.getAllowedLookupValues());
    } //else

    add(new ValuesForm("valuesForm", lookupValues));
    WebMarkupContainer editArea = new WebMarkupContainer("editArea");

    if (this.lookupValue == null) {
        editArea.add(new EditForm("editForm", new CustomAttributeLookupValue()));
        editArea.setVisible(false);
    } //if
    else {
        isNewEntry = (lookupValue.getAttribute() == null);
        editArea.add(new Label("editLabel",
                localize("asset.customAttributes." + String.valueOf(isNewEntry ? "add" : "edit") + "Value")));
        editArea.add(new EditForm("editForm", this.lookupValue));
    } //else

    add(editArea);

    Link add = new Link("add") {
        public void onClick() {

            activate(new IBreadCrumbPanelFactory() {
                public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {

                    //Remove last breadcrumb participant
                    if (breadCrumbModel.allBreadCrumbParticipants().size() > 0) {
                        breadCrumbModel.allBreadCrumbParticipants()
                                .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                    } //if

                    return new AssetCustomAttributeFormPagePanel(
                            breadCrumbModel.getActive().getComponent().getId(), breadCrumbModel,
                            AssetCustomAttributeLookupValuesFormPanel.this.assetTypeCustomAttribute,
                            new CustomAttributeLookupValue()).setReferenceAssetType(referenceAssetType);
                }
            });

        }//onClick
    };
    add(add);

}

From source file:gr.abiss.calipso.wicket.asset.AssetCustomAttributesPanel.java

License:Open Source License

/**
 * Renders custom attribute list/*from   w  ww. j ava 2  s  . c  o m*/
 * */
private void listAttributes() {
    LoadableDetachableModel attributesListModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            return getCalipso().findCustomAttributesMatching(
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch);
        }//load
    };

    attributesListModel.getObject();

    ////////////////
    // Pagination //
    ////////////////

    PaginationPanel paginationPanel = new PaginationPanel("paginationPanel", getBreadCrumbModel(),
            this.assetTypeCustomAttributeSearch) {

        IBreadCrumbPanelFactory breadCrumbPanelFactory = new IBreadCrumbPanelFactory() {
            @Override
            public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                //Remove last breadcrumb participant
                if (breadCrumbModel.allBreadCrumbParticipants().size() > 0) {
                    breadCrumbModel.allBreadCrumbParticipants()
                            .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                } //if

                return new AssetCustomAttributesPanel(breadCrumbModel.getActive().getComponent().getId(),
                        breadCrumbModel, AssetCustomAttributesPanel.this.referenceAssetType,
                        AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch,
                        AssetCustomAttributesPanel.this.isSearchOpen);
            }
        };

        @Override
        public void onNextPageClick() {
            activate(breadCrumbPanelFactory);
        }

        @Override
        public void onPreviousPageClick() {
            activate(breadCrumbPanelFactory);
        }

        @Override
        public void onPageNumberClick() {
            activate(breadCrumbPanelFactory);
        }
    };

    add(paginationPanel);

    /////////////////
    // List header //
    /////////////////

    List<String> columnHeaders = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch
            .getColumnHeaders();

    ListView headings = new ListView("headings", columnHeaders) {
        @Override
        protected void populateItem(ListItem listItem) {
            final String header = (String) listItem.getModelObject();

            Link headingLink = new Link("heading") {
                @Override
                public void onClick() {
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.doSort(header);
                }
            };
            listItem.add(headingLink);
            String label = localize("asset.customAttributes." + header);
            headingLink.add(new Label("heading", label));
            if (header.equals(
                    AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.getSortFieldName())) {
                String order = AssetCustomAttributesPanel.this.assetTypeCustomAttributeSearch.isSortDescending()
                        ? "order-down"
                        : "order-up";
                listItem.add(new SimpleAttributeModifier("class", order));
            }
        }
    };

    add(headings);

    /////////////////////
    // Attributes List //
    /////////////////////

    final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt");

    if (this.referenceAssetType != null) {
        add(new Label("add", localize("asset.assetTypes.addCustomAttributeToType",
                localize(this.referenceAssetType.getNameTranslationResourceKey()))));
    } //if
    else {
        add(new WebMarkupContainer("add").setVisible(false));
    } //else

    ListView listView = new ListView("attributesList", attributesListModel) {
        AssetType referenceAssetType = AssetCustomAttributesPanel.this.referenceAssetType;

        @Override
        protected void populateItem(ListItem listItem) {
            final AssetTypeCustomAttribute attribute = (AssetTypeCustomAttribute) listItem.getModelObject();

            if (attribute.getId().equals(selectedAttributeId)) {
                listItem.add(new SimpleAttributeModifier("class", "selected"));
            } else if (listItem.getIndex() % 2 != 0) {
                listItem.add(sam);
            } //if

            // listItem.add(new Label("name", new PropertyModel(attribute, "name")));
            listItem.add(new Label("name", localize(attribute.getNameTranslationResourceKey())));
            listItem.add(new Label("formType",
                    new Model(localize("asset.attributeType_" + attribute.getFormType()))));
            listItem.add(new Label("mandatory",
                    new Model(attribute.isMandatory() ? localize("yes") : localize("no"))));
            listItem.add(
                    new Label("active", new Model(attribute.isActive() ? localize("yes") : localize("no"))));

            Link edit = new Link("edit") {
                @Override
                public void onClick() {

                    activate(new IBreadCrumbPanelFactory() {
                        @Override
                        public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                            AssetCustomAttributeFormPagePanel assetCustomAttributeFormPagePanel = new AssetCustomAttributeFormPagePanel(
                                    id, breadCrumbModel, attribute);
                            if (referenceAssetType != null) {
                                assetCustomAttributeFormPagePanel.setReferenceAssetType(referenceAssetType);
                            } //if
                            return assetCustomAttributeFormPagePanel;
                        }
                    });

                }//onClick
            };

            listItem.add(edit);

            if (referenceAssetType == null) {
                listItem.add(new WebMarkupContainer("add").setVisible(false));
            } //if
            else {
                WebMarkupContainer add;

                if (referenceAssetType.getAllowedCustomAttributes().contains(attribute)) {//if this customAttribute is used  

                    add = new Fragment("add", "removeLink", this);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Allowed custom attributes : "
                                + referenceAssetType.getAllowedCustomAttributes());
                    }
                    add.add(new Link("link") {
                        //remove a custom attribute to the Asset Type in question
                        @Override
                        public void onClick() {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                                logger.debug("Removing attribute : " + attribute.getName());
                            }
                            AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes()
                                    .remove(attribute);
                            if (logger.isDebugEnabled()) {
                                logger.debug("new Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                            }
                            //Remove last 2 breadcrumb participants
                            if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) {
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                            } //if

                            activate(new IBreadCrumbPanelFactory() {
                                @Override
                                public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                                    return new AssetTypeFormPagePanel(
                                            getBreadCrumbModel().getActive().getComponent().getId(),
                                            getBreadCrumbModel(),
                                            AssetCustomAttributesPanel.this.referenceAssetType);
                                }
                            });

                        }//onClick
                    });
                } else {//if this customAttribute is not used, can add it
                    add = new Fragment("add", "addLink", this);

                    add.add(new Link("link") {
                        //Adds a custom attribute to the Asset Type in question
                        @Override
                        public void onClick() {
                            if (logger.isDebugEnabled()) {
                                logger.debug("Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                                logger.debug("Added custom attribute : " + attribute.getName());
                            }
                            AssetCustomAttributesPanel.this.referenceAssetType.getAllowedCustomAttributes()
                                    .add(attribute);
                            if (logger.isDebugEnabled()) {
                                logger.debug("New Allowed custom attributes : "
                                        + referenceAssetType.getAllowedCustomAttributes());
                            }
                            //Remove last 2 breadcrumb participants
                            if (breadCrumbModel.allBreadCrumbParticipants().size() > 2) {
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                                breadCrumbModel.allBreadCrumbParticipants()
                                        .remove(breadCrumbModel.allBreadCrumbParticipants().size() - 1);
                            } //if

                            activate(new IBreadCrumbPanelFactory() {
                                @Override
                                public BreadCrumbPanel create(String id, IBreadCrumbModel breadCrumbModel) {
                                    return new AssetTypeFormPagePanel(
                                            getBreadCrumbModel().getActive().getComponent().getId(),
                                            getBreadCrumbModel(),
                                            AssetCustomAttributesPanel.this.referenceAssetType);
                                }
                            });

                        }//onClick
                    });
                }

                listItem.add(add);
            } //else
        }
    };

    add(listView);
    add(new WebMarkupContainer("noData").setVisible(this.assetTypeCustomAttributeSearch.getResultCount() == 0));

}

From source file:gr.abiss.calipso.wicket.asset.menu.AssetPanelManageCustomAttributes.java

License:Open Source License

private void deleteLink() {
    //hide link if: admin, user==null, try to delete self or new user
    if (canBeDeleted == false || assetTypeCustomAttribute == null || assetTypeCustomAttribute.getId() == null) {
        add(new WebMarkupContainer("delete").setVisible(false));
    } else {//if edit
        add(new Link("delete") {
            @Override//from  w ww .j a va  2  s .co m
            public void onClick() {

                final String line1 = localize("asset.customAttributes.deleteConfirmMessage");
                final String line2 = new String("\"" + assetTypeCustomAttribute.getName() + "\"");
                final String heading = new String(localize("asset.customAttributes.deleteConfirmHeading"));
                final String warning = new String("");

                activate(new IBreadCrumbPanelFactory() {
                    public BreadCrumbPanel create(String componentId, IBreadCrumbModel breadCrumbModel) {
                        ConfirmPanel confirm = new ConfirmPanel(componentId, breadCrumbModel, heading, warning,
                                new String[] { line1 }) {
                            public void onConfirm() {
                                //Delete Custom Attribute
                                getCalipso().removeCustomAttribute(assetTypeCustomAttribute);

                                BreadCrumbUtils.removePreviousBreadCrumbPanel(getBreadCrumbModel());

                                activate(new IBreadCrumbPanelFactory() {
                                    public BreadCrumbPanel create(String componentId,
                                            IBreadCrumbModel breadCrumbModel) {
                                        return (BreadCrumbPanel) breadCrumbModel.getActive();
                                    }
                                });
                            }
                        };
                        return confirm;
                    }
                });
            }
        });
    }
}

From source file:gr.abiss.calipso.wicket.hlpcls.RelateLink.java

License:Open Source License

@Override
public void onClick() {
    final ItemSearch itemSearch = new ItemSearch(user, itemView);
    itemSearch.setRelatingItemRefId(item.getUniqueRefId());

    ((BreadCrumbPanel) breadCrumbModel.getActive()).activate(new IBreadCrumbPanelFactory() {
        public BreadCrumbPanel create(String componentId, IBreadCrumbModel breadCrumbModel) {
            return new ItemSearchFormPanel(componentId, breadCrumbModel, itemSearch);
        }// www. ja  va2s  .co m
    });
}