Author: vyemialyanchyk
Date: 2010-12-24 09:58:28 -0500 (Fri, 24 Dec 2010)
New Revision: 27714
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationPropertySource.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySourceProvider.java
Log:
https://issues.jboss.org/browse/JBIDE-7990 - fixed
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationPropertySource.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationPropertySource.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationPropertySource.java 2010-12-24
14:58:28 UTC (rev 27714)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.views;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * Responsible to provide Hibernate configuration
+ * properties for Properties View.
+ * Properties are not editable - just to view.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ConfigurationPropertySource implements IPropertySource {
+
+ private Configuration cfg;
+
+ public ConfigurationPropertySource(Configuration cfg) {
+ this.cfg = cfg;
+ }
+
+ public Object getEditableValue() {
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ final Properties props = cfg.getProperties();
+ IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[props.size()];
+ int i = 0;
+ for (Map.Entry prop : props.entrySet()) {
+ propertyDescriptors[i++] = new PropertyDescriptor(prop.getKey(),
prop.getKey().toString());
+ }
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ final Properties props = cfg.getProperties();
+ return props.get(id);
+ }
+
+ public boolean isPropertySet(Object id) {
+ return true;
+ }
+
+ public void resetPropertyValue(Object id) {
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySourceProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySourceProvider.java 2010-12-23
19:16:56 UTC (rev 27713)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySourceProvider.java 2010-12-24
14:58:28 UTC (rev 27714)
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
+import org.hibernate.cfg.Configuration;
import org.hibernate.console.ConsoleConfiguration;
public class ConsoleConfigurationPropertySourceProvider implements
@@ -36,6 +37,9 @@
if (object instanceof ConsoleConfiguration) {
return new ConsoleConfigurationPropertySource((ConsoleConfiguration)object);
}
+ if (object instanceof Configuration) {
+ return new ConfigurationPropertySource((Configuration)object);
+ }
return (IPropertySource) Platform.getAdapterManager().getAdapter(object,
IPropertySource.class);
}