001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.core.ui.ribbonconfiguration; 017 018import java.util.ArrayList; 019import java.util.HashMap; 020import java.util.LinkedList; 021import java.util.List; 022import java.util.Map; 023 024/** 025 * A ribbon configuration, with tab, user and app menus 026 */ 027public class RibbonConfiguration 028{ 029 /** The tabs of the ribbon */ 030 protected LinkedList<Tab> _tabs = new LinkedList<>(); 031 032 /** The App menu of the ribbon */ 033 protected RibbonMenu _appMenu = new RibbonMenu(); 034 035 /** The user menu elements of the ribbon */ 036 protected RibbonMenu _userMenu = new RibbonMenu(); 037 038 /** The dependencies of the ribbon */ 039 protected Map<String, List<String>> _dependencies = new HashMap<>(); 040 041 /** 042 * Get the tabs for this configuration 043 * @return the tabs 044 */ 045 public LinkedList<Tab> getTabs() 046 { 047 return _tabs; 048 } 049 050 /** 051 * Set the tabs for this configuration 052 * @param tabs The tabs 053 */ 054 public void setTabs(LinkedList<Tab> tabs) 055 { 056 _tabs = tabs; 057 } 058 059 /** 060 * Get the app menu for this configuration 061 * @return the appMenu 062 */ 063 public RibbonMenu getAppMenu() 064 { 065 return _appMenu; 066 } 067 068 /** 069 * Get the user menu for this configuration 070 * @return the userMenu 071 */ 072 public RibbonMenu getUserMenu() 073 { 074 return _userMenu; 075 } 076 077 /** 078 * Add a new ribbon dependency 079 * @param extensionPoint The dependency extension point 080 * @param extensionId The dependency extension id 081 */ 082 public void addDependency(String extensionPoint, String extensionId) 083 { 084 if (!_dependencies.containsKey(extensionPoint)) 085 { 086 _dependencies.put(extensionPoint, new ArrayList<>()); 087 } 088 List<String> extensions = _dependencies.get(extensionPoint); 089 if (!extensions.contains(extensionId)) 090 { 091 extensions.add(extensionId); 092 } 093 } 094 095 /** 096 * Get the list of dependencies 097 * @return The list of extensions id, mapped by extension point 098 */ 099 public Map<String, List<String>> getDependencies() 100 { 101 return _dependencies; 102 } 103 104}