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>");
}
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));
}
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));
}
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;
}
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;
}
Aggregations