Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjechoi2006-06-30 05:42:56 -0400
committerjechoi2006-06-30 05:42:56 -0400
commit178c5e224f4eb333d111a3608b9892d302d79f30 (patch)
tree4e055ab4a4abb1c5e952a1fccd679a3d96d40a6f
parent6a10dbc011be59647cd34aed7cc2b79f9a8d679d (diff)
downloadwebtools.jsf-178c5e224f4eb333d111a3608b9892d302d79f30.tar.gz
webtools.jsf-178c5e224f4eb333d111a3608b9892d302d79f30.tar.xz
webtools.jsf-178c5e224f4eb333d111a3608b9892d302d79f30.zip
bug fix 124354: Out of SWT Handles Error
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java45
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java4
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties3
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java3
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java16
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java48
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java80
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java2
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java24
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java2
10 files changed, 121 insertions, 106 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java
index 976cb0167..bfb53c43e 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java
@@ -69,7 +69,9 @@ import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.util.TransferDropTargetListener;
@@ -99,6 +101,7 @@ import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -1044,8 +1047,7 @@ public class PageflowEditor extends GraphicalEditorWithFlyoutPalette implements
if (property == null || GEMPreferences.LINE_LABEL_FONT.equals(property)
|| GEMPreferences.LINE_LABEL_FONT_COLOR.equals(property)) {
- Font linkLabelFont = new Font(null, PreferenceConverter
- .getFontData(store, GEMPreferences.LINE_LABEL_FONT));
+ Font linkLabelFont = getLinkLabelFont();
Color linkLabelFgColor = GEMPreferences.getColor(store,
GEMPreferences.LINE_LABEL_FONT_COLOR);
if (part instanceof IConnectionPreference) {
@@ -1085,8 +1087,7 @@ public class PageflowEditor extends GraphicalEditorWithFlyoutPalette implements
if (property == null
|| GEMPreferences.FIGURE_LABEL_FONT.equals(property)
|| GEMPreferences.FIGURE_LABEL_FONT_COLOR.equals(property)) {
- Font nodeLabelFont = new Font(null, PreferenceConverter
- .getFontData(store, GEMPreferences.FIGURE_LABEL_FONT));
+ Font nodeLabelFont = getNodeLabelFont();
Color nodeLabelFgColor = GEMPreferences.getColor(store,
GEMPreferences.FIGURE_LABEL_FONT_COLOR);
@@ -1102,20 +1103,44 @@ public class PageflowEditor extends GraphicalEditorWithFlyoutPalette implements
.getString(GEMPreferences.LABEL_PLACEMENT);
if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(nodeLabelPlacement))
placement = PositionConstants.NORTH;
- if (GEMPreferences.LABEL_PLACEMENT_BOTTOM
+ else if (GEMPreferences.LABEL_PLACEMENT_BOTTOM
.equals(nodeLabelPlacement))
placement = PositionConstants.SOUTH;
- if (GEMPreferences.LABEL_PLACEMENT_LEFT.equals(nodeLabelPlacement))
+ else if (GEMPreferences.LABEL_PLACEMENT_LEFT
+ .equals(nodeLabelPlacement))
placement = PositionConstants.WEST;
- if (GEMPreferences.LABEL_PLACEMENT_RIGHT.equals(nodeLabelPlacement))
+ else if (GEMPreferences.LABEL_PLACEMENT_RIGHT
+ .equals(nodeLabelPlacement))
placement = PositionConstants.EAST;
-
- if (part instanceof INodePreference) {
+ if (part instanceof INodePreference)
((INodePreference) part).setTextPlacement(placement);
- }
}
}
+ private Font getLinkLabelFont() {
+ FontRegistry registry = JFaceResources.getFontRegistry();
+ IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
+ FontData fontData = PreferenceConverter.getFontData(store,
+ GEMPreferences.LINE_LABEL_FONT);
+ if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
+ return registry.get(fontData.toString());
+
+ registry.put(fontData.toString(), new FontData[] {fontData});
+ return registry.get(fontData.toString());
+ }
+
+ private Font getNodeLabelFont() {
+ FontRegistry registry = JFaceResources.getFontRegistry();
+ IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
+ FontData fontData = PreferenceConverter.getFontData(store,
+ GEMPreferences.FIGURE_LABEL_FONT);
+ if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
+ return registry.get(fontData.toString());
+
+ registry.put(fontData.toString(), new FontData[] {fontData});
+ return registry.get(fontData.toString());
+ }
+
/*
* (non-Javadoc)
*
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java
index d663c41a1..64b31a60d 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java
@@ -10,7 +10,6 @@
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
-
package org.eclipse.jst.jsf.facesconfig.ui.pageflow;
import org.eclipse.osgi.util.NLS;
@@ -187,4 +186,7 @@ public final class PageflowMessages extends NLS {
public static String ExistingPagePathDialogCellEdito_LabelText;
+ public static String PageflowLinkEditPart_FromAction;
+
+ public static String PageflowLinkEditPart_FromOutcome;
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties
index e4509f8ff..e835f51e4 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties
@@ -131,3 +131,6 @@ Pageflow_Validation_MissingManagedBean=The managed bean \''{0}\'' is not defined
Pageflow_Validation_MissingAction=The action should be specified.
ExistingPagePathDialogCellEdito_LabelText = Please enter or select a web page path:
+
+PageflowLinkEditPart_FromAction=fromAction:
+PageflowLinkEditPart_FromOutcome=fromOutcome:
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java
index 7c40d67fd..caf57d87a 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java
@@ -110,6 +110,9 @@ public class PageflowDirectEditManager extends DirectEditManager {
Dimension fontSize = new Dimension(0, data.getHeight());
label.translateToAbsolute(fontSize);
data.setHeight(fontSize.height);
+
+ if (scaledFont != null & !scaledFont.isDisposed())
+ scaledFont.dispose();
scaledFont = new Font(null, data);
text.setFont(scaledFont);
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java
index 979190b40..bf9d4ec31 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
+import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkBendpointEditPolicy;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkEditPolicy;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkEndpointEditPolicy;
@@ -379,24 +380,25 @@ public class PageflowLinkEditPart extends AbstractConnectionEditPart implements
}
public void resetLabel() {
- String tip = "";
+ StringBuffer tip = new StringBuffer();
if (needDrawingAction()) {
((PFLinkFigure) getFigure()).setActionImage();
- tip = "fromAction:(" + ((PageflowLink) getModel()).getFromaction()
- + ") ";
+ tip.append(PageflowMessages.PageflowLinkEditPart_FromAction).append(
+ ((PageflowLink) getModel()).getFromaction());
} else if (((PFLinkFigure) getFigure()).getImage() != getImage(IMG_WARNING)) {
((PFLinkFigure) getFigure()).clearIcon();
- tip = "";
}
if (needDrawingLabel()) {
((PFLinkFigure) getFigure()).setLabel(((PageflowLink) getModel())
.getOutcome());
- tip += "fromOutcome:(";
- tip += ((PageflowLink) getModel()).getOutcome() + ")";
+ if (tip.length() > 0)
+ tip.append("\n");
+ tip.append(PageflowMessages.PageflowLinkEditPart_FromOutcome).append(
+ ((PageflowLink) getModel()).getOutcome());
} else {
((PFLinkFigure) getFigure()).clearOutcome();
}
- ((PFLinkFigure) getFigure()).setToolTipText(tip);
+ ((PFLinkFigure) getFigure()).setToolTipText(tip.toString());
}
/*
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java
index 21339af58..c6522f3df 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java
@@ -19,12 +19,15 @@ import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
/**
@@ -46,9 +49,6 @@ public class PFLinkFigure extends PolylineConnection {
/** The label's foreground color */
private Color labelFgColor;
- /** the label's font */
- private Font labelFont;
-
/** The label's visiblity */
private boolean bLabelVisible = false;
@@ -132,11 +132,10 @@ public class PFLinkFigure extends PolylineConnection {
}
public Image getImage() {
- if (textLabel != null) {
+ if (textLabel != null)
return textLabel.getIcon();
- } else {
+ else
return null;
- }
}
/*
@@ -161,9 +160,8 @@ public class PFLinkFigure extends PolylineConnection {
* @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText()
*/
public String getToolTipText() {
- if (getToolTip() != null) {
+ if (getToolTip() != null)
return ((Label) getToolTip()).getText();
- }
return null;
}
@@ -172,9 +170,8 @@ public class PFLinkFigure extends PolylineConnection {
*
*/
public void setFont(Font f) {
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setFont(f);
- }
super.setFont(f);
}
@@ -183,13 +180,15 @@ public class PFLinkFigure extends PolylineConnection {
*
*/
private Font getLabelFont() {
- if (labelFont == null) {
- IPreferenceStore store = EditorPlugin.getDefault()
- .getPreferenceStore();
- labelFont = new Font(null, PreferenceConverter.getFontData(store,
- GEMPreferences.LINE_LABEL_FONT));
- }
- return labelFont;
+ FontRegistry registry = JFaceResources.getFontRegistry();
+ IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
+ FontData fontData = PreferenceConverter.getFontData(store,
+ GEMPreferences.LINE_LABEL_FONT);
+ if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
+ return registry.get(fontData.toString());
+
+ registry.put(fontData.toString(), new FontData[] {fontData});
+ return registry.get(fontData.toString());
}
/*
@@ -198,9 +197,8 @@ public class PFLinkFigure extends PolylineConnection {
* @see org.eclipse.draw2d.Shape#setLineWidth(int)
*/
public void setLineWidth(int w) {
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setBorderWidth(w);
- }
arrow.setScale(10, getLineWidth() * 2);
super.setLineWidth(w);
}
@@ -221,9 +219,8 @@ public class PFLinkFigure extends PolylineConnection {
* visible or not.
*/
public void setLabelVisible(boolean flag) {
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setVisible(flag);
- }
}
/**
@@ -243,9 +240,8 @@ public class PFLinkFigure extends PolylineConnection {
*/
public void setLabelForegroundColor(Color c) {
labelFgColor = c;
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setForegroundColor(c);
- }
}
/**
@@ -269,9 +265,8 @@ public class PFLinkFigure extends PolylineConnection {
*/
public void setLabelBackgroundColor(Color c) {
labelBgColor = c;
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setBackgroundColor(c);
- }
}
/**
@@ -303,9 +298,8 @@ public class PFLinkFigure extends PolylineConnection {
* color.
*/
public void setForegroundColor(Color c) {
- if (textLabel != null) {
+ if (textLabel != null)
textLabel.setBorderColor(c);
- }
super.setForegroundColor(c);
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java
index 28fb8cff1..32806818c 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java
@@ -26,16 +26,18 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
/**
* The figure for pageflow node, used by pageflow node edit part.
*
- * @author Xiao-guang Zhang
*/
public class PageflowNodeFigure extends Figure {
/** Same connection anchors for source and target */
@@ -53,9 +55,6 @@ public class PageflowNodeFigure extends Figure {
/** the text placement for the label */
private int textPlacement = PositionConstants.SOUTH;
- /** the label's font */
- private Font labelFont;
-
public PageflowNodeFigure() {
setLayoutManager(new FlowLayout());
@@ -70,9 +69,8 @@ public class PageflowNodeFigure extends Figure {
* @return - Source ConnectionAnchor
*/
public ConnectionAnchor getSourceConnectionAnchorAt(Point p) {
- if (getSourceConnectionAnchors().size() == 0) {
+ if (getSourceConnectionAnchors().size() == 0)
return null;
- }
return (ConnectionAnchor) getSourceConnectionAnchors().get(0);
}
@@ -82,9 +80,8 @@ public class PageflowNodeFigure extends Figure {
* @return - Source ConnectionAnchor
*/
public ConnectionAnchor getSourceConnectionAnchor() {
- if (getSourceConnectionAnchors().size() == 0) {
+ if (getSourceConnectionAnchors().size() == 0)
return null;
- }
return (ConnectionAnchor) getSourceConnectionAnchors().get(0);
}
@@ -105,9 +102,8 @@ public class PageflowNodeFigure extends Figure {
* @return - ConnectionAnchor
*/
public ConnectionAnchor getTargetConnectionAnchorAt(Point p) {
- if (getTargetConnectionAnchors().size() == 0) {
+ if (getTargetConnectionAnchors().size() == 0)
return null;
- }
return (ConnectionAnchor) getTargetConnectionAnchors().get(0);
}
@@ -117,9 +113,8 @@ public class PageflowNodeFigure extends Figure {
* @return - ConnectionAnchor
*/
public ConnectionAnchor getTargetConnectionAnchor() {
- if (getTargetConnectionAnchors().size() == 0) {
+ if (getTargetConnectionAnchors().size() == 0)
return null;
- }
return (ConnectionAnchor) getTargetConnectionAnchors().get(0);
}
@@ -157,18 +152,14 @@ public class PageflowNodeFigure extends Figure {
private int getTextPlacement() {
IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
String s = store.getString(GEMPreferences.LABEL_PLACEMENT);
- if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(s)) {
+ if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(s))
textPlacement = PositionConstants.NORTH;
- }
- if (GEMPreferences.LABEL_PLACEMENT_BOTTOM.equals(s)) {
+ else if (GEMPreferences.LABEL_PLACEMENT_BOTTOM.equals(s))
textPlacement = PositionConstants.SOUTH;
- }
- if (GEMPreferences.LABEL_PLACEMENT_LEFT.equals(s)) {
+ else if (GEMPreferences.LABEL_PLACEMENT_LEFT.equals(s))
textPlacement = PositionConstants.WEST;
- }
- if (GEMPreferences.LABEL_PLACEMENT_RIGHT.equals(s)) {
+ else if (GEMPreferences.LABEL_PLACEMENT_RIGHT.equals(s))
textPlacement = PositionConstants.EAST;
- }
return textPlacement;
}
@@ -202,13 +193,15 @@ public class PageflowNodeFigure extends Figure {
* @return
*/
private Font getLabelFont() {
- if (labelFont == null) {
- IPreferenceStore store = EditorPlugin.getDefault()
- .getPreferenceStore();
- labelFont = new Font(null, PreferenceConverter.getFontData(store,
- GEMPreferences.FIGURE_LABEL_FONT));
- }
- return labelFont;
+ FontRegistry registry = JFaceResources.getFontRegistry();
+ IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore();
+ FontData fontData = PreferenceConverter.getFontData(store,
+ GEMPreferences.FIGURE_LABEL_FONT);
+ if (!registry.get(fontData.toString()).equals(registry.defaultFont()))
+ return registry.get(fontData.toString());
+
+ registry.put(fontData.toString(), new FontData[] {fontData});
+ return registry.get(fontData.toString());
}
/**
@@ -220,11 +213,11 @@ public class PageflowNodeFigure extends Figure {
* the label
*/
public void setImageText(Image image, String str) {
- if (image == null) {
+ if (image == null)
setText(str);
- } else if (str == null) {
+ else if (str == null)
setImage(image);
- } else {
+ else {
if (label == null) {
label = new NodeLabel(str, image);
label.setTextPlacement(getTextPlacement());
@@ -246,9 +239,8 @@ public class PageflowNodeFigure extends Figure {
* the image
*/
public void setImage(Image image) {
- if (image == null) {
+ if (image == null)
return;
- }
if (label == null) {
label = new NodeLabel(image);
label.setTextPlacement(getTextPlacement());
@@ -256,9 +248,8 @@ public class PageflowNodeFigure extends Figure {
label.setFont(getLabelFont());
add(label);
initializeConnectionAnchors();
- } else {
+ } else
label.setIcon(image);
- }
}
/**
@@ -268,9 +259,8 @@ public class PageflowNodeFigure extends Figure {
* the text
*/
public void setText(String str) {
- if (str == null) {
+ if (str == null)
return;
- }
if (label == null) {
label = new NodeLabel(str);
label.setTextPlacement(getTextPlacement());
@@ -278,9 +268,8 @@ public class PageflowNodeFigure extends Figure {
label.setFont(getLabelFont());
add(label);
initializeConnectionAnchors();
- } else {
+ } else
label.setText(str);
- }
}
/*
@@ -324,9 +313,8 @@ public class PageflowNodeFigure extends Figure {
*/
public void setBackgroundColor(Color bg) {
labelBgColor = bg;
- if (label != null) {
+ if (label != null)
label.setBackgroundColor(bg);
- }
}
/**
@@ -335,18 +323,16 @@ public class PageflowNodeFigure extends Figure {
public void setForegroundColor(Color fg) {
labelFgColor = fg;
- if (label != null) {
+ if (label != null)
label.setForegroundColor(fg);
- }
}
/**
* Set the label's font
*/
public void setFont(Font f) {
- if (label != null) {
+ if (label != null)
label.setFont(f);
- }
super.setFont(f);
}
@@ -357,9 +343,8 @@ public class PageflowNodeFigure extends Figure {
*/
public void setTextPlacement(int where) {
textPlacement = where;
- if (label != null) {
+ if (label != null)
label.setTextPlacement(where);
- }
}
/*
@@ -384,9 +369,8 @@ public class PageflowNodeFigure extends Figure {
* @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText()
*/
public String getToolTipText() {
- if (getToolTip() != null) {
+ if (getToolTip() != null)
return ((Label) getToolTip()).getText();
- }
return null;
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java
index b558a025c..c11bf0512 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java
@@ -1 +1 @@
-/******************************************************************************* * Copyright (c) 2004, 2006 Sybase, Inc. and others. * * 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: * Sybase, Inc. - initial API and implementation *******************************************************************************/ package org.eclipse.jst.jsf.facesconfig.ui.preference; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.StringConverter; import org.eclipse.jface.util.Assert; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; /** * * A field editor for a font type preference. * */ public class ColorFontFieldEditor extends FieldEditor { /** * * The change font button, or <code>null</code> if none * * (before creation and after disposal). * */ private Button changeFontButton = null; /** * * The text for the change font button, or <code>null</code> * * if missing. * */ private String changeButtonText; /** * * The text for the preview, or <code>null</code> if no preview is desired * */ private String previewText; /** * * Font data for the chosen font button, or <code>null</code> if none. * */ private FontData[] chosenFont; /** * * Font color for the chosen font * */ private RGB fontRGB; /** * * The label that displays the selected font, or <code>null</code> if * none. * */ private Label valueControl; /** * * The previewer, or <code>null</code> if none. * */ private DefaultPreviewer previewer; /** * * Internal font previewer implementation. * */ private static class DefaultPreviewer { private Text text; private String string; private Font font; public DefaultPreviewer(String s, Composite parent) { string = s; text = new Text(parent, SWT.READ_ONLY | SWT.BORDER); text.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (font != null) font.dispose(); } }); if (string != null) text.setText(string); } public Control getControl() { return text; } public void setFont(FontData[] fontData) { if (font != null) font.dispose(); font = new Font(text.getDisplay(), fontData); text.setFont(font); } public void setRGB(RGB fontRGB) { if (fontRGB != null) text.setForeground(new Color(null, fontRGB)); } public int getPreferredExtent() { return 40; } } /** * * Creates a new font field editor * */ protected ColorFontFieldEditor() { } /** * * Creates a font field editor with an optional preview area. * * * * @param name * the name of the preference this field editor works on * * @param labelText * the label text of the field editor * * @param previewAreaText * the text used for the preview window. If it is * * <code>null</code> there will be no preview area, * * @param parent * the parent of the field editor's control * */ public ColorFontFieldEditor( String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); } /** * * Creates a font field editor without a preview. * * * * @param name * the name of the preference this field editor works on * * @param labelText * the label text of the field editor * * @param parent * the parent of the field editor's control * */ public ColorFontFieldEditor(String name, String labelText, Composite parent) { this(name, labelText, null, parent); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void adjustForNumColumns(int numColumns) { GridData data = new GridData(); if (valueControl.getLayoutData() != null) data = (GridData) valueControl.getLayoutData(); data.horizontalSpan = numColumns - getNumberOfControls() + 1; valueControl.setLayoutData(data); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void applyFont() { if (chosenFont != null && previewer != null) previewer.setFont(chosenFont); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doFillIntoGrid(Composite parent, int numColumns) { getLabelControl(parent); valueControl = getValueControl(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan = numColumns - getNumberOfControls() + 1; valueControl.setLayoutData(gd); if (previewText != null) { previewer = new DefaultPreviewer(previewText, parent); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = previewer.getPreferredExtent(); gd.widthHint = previewer.getPreferredExtent(); previewer.getControl().setLayoutData(gd); } changeFontButton = getChangeControl(parent); gd = new GridData(); gd.heightHint = convertVerticalDLUsToPixels( changeFontButton, IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels( changeFontButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max( widthHint, changeFontButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); changeFontButton.setLayoutData(gd); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doLoad() { if (changeFontButton == null) return; fontRGB = PreferenceConverter.getColor( getPreferenceStore(), getPreferenceName() + "Color"); updateFont( PreferenceConverter.getFontDataArray( getPreferenceStore(), getPreferenceName())); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doLoadDefault() { if (changeFontButton == null) return; updateFont( PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(), getPreferenceName())); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doStore() { if (chosenFont != null) { PreferenceConverter.setValue( getPreferenceStore(), getPreferenceName(), chosenFont); } if (fontRGB != null) { PreferenceConverter.setValue( getPreferenceStore(), getPreferenceName() + "Color", fontRGB); } } /** * * Returns the change button for this field editor. * * * * @return the change button * */ protected Button getChangeControl(Composite parent) { if (changeFontButton == null) { changeFontButton = new Button(parent, SWT.PUSH); if (changeButtonText != null) changeFontButton.setText(changeButtonText); changeFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog fontDialog = new FontDialog(changeFontButton.getShell()); if (chosenFont != null) fontDialog.setFontList(chosenFont); if (fontRGB != null) fontDialog.setRGB(fontRGB); FontData font = fontDialog.open(); if (font != null) { FontData[] oldFont = chosenFont; if (oldFont == null) oldFont = JFaceResources.getDefaultFont() .getFontData(); setPresentsDefaultValue(false); FontData[] newData = new FontData[1]; newData[0] = font; fontRGB = fontDialog.getRGB(); updateFont(newData); fireValueChanged(VALUE, oldFont[0], font); } } }); changeFontButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { changeFontButton = null; } }); changeFontButton.setFont(parent.getFont()); setButtonLayoutData(changeFontButton); } else { checkParent(changeFontButton, parent); } return changeFontButton; } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ public int getNumberOfControls() { if (previewer == null) return 3; else return 4; } /** * * Returns the preferred preview height. * * * * @return the height, or <code>-1</code> if no previewer * * is installed * */ public int getPreferredPreviewHeight() { if (previewer == null) return -1; return previewer.getPreferredExtent(); } /** * * Returns the preview control for this field editor. * * * * @return the preview control * */ public Control getPreviewControl() { if (previewer == null) return null; return previewer.getControl(); } /** * * Returns the value control for this field editor. The value control * * displays the currently selected font name. * * * * @return the value control * */ protected Label getValueControl(Composite parent) { if (valueControl == null) { valueControl = new Label(parent, SWT.LEFT); valueControl.setFont(parent.getFont()); valueControl.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { valueControl = null; } }); } else { checkParent(valueControl, parent); } return valueControl; } /** * * Sets the text of the change button. * * * * @param text * the new text * */ public void setChangeButtonText(String text) { Assert.isNotNull(text); changeButtonText = text; if (changeFontButton != null) changeFontButton.setText(text); } /** * * Updates the change font button and the previewer to reflect the * * newly selected font. * */ private void updateFont(FontData font[]) { FontData[] bestFont = JFaceResources.getFontRegistry().bestDataArray( font, valueControl.getDisplay()); // if we have nothing valid do as best we can if (bestFont == null) bestFont = getDefaultFontData(); // Now cache this value in the receiver this.chosenFont = bestFont; if (valueControl != null) { if (fontRGB != null) valueControl.setForeground(new Color(null, fontRGB)); valueControl.setText(StringConverter.asString(chosenFont[0])); } if (previewer != null) { previewer.setFont(bestFont); } } /** * * Store the default preference for the field * * being edited * */ protected void setToDefault() { FontData[] defaultFontData = PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(), getPreferenceName()); PreferenceConverter.setValue( getPreferenceStore(), getPreferenceName(), defaultFontData); } /** * * Get the system default font data. * */ private FontData[] getDefaultFontData() { return valueControl.getDisplay().getSystemFont().getFontData(); } /* * * @see FieldEditor.setEnabled(boolean,Composite). * */ public void setEnabled(boolean enabled, Composite parent) { super.setEnabled(enabled, parent); getChangeControl(parent).setEnabled(enabled); getValueControl(parent).setEnabled(enabled); } } \ No newline at end of file
+/******************************************************************************* * Copyright (c) 2004, 2006 Sybase, Inc. and others. * * 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: * Sybase, Inc. - initial API and implementation *******************************************************************************/ package org.eclipse.jst.jsf.facesconfig.ui.preference; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.resource.StringConverter; import org.eclipse.jface.util.Assert; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; /** * * A field editor for a font type preference. * */ public class ColorFontFieldEditor extends FieldEditor { /** * * The change font button, or <code>null</code> if none * * (before creation and after disposal). * */ private Button changeFontButton = null; /** * * The text for the change font button, or <code>null</code> * * if missing. * */ private String changeButtonText; /** * * The text for the preview, or <code>null</code> if no preview is desired * */ private String previewText; /** * * Font data for the chosen font button, or <code>null</code> if none. * */ private FontData[] chosenFont; /** * * Font color for the chosen font * */ private RGB fontRGB; /** * * The label that displays the selected font, or <code>null</code> if * none. * */ private Label valueControl; /** * * The previewer, or <code>null</code> if none. * */ private DefaultPreviewer previewer; /** * * Internal font previewer implementation. * */ private static class DefaultPreviewer { private Text text; private String string; private Font font; private Color color; public DefaultPreviewer(String s, Composite parent) { string = s; text = new Text(parent, SWT.READ_ONLY | SWT.BORDER); text.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (font != null) font.dispose(); } }); if (string != null) text.setText(string); } public Control getControl() { return text; } public void setFont(FontData[] fontData) { if (font != null && !font.isDisposed()) font.dispose(); font = new Font(text.getDisplay(), fontData); text.setFont(font); } public void setRGB(RGB fontRGB) { if (fontRGB != null) { if (color != null && !color.isDisposed()) color.dispose(); color = new Color(null, fontRGB); text.setForeground(color); } } public int getPreferredExtent() { return 40; } } /** * * Creates a new font field editor * */ protected ColorFontFieldEditor() { } /** * * Creates a font field editor with an optional preview area. * * * * @param name * the name of the preference this field editor works on * * @param labelText * the label text of the field editor * * @param previewAreaText * the text used for the preview window. If it is * * <code>null</code> there will be no preview area, * * @param parent * the parent of the field editor's control * */ public ColorFontFieldEditor( String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); } /** * * Creates a font field editor without a preview. * * * * @param name * the name of the preference this field editor works on * * @param labelText * the label text of the field editor * * @param parent * the parent of the field editor's control * */ public ColorFontFieldEditor(String name, String labelText, Composite parent) { this(name, labelText, null, parent); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void adjustForNumColumns(int numColumns) { GridData data = new GridData(); if (valueControl.getLayoutData() != null) data = (GridData) valueControl.getLayoutData(); data.horizontalSpan = numColumns - getNumberOfControls() + 1; valueControl.setLayoutData(data); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void applyFont() { if (chosenFont != null && previewer != null) previewer.setFont(chosenFont); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doFillIntoGrid(Composite parent, int numColumns) { getLabelControl(parent); valueControl = getValueControl(parent); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan = numColumns - getNumberOfControls() + 1; valueControl.setLayoutData(gd); if (previewText != null) { previewer = new DefaultPreviewer(previewText, parent); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = previewer.getPreferredExtent(); gd.widthHint = previewer.getPreferredExtent(); previewer.getControl().setLayoutData(gd); } changeFontButton = getChangeControl(parent); gd = new GridData(); gd.heightHint = convertVerticalDLUsToPixels(changeFontButton, IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(changeFontButton, IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, changeFontButton.computeSize( SWT.DEFAULT, SWT.DEFAULT, true).x); changeFontButton.setLayoutData(gd); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doLoad() { if (changeFontButton == null) return; fontRGB = PreferenceConverter.getColor(getPreferenceStore(), getPreferenceName() + "Color"); updateFont(PreferenceConverter.getFontDataArray(getPreferenceStore(), getPreferenceName())); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doLoadDefault() { if (changeFontButton == null) return; updateFont(PreferenceConverter.getDefaultFontDataArray( getPreferenceStore(), getPreferenceName())); } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ protected void doStore() { if (chosenFont != null) { PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), chosenFont); } if (fontRGB != null) { PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName() + "Color", fontRGB); } } /** * * Returns the change button for this field editor. * * * * @return the change button * */ protected Button getChangeControl(Composite parent) { if (changeFontButton == null) { changeFontButton = new Button(parent, SWT.PUSH); if (changeButtonText != null) changeFontButton.setText(changeButtonText); changeFontButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { FontDialog fontDialog = new FontDialog(changeFontButton .getShell()); if (chosenFont != null) fontDialog.setFontList(chosenFont); if (fontRGB != null) fontDialog.setRGB(fontRGB); FontData font = fontDialog.open(); if (font != null) { FontData[] oldFont = chosenFont; if (oldFont == null) oldFont = JFaceResources.getDefaultFont() .getFontData(); setPresentsDefaultValue(false); FontData[] newData = new FontData[1]; newData[0] = font; fontRGB = fontDialog.getRGB(); updateFont(newData); fireValueChanged(VALUE, oldFont[0], font); } } }); changeFontButton.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { changeFontButton = null; } }); changeFontButton.setFont(parent.getFont()); setButtonLayoutData(changeFontButton); } else checkParent(changeFontButton, parent); return changeFontButton; } /* * (non-Javadoc) * * Method declared on FieldEditor. * */ public int getNumberOfControls() { if (previewer == null) return 3; else return 4; } /** * * Returns the preferred preview height. * * * * @return the height, or <code>-1</code> if no previewer * * is installed * */ public int getPreferredPreviewHeight() { if (previewer == null) return -1; return previewer.getPreferredExtent(); } /** * * Returns the preview control for this field editor. * * * * @return the preview control * */ public Control getPreviewControl() { if (previewer == null) return null; return previewer.getControl(); } /** * * Returns the value control for this field editor. The value control * * displays the currently selected font name. * * * * @return the value control * */ protected Label getValueControl(Composite parent) { if (valueControl == null) { valueControl = new Label(parent, SWT.LEFT); valueControl.setFont(parent.getFont()); valueControl.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event) { valueControl = null; } }); } else checkParent(valueControl, parent); return valueControl; } /** * * Sets the text of the change button. * * * * @param text * the new text * */ public void setChangeButtonText(String text) { Assert.isNotNull(text); changeButtonText = text; if (changeFontButton != null) changeFontButton.setText(text); } /** * * Updates the change font button and the previewer to reflect the * * newly selected font. * */ private void updateFont(FontData font[]) { FontData[] bestFont = JFaceResources.getFontRegistry().bestDataArray( font, valueControl.getDisplay()); // if we have nothing valid do as best we can if (bestFont == null) bestFont = getDefaultFontData(); // Now cache this value in the receiver this.chosenFont = bestFont; if (valueControl != null) { if (fontRGB != null) { ColorRegistry registry = JFaceResources.getColorRegistry(); Color color = registry.get(fontRGB.toString()); if (color == null) { registry.put(fontRGB.toString(), fontRGB); color = registry.get(fontRGB.toString()); } valueControl.setForeground(color); } valueControl.setText(StringConverter.asString(chosenFont[0])); } if (previewer != null) { previewer.setFont(bestFont); } } /** * * Store the default preference for the field * * being edited * */ protected void setToDefault() { FontData[] defaultFontData = PreferenceConverter .getDefaultFontDataArray(getPreferenceStore(), getPreferenceName()); PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), defaultFontData); } /** * * Get the system default font data. * */ private FontData[] getDefaultFontData() { return valueControl.getDisplay().getSystemFont().getFontData(); } /* * * @see FieldEditor.setEnabled(boolean,Composite). * */ public void setEnabled(boolean enabled, Composite parent) { super.setEnabled(enabled, parent); getChangeControl(parent).setEnabled(enabled); getValueControl(parent).setEnabled(enabled); } } \ No newline at end of file
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java
index 545db1d66..d21390754 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
-import java.util.Hashtable;
import java.util.Iterator;
import org.eclipse.draw2d.ColorConstants;
@@ -27,6 +26,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.swt.SWT;
@@ -169,7 +170,7 @@ public class GEMPreferences extends FieldEditorPreferencePage implements
// CR392586: resource leaks
// at least keep leaks bounded...
- private static Hashtable resourceRegistry = new Hashtable();
+// private static Hashtable resourceRegistry = new Hashtable();
private class BooleanField extends BooleanFieldEditor {
private Composite parent;
@@ -482,10 +483,11 @@ public class GEMPreferences extends FieldEditorPreferencePage implements
} else {
// CR392586: resource leaks
RGB rgb = PreferenceConverter.getColor(store, property);
- if (resourceRegistry.containsKey(rgb.toString()))
- return (Color) resourceRegistry.get(rgb.toString());
- c = new Color(Display.getCurrent(), rgb);
- resourceRegistry.put(rgb.toString(), c);
+ ColorRegistry registry = JFaceResources.getColorRegistry();
+ if (registry.get(rgb.toString()) != null)
+ return (Color) registry.get(rgb.toString());
+ registry.put(rgb.toString(), rgb);
+ c = registry.get(rgb.toString());
}
return c;
}
@@ -493,12 +495,12 @@ public class GEMPreferences extends FieldEditorPreferencePage implements
// CR392586: resource leaks
public static Font getFont(IPreferenceStore store, String property) {
FontData fd = PreferenceConverter.getFontData(store, property);
- if (resourceRegistry.containsKey(fd.toString()))
- return (Font) resourceRegistry.get(fd.toString());
+ FontRegistry registry = JFaceResources.getFontRegistry();
+ if (!registry.get(fd.toString()).equals(registry.defaultFont()))
+ return registry.get(fd.toString());
- Font f = new Font(null, fd);
- resourceRegistry.put(fd.toString(), f);
- return f;
+ registry.put(fd.toString(), new FontData[] {fd});
+ return registry.get(fd.toString());
}
public static void propagateProperty(String property, Figure fig) {
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java
index 66b0f1876..7ca2927da 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java
@@ -114,7 +114,7 @@ public class TabbedWindowBorder extends FrameBorder {
gc.setClipping(new org.eclipse.swt.graphics.Rectangle(left, top,
right - left, bottom - top));
- Color color = new Color(Display.getDefault(), new RGB(255, 0, 0));
+ Color color = ColorConstants.red;
gc.setForeground(color);
gc.drawLine(left, top, right, bottom);

Back to the top