001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps.git; 029 030import org.opencms.file.CmsObject; 031import org.opencms.security.CmsRole; 032import org.opencms.ui.A_CmsUI; 033import org.opencms.ui.CmsCssIcon; 034import org.opencms.ui.apps.A_CmsWorkplaceApp; 035import org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration; 036import org.opencms.ui.apps.CmsAppVisibilityStatus; 037import org.opencms.ui.apps.CmsWorkplaceAppManager; 038import org.opencms.ui.apps.I_CmsWorkplaceApp; 039 040import java.util.LinkedHashMap; 041import java.util.List; 042import java.util.Locale; 043 044import com.vaadin.server.Resource; 045import com.vaadin.ui.Component; 046 047/** 048 * App configuration for the Git checkin tool.<p> 049 */ 050public class CmsGitAppConfiguration extends A_CmsWorkplaceAppConfiguration { 051 052 /** The app icon resource (size 32x32). */ 053 public static final CmsCssIcon ICON = new CmsCssIcon("oc-icon-32-git"); 054 055 /** 056 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppCategory() 057 */ 058 @Override 059 public String getAppCategory() { 060 061 return CmsWorkplaceAppManager.ADMINISTRATION_CATEGORY_ID; 062 } 063 064 /** 065 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getAppInstance() 066 */ 067 public I_CmsWorkplaceApp getAppInstance() { 068 069 return new A_CmsWorkplaceApp() { 070 071 @Override 072 protected LinkedHashMap<String, String> getBreadCrumbForState(String state) { 073 074 return null; 075 } 076 077 @Override 078 protected Component getComponentForState(String state) { 079 080 CmsGitCheckin checkin = new CmsGitCheckin(A_CmsUI.getCmsObject()); 081 return new CmsGitToolOptionsPanel(checkin); 082 } 083 084 @Override 085 protected List<NavEntry> getSubNavEntries(String state) { 086 087 return null; 088 } 089 }; 090 } 091 092 /** 093 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getHelpText(java.util.Locale) 094 */ 095 @Override 096 public String getHelpText(Locale locale) { 097 098 return Messages.get().getBundle(locale).key(Messages.GUI_GIT_APP_HELP_TEXT_0); 099 } 100 101 /** 102 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon() 103 */ 104 public Resource getIcon() { 105 106 return ICON; 107 } 108 109 /** 110 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getId() 111 */ 112 public String getId() { 113 114 return "gitCheckin"; 115 } 116 117 /** 118 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getName(java.util.Locale) 119 */ 120 @Override 121 public String getName(Locale locale) { 122 123 return Messages.get().getBundle(locale).key(Messages.GUI_GIT_APP_NAME_0); 124 } 125 126 /** 127 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getOrder() 128 */ 129 @Override 130 public int getOrder() { 131 132 return 110; 133 } 134 135 /** 136 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getRequiredRole() 137 */ 138 @Override 139 public CmsRole getRequiredRole() { 140 141 return CmsRole.VFS_MANAGER; 142 } 143 144 /** 145 * @see org.opencms.ui.apps.A_CmsWorkplaceAppConfiguration#getVisibility(org.opencms.file.CmsObject) 146 */ 147 @Override 148 public CmsAppVisibilityStatus getVisibility(CmsObject cms) { 149 150 CmsGitCheckin checkin = new CmsGitCheckin(A_CmsUI.getCmsObject()); 151 if (!checkin.hasValidConfiguration()) { 152 return CmsAppVisibilityStatus.INVISIBLE; 153 } 154 return super.getVisibility(cms); 155 } 156}