diff options
author | cbateman | 2007-01-24 08:07:41 +0000 |
---|---|---|
committer | cbateman | 2007-01-24 08:07:41 +0000 |
commit | a09d20599ba4fc06df998408c63c4a23cbe212f4 (patch) | |
tree | 723507d97b7fdb30c24f10b21ca2517ee9e4f7a3 | |
parent | 2ea8bf456b8a7c0ec3a7b6318e4d5214c17a9ce8 (diff) | |
download | webtools.jsf-a09d20599ba4fc06df998408c63c4a23cbe212f4.tar.gz webtools.jsf-a09d20599ba4fc06df998408c63c4a23cbe212f4.tar.xz webtools.jsf-a09d20599ba4fc06df998408c63c4a23cbe212f4.zip |
Fixed up some deprecated Assert and JavaConventions API calls plus removed some unnecessary casts.
11 files changed, 16 insertions, 15 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java index 1938bcabc..efff345e1 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java @@ -14,9 +14,9 @@ package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; import java.util.Iterator; import java.util.List; +import org.eclipse.core.runtime.Assert; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.util.Assert; import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; import org.eclipse.jst.jsf.facesconfig.emf.FromActionType; import org.eclipse.jst.jsf.facesconfig.emf.FromOutcomeType; diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java index bca363ce8..e78cf0910 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java @@ -14,9 +14,9 @@ package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; import java.util.Iterator; import java.util.List; +import org.eclipse.core.runtime.Assert; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.util.Assert; import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java index c35287462..755c51401 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java @@ -372,14 +372,14 @@ public class PageflowLinkBendpointImpl extends EObjectImpl implements PageflowLi if (eContainerFeatureID >= 0) { switch (eContainerFeatureID) { case PageflowPackage.PF_LINK_BENDPOINT__LINK: - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, PageflowPackage.PF_LINK__BEND_POINTS, PageflowLink.class, msgs); default: return eDynamicBasicRemoveFromContainer(msgs); } } - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java index 73fa755a7..d75ccedd2 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java @@ -443,13 +443,13 @@ public class PageflowLinkImpl extends PageflowElementImpl implements if (eContainerFeatureID >= 0) { switch (eContainerFeatureID) { case PageflowPackage.PF_LINK__PAGEFLOW: - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, PageflowPackage.PAGEFLOW__LINKS, Pageflow.class, msgs); default: return eDynamicBasicRemoveFromContainer(msgs); } } - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java index 42fe7346f..0e86e8706 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java @@ -225,13 +225,13 @@ public abstract class PageflowNodeImpl extends PageflowElementImpl implements if (eContainerFeatureID >= 0) { switch (eContainerFeatureID) { case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, PageflowPackage.PAGEFLOW__NODES, Pageflow.class, msgs); default: return eDynamicBasicRemoveFromContainer(msgs); } } - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java index 105382c41..11d99e1e0 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java @@ -307,13 +307,13 @@ public class PageflowPageImpl extends PageflowNodeImpl implements PageflowPage { if (eContainerFeatureID >= 0) { switch (eContainerFeatureID) { case PageflowPackage.PF_PAGE__PAGEFLOW: - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, PageflowPackage.PAGEFLOW__NODES, Pageflow.class, msgs); default: return eDynamicBasicRemoveFromContainer(msgs); } } - return ((InternalEObject) eContainer).eInverseRemove(this, + return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java index 200e47a21..334b5b418 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java @@ -11,13 +11,13 @@ *******************************************************************************/ package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; +import org.eclipse.core.runtime.Assert; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jface.util.Assert; import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType; diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java index 81f96958a..e59f877dc 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java @@ -16,6 +16,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.core.runtime.Assert; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.AdapterImpl; @@ -23,7 +24,6 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jface.util.Assert; import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; 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 fce8bed93..2bd8d2390 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.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 {
private static final int NUM_CONTROLS_WHEN_PREVIEWER = 4;
private static final int NUM_CONTROLS_WHEN_NO_PREVIEWER = 3;
/**
*
* 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() {
// control instantiation
}
/**
*
* 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();
/* TODO: this constant is deprecated IDialogConstants.BUTTON_HEIGHT but == 14*/
// C.B: I think the correct thing to do is simply to remove this code, since
// the deprecation mechanism says that button height is now determined by layout,
// so setting a heightHint prob won't do anything anyway.
// gd.heightHint = convertVerticalDLUsToPixels(changeFontButton,
// 14 );
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 NUM_CONTROLS_WHEN_NO_PREVIEWER;
}
return NUM_CONTROLS_WHEN_PREVIEWER;
}
/**
*
* 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().filterData(
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 +/*******************************************************************************
* 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.core.runtime.Assert;
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.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 {
private static final int NUM_CONTROLS_WHEN_PREVIEWER = 4;
private static final int NUM_CONTROLS_WHEN_NO_PREVIEWER = 3;
/**
*
* 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() {
// control instantiation
}
/**
*
* 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();
/* TODO: this constant is deprecated IDialogConstants.BUTTON_HEIGHT but == 14*/
// C.B: I think the correct thing to do is simply to remove this code, since
// the deprecation mechanism says that button height is now determined by layout,
// so setting a heightHint prob won't do anything anyway.
// gd.heightHint = convertVerticalDLUsToPixels(changeFontButton,
// 14 );
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 NUM_CONTROLS_WHEN_NO_PREVIEWER;
}
return NUM_CONTROLS_WHEN_PREVIEWER;
}
/**
*
* 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().filterData(
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/ComboFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java index 42114b07e..cb344b36e 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.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.preference.FieldEditor;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* A field editor for a combo box that allows the drop-down selection of one of
* a list of items.
*
*/
public class ComboFieldEditor extends FieldEditor {
/**
*
* The <code>Combo</code> widget.
*
*/
private Combo fCombo;
/**
*
* The value (not the name) of the currently selected item in the Combo
* widget.
*
*/
private String fValue;
/**
*
* The names (labels) and underlying values to populate the combo widget.
* These should be
*
* arranged as: { {name1, value1}, {name2, value2}, ...}
*
*/
private String[][] fEntryNamesAndValues;
public ComboFieldEditor(String name, String labelText,
String[][] entryNamesAndValues, Composite parent) {
init(name, labelText);
Assert.isTrue(checkArray(entryNamesAndValues));
fEntryNamesAndValues = entryNamesAndValues;
createControl(parent);
}
/**
*
* Checks whether given <code>String[][]</code> is of "type"
*
* <code>String[][2]</code>.
*
*
*
* @return <code>true</code> if it is ok, and <code>false</code>
* otherwise
*
*/
private boolean checkArray(String[][] table) {
if (table == null) {
return false;
}
for (int i = 0; i < table.length; i++) {
String[] array = table[i];
if (array == null || array.length != 2) {
return false;
}
}
return true;
}
/**
*
* @see FieldEditor#adjustForNumColumns(int)
*
*/
protected void adjustForNumColumns(int numColumns) {
if (numColumns > 1) {
Control control = getLabelControl();
int left = numColumns;
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
left = left - 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = left;
} else {
Control control = getLabelControl();
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = 1;
}
}
/**
*
* @see FieldEditor#doFillIntoGrid(Composite, int)
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
int comboC = 1;
if (numColumns > 1) {
comboC = numColumns - 1;
}
Control control = getLabelControl(parent);
GridData gd = new GridData();
gd.horizontalSpan = 1;
control.setLayoutData(gd);
control = getComboBoxControl(parent);
gd = new GridData();
gd.horizontalSpan = comboC;
gd.horizontalAlignment = GridData.FILL;
control.setLayoutData(gd);
}
/**
*
* @see FieldEditor#doLoad()
*
*/
protected void doLoad() {
updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
}
/**
*
* @see FieldEditor#doLoadDefault()
*
*/
protected void doLoadDefault() {
updateComboForValue(getPreferenceStore().getDefaultString(
getPreferenceName()));
}
/**
*
* @see FieldEditor#doStore()
*
*/
protected void doStore() {
if (fValue == null) {
getPreferenceStore().setToDefault(getPreferenceName());
return;
}
getPreferenceStore().setValue(getPreferenceName(), fValue);
}
/**
*
* @see FieldEditor#getNumberOfControls()
*
*/
public int getNumberOfControls() {
return 1;
}
/**
*
* Lazily create and return the Combo control.
*
*/
public Combo getComboBoxControl(Composite parent) {
if (fCombo == null) {
fCombo = new Combo(parent, SWT.READ_ONLY);
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
fCombo.add(fEntryNamesAndValues[i][0], i);
}
fCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
String oldValue = fValue;
String name = fCombo.getText();
fValue = getValueForName(name);
setPresentsDefaultValue(false);
fireValueChanged(VALUE, oldValue, fValue);
}
});
}
return fCombo;
}
/**
*
* Given the name (label) of an entry, return the corresponding value.
*
*/
protected String getValueForName(String name) {
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
String[] entry = fEntryNamesAndValues[i];
if (name.equals(entry[0])) {
return entry[1];
}
}
return fEntryNamesAndValues[0][0];
}
/**
*
* Set the name in the combo widget to match the specified value.
*
*/
protected void updateComboForValue(String value) {
fValue = value;
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
if (value.equals(fEntryNamesAndValues[i][1])) {
fCombo.setText(fEntryNamesAndValues[i][0]);
return;
}
}
if (fEntryNamesAndValues.length > 0) {
fValue = fEntryNamesAndValues[0][1];
}
}
}
\ 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.core.runtime.Assert;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* A field editor for a combo box that allows the drop-down selection of one of
* a list of items.
*
*/
public class ComboFieldEditor extends FieldEditor {
/**
*
* The <code>Combo</code> widget.
*
*/
private Combo fCombo;
/**
*
* The value (not the name) of the currently selected item in the Combo
* widget.
*
*/
private String fValue;
/**
*
* The names (labels) and underlying values to populate the combo widget.
* These should be
*
* arranged as: { {name1, value1}, {name2, value2}, ...}
*
*/
private String[][] fEntryNamesAndValues;
public ComboFieldEditor(String name, String labelText,
String[][] entryNamesAndValues, Composite parent) {
init(name, labelText);
Assert.isTrue(checkArray(entryNamesAndValues));
fEntryNamesAndValues = entryNamesAndValues;
createControl(parent);
}
/**
*
* Checks whether given <code>String[][]</code> is of "type"
*
* <code>String[][2]</code>.
*
*
*
* @return <code>true</code> if it is ok, and <code>false</code>
* otherwise
*
*/
private boolean checkArray(String[][] table) {
if (table == null) {
return false;
}
for (int i = 0; i < table.length; i++) {
String[] array = table[i];
if (array == null || array.length != 2) {
return false;
}
}
return true;
}
/**
*
* @see FieldEditor#adjustForNumColumns(int)
*
*/
protected void adjustForNumColumns(int numColumns) {
if (numColumns > 1) {
Control control = getLabelControl();
int left = numColumns;
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
left = left - 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = left;
} else {
Control control = getLabelControl();
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = 1;
}
}
/**
*
* @see FieldEditor#doFillIntoGrid(Composite, int)
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
int comboC = 1;
if (numColumns > 1) {
comboC = numColumns - 1;
}
Control control = getLabelControl(parent);
GridData gd = new GridData();
gd.horizontalSpan = 1;
control.setLayoutData(gd);
control = getComboBoxControl(parent);
gd = new GridData();
gd.horizontalSpan = comboC;
gd.horizontalAlignment = GridData.FILL;
control.setLayoutData(gd);
}
/**
*
* @see FieldEditor#doLoad()
*
*/
protected void doLoad() {
updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
}
/**
*
* @see FieldEditor#doLoadDefault()
*
*/
protected void doLoadDefault() {
updateComboForValue(getPreferenceStore().getDefaultString(
getPreferenceName()));
}
/**
*
* @see FieldEditor#doStore()
*
*/
protected void doStore() {
if (fValue == null) {
getPreferenceStore().setToDefault(getPreferenceName());
return;
}
getPreferenceStore().setValue(getPreferenceName(), fValue);
}
/**
*
* @see FieldEditor#getNumberOfControls()
*
*/
public int getNumberOfControls() {
return 1;
}
/**
*
* Lazily create and return the Combo control.
*
*/
public Combo getComboBoxControl(Composite parent) {
if (fCombo == null) {
fCombo = new Combo(parent, SWT.READ_ONLY);
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
fCombo.add(fEntryNamesAndValues[i][0], i);
}
fCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
String oldValue = fValue;
String name = fCombo.getText();
fValue = getValueForName(name);
setPresentsDefaultValue(false);
fireValueChanged(VALUE, oldValue, fValue);
}
});
}
return fCombo;
}
/**
*
* Given the name (label) of an entry, return the corresponding value.
*
*/
protected String getValueForName(String name) {
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
String[] entry = fEntryNamesAndValues[i];
if (name.equals(entry[0])) {
return entry[1];
}
}
return fEntryNamesAndValues[0][0];
}
/**
*
* Set the name in the combo widget to match the specified value.
*
*/
protected void updateComboForValue(String value) {
fValue = value;
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
if (value.equals(fEntryNamesAndValues[i][1])) {
fCombo.setText(fEntryNamesAndValues[i][0]);
return;
}
}
if (fEntryNamesAndValues.length > 0) {
fValue = fEntryNamesAndValues[0][1];
}
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java index 04b59c3a7..7fed98fa3 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java +++ b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java @@ -13,6 +13,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaConventions; +import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; @@ -260,7 +261,7 @@ public class ManagedBeanClassSelectionPage extends WizardPage { } else { // ensure the name follows the java conventsions. status = JavaConventions - .validateJavaTypeName(classSearchDialogField.getText()); + .validateJavaTypeName(classSearchDialogField.getText(), CompilerOptions.VERSION_1_3,CompilerOptions.VERSION_1_3); if (status.getSeverity() != IStatus.ERROR) { // ensure the input or selected type is defined in the current // project |