/***************************************************************************** * Copyright (c) 2011 CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * * CEA LIST - Initial API and implementation * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.pkg.preferences; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper; import org.eclipse.papyrus.uml.diagram.pkg.provider.ElementTypes; public class PackagePreferencePage extends PackageDiagramNodePreferencePage { /** Constant key to access preferences */ protected static String prefKey = ElementTypes.DIAGRAM_ID + "_Package"; //$NON-NLS-1$ /** The compartments default visibility for preferences */ public static final Map<String, Boolean> compartmentDefaultVisibilityMap; /** The compartment titles default visibility for preferences */ public static final Map<String, Boolean> compartmentTitleDefaultVisibilityMap; /** Static attribute initialization */ static { compartmentDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); compartmentDefaultVisibilityMap.put("PackageableElementCompartment", Boolean.TRUE); //$NON-NLS-1$ compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>(); compartmentTitleDefaultVisibilityMap.put("PackageableElementCompartment", Boolean.TRUE); //$NON-NLS-1$ // Start of user code custom static initializations // End of user code Collections.unmodifiableMap(compartmentDefaultVisibilityMap); Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap); } /** Default constructor */ public PackagePreferencePage() { super(); setPreferenceKey(ElementTypes.DIAGRAM_ID + "_Package"); //$NON-NLS-1$ } /** * Initialize defaults using a specified {@link IPreferenceStore} * * @param store * the preference store. */ public static void initDefaults(IPreferenceStore store) { // Start of user code custom default initializations // End of user code store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 200); store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 100); // Initialize default visibility for compartments in preference page. for(String compartmentName : compartmentDefaultVisibilityMap.keySet()) { String showCompartmentKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY); store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName)); } // Initialize default title visibility for compartments in preference page. for(String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) { String showCompartmentTitleKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); store.setDefault(showCompartmentTitleKey, compartmentTitleDefaultVisibilityMap.get(compartmentName)); } } /** * {@inheritDoc} */ @Override protected void initializeCompartmentNamesList() { for(String name : compartmentDefaultVisibilityMap.keySet()) { this.compartmentNamesList.add(name); } } /** * {@inheritDoc} */ @Override protected void initializeCompartmentTitlesList() { for(String name : compartmentTitleDefaultVisibilityMap.keySet()) { this.compartmentTitlesList.add(name); } } }