/**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- *
+ * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
* 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:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences;
import java.util.Arrays;
/**
* This is the Sequence Diagram preference handler. This class is responsible for accessing the current user preferences
* selection This class also provider getters for each modifiable preferences.
- *
+ *
* @version 1.0
* @author sveyrier
*/
// Constants
// ------------------------------------------------------------------------
/**
- * Postfix string for background color property
+ * Postfix string for background color property
*/
public static final String BACK_COLOR_POSTFIX = "_BACK_COLOR";//$NON-NLS-1$
/**
- * Postfix string for foreground color property
+ * Postfix string for foreground color property
*/
public static final String FORE_COLOR_POSTFIX = "_FORE_COLOR";//$NON-NLS-1$
/**
- * Postfix string for text color property
+ * Postfix string for text color property
*/
public static final String TEXT_COLOR_POSTFIX = "_TEXT_COLOR";//$NON-NLS-1$
/**
*/
private static final String[] PREF_TEXT_COLOR_LIST = { PREF_LIFELINE, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_LIFELINE_HEADER, PREF_FRAME_NAME };
/**
- * Temporary tag
+ * Temporary tag
*/
protected static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$
*/
private static SDViewPref fHandle = null;
/**
- * Hashtable for font preferences
+ * Hashtable for font preferences
*/
protected Map<String, IFont> fFontPref;
/**
- * Hashtable for foreground color preferences
+ * Hashtable for foreground color preferences
*/
protected Map<String, IColor> fForeColorPref;
/**
- * Hashtable for background color preferences
+ * Hashtable for background color preferences
*/
protected Map<String, IColor> fBackColorPref;
/**
- * Hashtable for text color preferences
+ * Hashtable for text color preferences
*/
protected Map<String, IColor> fTextColorPref;
/**
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+
/**
* Builds the Sequence Diagram preference handler: - Define the preference default values. - Load the currently used
* preferences setting
/**
* Returns the PreferenceStore
- *
+ *
* @return the PreferenceStore
*/
public IPreferenceStore getPreferenceStore() {
/**
* Returns an unique instance of the Sequence Diagram preference handler
- *
+ *
* @return the preference handler instance
*/
public static synchronized SDViewPref getInstance() {
@Override
public IColor getForeGroundColor(String prefName) {
if ((fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fForeColorPref.get(prefName + FORE_COLOR_POSTFIX);
+ return fForeColorPref.get(prefName + FORE_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
@Override
public IColor getBackGroundColor(String prefName) {
if ((fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fBackColorPref.get(prefName + BACK_COLOR_POSTFIX);
+ return fBackColorPref.get(prefName + BACK_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_WHITE);
}
@Override
public IColor getFontColor(String prefName) {
if ((fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl)) {
- return (IColor) fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX);
+ return fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX);
}
return ColorImpl.getSystemColor(SWT.COLOR_BLACK);
}
*/
@Override
public IFont getFont(String prefName) {
- if ((fFontPref.get(prefName) != null) && (fFontPref.get(prefName) instanceof IFont)) {
- return (IFont) fFontPref.get(prefName);
+ if (fFontPref.get(prefName) != null) {
+ return fFontPref.get(prefName);
}
return FontImpl.getSystemFont();
}
/**
* Returns the SwimLane width chosen
- *
+ *
* @return the SwimLane width
*/
public int getLifelineWidth() {
/**
* Returns if font linkage with zoom has been chosen
- *
+ *
* @return true if checked false otherwise
*/
public boolean fontLinked() {
/**
* Returns the tooltip enablement
- *
+ *
* @return true if checked false otherwise
*/
public boolean tooltipEnabled() {
/**
* Return true if the user do not want to take external time (basically found and lost messages with time) into
* account in the min max computation
- *
+ *
* @return true if checked false otherwise
*/
public boolean excludeExternalTime() {
for (int i = 0; i < FONT_LIST.length; i++) {
FontData fontData = PreferenceConverter.getFontData(fPrefStore, FONT_LIST[i]);
- if ((fFontPref.get(FONT_LIST[i]) != null) && (fFontPref.get(FONT_LIST[i]) instanceof IFont)) {
- ((IFont) fFontPref.get(FONT_LIST[i])).dispose();
+ if (fFontPref.get(FONT_LIST[i]) != null) {
+ fFontPref.get(FONT_LIST[i]).dispose();
}
fFontPref.put(FONT_LIST[i], new FontImpl(display, fontData));
}
for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX);
- if ((fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX)).dispose();
+ if (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) {
+ fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX).dispose();
}
fBackColorPref.put(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX);
- if ((fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX)).dispose();
+ if (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) {
+ fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX).dispose();
}
fForeColorPref.put(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) {
RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX);
- if ((fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) instanceof IColor)) {
- ((IColor) fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX)).dispose();
+ if (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) {
+ fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX).dispose();
}
fTextColorPref.put(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue));
}
fTimeCompressionSelectionColor = new ColorImpl(display, rgb.red, rgb.green, rgb.blue);
}
+ /**
+ * Add a property-change listener
+ *
+ * @param listener
+ * The listener to add
+ */
public void addPropertyChangeListener(IPropertyChangeListener listener) {
fPrefStore.addPropertyChangeListener(listener);
}
+ /**
+ * Remove a property-change listener
+ *
+ * @param listener
+ * The listerner to remove
+ */
public void removePropertyChangeListener(IPropertyChangeListener listener) {
fPrefStore.removePropertyChangeListener(listener);
}
public void propertyChange(PropertyChangeEvent event) {
if (!event.getProperty().equals("PREFOK")) { //$NON-NLS-1$
buildFontsAndColors();
- fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$
+ fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$
}
}
+ /**
+ * Set the "no focus selection" preference
+ *
+ * @param v
+ * New value to use
+ */
public void setNoFocusSelection(boolean v) {
fNoFocusSelection = v;
}
/**
* Returns the static font list.
- *
+ *
* @return static font list
*/
public static String[] getFontList() {
return Arrays.copyOf(FONT_LIST, FONT_LIST.length);
}
-
+
/**
* Returns the 2nd static font list.
- *
+ *
* @return 2nd static font list
*/
public static String[] getFontList2() {
return Arrays.copyOf(FONT_LIST2, FONT_LIST2.length);
}
-
+
/**
* Returns the preference background color list.
- *
+ *
* @return preference background color list
*/
public static String[] getPrefBackColorList() {
return Arrays.copyOf(PREF_BACK_COLOR_LIST, PREF_BACK_COLOR_LIST.length);
}
-
+
/**
* Returns the preference foreground color list.
- *
+ *
* @return preference foreground color list
*/
public static String[] getPrefForeColorList() {
return Arrays.copyOf(PREF_FORE_COLOR_LIST, PREF_FORE_COLOR_LIST.length);
}
-
+
/**
* Returns the preference text color list color list.
- *
+ *
* @return preference text color list color list
*/
public static String[] getPrefTextColorList() {