Example usage for org.apache.wicket.markup.html WebMarkupContainer getParent

List of usage examples for org.apache.wicket.markup.html WebMarkupContainer getParent

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebMarkupContainer getParent.

Prototype

@Override
public final MarkupContainer getParent() 

Source Link

Document

Gets any parent container, or null if there is none.

Usage

From source file:au.org.theark.study.web.component.subject.ChildStudySubjectPanel.java

License:Open Source License

private void setSubjectIntoContext(AjaxRequestTarget target, final SubjectVO subject) {
    Study study = subject.getLinkSubjectStudy().getStudy();
    SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID,
            study.getId());/*from  www  . java  2  s . c  o  m*/

    // We specify the type of person here as Subject
    SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID,
            subject.getLinkSubjectStudy().getPerson().getId());
    SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_TYPE,
            au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT);

    SubjectVO subjectFromBackend = new SubjectVO();

    LinkSubjectStudy subjectRefreshed = iArkCommonService.getSubjectRefreshed(subject.getLinkSubjectStudy());

    subjectFromBackend.setLinkSubjectStudy(subjectRefreshed);

    // Available/assigned child studies
    List<Study> availableChildStudies = new ArrayList<Study>(0);
    List<Study> selectedChildStudies = new ArrayList<Study>(0);

    if (study.getParentStudy() != null) {
        availableChildStudies = iStudyService.getChildStudyListOfParent(study);
        Person person = null;
        try {
            person = iStudyService.getPerson(subject.getLinkSubjectStudy().getPerson().getId());
        } catch (EntityNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ArkSystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        selectedChildStudies = iArkCommonService.getAssignedChildStudyListForPerson(study, person);
    }

    ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO);

    subjectContainerForm.setModelObject(subjectFromBackend);
    subjectContainerForm.getModelObject().setAvailableChildStudies(availableChildStudies);
    subjectContainerForm.getModelObject().setSelectedChildStudies(selectedChildStudies);

    // Set SubjectUID into context
    SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.SUBJECTUID,
            subjectFromBackend.getLinkSubjectStudy().getSubjectUID());
    ContextHelper contextHelper = new ContextHelper();
    contextHelper.setStudyContextLabel(target, study.getName(), arkContextMarkup);
    contextHelper.setSubjectContextLabel(target, subject.getLinkSubjectStudy().getSubjectUID(),
            arkContextMarkup);

    // Set Study Logo
    StudyHelper studyHelper = new StudyHelper();
    WebMarkupContainer wmc = (WebMarkupContainer) getParent();
    au.org.theark.study.web.component.subject.form.DetailForm detailForm = (au.org.theark.study.web.component.subject.form.DetailForm) wmc
            .getParent();
    au.org.theark.study.web.component.subject.DetailPanel detailPanel = (au.org.theark.study.web.component.subject.DetailPanel) detailForm
            .getParent();

    studyHelper.setStudyLogo(study, target, detailPanel.studyNameMarkup, detailPanel.studyLogoMarkup);
}

From source file:org.artifactory.webapp.actionable.action.DeleteAction.java

License:Open Source License

private void removeNodePanel(ItemEvent event) {
    WebMarkupContainer nodePanelContainer = event.getTargetComponents().getNodePanelContainer();
    TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodePanelContainer.getParent();
    browseRepoPanel.removeNodePanel(event.getTarget());
}

From source file:org.artifactory.webapp.actionable.action.DeleteVersionsAction.java

License:Open Source License

@Override
public void onAction(RepoAwareItemEvent event) {
    RepoAwareActionableItem source = event.getSource();
    org.artifactory.fs.ItemInfo info = source.getItemInfo();
    RepoPath itemPath = info.getRepoPath();
    if (!info.isFolder() && itemPath.getParent() != null) {
        itemPath = itemPath.getParent();
    }//w  w  w .ja va  2 s.  c  om
    RepositoryService repositoryService = getRepoService();
    ItemSearchResults<VersionUnitSearchResult> results = repositoryService.getVersionUnitsUnder(itemPath);

    List<VersionUnit> versionUnits = Lists.newArrayList();
    for (VersionUnitSearchResult result : results.getResults()) {
        versionUnits.add(result.getVersionUnit());
    }

    ItemEventTargetComponents eventTargetComponents = event.getTargetComponents();
    ModalWindow modalWindow = eventTargetComponents.getModalWindow();
    WebMarkupContainer nodePanelContainer = eventTargetComponents.getNodePanelContainer();
    TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodePanelContainer.getParent();

    DeleteVersionsPanel panel = new DeleteVersionsPanel(modalWindow.getContentId(), versionUnits,
            browseRepoPanel, event.getSource());
    BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel);
    modalPanel.setTitle("Delete Versions");
    modalWindow.setContent(modalPanel);
    AjaxRequestTarget target = event.getTarget();

    //VfsQueryDb returns -1 if userQueryLimit was exceeded.
    boolean exceededQueryLimit = results.getFullResultsCount() == -1;
    String warnMessage = "";
    String bubbleMessage = "";

    if (exceededQueryLimit) {
        modalWindow.setInitialWidth(700); //So that the warning text and the bubble are inline

        warnMessage = "The results shown are limited. Try executing Delete Versions from a node lower in the "
                + "hierarchy.";

        bubbleMessage = "The results shown are limited by the artifactory.search.userQueryLimit system property."
                + "\n You can modify it to get more results, but this can dramatically impact performance on large "
                + "repositories.";
    }
    Label label = new Label("largeQueryWarn", warnMessage);
    HelpBubble bubble = new HelpBubble("largeQueryWarn.help", bubbleMessage);
    panel.add(label);
    panel.add(bubble);
    label.setVisible(exceededQueryLimit);
    bubble.setVisible(exceededQueryLimit);
    modalWindow.show(target);
}

From source file:org.artifactory.webapp.actionable.action.MoveAction.java

License:Open Source License

@Override
public void onAction(RepoAwareItemEvent event) {
    RepoPath repoPath = event.getRepoPath();

    // create a modal window and add the move path panel to it
    ItemEventTargetComponents eventTargetComponents = event.getTargetComponents();
    // should be the tree
    Component tree = eventTargetComponents.getRefreshableComponent();

    WebMarkupContainer nodaPanelContainer = eventTargetComponents.getNodePanelContainer();
    TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodaPanelContainer.getParent();

    ModalWindow modalWindow = eventTargetComponents.getModalWindow();
    MovePathPanel panel = new MovePathPanel(modalWindow.getContentId(), repoPath, tree, browseRepoPanel);

    BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel);
    modalPanel.setWidth(500);//  www.  j  a v a  2s .com
    modalPanel.setTitle(String.format("Move '%s'", repoPath));
    modalWindow.setContent(modalPanel);
    modalWindow.show(event.getTarget());
}

From source file:org.geoserver.gwc.web.BlobStorePanel.java

License:Open Source License

public BlobStorePanel(String id, final IModel<GWCConfig> gwcConfigModel) {

    super(id, gwcConfigModel);
    // Initialize the map
    values = new HashMap<String, String>();

    // get the CacheConfigurations Model
    IModel<Map<String, CacheConfiguration>> cacheConfigurations = new PropertyModel<Map<String, CacheConfiguration>>(
            gwcConfigModel, "cacheConfigurations");

    // Creation of the Checbox for enabling disabling inmemory caching
    IModel<Boolean> innerCachingEnabled = new PropertyModel<Boolean>(gwcConfigModel, "innerCachingEnabled");
    final CheckBox innerCachingEnabledChoice = new CheckBox("innerCachingEnabled", innerCachingEnabled);

    // Container containing all the other parameters
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true).setEnabled(true);

    // Container containing all the parameters related to cache configuration which can be seen only if In Memory caching is enabled
    final CacheConfigContainerWrapper cacheConfigContainer = new CacheConfigContainerWrapper(
            "cacheConfContainer", gwcConfigModel.getObject().getCacheProviderClass(), gwcConfigModel);
    cacheConfigContainer.setOutputMarkupId(true);

    // Avoid Persistence checkbox
    IModel<Boolean> persistenceEnabled = new PropertyModel<Boolean>(gwcConfigModel, "persistenceEnabled");
    final CheckBox persistenceEnabledChoice = new CheckBox("persistenceEnabled", persistenceEnabled);
    boolean visible = innerCachingEnabledChoice.getModelObject() == null ? false
            : innerCachingEnabledChoice.getModelObject();
    container.setVisible(visible);/*from  w w  w. j  av  a 2  s .  com*/

    // Choice between the various Cache objects
    final DropDownChoice<String> choice;
    final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
    if (store != null) {
        final Map<String, String> cacheProviders = store.getCacheProvidersNames();
        final IModel<String> providerClass = new PropertyModel<String>(gwcConfigModel, "cacheProviderClass");
        IChoiceRenderer<String> renderer = new CacheProviderRenderer(cacheProviders);
        choice = new DropDownChoice<String>("caches", providerClass,
                new ArrayList<String>(cacheProviders.keySet()), renderer);
        choice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
                String cacheClass = providerClass.getObject();
                boolean immutable = false;
                if (store != null) {
                    immutable = store.getCacheProviders().get(cacheClass).isImmutable();
                }
                cacheConfigContainer.setEnabled(!immutable);
                // If changing the cacheProvider, you must change also the configuration
                if (!immutable) {
                    if (!gwcConfigModel.getObject().getCacheConfigurations().containsKey(cacheClass)) {
                        gwcConfigModel.getObject().getCacheConfigurations().put(cacheClass,
                                new CacheConfiguration());
                    }
                    cacheConfigContainer.setMapKey(cacheClass, gwcConfigModel);
                }

                target.addComponent(cacheConfigContainer);
            }
        });
        cacheConfigContainer
                .setEnabled(!store.getCacheProviders().get(providerClass.getObject()).isImmutable());
    } else {
        choice = new DropDownChoice<String>("caches", new ArrayList<String>());
    }
    // Adding cache choice to the container
    container.add(choice);

    persistenceEnabledChoice.setOutputMarkupId(true).setEnabled(true);
    // Adding cache configuration container to the global container
    container.add(cacheConfigContainer);
    // Definition of the behavior related to caching
    innerCachingEnabledChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // If In Memory caching is disabled, all the other parameters cannot be seen
            boolean isVisible = innerCachingEnabledChoice.getModelObject() == null ? false
                    : innerCachingEnabledChoice.getModelObject();
            container.setVisible(isVisible);
            target.addComponent(container.getParent());
        }
    });

    add(innerCachingEnabledChoice);
    container.add(persistenceEnabledChoice);
    add(container);

    // Cache Clearing Option
    Button clearCache = new Button("cacheClear") {
        @Override
        public void onSubmit() {
            final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
            // Clear cache
            if (store != null) {
                store.clearCache();
            }
        }
    };
    container.add(clearCache);

    // Cache Statistics
    final WebMarkupContainer statsContainer = new WebMarkupContainer("statsContainer");
    statsContainer.setOutputMarkupId(true);

    // Container for the statistics
    final Label totalCountLabel = new Label("totalCount", new MapModel(values, KEY_TOTAL_COUNT));
    final Label hitCountLabel = new Label("hitCount", new MapModel(values, KEY_HIT_COUNT));
    final Label missCountLabel = new Label("missCount", new MapModel(values, KEY_MISS_COUNT));
    final Label missRateLabel = new Label("missRate", new MapModel(values, KEY_MISS_RATE));
    final Label hitRateLabel = new Label("hitRate", new MapModel(values, KEY_HIT_RATE));
    final Label evictedLabel = new Label("evicted", new MapModel(values, KEY_EVICTED));
    final Label currentMemoryLabel = new Label("currentMemory", new MapModel(values, KEY_CURRENT_MEM));
    final Label cacheSizeLabel = new Label("cacheSize", new MapModel(values, KEY_SIZE));

    statsContainer.add(new Label("title"));
    statsContainer.add(totalCountLabel);
    statsContainer.add(hitCountLabel);
    statsContainer.add(missCountLabel);
    statsContainer.add(missRateLabel);
    statsContainer.add(hitRateLabel);
    statsContainer.add(evictedLabel);
    statsContainer.add(currentMemoryLabel);
    statsContainer.add(cacheSizeLabel);

    AjaxButton statistics = new AjaxButton("statistics") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
                // If checked, all the statistics are reported
                if (store != null) {
                    CacheStatistics stats = store.getCacheStatistics();

                    long hitCount = stats.getHitCount();
                    long missCount = stats.getMissCount();
                    long total = stats.getRequestCount();
                    double hitRate = stats.getHitRate();
                    double missRate = stats.getMissRate();
                    long evicted = stats.getEvictionCount();
                    double currentMem = stats.getCurrentMemoryOccupation();
                    long byteToMb = 1024 * 1024;
                    double actualSize = ((long) (100 * (stats.getActualSize() * 1.0d) / byteToMb)) / 100d;
                    double totalSize = ((long) (100 * (stats.getTotalSize() * 1.0d) / byteToMb)) / 100d;
                    // If a parameter is not correct, Unavailable is used
                    values.put(KEY_MISS_RATE, missRate >= 0 ? missRate + " %" : "Unavailable");
                    values.put(KEY_HIT_RATE, hitRate >= 0 ? hitRate + " %" : "Unavailable");
                    values.put(KEY_EVICTED, evicted >= 0 ? evicted + "" : "Unavailable");
                    values.put(KEY_TOTAL_COUNT, total >= 0 ? total + "" : "Unavailable");
                    values.put(KEY_MISS_COUNT, missCount >= 0 ? missCount + "" : "Unavailable");
                    values.put(KEY_HIT_COUNT, hitCount >= 0 ? hitCount + "" : "Unavailable");
                    values.put(KEY_CURRENT_MEM, currentMem >= 0 ? currentMem + " %" : "Unavailable");
                    values.put(KEY_SIZE,
                            currentMem >= 0 && actualSize >= 0 ? actualSize + " / " + totalSize + " Mb"
                                    : "Unavailable");

                }
            } catch (Throwable t) {
                error(t);
            }
            target.addComponent(statsContainer);
        }
    };

    container.add(statsContainer);
    container.add(statistics);
}

From source file:org.geoserver.gwc.web.InMemoryBlobStorePanel.java

License:Open Source License

public InMemoryBlobStorePanel(String id, final IModel<GWCConfig> gwcConfigModel) {

    super(id, gwcConfigModel);
    // Initialize the map
    values = new HashMap<String, String>();

    // get the CacheConfigurations Model
    IModel<Map<String, CacheConfiguration>> cacheConfigurations = new PropertyModel<Map<String, CacheConfiguration>>(
            gwcConfigModel, "cacheConfigurations");

    // Creation of the Checbox for enabling disabling inmemory caching
    IModel<Boolean> innerCachingEnabled = new PropertyModel<Boolean>(gwcConfigModel, "innerCachingEnabled");
    final CheckBox innerCachingEnabledChoice = new CheckBox("innerCachingEnabled", innerCachingEnabled);

    // Container containing all the other parameters
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true).setEnabled(true);

    // Container containing all the parameters related to cache configuration which can be seen only if In Memory caching is enabled
    final CacheConfigContainerWrapper cacheConfigContainer = new CacheConfigContainerWrapper(
            "cacheConfContainer", gwcConfigModel.getObject().getCacheProviderClass(), gwcConfigModel);
    cacheConfigContainer.setOutputMarkupId(true);

    // Avoid Persistence checkbox
    IModel<Boolean> persistenceEnabled = new PropertyModel<Boolean>(gwcConfigModel, "persistenceEnabled");
    final CheckBox persistenceEnabledChoice = new CheckBox("persistenceEnabled", persistenceEnabled);
    boolean visible = innerCachingEnabledChoice.getModelObject() == null ? false
            : innerCachingEnabledChoice.getModelObject();
    container.setVisible(visible);//from www.j av  a  2  s  .  c  o m

    // Choice between the various Cache objects
    final DropDownChoice<String> choice;
    final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
    if (store != null) {
        final Map<String, String> cacheProviders = store.getCacheProvidersNames();
        final IModel<String> providerClass = new PropertyModel<String>(gwcConfigModel, "cacheProviderClass");
        IChoiceRenderer<String> renderer = new CacheProviderRenderer(cacheProviders);
        choice = new DropDownChoice<String>("caches", providerClass,
                new ArrayList<String>(cacheProviders.keySet()), renderer);
        choice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
                String cacheClass = providerClass.getObject();
                boolean immutable = false;
                if (store != null) {
                    immutable = store.getCacheProviders().get(cacheClass).isImmutable();
                }
                cacheConfigContainer.setEnabled(!immutable);
                // If changing the cacheProvider, you must change also the configuration
                if (!immutable) {
                    if (!gwcConfigModel.getObject().getCacheConfigurations().containsKey(cacheClass)) {
                        gwcConfigModel.getObject().getCacheConfigurations().put(cacheClass,
                                new CacheConfiguration());
                    }
                    cacheConfigContainer.setMapKey(cacheClass, gwcConfigModel);
                }

                target.addComponent(cacheConfigContainer);
            }
        });
        cacheConfigContainer
                .setEnabled(!store.getCacheProviders().get(providerClass.getObject()).isImmutable());
    } else {
        choice = new DropDownChoice<String>("caches", new ArrayList<String>());
    }
    // Adding cache choice to the container
    container.add(choice);

    persistenceEnabledChoice.setOutputMarkupId(true).setEnabled(true);
    // Adding cache configuration container to the global container
    container.add(cacheConfigContainer);
    // Definition of the behavior related to caching
    innerCachingEnabledChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // If In Memory caching is disabled, all the other parameters cannot be seen
            boolean isVisible = innerCachingEnabledChoice.getModelObject() == null ? false
                    : innerCachingEnabledChoice.getModelObject();
            container.setVisible(isVisible);
            target.addComponent(container.getParent());
        }
    });

    add(innerCachingEnabledChoice);
    container.add(persistenceEnabledChoice);
    add(container);

    // Cache Clearing Option
    Button clearCache = new Button("cacheClear") {
        @Override
        public void onSubmit() {
            final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
            // Clear cache
            if (store != null) {
                store.clearCache();
            }
        }
    };
    container.add(clearCache);

    // Cache Statistics
    final WebMarkupContainer statsContainer = new WebMarkupContainer("statsContainer");
    statsContainer.setOutputMarkupId(true);

    // Container for the statistics
    final Label totalCountLabel = new Label("totalCount", new MapModel(values, KEY_TOTAL_COUNT));
    final Label hitCountLabel = new Label("hitCount", new MapModel(values, KEY_HIT_COUNT));
    final Label missCountLabel = new Label("missCount", new MapModel(values, KEY_MISS_COUNT));
    final Label missRateLabel = new Label("missRate", new MapModel(values, KEY_MISS_RATE));
    final Label hitRateLabel = new Label("hitRate", new MapModel(values, KEY_HIT_RATE));
    final Label evictedLabel = new Label("evicted", new MapModel(values, KEY_EVICTED));
    final Label currentMemoryLabel = new Label("currentMemory", new MapModel(values, KEY_CURRENT_MEM));
    final Label cacheSizeLabel = new Label("cacheSize", new MapModel(values, KEY_SIZE));

    statsContainer.add(new Label("title"));
    statsContainer.add(totalCountLabel);
    statsContainer.add(hitCountLabel);
    statsContainer.add(missCountLabel);
    statsContainer.add(missRateLabel);
    statsContainer.add(hitRateLabel);
    statsContainer.add(evictedLabel);
    statsContainer.add(currentMemoryLabel);
    statsContainer.add(cacheSizeLabel);

    AjaxButton statistics = new AjaxButton("statistics") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                final ConfigurableBlobStore store = GeoServerExtensions.bean(ConfigurableBlobStore.class);
                // If checked, all the statistics are reported
                if (store != null) {
                    CacheStatistics stats = store.getCacheStatistics();

                    long hitCount = stats.getHitCount();
                    long missCount = stats.getMissCount();
                    long total = stats.getRequestCount();
                    double hitRate = stats.getHitRate();
                    double missRate = stats.getMissRate();
                    long evicted = stats.getEvictionCount();
                    double currentMem = stats.getCurrentMemoryOccupation();
                    long byteToMb = 1024 * 1024;
                    double actualSize = ((long) (100 * (stats.getActualSize() * 1.0d) / byteToMb)) / 100d;
                    double totalSize = ((long) (100 * (stats.getTotalSize() * 1.0d) / byteToMb)) / 100d;
                    // If a parameter is not correct, Unavailable is used
                    values.put(KEY_MISS_RATE, missRate >= 0 ? missRate + " %" : "Unavailable");
                    values.put(KEY_HIT_RATE, hitRate >= 0 ? hitRate + " %" : "Unavailable");
                    values.put(KEY_EVICTED, evicted >= 0 ? evicted + "" : "Unavailable");
                    values.put(KEY_TOTAL_COUNT, total >= 0 ? total + "" : "Unavailable");
                    values.put(KEY_MISS_COUNT, missCount >= 0 ? missCount + "" : "Unavailable");
                    values.put(KEY_HIT_COUNT, hitCount >= 0 ? hitCount + "" : "Unavailable");
                    values.put(KEY_CURRENT_MEM, currentMem >= 0 ? currentMem + " %" : "Unavailable");
                    values.put(KEY_SIZE,
                            currentMem >= 0 && actualSize >= 0 ? actualSize + " / " + totalSize + " Mb"
                                    : "Unavailable");

                }
            } catch (Throwable t) {
                error(t);
            }
            target.addComponent(statsContainer);
        }
    };

    container.add(statsContainer);
    container.add(statistics);
}