1 31 32 package org.opencms.workplace.tools.accounts; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.main.CmsException; 36 import org.opencms.util.CmsUUID; 37 import org.opencms.workplace.CmsWorkplace; 38 import org.opencms.workplace.list.CmsListResourceIconAction; 39 import org.opencms.workplace.tools.A_CmsHtmlIconButton; 40 41 50 public class CmsDependencyIconAction extends CmsListResourceIconAction { 51 52 53 public static final String PATH_BUTTONS = "tools/accounts/buttons/"; 54 55 56 private final CmsDependencyIconActionType m_type; 57 58 65 public CmsDependencyIconAction(String id, CmsDependencyIconActionType type, CmsObject cms) { 66 67 super(id + type.getId(), CmsGroupDependenciesList.LIST_COLUMN_TYPE, cms); 68 m_type = type; 69 } 70 71 74 public String buttonHtml(CmsWorkplace wp) { 75 76 if (!isVisible()) { 77 return ""; 78 } 79 if (m_type == CmsDependencyIconActionType.RESOURCE) { 80 return super.buttonHtml(wp); 81 } else { 82 return A_CmsHtmlIconButton.defaultButtonHtml( 83 wp.getJsp(), 84 resolveButtonStyle(), 85 getId() + getItem().getId(), 86 getId(), 87 resolveName(wp.getLocale()), 88 resolveHelpText(wp.getLocale()), 89 isEnabled(), 90 getIconPath(), 91 null, 92 resolveOnClic(wp.getLocale()), 93 getColumnForTexts() == null); 94 } 95 } 96 97 100 public String getIconPath() { 101 102 if (m_type == CmsDependencyIconActionType.USER) { 103 return PATH_BUTTONS + "user.png"; 104 } else if (m_type == CmsDependencyIconActionType.GROUP) { 105 return PATH_BUTTONS + "group.png"; 106 } else { 107 return super.getIconPath(); 108 } 109 } 110 111 116 public CmsDependencyIconActionType getType() { 117 118 return m_type; 119 } 120 121 124 public boolean isVisible() { 125 126 boolean visible = false; 127 if (getItem() != null) { 128 CmsUUID id = new CmsUUID(getItem().getId()); 129 try { 130 if (m_type == CmsDependencyIconActionType.RESOURCE) { 131 try { 132 getCms().readUser(id); 133 } catch (CmsException e1) { 134 try { 135 getCms().readGroup(id); 136 } catch (CmsException e2) { 137 visible = true; 138 } 139 } 140 } else if (m_type == CmsDependencyIconActionType.USER) { 141 getCms().readUser(id); 142 visible = true; 143 } else if (m_type == CmsDependencyIconActionType.GROUP) { 144 getCms().readGroup(id); 145 visible = true; 146 } 147 } catch (CmsException e) { 148 } 150 } else { 151 visible = super.isVisible(); 152 } 153 return visible; 154 } 155 } | Popular Tags |