Author: vyemialyanchyk
Date: 2010-12-22 13:13:05 -0500 (Wed, 22 Dec 2010)
New Revision: 27684
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java
Log:
https://issues.jboss.org/browse/JBIDE-7982 - fixed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java 2010-12-22
18:09:46 UTC (rev 27683)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java 2010-12-22
18:13:05 UTC (rev 27684)
@@ -24,8 +24,7 @@
import java.io.File;
import java.io.Serializable;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
import java.util.Properties;
import org.w3c.dom.Element;
@@ -52,16 +51,20 @@
// TODO: we should move this to some classhandler
static public class ConfigurationMode implements Serializable {
- private static final Map<String, ConfigurationMode> INSTANCES = new
HashMap<String, ConfigurationMode>();
+ private static final ArrayList<ConfigurationMode> INSTANCES = new
ArrayList<ConfigurationMode>();
+ private static final ArrayList<String> LABELS = new ArrayList<String>();
public static final ConfigurationMode CORE = new ConfigurationMode( "CORE" );
//$NON-NLS-1$
public static final ConfigurationMode ANNOTATIONS = new ConfigurationMode(
"ANNOTATIONS" ); //$NON-NLS-1$
public static final ConfigurationMode JPA = new ConfigurationMode( "JPA" );
//$NON-NLS-1$
static {
- INSTANCES.put( CORE.name, CORE );
- INSTANCES.put( ANNOTATIONS.name, ANNOTATIONS );
- INSTANCES.put( JPA.name, JPA );
+ INSTANCES.add(CORE);
+ INSTANCES.add(ANNOTATIONS);
+ INSTANCES.add(JPA);
+ LABELS.add("Core"); //$NON-NLS-1$
+ LABELS.add("Annotations"); //$NON-NLS-1$
+ LABELS.add("JPA"); //$NON-NLS-1$
}
private final String name;
@@ -75,11 +78,22 @@
}
private Object readResolve() {
- return INSTANCES.get( name );
+ Object res = null;
+ for (int i = 0; i < INSTANCES.size() && res == null; i++) {
+ if (INSTANCES.get(i).name.equals(name)) {
+ res = INSTANCES.get(i);
+ }
+ }
+ return res;
}
public static ConfigurationMode parse(String name) {
- ConfigurationMode rtn = INSTANCES.get( name );
+ ConfigurationMode rtn = null;
+ for (int i = 0; i < INSTANCES.size() && rtn == null; i++) {
+ if (INSTANCES.get(i).name.equals(name)) {
+ rtn = INSTANCES.get(i);
+ }
+ }
if ( rtn == null ) {
// default is POJO
rtn = CORE;
@@ -87,9 +101,17 @@
return rtn;
}
- public static String[] values(){
- return INSTANCES.keySet().toArray(new String[INSTANCES.size()]);
+ public static String[] values() {
+ final String[] res = new String[INSTANCES.size()];
+ for (int i = 0; i < INSTANCES.size(); i++) {
+ res[i] = INSTANCES.get(i).name;
+ }
+ return res;
}
+
+ public static String[] labels() {
+ return LABELS.toArray(new String[LABELS.size()]);
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2010-12-22
18:09:46 UTC (rev 27683)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2010-12-22
18:13:05 UTC (rev 27684)
@@ -37,7 +37,6 @@
import org.eclipse.debug.internal.core.LaunchConfiguration;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -63,20 +62,7 @@
ComboBoxPropertyDescriptor modeDescriptor = new ComboBoxPropertyDescriptor(
"mode", //$NON-NLS-1$
HibernateConsoleMessages.ConsoleConfigurationPropertySource_mode,
- ConfigurationMode.values());
- modeDescriptor.setLabelProvider(new LabelProvider(){
-
- @Override
- public String getText(Object element) {
- if (ConfigurationMode.CORE.toString().equals(element)){
- return "Core"; //$NON-NLS-1$
- }
- if (ConfigurationMode.ANNOTATIONS.toString().equals(element)){
- return "Annotations"; //$NON-NLS-1$
- }
- return super.getText(element);
- }
- });
+ ConfigurationMode.labels());
List<IPropertyDescriptor> l = new ArrayList<IPropertyDescriptor>();
l.add(new TextPropertyDescriptor("name",
HibernateConsoleMessages.ConsoleConfigurationPropertySource_name)); //$NON-NLS-1$