private PortletApplicationDefinition parsePortlets( String modulePath, PortalDeployDefinition define, String moduleName) throws FileNotFoundException, IOException { FileInputStream input = null; try { File f = new File(modulePath + "/portalspec/portlet.xml"); if (!f.exists()) return null; input = new FileInputStream(f); PortletApplicationDefinition pad = (PortletApplicationDefinition) PortalServiceUtil.getPortletAppDescriptorService().read(moduleName, input); List<PortletDefinition> pList = pad.getPortlets(); Iterator<PortletDefinition> pit = pList.iterator(); while (pit.hasNext()) { PortletDefinition p = pit.next(); ContainerRuntimeOption cr = new ContainerRuntimeOption(); cr.setName(ContainerRuntimeOption.MODULE); cr.addValue(moduleName); p.getContainerRuntimeOptions().add(cr); } return pad; } finally { if (input != null) try { input.close(); } catch (IOException e) { LfwLogger.error(e.getMessage(), e); } } }
public void deleteNode() { String projectPath = LFWPersTool.getProjectWithBcpPath(); String projectModuleName = LFWPersTool.getCurrentProjectModuleName(); PortletApplicationDefinition portletApp = PortalConnector.getPortletApp(projectPath, projectModuleName); PortletDefinition portletDefinition = (PortletDefinition) this.getData(); if (portletApp.getPortlet(portletDefinition.getPortletName()) != null) { portletApp.getPortlets().remove(portletApp.getPortlet(portletDefinition.getPortletName())); PortalConnector.savePortletAppToXml(projectPath, projectModuleName, portletApp); } /** 删除 portlet分类中的配置 */ if (this.getParentItem() instanceof CategoryTreeItem) { Display display = PortalConnector.getDisplay(projectPath, projectModuleName); PortletDisplayCategory portletDisplayCategory = (PortletDisplayCategory) this.getParentItem().getData(); for (PortletDisplayCategory pdc : display.getCategory()) { if (pdc.getId().equals(portletDisplayCategory.getId())) { removeDisplay(pdc, portletDefinition); break; } } PortalConnector.saveDisplayToXml(projectPath, projectModuleName, display); } dispose(); }
public PortletTreeItem(TreeItem parentItem, PortletDefinition portlet) { super(parentItem, SWT.NONE); setData(portlet); setText( portlet.getDisplayNames().isEmpty() ? "" : portlet.getDisplayNames().get(0).getDisplayName()); setImage(getDirImage()); }
private void removeDisplay(PortletDisplayCategory pdc, PortletDefinition portletDefinition) { for (PortletDisplay pd : pdc.getPortletDisplayList()) { if (pd.getId().equals(portletDefinition.getPortletName())) { pdc.getPortletDisplayList().remove(pd); break; } } }
/** * 增加右键菜单 * * @param manager */ public void addMenuListener(IMenuManager manager) { DeletePortletAction deletePortletAction = new DeletePortletAction(); manager.add(deletePortletAction); if (getParentItem() instanceof CategoryTreeItem) { PortletDisplayCategory portletDisplayCategory = (PortletDisplayCategory) getParentItem().getData(); PortletDefinition portlet = (PortletDefinition) getData(); for (PortletDisplay pd : portletDisplayCategory.getPortletDisplayList()) { if (pd.getId().equals(portlet.getPortletName())) { if (pd.getDynamic()) { manager.add(new DynamicAction(true, "checked.gif")); } else { manager.add(new DynamicAction(false, "un_checked.gif")); } break; } } } }