diff options
Diffstat (limited to 'documentation/articles/img')
34 files changed, 338 insertions, 0 deletions
diff --git a/documentation/articles/img/DmoOrgTreeUI.java b/documentation/articles/img/DmoOrgTreeUI.java new file mode 100644 index 0000000000..5e343cc347 --- /dev/null +++ b/documentation/articles/img/DmoOrgTreeUI.java @@ -0,0 +1,338 @@ + +package com.dmo.util.ui; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.EventRequest; +import javax.portlet.EventResponse; +import javax.portlet.PortletMode; +import javax.portlet.PortletRequest; +import javax.portlet.PortletSession; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.ResourceRequest; +import javax.portlet.ResourceResponse; +import javax.servlet.annotation.WebServlet; + +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; +import com.liferay.portal.kernel.util.WebKeys; +import com.liferay.portal.model.Organization; +import com.liferay.portal.model.User; +import com.liferay.portal.service.OrganizationLocalServiceUtil; +import com.liferay.portal.service.UserLocalServiceUtil; +import com.liferay.portal.theme.ThemeDisplay; +import com.liferay.portal.util.PortalUtil; +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.VaadinServletConfiguration; +import com.vaadin.data.util.HierarchicalContainer; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.server.VaadinPortletSession; +import com.vaadin.server.VaadinPortletSession.PortletListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.server.VaadinSession; +import com.vaadin.ui.AbstractSelect.ItemCaptionMode; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; +import com.vaadin.ui.Tree; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings({ + "serial", "deprecation" +}) +@Theme("dmoprojectview") +public class DmoOrgTreeUI extends UI implements PortletListener { + + private PortletMode previousMode = null; + private PortletRequest portletRequest; + private PortletSession portletSession; + private User user; + private ThemeDisplay themeDisplay; + private VerticalLayout viewContent = new VerticalLayout(); + private Tree tree = new Tree("Organization Tree"); + private HashSet<Long> checked = new HashSet<Long>(); + + @WebServlet(value = "/*", asyncSupported = true) + @VaadinServletConfiguration(productionMode = false, ui = DmoOrgTreeUI.class) + public static class Servlet extends VaadinServlet { + } + + @Override + protected void init(VaadinRequest request) { + + viewContent = new VerticalLayout(); + viewContent.setMargin(true); + setContent(viewContent); + + if (VaadinSession.getCurrent() instanceof VaadinPortletSession) { + final VaadinPortletSession portletsession = (VaadinPortletSession) VaadinSession.getCurrent(); + portletsession.addPortletListener(this); + + try { + setPortletRequestUI((PortletRequest) request); + setPortletSessionUI(portletsession.getPortletSession()); + user = UserLocalServiceUtil.getUser(PortalUtil.getUser((PortletRequest) request).getUserId()); + setThemeDisplayUI((ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY)); + //System.out.println("DEBUG=>" + this.getClass() + "\n ==>themeDisplay getLayout=" + themeDisplay.getLayout().toString()); + doView(); + } + catch (PortalException e) { + e.printStackTrace(); + } + catch (com.liferay.portal.kernel.exception.SystemException e) { + e.printStackTrace(); + } + } + else { + Notification.show("Not initialized in a Portal!", Notification.Type.ERROR_MESSAGE); + } + + } + + @Override + public void handleRenderRequest(RenderRequest request, RenderResponse response, UI root) { + + PortletMode portletMode = request.getPortletMode(); + try { + setPortletRequestUI((PortletRequest) request); + setPortletSessionUI(request.getPortletSession()); + + setThemeDisplayUI((ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY)); + user = UserLocalServiceUtil.getUser(PortalUtil.getUser((PortletRequest) request).getUserId()); + + if (request.getPortletMode() == PortletMode.VIEW) { + doView(); + } + } + catch (PortalException e) { + Notification.show(e.getMessage(), Type.ERROR_MESSAGE); + } + catch (com.liferay.portal.kernel.exception.SystemException e) { + Notification.show(e.getMessage(), Type.ERROR_MESSAGE); + } + + setPreviousModeUI(portletMode); + + } + + @Override + public void handleActionRequest(ActionRequest request, ActionResponse response, UI root) { + + } + + @Override + public void handleEventRequest(EventRequest request, EventResponse response, UI root) { + + } + + @Override + public void handleResourceRequest(ResourceRequest request, ResourceResponse response, UI root) { + + this.setThemeDisplayUI((ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY)); + + setPortletRequestUI((PortletRequest) request); + setPortletSessionUI(request.getPortletSession()); + setThemeDisplayUI((ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY)); + try { + user = UserLocalServiceUtil.getUser(PortalUtil.getUser((PortletRequest) request).getUserId()); + } + catch (PortalException e) { + Notification.show(e.getMessage(), Type.ERROR_MESSAGE); + } + catch (com.liferay.portal.kernel.exception.SystemException e) { + Notification.show(e.getMessage(), Type.ERROR_MESSAGE); + } + } + + public void doView() { + + try { + buildMainLayout(); + } + catch (SystemException e) { + Notification.show("System error occurred. Contact administrator.", Type.WARNING_MESSAGE); + } + catch (PortalException e) { + Notification.show("System error occurred. Contact administrator.", Type.WARNING_MESSAGE); + } + catch (Exception e) { + Notification.show("System error occurred. Contact administrator.", Type.WARNING_MESSAGE); + } + } + + private void buildMainLayout() + throws SystemException, PortalException { + + if (viewContent.getComponentCount() > 0) { + viewContent.removeAllComponents(); + } + + viewContent.setMargin(true); + viewContent.addStyleName("view"); + + List<Organization> orgList = new ArrayList<Organization>(); + orgList = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId()); + final HierarchicalContainer container = createTreeContent(orgList); + + tree = new Tree("My Organizations", container); + tree.addStyleName("checkboxed"); + tree.setSelectable(false); + tree.setItemCaptionMode(ItemCaptionMode.PROPERTY); + tree.setItemCaptionPropertyId("name"); + tree.addItemClickListener(new ItemClickEvent.ItemClickListener() { + + public void itemClick(ItemClickEvent event) { + + if (event.getItemId().getClass() == Long.class) { + long itemId = (Long) event.getItemId(); + if (checked.contains(itemId)) { + checkboxChildren(container, itemId, false); + } + else { + checkboxChildren(container, itemId, true); + tree.expandItemsRecursively(itemId); + } + } + tree.markAsDirty(); + } + }); + + Tree.ItemStyleGenerator itemStyleGenerator = new Tree.ItemStyleGenerator() { + + @Override + public String getStyle(Tree source, Object itemId) { + + if (checked.contains(itemId)) + return "checked"; + else + return "unchecked"; + } + }; + tree.setItemStyleGenerator(itemStyleGenerator); + + viewContent.addComponent(tree); + viewContent.setVisible(true); + setContent(viewContent); + } + + public void checkboxChildren(HierarchicalContainer hc, long itemId, boolean bAdd) { + + try { + + if (bAdd) { + checked.add(itemId); + } + else { + checked.remove(itemId); + } + + if (hc.hasChildren(itemId)) { + Collection<?> children = hc.getChildren(itemId); + for (Object o : children) { + if (o.getClass() == Long.class) { + itemId = (Long) o; + checkboxChildren(hc, itemId, bAdd); + } + } + } + } + catch (Exception e) { + Notification.show("Unable to build Organization tree. Contact Administrator.", Type.ERROR_MESSAGE); + } + } + + public static HierarchicalContainer createTreeContent(List<Organization> oTrees) + throws SystemException, PortalException { + + HierarchicalContainer container = new HierarchicalContainer(); + container.addContainerProperty("name", String.class, ""); + + new Object() { + + @SuppressWarnings("unchecked") + public void put(List<Organization> data, HierarchicalContainer container) + throws SystemException, PortalException { + + for (Organization o : data) { + long orgId = o.getOrganizationId(); + + if (!container.containsId(orgId)) { + + container.addItem(orgId); + container.getItem(orgId).getItemProperty("name").setValue(o.getName()); + + if (!o.hasSuborganizations()) { + container.setChildrenAllowed(orgId, false); + } + else { + container.setChildrenAllowed(orgId, true); + } + + if (o.isRoot()) { + container.setParent(orgId, null); + } + else { + if (!container.containsId(o.getParentOrganizationId())) { + List<Organization> sub = new ArrayList<Organization>(); + sub.add(o.getParentOrganization()); + put(sub, container); + } + + container.setParent(orgId, (Object) o.getParentOrganizationId()); + } + } + } + } + }.put(oTrees, container); + + return container; + } + + public PortletRequest getPortletRequestUI() { + + return portletRequest; + } + + public void setPortletRequestUI(PortletRequest portletRequest) { + + this.portletRequest = portletRequest; + } + + public PortletSession getPortletSessionUI() { + + return portletSession; + } + + public void setPortletSessionUI(PortletSession portletSession) { + + this.portletSession = portletSession; + } + + public ThemeDisplay getThemeDisplayUI() { + + return themeDisplay; + } + + public void setThemeDisplayUI(ThemeDisplay themeDisplay) { + + this.themeDisplay = themeDisplay; + } + + public PortletMode getPreviousModeUI() { + + return previousMode; + } + + public void setPreviousModeUI(PortletMode previousMode) { + + this.previousMode = previousMode; + } + +} diff --git a/documentation/articles/img/JAR Export (1).png b/documentation/articles/img/JAR Export (1).png Binary files differnew file mode 100644 index 0000000000..a67ef892b6 --- /dev/null +++ b/documentation/articles/img/JAR Export (1).png diff --git a/documentation/articles/img/JAR Export (2).png b/documentation/articles/img/JAR Export (2).png Binary files differnew file mode 100644 index 0000000000..7a88f9be92 --- /dev/null +++ b/documentation/articles/img/JAR Export (2).png diff --git a/documentation/articles/img/New Java Project.png b/documentation/articles/img/New Java Project.png Binary files differnew file mode 100644 index 0000000000..b22895d183 --- /dev/null +++ b/documentation/articles/img/New Java Project.png diff --git a/documentation/articles/img/New Vaadin project (1).png b/documentation/articles/img/New Vaadin project (1).png Binary files differnew file mode 100644 index 0000000000..73799e80b6 --- /dev/null +++ b/documentation/articles/img/New Vaadin project (1).png diff --git a/documentation/articles/img/New Vaadin project (2).png b/documentation/articles/img/New Vaadin project (2).png Binary files differnew file mode 100644 index 0000000000..3bde1bef7a --- /dev/null +++ b/documentation/articles/img/New Vaadin project (2).png diff --git a/documentation/articles/img/Theme to build path.png b/documentation/articles/img/Theme to build path.png Binary files differnew file mode 100644 index 0000000000..5641c4b987 --- /dev/null +++ b/documentation/articles/img/Theme to build path.png diff --git a/documentation/articles/img/Theme to deployment assembly.png b/documentation/articles/img/Theme to deployment assembly.png Binary files differnew file mode 100644 index 0000000000..d6b58bf898 --- /dev/null +++ b/documentation/articles/img/Theme to deployment assembly.png diff --git a/documentation/articles/img/VAADIN to deployment assembly.png b/documentation/articles/img/VAADIN to deployment assembly.png Binary files differnew file mode 100644 index 0000000000..44d3463ca5 --- /dev/null +++ b/documentation/articles/img/VAADIN to deployment assembly.png diff --git a/documentation/articles/img/Vaadin to build path.png b/documentation/articles/img/Vaadin to build path.png Binary files differnew file mode 100644 index 0000000000..a346c0ab15 --- /dev/null +++ b/documentation/articles/img/Vaadin to build path.png diff --git a/documentation/articles/img/VaadinJasperReportsSample_small.jpg b/documentation/articles/img/VaadinJasperReportsSample_small.jpg Binary files differnew file mode 100644 index 0000000000..47f14fa7a4 --- /dev/null +++ b/documentation/articles/img/VaadinJasperReportsSample_small.jpg diff --git a/documentation/articles/img/ab-with-vaadin-scrshot.png b/documentation/articles/img/ab-with-vaadin-scrshot.png Binary files differnew file mode 100644 index 0000000000..4da34e1b24 --- /dev/null +++ b/documentation/articles/img/ab-with-vaadin-scrshot.png diff --git a/documentation/articles/img/address editor.png b/documentation/articles/img/address editor.png Binary files differnew file mode 100644 index 0000000000..1dd60c3dc8 --- /dev/null +++ b/documentation/articles/img/address editor.png diff --git a/documentation/articles/img/architecture.png b/documentation/articles/img/architecture.png Binary files differnew file mode 100644 index 0000000000..fa0930179a --- /dev/null +++ b/documentation/articles/img/architecture.png diff --git a/documentation/articles/img/architecture2.png b/documentation/articles/img/architecture2.png Binary files differnew file mode 100644 index 0000000000..c9631cc022 --- /dev/null +++ b/documentation/articles/img/architecture2.png diff --git a/documentation/articles/img/buttons added.png b/documentation/articles/img/buttons added.png Binary files differnew file mode 100644 index 0000000000..26ea5852f9 --- /dev/null +++ b/documentation/articles/img/buttons added.png diff --git a/documentation/articles/img/complexdomain.png b/documentation/articles/img/complexdomain.png Binary files differnew file mode 100644 index 0000000000..050049dff5 --- /dev/null +++ b/documentation/articles/img/complexdomain.png diff --git a/documentation/articles/img/complexdomain_saving.png b/documentation/articles/img/complexdomain_saving.png Binary files differnew file mode 100644 index 0000000000..97cf0cc790 --- /dev/null +++ b/documentation/articles/img/complexdomain_saving.png diff --git a/documentation/articles/img/complexdomain_saving2.png b/documentation/articles/img/complexdomain_saving2.png Binary files differnew file mode 100644 index 0000000000..af4d5d4f25 --- /dev/null +++ b/documentation/articles/img/complexdomain_saving2.png diff --git a/documentation/articles/img/customForms.png b/documentation/articles/img/customForms.png Binary files differnew file mode 100644 index 0000000000..0edb698b71 --- /dev/null +++ b/documentation/articles/img/customForms.png diff --git a/documentation/articles/img/database connected.png b/documentation/articles/img/database connected.png Binary files differnew file mode 100644 index 0000000000..80c3588224 --- /dev/null +++ b/documentation/articles/img/database connected.png diff --git a/documentation/articles/img/deployartifact.png b/documentation/articles/img/deployartifact.png Binary files differnew file mode 100644 index 0000000000..f3e89561db --- /dev/null +++ b/documentation/articles/img/deployartifact.png diff --git a/documentation/articles/img/jm1B.png b/documentation/articles/img/jm1B.png Binary files differnew file mode 100644 index 0000000000..9d4bf9ecf1 --- /dev/null +++ b/documentation/articles/img/jm1B.png diff --git a/documentation/articles/img/jm2B.png b/documentation/articles/img/jm2B.png Binary files differnew file mode 100644 index 0000000000..dfcbd6d30a --- /dev/null +++ b/documentation/articles/img/jm2B.png diff --git a/documentation/articles/img/jm3B.png b/documentation/articles/img/jm3B.png Binary files differnew file mode 100644 index 0000000000..da2cb86b65 --- /dev/null +++ b/documentation/articles/img/jm3B.png diff --git a/documentation/articles/img/jm4.png b/documentation/articles/img/jm4.png Binary files differnew file mode 100644 index 0000000000..4dedd80647 --- /dev/null +++ b/documentation/articles/img/jm4.png diff --git a/documentation/articles/img/jm5.png b/documentation/articles/img/jm5.png Binary files differnew file mode 100644 index 0000000000..058193fe4f --- /dev/null +++ b/documentation/articles/img/jm5.png diff --git a/documentation/articles/img/master detail wireframe.jpg b/documentation/articles/img/master detail wireframe.jpg Binary files differnew file mode 100644 index 0000000000..4745b4831f --- /dev/null +++ b/documentation/articles/img/master detail wireframe.jpg diff --git a/documentation/articles/img/person editor.png b/documentation/articles/img/person editor.png Binary files differnew file mode 100644 index 0000000000..71de0a3ebb --- /dev/null +++ b/documentation/articles/img/person editor.png diff --git a/documentation/articles/img/process.png b/documentation/articles/img/process.png Binary files differnew file mode 100644 index 0000000000..f8b1b3e1ad --- /dev/null +++ b/documentation/articles/img/process.png diff --git a/documentation/articles/img/screenshot.png b/documentation/articles/img/screenshot.png Binary files differnew file mode 100644 index 0000000000..13522d4c66 --- /dev/null +++ b/documentation/articles/img/screenshot.png diff --git a/documentation/articles/img/sd_s_per_r.gif b/documentation/articles/img/sd_s_per_r.gif Binary files differnew file mode 100644 index 0000000000..cccdddc43b --- /dev/null +++ b/documentation/articles/img/sd_s_per_r.gif diff --git a/documentation/articles/img/table and form.png b/documentation/articles/img/table and form.png Binary files differnew file mode 100644 index 0000000000..d454da1fd9 --- /dev/null +++ b/documentation/articles/img/table and form.png diff --git a/documentation/articles/img/views.png b/documentation/articles/img/views.png Binary files differnew file mode 100644 index 0000000000..fd4bb48f64 --- /dev/null +++ b/documentation/articles/img/views.png |