1 31 32 package org.opencms.workplace.tools.projects; 33 34 import org.opencms.db.CmsUserProjectSettings; 35 import org.opencms.db.CmsUserSettings; 36 import org.opencms.file.CmsGroup; 37 import org.opencms.jsp.CmsJspActionElement; 38 import org.opencms.main.CmsException; 39 import org.opencms.main.CmsIllegalArgumentException; 40 import org.opencms.util.CmsUUID; 41 import org.opencms.widgets.CmsSelectWidgetOption; 42 import org.opencms.workplace.CmsWidgetDialog; 43 44 import java.util.ArrayList ; 45 import java.util.Iterator ; 46 import java.util.List ; 47 48 57 public abstract class A_CmsProjectDialog extends CmsWidgetDialog { 58 59 60 public static final String [] PAGES = {"page1"}; 61 62 63 private String m_managerGroup; 64 65 66 private String m_userGroup; 67 68 73 public A_CmsProjectDialog(CmsJspActionElement jsp) { 74 75 super(jsp); 76 } 77 78 83 public String getManagerGroup() { 84 85 return m_managerGroup; 86 } 87 88 93 public String getUserGroup() { 94 95 return m_userGroup; 96 } 97 98 103 public void setManagerGroup(String managerGroup) { 104 105 checkGroup(managerGroup); 106 m_managerGroup = managerGroup; 107 } 108 109 114 public void setUserGroup(String userGroup) { 115 116 checkGroup(userGroup); 117 m_userGroup = userGroup; 118 } 119 120 123 protected String [] getPageArray() { 124 125 return PAGES; 126 } 127 128 135 protected List getSelectGroups(boolean pManager) { 136 137 List retVal = new ArrayList (); 138 CmsUUID defaultGroup = null; 139 CmsUserProjectSettings settings = new CmsUserSettings(getCms()).getProjectSettings(); 140 if (settings != null) { 141 if (pManager) { 142 defaultGroup = settings.getManagerGroup(); 143 } else { 144 defaultGroup = settings.getUserGroup(); 145 } 146 } 147 try { 148 Iterator itGroups = getCms().getGroups().iterator(); 149 while (itGroups.hasNext()) { 150 CmsGroup group = (CmsGroup)itGroups.next(); 151 if (!pManager || group.getProjectManager()) { 152 if (group.getId().equals(defaultGroup)) { 153 retVal.add(new CmsSelectWidgetOption(group.getName(), true)); 154 } else { 155 retVal.add(new CmsSelectWidgetOption(group.getName())); 156 } 157 } 158 } 159 } catch (Exception e) { 160 } 162 return retVal; 163 } 164 165 168 protected void initMessages() { 169 170 addMessages(Messages.get().getBundleName()); 172 super.initMessages(); 174 } 175 176 181 private void checkGroup(String groupName) { 182 183 try { 184 getCms().readGroup(groupName); 185 } catch (CmsException e) { 186 throw new CmsIllegalArgumentException(e.getMessageContainer()); 187 } 188 } 189 } | Popular Tags |