Search in sources :

Example 6 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project wicket by apache.

the class MarkupFragmentTest method panel.

/**
 * @throws Exception
 */
@Test
public void panel() throws Exception {
    Page page = new MyPage();
    Panel panel = new MyPanel("panel");
    page.add(panel);
    // Get the associated markup file
    IMarkupFragment markup = panel.getAssociatedMarkup();
    compareMarkupWithFile(markup, "MyPanel_ExpectedResult.html", MyPage.class);
    // The Page is missing the tag to "call" the panel
    assertNull(panel.getMarkup());
    // Create a Page with proper markup for the panel
    page = new MyPanelPage();
    panel = (Panel) page.get("panel");
    // getMarkup() returns the "calling" tags
    markup = panel.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"panel\">test</span>");
    // getMarkup(null) returns the markup which is used to find a child component, which in case
    // of Panel is the <wicket:panel> tag and is thus may not be equal to the associated markup
    // file.
    markup = panel.getMarkup(null);
    compareMarkupWithString(markup, "<wicket:panel>  <span wicket:id=\"label\">text</span></wicket:panel>");
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Example 7 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project wicket by apache.

the class ComponentStringResourceLoaderTest method multiLevelEmbeddedComponentLoadFromComponent.

/**
 */
@Test
public void multiLevelEmbeddedComponentLoadFromComponent() {
    DummyPage p = new DummyPage();
    Panel panel = new EmptyPanel("panel");
    p.add(panel);
    DummyComponent c = new DummyComponent("hello", tester.getApplication());
    panel.add(c);
    IStringResourceLoader loader = new ComponentStringResourceLoader();
    assertEquals("Valid resourse string should be found", "Component string", loader.loadStringResource(c.getClass(), "component.string", Locale.getDefault(), null, null));
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Test(org.junit.Test)

Example 8 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project webanno by webanno.

the class ProjectSettingsPanelRegistryServiceImpl method scan.

private void scan() {
    panels = new ArrayList<>();
    // Scan project settings using annotation
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(ProjectSettingsPanel.class));
    for (BeanDefinition bd : scanner.findCandidateComponents("de.tudarmstadt.ukp")) {
        try {
            @SuppressWarnings("unchecked") Class<? extends Panel> panelClass = (Class<? extends Panel>) Class.forName(bd.getBeanClassName());
            ProjectSettingsPanel mia = panelClass.getAnnotation(ProjectSettingsPanel.class);
            ProjectSettingsPanelDecl panel = new ProjectSettingsPanelDecl();
            panel.label = mia.label();
            panel.prio = mia.prio();
            panel.panel = panelClass;
            panels.add(panel);
            log.debug("Found settings panel: {} ({})", panel.label, panel.prio);
            List<Method> methods = MethodUtils.getMethodsListWithAnnotation(panelClass, ProjectSettingsPanelCondition.class);
            if (!methods.isEmpty()) {
                panel.condition = (aProject) -> {
                    try {
                        // Need to look the method up again here because methods are not
                        // serializable
                        Method m = MethodUtils.getMethodsListWithAnnotation(panelClass, ProjectSettingsPanelCondition.class).get(0);
                        return (boolean) m.invoke(null, aProject);
                    } catch (Exception e) {
                        LoggerFactory.getLogger(ProjectSettingsPanelRegistryServiceImpl.class).error("Unable to invoke settings panel condition method", e);
                        return false;
                    }
                };
            } else {
                panel.condition = (aProject) -> aProject != null;
            }
        } catch (ClassNotFoundException e) {
            log.error("Settings panel class [{}] not found", bd.getBeanClassName(), e);
        }
    }
    panels.sort(Comparator.comparingInt(a -> a.prio));
}
Also used : Logger(org.slf4j.Logger) ProjectService(de.tudarmstadt.ukp.clarin.webanno.api.ProjectService) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) LoggerFactory(org.slf4j.LoggerFactory) UserDao(de.tudarmstadt.ukp.clarin.webanno.security.UserDao) MethodUtils(org.apache.commons.lang3.reflect.MethodUtils) Autowired(org.springframework.beans.factory.annotation.Autowired) ArrayList(java.util.ArrayList) SmartLifecycle(org.springframework.context.SmartLifecycle) Panel(org.apache.wicket.markup.html.panel.Panel) List(java.util.List) Component(org.springframework.stereotype.Component) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Comparator(java.util.Comparator) Method(java.lang.reflect.Method) Collections(java.util.Collections) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) Method(java.lang.reflect.Method) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Panel(org.apache.wicket.markup.html.panel.Panel) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider)

Example 9 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project syncope by apache.

the class ConnObjectPanel method getValuePanel.

/**
 * Get panel for attribute value (not remote status).
 *
 * @param id component id to be replaced with the fragment content.
 * @param attrTO remote attribute.
 * @return fragment.
 */
private Panel getValuePanel(final String id, final String schemaName, final AttrTO attrTO) {
    Panel field;
    if (attrTO == null) {
        field = new AjaxTextFieldPanel(id, schemaName, new Model<>());
    } else if (CollectionUtils.isEmpty(attrTO.getValues())) {
        field = new AjaxTextFieldPanel(id, schemaName, new Model<>());
    } else if (ConnIdSpecialName.PASSWORD.equals(schemaName)) {
        field = new AjaxTextFieldPanel(id, schemaName, new Model<>("********"));
    } else if (attrTO.getValues().size() == 1) {
        field = new AjaxTextFieldPanel(id, schemaName, new Model<>(attrTO.getValues().get(0)));
    } else {
        field = new MultiFieldPanel.Builder<>(new ListModel<>(attrTO.getValues())).build(id, schemaName, new AjaxTextFieldPanel("panel", schemaName, new Model<>()));
    }
    field.setEnabled(false);
    return field;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) Panel(org.apache.wicket.markup.html.panel.Panel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) ListModel(org.apache.wicket.model.util.ListModel) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel)

Example 10 with Panel

use of org.apache.wicket.markup.html.panel.Panel in project syncope by apache.

the class CamelRoutes method buildTabList.

private List<ITab> buildTabList() {
    List<ITab> tabs = new ArrayList<>(3);
    tabs.add(new AbstractTab(new Model<>(AnyTypeKind.USER.name())) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            CamelRoutesDirectoryPanel panel = new CamelRoutesDirectoryPanel(panelId, getPageReference(), AnyTypeKind.USER);
            panel.setEnabled(restClient.isCamelEnabledFor(AnyTypeKind.USER));
            return panel;
        }
    });
    tabs.add(new AbstractTab(new Model<>(AnyTypeKind.GROUP.name())) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            CamelRoutesDirectoryPanel panel = new CamelRoutesDirectoryPanel(panelId, getPageReference(), AnyTypeKind.GROUP);
            panel.setEnabled(restClient.isCamelEnabledFor(AnyTypeKind.GROUP));
            return panel;
        }
    });
    tabs.add(new AbstractTab(new Model<>(AnyTypeKind.ANY_OBJECT.name())) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            CamelRoutesDirectoryPanel panel = new CamelRoutesDirectoryPanel(panelId, getPageReference(), AnyTypeKind.ANY_OBJECT);
            panel.setEnabled(restClient.isCamelEnabledFor(AnyTypeKind.ANY_OBJECT));
            return panel;
        }
    });
    return tabs;
}
Also used : CamelRoutesDirectoryPanel(org.apache.syncope.client.console.panels.CamelRoutesDirectoryPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ArrayList(java.util.ArrayList) Model(org.apache.wicket.model.Model) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) CamelRoutesDirectoryPanel(org.apache.syncope.client.console.panels.CamelRoutesDirectoryPanel) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab)

Aggregations

Panel (org.apache.wicket.markup.html.panel.Panel)76 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)27 ArrayList (java.util.ArrayList)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)18 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)16 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)16 Before (org.junit.Before)16 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)15 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)12 ResourceModel (org.apache.wicket.model.ResourceModel)11 DivTestPanel (org.odlabs.wiquery.ui.DivTestPanel)11 ItemPanelSettingsBuilder (com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 List (java.util.List)9 Test (org.junit.Test)9 IModel (org.apache.wicket.model.IModel)8 Model (org.apache.wicket.model.Model)6 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)5 Label (org.apache.wicket.markup.html.basic.Label)5