blob: 6a2b5821046f7ddf12282a7ca194b7f94d45f278 [file] [log] [blame]
/*****************************************************************************
* 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.sysml.diagram.blockdefinition.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.common.preferences.PreferencesConstantsHelper;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.provider.ElementTypes;
import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
public class DataTypePreferencePage extends BlockDefinitionDiagramNodePreferencePage {
/** Constant key to access preferences */
public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_DATATYPE_AS_CLASSIFIER_ID; //$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("properties", Boolean.TRUE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("operations", Boolean.FALSE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>();
compartmentTitleDefaultVisibilityMap.put("properties", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("operations", Boolean.TRUE); //$NON-NLS-1$
// Start of user code custom static initializations
// End of user code
Collections.unmodifiableMap(compartmentDefaultVisibilityMap);
Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap);
}
/** Constructor */
public DataTypePreferencePage() {
super();
setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + UMLGraphicalTypes.SHAPE_UML_DATATYPE_AS_CLASSIFIER_ID); //$NON-NLS-1$
}
/** Default preferences initializer */
public static void initDefaults(IPreferenceStore store) {
// Start of user code custom default initializations
// End of user code
// Initialize default visibility for compartments in preference page.
for (String compartmentName : compartmentDefaultVisibilityMap.keySet()) {
String showCompartmentKey = PreferencesConstantsHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferencesConstantsHelper.COMPARTMENT_VISIBILITY);
store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName));
}
// Initialize default title visibility for compartments in preference page.
for (String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) {
String showCompartmentTitleKey = PreferencesConstantsHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferencesConstantsHelper.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);
}
}
}