JBoss Tools SVN: r28293 - in branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui: view and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2011-01-17 07:52:20 -0500 (Mon, 17 Jan 2011)
New Revision: 28293
Added:
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java
Modified:
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
Log:
https://issues.jboss.org/browse/JBIDE-8084 - fixed
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -20,8 +20,8 @@
*/
public class ComponentShape extends ExpandableShape {
- public ComponentShape(Object ioe) {
- super(ioe);
+ public ComponentShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
initModel();
}
@@ -32,10 +32,10 @@
Object ormElement = getOrmElement();
if (ormElement instanceof Property) {
Collection collection = (Collection)((Property)ormElement).getValue();
- Shape bodyOrmShape = new Shape(collection.getKey());
+ Shape bodyOrmShape = new Shape(collection.getKey(), getConsoleConfigName());
bodyOrmShape.setIndent(20);
addChild(bodyOrmShape);
- bodyOrmShape = new Shape(collection.getElement());
+ bodyOrmShape = new Shape(collection.getElement(), getConsoleConfigName());
bodyOrmShape.setIndent(20);
addChild(bodyOrmShape);
}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -16,9 +16,9 @@
import java.util.Iterator;
import java.util.Set;
-import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -44,13 +44,13 @@
*/
public class ElementsFactory {
- private final Configuration config;
+ private final String consoleConfigName;
private final HashMap<String, OrmShape> elements;
private final ArrayList<Connection> connections;
- public ElementsFactory(Configuration config, HashMap<String, OrmShape> elements,
+ public ElementsFactory(String consoleConfigName, HashMap<String, OrmShape> elements,
ArrayList<Connection> connections) {
- this.config = config;
+ this.consoleConfigName = consoleConfigName;
this.elements = elements;
this.connections = connections;
}
@@ -117,13 +117,9 @@
OrmShape s = null;
Property property = (Property)element;
if (!property.isComposite()) {
- Type type = null;
- try {
- type = property.getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
+ final Configuration config = getConfig();
+ //
+ Type type = UtilTypeExtract.getTypeUsingExecContext(property.getValue(), getConsoleConfig());
if (type != null && type.isEntityType()) {
EntityType et = (EntityType) type;
Object clazz = config != null ?
@@ -245,6 +241,7 @@
tableShape = getShape(databaseTable);
if (tableShape == null) {
tableShape = createShape(databaseTable);
+ final Configuration config = getConfig();
if (config != null) {
Iterator iterator = config.getClassMappings();
while (iterator.hasNext()) {
@@ -426,14 +423,14 @@
String key = Utils.getName(specialRootClass.getEntityName());
ormShape = elements.get(key);
if (null == ormShape) {
- ormShape = new SpecialOrmShape(specialRootClass);
+ ormShape = new SpecialOrmShape(specialRootClass, consoleConfigName);
elements.put(key, ormShape);
}
} else {
String key = Utils.getName(ormElement);
ormShape = elements.get(key);
if (null == ormShape) {
- ormShape = new OrmShape(ormElement);
+ ormShape = new OrmShape(ormElement, consoleConfigName);
elements.put(key, ormShape);
}
}
@@ -523,4 +520,19 @@
}
return true;
}
+
+ public ConsoleConfiguration getConsoleConfig() {
+ final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
+ return consoleConfig;
+ }
+
+ public Configuration getConfig() {
+ Configuration config = null;
+ final ConsoleConfiguration consoleConfig = getConsoleConfig();
+ if (consoleConfig != null) {
+ config = consoleConfig.getConfiguration();
+ }
+ return config;
+ }
}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -25,8 +25,8 @@
protected boolean expanded = true;
- public ExpandableShape(Object ioe) {
- super(ioe);
+ public ExpandableShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
}
public boolean isExpanded() {
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -16,8 +16,8 @@
*/
public class MessageShape extends OrmShape {
- protected MessageShape(String error) {
- super(error);
+ protected MessageShape(String error, String consoleConfigName) {
+ super(error, consoleConfigName);
}
@Override
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -219,7 +219,7 @@
StringBuilder errorMessage = new StringBuilder();
Configuration config = getConfig(errorMessage);
final ElementsFactory factory = new ElementsFactory(
- config, elements, connections);
+ consoleConfigName, elements, connections);
for (int i = 0; i < roots.size(); i++) {
RootClass rc = roots.get(i);
if (rc != null) {
@@ -242,7 +242,7 @@
if (errorMessage.length() > 0) {
error = errorMessage.toString();
}
- addChild(new MessageShape(error));
+ addChild(new MessageShape(error, getConsoleConfigName()));
}
}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -26,6 +26,8 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramGuide;
/**
@@ -147,22 +149,22 @@
} // static
- public OrmShape(Object ioe) {
- super(ioe);
+ public OrmShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
initModel();
}
/**
* creates children of the shape,
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
protected void initModel() {
Object ormElement = getOrmElement();
if (ormElement instanceof RootClass) {
RootClass rootClass = (RootClass)ormElement;
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
KeyValue identifier = rootClass.getIdentifier();
@@ -172,7 +174,7 @@
Iterator<Property> iterator = ((Component)identifier).getPropertyIterator();
while (iterator.hasNext()) {
Property property = iterator.next();
- addChild(new Shape(property));
+ addChild(new Shape(property, getConsoleConfigName()));
}
}
}
@@ -182,27 +184,25 @@
Property field = iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
- boolean typeIsAccessible = true;
- if (field.getValue().isSimpleValue() && ((SimpleValue)field.getValue()).isTypeSpecified()) {
- try {
- field.getValue().getType();
- } catch (Exception e) {
- typeIsAccessible = false;
- }
- }
+ final Value val = field.getValue();
Shape bodyOrmShape = null;
- if (field.getValue().isSimpleValue() && !((SimpleValue)field.getValue()).isTypeSpecified()) {
- bodyOrmShape = new Shape(field);
- } else if (typeIsAccessible && field.getValue() instanceof Collection) {
- bodyOrmShape = new ComponentShape(field);
- } else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ if (val.isSimpleValue() && !((SimpleValue)val).isTypeSpecified()) {
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ if (val instanceof Collection) {
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
+ } else {
+ Type type = getTypeUsingExecContext(val);
+ if (type != null && type.isEntityType()) {
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
+ } else {
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
+ }
+ }
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -212,7 +212,7 @@
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
KeyValue identifier = rootClass.getIdentifier();
@@ -220,7 +220,7 @@
Iterator<Property> iterator = ((Component)identifier).getPropertyIterator();
while (iterator.hasNext()) {
Property property = iterator.next();
- addChild(new Shape(property));
+ addChild(new Shape(property, getConsoleConfigName()));
}
}
@@ -240,17 +240,17 @@
}
Shape bodyOrmShape = null;
if (typeIsAccessible && field.getValue().isSimpleValue()) {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -271,15 +271,15 @@
}
Shape bodyOrmShape = null;
if (typeIsAccessible && property.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(property);
+ bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
} else if (typeIsAccessible && property.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(property);
+ bodyOrmShape = new ComponentShape(property, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(property);
+ bodyOrmShape = new Shape(property, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(property);
+ Shape bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -288,7 +288,7 @@
Iterator iterator = ((Table)getOrmElement()).getColumnIterator();
while (iterator.hasNext()) {
Column column = (Column)iterator.next();
- Shape bodyOrmShape = new Shape(column);
+ Shape bodyOrmShape = new Shape(column, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -17,8 +17,8 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.hibernate.HibernateException;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
@@ -54,6 +54,10 @@
* only one BaseElement offspring has a parent - this is Shape
*/
private BaseElement parent;
+ /**
+ * name of Hibernate Console Configuration
+ */
+ private final String consoleConfigName;
private static IPropertyDescriptor[] descriptors_property;
private static IPropertyDescriptor[] descriptors_column;
@@ -105,8 +109,9 @@
} // static
- protected Shape(Object ioe) {
+ protected Shape(Object ioe, String consoleConfigName) {
ormElement = ioe;
+ this.consoleConfigName = consoleConfigName;
}
@Override
@@ -131,6 +136,10 @@
return res;
}
+ public String getConsoleConfigName() {
+ return consoleConfigName;
+ }
+
public void addConnection(Connection conn) {
if (conn == null || conn.getSource() == conn.getTarget()) {
throw new IllegalArgumentException();
@@ -293,13 +302,7 @@
if (value instanceof Component) {
res = prop.getValue().toString();
} else {
- Type type = null;
- try {
- type = prop.getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
+ Type type = getTypeUsingExecContext(prop.getValue());
if (type != null) {
res = type.getReturnedClass().getName();
}
@@ -360,4 +363,14 @@
}
return toEmptyStr(res);
}
+
+ public ConsoleConfiguration getConsoleConfig() {
+ final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
+ return consoleConfig;
+ }
+
+ public Type getTypeUsingExecContext(final Value val) {
+ return UtilTypeExtract.getTypeUsingExecContext(val, getConsoleConfig());
+ }
}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -12,10 +12,6 @@
import java.util.Iterator;
-import org.hibernate.HibernateException;
-import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.execution.ExecutionContext.Command;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.type.Type;
@@ -27,8 +23,8 @@
public class SpecialOrmShape extends OrmShape {
private Shape parentShape;
- public SpecialOrmShape(SpecialRootClass ioe) {
- super(ioe);
+ public SpecialOrmShape(SpecialRootClass ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
}
/**
@@ -40,12 +36,12 @@
RootClass rootClass = (RootClass)getOrmElement();
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
SpecialRootClass src = (SpecialRootClass)getOrmElement();
if (src.getParentProperty() != null) {
- Shape bodyOrmShape = new Shape(src.getParentProperty());
+ Shape bodyOrmShape = new Shape(src.getParentProperty(), getConsoleConfigName());
addChild(bodyOrmShape);
parentShape = bodyOrmShape;
}
@@ -53,30 +49,14 @@
Iterator<Property> iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
Property field = iterator.next();
- Type type = null;
- if (getOrmDiagram() != null) {
- ConsoleConfiguration cfg = getOrmDiagram().getConsoleConfig();
- final Property fField = field;
- type = (Type) cfg.execute(new Command() {
- public Object execute() {
- return fField.getValue().getType();
- }
- });
- } else {
- try {
- type = field.getValue().getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
- }
+ Type type = getTypeUsingExecContext(field.getValue());
Shape bodyOrmShape = null;
if (type != null && type.isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else if (type != null && type.isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
}
addChild(bodyOrmShape);
}
Added: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java (rev 0)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import org.hibernate.HibernateException;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.execution.ExecutionContext.Command;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.Type;
+
+/**
+ * @author vitali
+ */
+public class UtilTypeExtract {
+
+ public static Type getTypeUsingExecContext(final Value val, final ConsoleConfiguration cfg) {
+ Type type = null;
+ if (val == null) {
+ return type;
+ }
+ try {
+ if (cfg != null) {
+ type = (Type) cfg.execute(new Command() {
+ public Object execute() {
+ return val.getType();
+ }
+ });
+ } else {
+ type = val.getType();
+ }
+ } catch (HibernateException e) {
+ //type is not accessible
+ HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
+ } catch (Exception e) {
+ //type is not accessible
+ // EnumType -> setParameterValues(Properties parameters) in case parameters := null NPE
+ // and this is only way to catch java.lang.reflect.InvocationTargetException
+ HibernateConsolePlugin.getDefault().logErrorMessage("Exception: ", e); //$NON-NLS-1$
+ }
+ return type;
+ }
+
+}
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.ui.view;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Array;
import org.hibernate.mapping.Bag;
@@ -32,6 +33,7 @@
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.UtilTypeExtract;
/**
* Map: ORM object -> Image descriptor
@@ -40,14 +42,14 @@
private OrmImageMap() {}
- public static ImageDescriptor getImageDescriptor(final Object obj) {
+ public static ImageDescriptor getImageDescriptor(final Object obj, final ConsoleConfiguration cfg) {
String imageName = null;
if (obj instanceof Table) {
imageName = getImageName((Table)obj);
} else if (obj instanceof Column) {
imageName = getImageName((Column)obj);
} else if (obj instanceof Property) {
- imageName = getImageName((Property)obj);
+ imageName = getImageName((Property)obj, cfg);
} else if (obj instanceof OneToMany) {
imageName = getImageName((OneToMany)obj);
} else if (obj instanceof SimpleValue) {
@@ -100,7 +102,7 @@
* @param field
* @return
*/
- public static String getImageName(Property field) {
+ public static String getImageName(Property field, final ConsoleConfiguration cfg) {
String str = "Image_PersistentFieldSimple"; //$NON-NLS-1$
if (field == null) {
return str;
@@ -121,12 +123,7 @@
} else if (value instanceof Any) {
str = "Image_PersistentFieldAny"; //$NON-NLS-1$
} else {
- Type type = null;
- try {
- type = field.getType();
- } catch (Exception ex) {
- // ignore it
- }
+ Type type = UtilTypeExtract.getTypeUsingExecContext(value, cfg);
if (type != null && type.isCollectionType()) {
if (value instanceof PrimitiveArray) {
str = "Image_Collection_primitive_array"; //$NON-NLS-1$
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.view;
+import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.workbench.TypeNameValueVisitor;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -21,6 +22,7 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.UtilTypeExtract;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Utils;
/**
@@ -34,14 +36,14 @@
private OrmLabelMap() {}
- public static String getLabel(final Object obj) {
+ public static String getLabel(final Object obj, final ConsoleConfiguration cfg) {
String label = null;
if (obj instanceof Table) {
label = getParticularLabel((Table)obj);
} else if (obj instanceof Column) {
label = getParticularLabel((Column)obj);
} else if (obj instanceof Property) {
- label = getParticularLabel((Property)obj);
+ label = getParticularLabel((Property)obj, cfg);
} else if (obj instanceof OneToMany) {
label = getParticularLabel((OneToMany)obj);
} else if (obj instanceof SimpleValue) {
@@ -80,17 +82,12 @@
return name.toString();
}
- public static String getParticularLabel(Property field) {
+ public static String getParticularLabel(Property field, final ConsoleConfiguration cfg) {
StringBuffer name = new StringBuffer();
name.append(field.getName());
name.append(" :"); //$NON-NLS-1$
String typeString = null;
- Type type = null;
- try {
- type = field.getType();
- } catch (Exception e) {
- // ignore - this is only way to catch java.lang.reflect.InvocationTargetException
- }
+ Type type = UtilTypeExtract.getTypeUsingExecContext(field.getValue(), cfg);
if (type != null && type.getReturnedClass() != null) {
typeString = type.getReturnedClass().getName();
} else {
Modified: branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2011-01-17 12:52:11 UTC (rev 28292)
+++ branches/jbosstools-3.2.0.CR1/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2011-01-17 12:52:20 UTC (rev 28293)
@@ -97,7 +97,7 @@
@Override
public Image getImage(Object element) {
- ImageDescriptor descriptor = OrmImageMap.getImageDescriptor(element);
+ ImageDescriptor descriptor = OrmImageMap.getImageDescriptor(element, getConsoleConfig());
if (descriptor == null) {
return null;
}
@@ -114,7 +114,7 @@
if (obj instanceof Column) {
updateColumnSqlType((Column)obj);
}
- return OrmLabelMap.getLabel(obj);
+ return OrmLabelMap.getLabel(obj, getConsoleConfig());
}
public void dispose() {
15 years, 2 months
JBoss Tools SVN: r28292 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui: view and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2011-01-17 07:52:11 -0500 (Mon, 17 Jan 2011)
New Revision: 28292
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
Log:
https://issues.jboss.org/browse/JBIDE-8084 - fixed
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ComponentShape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -20,8 +20,8 @@
*/
public class ComponentShape extends ExpandableShape {
- public ComponentShape(Object ioe) {
- super(ioe);
+ public ComponentShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
initModel();
}
@@ -32,10 +32,10 @@
Object ormElement = getOrmElement();
if (ormElement instanceof Property) {
Collection collection = (Collection)((Property)ormElement).getValue();
- Shape bodyOrmShape = new Shape(collection.getKey());
+ Shape bodyOrmShape = new Shape(collection.getKey(), getConsoleConfigName());
bodyOrmShape.setIndent(20);
addChild(bodyOrmShape);
- bodyOrmShape = new Shape(collection.getElement());
+ bodyOrmShape = new Shape(collection.getElement(), getConsoleConfigName());
bodyOrmShape.setIndent(20);
addChild(bodyOrmShape);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ElementsFactory.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -16,9 +16,9 @@
import java.util.Iterator;
import java.util.Set;
-import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -44,13 +44,13 @@
*/
public class ElementsFactory {
- private final Configuration config;
+ private final String consoleConfigName;
private final HashMap<String, OrmShape> elements;
private final ArrayList<Connection> connections;
- public ElementsFactory(Configuration config, HashMap<String, OrmShape> elements,
+ public ElementsFactory(String consoleConfigName, HashMap<String, OrmShape> elements,
ArrayList<Connection> connections) {
- this.config = config;
+ this.consoleConfigName = consoleConfigName;
this.elements = elements;
this.connections = connections;
}
@@ -117,13 +117,9 @@
OrmShape s = null;
Property property = (Property)element;
if (!property.isComposite()) {
- Type type = null;
- try {
- type = property.getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
+ final Configuration config = getConfig();
+ //
+ Type type = UtilTypeExtract.getTypeUsingExecContext(property.getValue(), getConsoleConfig());
if (type != null && type.isEntityType()) {
EntityType et = (EntityType) type;
Object clazz = config != null ?
@@ -245,6 +241,7 @@
tableShape = getShape(databaseTable);
if (tableShape == null) {
tableShape = createShape(databaseTable);
+ final Configuration config = getConfig();
if (config != null) {
Iterator iterator = config.getClassMappings();
while (iterator.hasNext()) {
@@ -426,14 +423,14 @@
String key = Utils.getName(specialRootClass.getEntityName());
ormShape = elements.get(key);
if (null == ormShape) {
- ormShape = new SpecialOrmShape(specialRootClass);
+ ormShape = new SpecialOrmShape(specialRootClass, consoleConfigName);
elements.put(key, ormShape);
}
} else {
String key = Utils.getName(ormElement);
ormShape = elements.get(key);
if (null == ormShape) {
- ormShape = new OrmShape(ormElement);
+ ormShape = new OrmShape(ormElement, consoleConfigName);
elements.put(key, ormShape);
}
}
@@ -523,4 +520,19 @@
}
return true;
}
+
+ public ConsoleConfiguration getConsoleConfig() {
+ final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
+ return consoleConfig;
+ }
+
+ public Configuration getConfig() {
+ Configuration config = null;
+ final ConsoleConfiguration consoleConfig = getConsoleConfig();
+ if (consoleConfig != null) {
+ config = consoleConfig.getConfiguration();
+ }
+ return config;
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/ExpandableShape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -25,8 +25,8 @@
protected boolean expanded = true;
- public ExpandableShape(Object ioe) {
- super(ioe);
+ public ExpandableShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
}
public boolean isExpanded() {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/MessageShape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -16,8 +16,8 @@
*/
public class MessageShape extends OrmShape {
- protected MessageShape(String error) {
- super(error);
+ protected MessageShape(String error, String consoleConfigName) {
+ super(error, consoleConfigName);
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -219,7 +219,7 @@
StringBuilder errorMessage = new StringBuilder();
Configuration config = getConfig(errorMessage);
final ElementsFactory factory = new ElementsFactory(
- config, elements, connections);
+ consoleConfigName, elements, connections);
for (int i = 0; i < roots.size(); i++) {
RootClass rc = roots.get(i);
if (rc != null) {
@@ -242,7 +242,7 @@
if (errorMessage.length() > 0) {
error = errorMessage.toString();
}
- addChild(new MessageShape(error));
+ addChild(new MessageShape(error, getConsoleConfigName()));
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmShape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -26,6 +26,8 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.rulers.DiagramGuide;
/**
@@ -147,22 +149,22 @@
} // static
- public OrmShape(Object ioe) {
- super(ioe);
+ public OrmShape(Object ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
initModel();
}
/**
* creates children of the shape,
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
protected void initModel() {
Object ormElement = getOrmElement();
if (ormElement instanceof RootClass) {
RootClass rootClass = (RootClass)ormElement;
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
KeyValue identifier = rootClass.getIdentifier();
@@ -172,7 +174,7 @@
Iterator<Property> iterator = ((Component)identifier).getPropertyIterator();
while (iterator.hasNext()) {
Property property = iterator.next();
- addChild(new Shape(property));
+ addChild(new Shape(property, getConsoleConfigName()));
}
}
}
@@ -182,27 +184,25 @@
Property field = iterator.next();
if (!field.isBackRef()) {
if (!field.isComposite()) {
- boolean typeIsAccessible = true;
- if (field.getValue().isSimpleValue() && ((SimpleValue)field.getValue()).isTypeSpecified()) {
- try {
- field.getValue().getType();
- } catch (Exception e) {
- typeIsAccessible = false;
- }
- }
+ final Value val = field.getValue();
Shape bodyOrmShape = null;
- if (field.getValue().isSimpleValue() && !((SimpleValue)field.getValue()).isTypeSpecified()) {
- bodyOrmShape = new Shape(field);
- } else if (typeIsAccessible && field.getValue() instanceof Collection) {
- bodyOrmShape = new ComponentShape(field);
- } else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ if (val.isSimpleValue() && !((SimpleValue)val).isTypeSpecified()) {
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ if (val instanceof Collection) {
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
+ } else {
+ Type type = getTypeUsingExecContext(val);
+ if (type != null && type.isEntityType()) {
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
+ } else {
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
+ }
+ }
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -212,7 +212,7 @@
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
KeyValue identifier = rootClass.getIdentifier();
@@ -220,7 +220,7 @@
Iterator<Property> iterator = ((Component)identifier).getPropertyIterator();
while (iterator.hasNext()) {
Property property = iterator.next();
- addChild(new Shape(property));
+ addChild(new Shape(property, getConsoleConfigName()));
}
}
@@ -240,17 +240,17 @@
}
Shape bodyOrmShape = null;
if (typeIsAccessible && field.getValue().isSimpleValue()) {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else if (typeIsAccessible && field.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(field);
+ Shape bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -271,15 +271,15 @@
}
Shape bodyOrmShape = null;
if (typeIsAccessible && property.getValue().getType().isEntityType()) {
- bodyOrmShape = new ExpandableShape(property);
+ bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
} else if (typeIsAccessible && property.getValue().getType().isCollectionType()) {
- bodyOrmShape = new ComponentShape(property);
+ bodyOrmShape = new ComponentShape(property, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(property);
+ bodyOrmShape = new Shape(property, getConsoleConfigName());
}
addChild(bodyOrmShape);
} else {
- Shape bodyOrmShape = new ExpandableShape(property);
+ Shape bodyOrmShape = new ExpandableShape(property, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
@@ -288,7 +288,7 @@
Iterator iterator = ((Table)getOrmElement()).getColumnIterator();
while (iterator.hasNext()) {
Column column = (Column)iterator.next();
- Shape bodyOrmShape = new Shape(column);
+ Shape bodyOrmShape = new Shape(column, getConsoleConfigName());
addChild(bodyOrmShape);
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/Shape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -17,8 +17,8 @@
import org.eclipse.ui.IMemento;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.hibernate.HibernateException;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Property;
@@ -54,6 +54,10 @@
* only one BaseElement offspring has a parent - this is Shape
*/
private BaseElement parent;
+ /**
+ * name of Hibernate Console Configuration
+ */
+ private final String consoleConfigName;
private static IPropertyDescriptor[] descriptors_property;
private static IPropertyDescriptor[] descriptors_column;
@@ -105,8 +109,9 @@
} // static
- protected Shape(Object ioe) {
+ protected Shape(Object ioe, String consoleConfigName) {
ormElement = ioe;
+ this.consoleConfigName = consoleConfigName;
}
@Override
@@ -131,6 +136,10 @@
return res;
}
+ public String getConsoleConfigName() {
+ return consoleConfigName;
+ }
+
public void addConnection(Connection conn) {
if (conn == null || conn.getSource() == conn.getTarget()) {
throw new IllegalArgumentException();
@@ -293,13 +302,7 @@
if (value instanceof Component) {
res = prop.getValue().toString();
} else {
- Type type = null;
- try {
- type = prop.getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
+ Type type = getTypeUsingExecContext(prop.getValue());
if (type != null) {
res = type.getReturnedClass().getName();
}
@@ -360,4 +363,14 @@
}
return toEmptyStr(res);
}
+
+ public ConsoleConfiguration getConsoleConfig() {
+ final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
+ return consoleConfig;
+ }
+
+ public Type getTypeUsingExecContext(final Value val) {
+ return UtilTypeExtract.getTypeUsingExecContext(val, getConsoleConfig());
+ }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/SpecialOrmShape.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -12,10 +12,6 @@
import java.util.Iterator;
-import org.hibernate.HibernateException;
-import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.execution.ExecutionContext.Command;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.RootClass;
import org.hibernate.type.Type;
@@ -27,8 +23,8 @@
public class SpecialOrmShape extends OrmShape {
private Shape parentShape;
- public SpecialOrmShape(SpecialRootClass ioe) {
- super(ioe);
+ public SpecialOrmShape(SpecialRootClass ioe, String consoleConfigName) {
+ super(ioe, consoleConfigName);
}
/**
@@ -40,12 +36,12 @@
RootClass rootClass = (RootClass)getOrmElement();
Property identifierProperty = rootClass.getIdentifierProperty();
if (identifierProperty != null) {
- addChild(new Shape(identifierProperty));
+ addChild(new Shape(identifierProperty, getConsoleConfigName()));
}
SpecialRootClass src = (SpecialRootClass)getOrmElement();
if (src.getParentProperty() != null) {
- Shape bodyOrmShape = new Shape(src.getParentProperty());
+ Shape bodyOrmShape = new Shape(src.getParentProperty(), getConsoleConfigName());
addChild(bodyOrmShape);
parentShape = bodyOrmShape;
}
@@ -53,30 +49,14 @@
Iterator<Property> iterator = rootClass.getPropertyIterator();
while (iterator.hasNext()) {
Property field = iterator.next();
- Type type = null;
- if (getOrmDiagram() != null) {
- ConsoleConfiguration cfg = getOrmDiagram().getConsoleConfig();
- final Property fField = field;
- type = (Type) cfg.execute(new Command() {
- public Object execute() {
- return fField.getValue().getType();
- }
- });
- } else {
- try {
- type = field.getValue().getType();
- } catch (HibernateException e) {
- //type is not accessible
- HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
- }
- }
+ Type type = getTypeUsingExecContext(field.getValue());
Shape bodyOrmShape = null;
if (type != null && type.isEntityType()) {
- bodyOrmShape = new ExpandableShape(field);
+ bodyOrmShape = new ExpandableShape(field, getConsoleConfigName());
} else if (type != null && type.isCollectionType()) {
- bodyOrmShape = new ComponentShape(field);
+ bodyOrmShape = new ComponentShape(field, getConsoleConfigName());
} else {
- bodyOrmShape = new Shape(field);
+ bodyOrmShape = new Shape(field, getConsoleConfigName());
}
addChild(bodyOrmShape);
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/UtilTypeExtract.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.jboss.tools.hibernate.ui.diagram.editors.model;
+
+import org.hibernate.HibernateException;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.execution.ExecutionContext.Command;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.Type;
+
+/**
+ * @author vitali
+ */
+public class UtilTypeExtract {
+
+ public static Type getTypeUsingExecContext(final Value val, final ConsoleConfiguration cfg) {
+ Type type = null;
+ if (val == null) {
+ return type;
+ }
+ try {
+ if (cfg != null) {
+ type = (Type) cfg.execute(new Command() {
+ public Object execute() {
+ return val.getType();
+ }
+ });
+ } else {
+ type = val.getType();
+ }
+ } catch (HibernateException e) {
+ //type is not accessible
+ HibernateConsolePlugin.getDefault().logErrorMessage("HibernateException: ", e); //$NON-NLS-1$
+ } catch (Exception e) {
+ //type is not accessible
+ // EnumType -> setParameterValues(Properties parameters) in case parameters := null NPE
+ // and this is only way to catch java.lang.reflect.InvocationTargetException
+ HibernateConsolePlugin.getDefault().logErrorMessage("Exception: ", e); //$NON-NLS-1$
+ }
+ return type;
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.ui.view;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Array;
import org.hibernate.mapping.Bag;
@@ -32,6 +33,7 @@
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
import org.jboss.tools.hibernate.ui.diagram.UiPlugin;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.UtilTypeExtract;
/**
* Map: ORM object -> Image descriptor
@@ -40,14 +42,14 @@
private OrmImageMap() {}
- public static ImageDescriptor getImageDescriptor(final Object obj) {
+ public static ImageDescriptor getImageDescriptor(final Object obj, final ConsoleConfiguration cfg) {
String imageName = null;
if (obj instanceof Table) {
imageName = getImageName((Table)obj);
} else if (obj instanceof Column) {
imageName = getImageName((Column)obj);
} else if (obj instanceof Property) {
- imageName = getImageName((Property)obj);
+ imageName = getImageName((Property)obj, cfg);
} else if (obj instanceof OneToMany) {
imageName = getImageName((OneToMany)obj);
} else if (obj instanceof SimpleValue) {
@@ -100,7 +102,7 @@
* @param field
* @return
*/
- public static String getImageName(Property field) {
+ public static String getImageName(Property field, final ConsoleConfiguration cfg) {
String str = "Image_PersistentFieldSimple"; //$NON-NLS-1$
if (field == null) {
return str;
@@ -121,12 +123,7 @@
} else if (value instanceof Any) {
str = "Image_PersistentFieldAny"; //$NON-NLS-1$
} else {
- Type type = null;
- try {
- type = field.getType();
- } catch (Exception ex) {
- // ignore it
- }
+ Type type = UtilTypeExtract.getTypeUsingExecContext(value, cfg);
if (type != null && type.isCollectionType()) {
if (value instanceof PrimitiveArray) {
str = "Image_Collection_primitive_array"; //$NON-NLS-1$
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelMap.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.hibernate.ui.view;
+import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.workbench.TypeNameValueVisitor;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
@@ -21,6 +22,7 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
import org.hibernate.type.Type;
+import org.jboss.tools.hibernate.ui.diagram.editors.model.UtilTypeExtract;
import org.jboss.tools.hibernate.ui.diagram.editors.model.Utils;
/**
@@ -34,14 +36,14 @@
private OrmLabelMap() {}
- public static String getLabel(final Object obj) {
+ public static String getLabel(final Object obj, final ConsoleConfiguration cfg) {
String label = null;
if (obj instanceof Table) {
label = getParticularLabel((Table)obj);
} else if (obj instanceof Column) {
label = getParticularLabel((Column)obj);
} else if (obj instanceof Property) {
- label = getParticularLabel((Property)obj);
+ label = getParticularLabel((Property)obj, cfg);
} else if (obj instanceof OneToMany) {
label = getParticularLabel((OneToMany)obj);
} else if (obj instanceof SimpleValue) {
@@ -80,17 +82,12 @@
return name.toString();
}
- public static String getParticularLabel(Property field) {
+ public static String getParticularLabel(Property field, final ConsoleConfiguration cfg) {
StringBuffer name = new StringBuffer();
name.append(field.getName());
name.append(" :"); //$NON-NLS-1$
String typeString = null;
- Type type = null;
- try {
- type = field.getType();
- } catch (Exception e) {
- // ignore - this is only way to catch java.lang.reflect.InvocationTargetException
- }
+ Type type = UtilTypeExtract.getTypeUsingExecContext(field.getValue(), cfg);
if (type != null && type.getReturnedClass() != null) {
typeString = type.getReturnedClass().getName();
} else {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2011-01-17 11:49:20 UTC (rev 28291)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java 2011-01-17 12:52:11 UTC (rev 28292)
@@ -97,7 +97,7 @@
@Override
public Image getImage(Object element) {
- ImageDescriptor descriptor = OrmImageMap.getImageDescriptor(element);
+ ImageDescriptor descriptor = OrmImageMap.getImageDescriptor(element, getConsoleConfig());
if (descriptor == null) {
return null;
}
@@ -114,7 +114,7 @@
if (obj instanceof Column) {
updateColumnSqlType((Column)obj);
}
- return OrmLabelMap.getLabel(obj);
+ return OrmLabelMap.getLabel(obj, getConsoleConfig());
}
public void dispose() {
15 years, 2 months
JBoss Tools SVN: r28291 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 06:49:20 -0500 (Mon, 17 Jan 2011)
New Revision: 28291
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
Log:
[JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-17 11:48:35 UTC (rev 28290)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-17 11:49:20 UTC (rev 28291)
@@ -1,3 +1,10 @@
+2011-01-17 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java:
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java:
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java:
+ [JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
+
2011-01-12 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
15 years, 2 months
JBoss Tools SVN: r28290 - branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 06:48:35 -0500 (Mon, 17 Jan 2011)
New Revision: 28290
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
Log:
[JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-17 11:47:20 UTC (rev 28289)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2011-01-17 11:48:35 UTC (rev 28290)
@@ -1,3 +1,10 @@
+2011-01-17 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java:
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java:
+ * src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java:
+ [JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
+
2011-01-12 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
15 years, 2 months
JBoss Tools SVN: r28289 - branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 06:47:20 -0500 (Mon, 17 Jan 2011)
New Revision: 28289
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
Log:
[JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2011-01-17 11:47:20 UTC (rev 28289)
@@ -11,12 +11,14 @@
package org.jboss.tools.deltacloud.ui.views.cloudelements;
import java.beans.PropertyChangeListener;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
@@ -37,25 +39,24 @@
private ICloudElementFilter<CLOUDELEMENT> localFilter;
private TableViewer viewer;
+ private AtomicReference<CLOUDELEMENT[]> elementsReference = new AtomicReference<CLOUDELEMENT[]>();
+
@Override
public Object[] getElements(Object input) {
- /*
- * items are added in asynchronous manner.
- *
- * @see #inputChanged
- *
- * @see #asyncAddCloudElements
- */
- return new Object[] {};
+ try {
+ return filter(getFilter(currentCloud), elementsReference.get());
+ } catch (DeltaCloudException e) {
+ ErrorUtils.handleError(
+ "Error", MessageFormat.format(
+ "Could not filter the elements for cloud \"{0}\"", currentCloud.getName()),
+ e, viewer.getControl().getDisplay().getActiveShell());
+ return new Object[] {};
+ }
}
- public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
- this.localFilter = filter;
- }
-
@Override
public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) {
- if (!(newInput instanceof DeltaCloud || newInput != null)) {
+ if (!(newInput instanceof DeltaCloud)) {
return;
}
Assert.isLegal(viewer instanceof TableViewer);
@@ -63,41 +64,55 @@
removeListener(currentCloud);
this.currentCloud = (DeltaCloud) newInput;
addPropertyChangeListener(currentCloud);
- asyncAddCloudElements(currentCloud);
+ asyncGetCloudElements(currentCloud);
}
- protected void updateCloudElements(CLOUDELEMENT[] elements, DeltaCloud cloud) {
- if (isCurrentCloud(cloud)) {
- addToViewer(elements);
- }
+ protected void setCloudElements(CLOUDELEMENT[] elements) {
+ this.elementsReference.set(elements);
+ refreshViewer();
}
- private boolean isCurrentCloud(final DeltaCloud cloud) {
- return cloud != null
- && currentCloud != null
- && cloud.getName().equals(currentCloud.getName());
- }
-
- protected void addToViewer(final CLOUDELEMENT[] cloudElements) {
+ private void refreshViewer() {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- try {
- clearTableViewer();
- Object[] elements = filter(getFilter(currentCloud), cloudElements);
- viewer.add(elements);
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error", "Could not filter the elements for cloud " + currentCloud.getName(),
- e, Display.getDefault().getActiveShell());
-
- }
+ viewer.refresh();
}
});
}
+ protected boolean isCurrentCloud(final DeltaCloud cloud) {
+ return cloud != null
+ && currentCloud != null
+ && cloud.getName().equals(currentCloud.getName());
+ }
+
+ // protected void addToViewer(final CLOUDELEMENT[] cloudElements) {
+ // viewer.getControl().getDisplay().asyncExec(new Runnable() {
+ //
+ // @Override
+ // public void run() {
+ // try {
+ // clearTableViewer();
+ // Object[] elements = filter(getFilter(currentCloud), cloudElements);
+ // viewer.add(elements);
+ // } catch (DeltaCloudException e) {
+ // // TODO: internationalize strings
+ // ErrorUtils.handleError(
+ // "Error", "Could not filter the elements for cloud " +
+ // currentCloud.getName(),
+ // e, Display.getDefault().getActiveShell());
+ //
+ // }
+ // }
+ // });
+ // }
+
+ public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
+ this.localFilter = filter;
+ }
+
private ICloudElementFilter<CLOUDELEMENT> getFilter(DeltaCloud cloud) {
if (localFilter != null) {
return localFilter;
@@ -130,12 +145,12 @@
}
protected void clearTableViewer() {
- viewer.refresh();
+ viewer.setInput(Collections.emptyList());
}
protected abstract ICloudElementFilter<CLOUDELEMENT> getCloudFilter(DeltaCloud cloud);
- protected abstract void asyncAddCloudElements(DeltaCloud cloud);
+ protected abstract void asyncGetCloudElements(DeltaCloud cloud);
protected abstract void addPropertyChangeListener(DeltaCloud cloud);
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2011-01-17 11:47:20 UTC (rev 28289)
@@ -99,32 +99,36 @@
}
@Override
- protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ protected void asyncGetCloudElements(final DeltaCloud cloud) {
if (cloud == null) {
clearTableViewer();
return;
}
- new AbstractCloudElementJob(
- MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.IMAGES) {
+ if (isCurrentCloud(cloud)) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.IMAGES) {
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- try {
- addToViewer(cloud.getImages());
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- throw e;
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ setCloudElements(cloud.getImages());
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ throw e;
+ }
}
- }
- }.schedule();
+ }.schedule();
+ }
}
@Override
public void propertyChange(PropertyChangeEvent event) {
if (DeltaCloud.PROP_IMAGES.equals(event.getPropertyName())) {
DeltaCloud cloud = (DeltaCloud) event.getSource();
- DeltaCloudImage[] images = (DeltaCloudImage[]) event.getNewValue();
- updateCloudElements(images, cloud);
+ if (isCurrentCloud(cloud)) {
+ DeltaCloudImage[] images = (DeltaCloudImage[]) event.getNewValue();
+ setCloudElements(images);
+ }
}
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2011-01-17 11:47:20 UTC (rev 28289)
@@ -124,32 +124,37 @@
}
@Override
- protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ protected void asyncGetCloudElements(final DeltaCloud cloud) {
if (cloud == null) {
clearTableViewer();
return;
}
- new AbstractCloudElementJob(
- MessageFormat.format("Get instances from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.INSTANCES) {
+ if (isCurrentCloud(cloud)) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get instances from cloud {0}", cloud.getName()), cloud,
+ CLOUDELEMENT.INSTANCES) {
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- try {
- addToViewer(cloud.getInstances());
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- throw e;
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ setCloudElements(cloud.getInstances());
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ throw e;
+ }
}
- }
- }.schedule();
+ }.schedule();
+ }
}
@Override
public void propertyChange(PropertyChangeEvent event) {
if (DeltaCloud.PROP_INSTANCES.equals(event.getPropertyName())) {
DeltaCloud cloud = (DeltaCloud) event.getSource();
- DeltaCloudInstance[] instances = (DeltaCloudInstance[]) event.getNewValue();
- updateCloudElements(instances, cloud);
+ if (isCurrentCloud(cloud)) {
+ DeltaCloudInstance[] instances = (DeltaCloudInstance[]) event.getNewValue();
+ setCloudElements(instances);
+ }
}
}
15 years, 2 months
JBoss Tools SVN: r28288 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 06:47:04 -0500 (Mon, 17 Jan 2011)
New Revision: 28288
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
Log:
[JBIDE-8104] moved to a viewer.refresh() based approach (was: add/remove items manually)
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2011-01-17 09:47:42 UTC (rev 28287)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
@@ -11,12 +11,14 @@
package org.jboss.tools.deltacloud.ui.views.cloudelements;
import java.beans.PropertyChangeListener;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.ICloudElementFilter;
@@ -37,25 +39,24 @@
private ICloudElementFilter<CLOUDELEMENT> localFilter;
private TableViewer viewer;
+ private AtomicReference<CLOUDELEMENT[]> elementsReference = new AtomicReference<CLOUDELEMENT[]>();
+
@Override
public Object[] getElements(Object input) {
- /*
- * items are added in asynchronous manner.
- *
- * @see #inputChanged
- *
- * @see #asyncAddCloudElements
- */
- return new Object[] {};
+ try {
+ return filter(getFilter(currentCloud), elementsReference.get());
+ } catch (DeltaCloudException e) {
+ ErrorUtils.handleError(
+ "Error", MessageFormat.format(
+ "Could not filter the elements for cloud \"{0}\"", currentCloud.getName()),
+ e, viewer.getControl().getDisplay().getActiveShell());
+ return new Object[] {};
+ }
}
- public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
- this.localFilter = filter;
- }
-
@Override
public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) {
- if (!(newInput instanceof DeltaCloud || newInput != null)) {
+ if (!(newInput instanceof DeltaCloud)) {
return;
}
Assert.isLegal(viewer instanceof TableViewer);
@@ -63,41 +64,55 @@
removeListener(currentCloud);
this.currentCloud = (DeltaCloud) newInput;
addPropertyChangeListener(currentCloud);
- asyncAddCloudElements(currentCloud);
+ asyncGetCloudElements(currentCloud);
}
- protected void updateCloudElements(CLOUDELEMENT[] elements, DeltaCloud cloud) {
- if (isCurrentCloud(cloud)) {
- addToViewer(elements);
- }
+ protected void setCloudElements(CLOUDELEMENT[] elements) {
+ this.elementsReference.set(elements);
+ refreshViewer();
}
- private boolean isCurrentCloud(final DeltaCloud cloud) {
- return cloud != null
- && currentCloud != null
- && cloud.getName().equals(currentCloud.getName());
- }
-
- protected void addToViewer(final CLOUDELEMENT[] cloudElements) {
+ private void refreshViewer() {
viewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
- try {
- clearTableViewer();
- Object[] elements = filter(getFilter(currentCloud), cloudElements);
- viewer.add(elements);
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error", "Could not filter the elements for cloud " + currentCloud.getName(),
- e, Display.getDefault().getActiveShell());
-
- }
+ viewer.refresh();
}
});
}
+ protected boolean isCurrentCloud(final DeltaCloud cloud) {
+ return cloud != null
+ && currentCloud != null
+ && cloud.getName().equals(currentCloud.getName());
+ }
+
+ // protected void addToViewer(final CLOUDELEMENT[] cloudElements) {
+ // viewer.getControl().getDisplay().asyncExec(new Runnable() {
+ //
+ // @Override
+ // public void run() {
+ // try {
+ // clearTableViewer();
+ // Object[] elements = filter(getFilter(currentCloud), cloudElements);
+ // viewer.add(elements);
+ // } catch (DeltaCloudException e) {
+ // // TODO: internationalize strings
+ // ErrorUtils.handleError(
+ // "Error", "Could not filter the elements for cloud " +
+ // currentCloud.getName(),
+ // e, Display.getDefault().getActiveShell());
+ //
+ // }
+ // }
+ // });
+ // }
+
+ public void setFilter(ICloudElementFilter<CLOUDELEMENT> filter) {
+ this.localFilter = filter;
+ }
+
private ICloudElementFilter<CLOUDELEMENT> getFilter(DeltaCloud cloud) {
if (localFilter != null) {
return localFilter;
@@ -130,12 +145,12 @@
}
protected void clearTableViewer() {
- viewer.refresh();
+ viewer.setInput(Collections.emptyList());
}
protected abstract ICloudElementFilter<CLOUDELEMENT> getCloudFilter(DeltaCloud cloud);
- protected abstract void asyncAddCloudElements(DeltaCloud cloud);
+ protected abstract void asyncGetCloudElements(DeltaCloud cloud);
protected abstract void addPropertyChangeListener(DeltaCloud cloud);
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2011-01-17 09:47:42 UTC (rev 28287)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/ImageViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
@@ -99,32 +99,36 @@
}
@Override
- protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ protected void asyncGetCloudElements(final DeltaCloud cloud) {
if (cloud == null) {
clearTableViewer();
return;
}
- new AbstractCloudElementJob(
- MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.IMAGES) {
+ if (isCurrentCloud(cloud)) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get images from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.IMAGES) {
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- try {
- addToViewer(cloud.getImages());
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- throw e;
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ setCloudElements(cloud.getImages());
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ throw e;
+ }
}
- }
- }.schedule();
+ }.schedule();
+ }
}
@Override
public void propertyChange(PropertyChangeEvent event) {
if (DeltaCloud.PROP_IMAGES.equals(event.getPropertyName())) {
DeltaCloud cloud = (DeltaCloud) event.getSource();
- DeltaCloudImage[] images = (DeltaCloudImage[]) event.getNewValue();
- updateCloudElements(images, cloud);
+ if (isCurrentCloud(cloud)) {
+ DeltaCloudImage[] images = (DeltaCloudImage[]) event.getNewValue();
+ setCloudElements(images);
+ }
}
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2011-01-17 09:47:42 UTC (rev 28287)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2011-01-17 11:47:04 UTC (rev 28288)
@@ -124,32 +124,37 @@
}
@Override
- protected void asyncAddCloudElements(final DeltaCloud cloud) {
+ protected void asyncGetCloudElements(final DeltaCloud cloud) {
if (cloud == null) {
clearTableViewer();
return;
}
- new AbstractCloudElementJob(
- MessageFormat.format("Get instances from cloud {0}", cloud.getName()), cloud, CLOUDELEMENT.INSTANCES) {
+ if (isCurrentCloud(cloud)) {
+ new AbstractCloudElementJob(
+ MessageFormat.format("Get instances from cloud {0}", cloud.getName()), cloud,
+ CLOUDELEMENT.INSTANCES) {
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- try {
- addToViewer(cloud.getInstances());
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- throw e;
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ setCloudElements(cloud.getInstances());
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ throw e;
+ }
}
- }
- }.schedule();
+ }.schedule();
+ }
}
@Override
public void propertyChange(PropertyChangeEvent event) {
if (DeltaCloud.PROP_INSTANCES.equals(event.getPropertyName())) {
DeltaCloud cloud = (DeltaCloud) event.getSource();
- DeltaCloudInstance[] instances = (DeltaCloudInstance[]) event.getNewValue();
- updateCloudElements(instances, cloud);
+ if (isCurrentCloud(cloud)) {
+ DeltaCloudInstance[] instances = (DeltaCloudInstance[]) event.getNewValue();
+ setCloudElements(instances);
+ }
}
}
15 years, 2 months
JBoss Tools SVN: r28287 - in branches/jbosstools-3.2.0.CR1/deltacloud/plugins: org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 04:47:42 -0500 (Mon, 17 Jan 2011)
New Revision: 28287
Added:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
Removed:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-8096]
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -396,7 +396,7 @@
}
public void deleteKey(String keyname) throws DeltaCloudClientException {
- requestStringResponse(new DeleteKeyRequest(baseUrl, keyname));
+ request(new DeleteKeyRequest(baseUrl, keyname));
}
public List<Key> listKeys() throws DeltaCloudClientException {
Deleted: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
-
-import org.eclipse.core.databinding.conversion.Converter;
-
-/**
- * @author André Dietisheim
- */
-public class BoundObjectPresentConverter extends Converter {
-
- public BoundObjectPresentConverter() {
- super(Object.class, Boolean.class);
- }
-
- @Override
- public Object convert(Object fromObject) {
- return fromObject != null;
- }
-}
Copied: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java (from rev 28147, branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java)
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java (rev 0)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class ObjectNotNullToBoolean extends Converter {
+
+ public ObjectNotNullToBoolean() {
+ super(Object.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null;
+ }
+}
Property changes on: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java (rev 0)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class StringNotEmptyToBoolean extends Converter {
+
+ public StringNotEmptyToBoolean() {
+ super(String.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null
+ && !((String) fromObject).isEmpty();
+ }
+}
Property changes on: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java (rev 0)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import java.io.File;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author André Dietisheim
+ */
+public class ValidWritableFilePathValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value instanceof String) {
+ File file = new File((String) value);
+ if (file.exists() &&
+ file.canWrite()) {
+ return ValidationStatus.ok();
+ }
+ }
+ return ValidationStatus.error("You must choose a valid and writable location");
+ }
+}
Property changes on: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -85,17 +85,21 @@
* the values
*/
public void remove(String... valuesToRemove) {
+ boolean removed = false;
String[] currentValues = get();
if (valuesToRemove != null) {
for (int i = 0; i < currentValues.length; i++) {
for (String valueToRemove : valuesToRemove) {
if (valueToRemove.equals(currentValues[i])) {
currentValues[i] = null;
+ removed = true;
}
}
}
}
- store(currentValues);
+ if (removed) {
+ store(currentValues);
+ }
}
/**
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -12,14 +12,21 @@
import java.text.MessageFormat;
+import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -33,15 +40,24 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
+import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.BoundObjectPresentConverter;
+import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObjectNotNullToBoolean;
+import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ValidWritableFilePathValidator;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
@@ -60,7 +76,6 @@
private final static String CONFIRM_KEY_DELETE_TITLE = "ConfirmKeyDelete.title"; //$NON-NLS-1$
private final static String CONFIRM_KEY_DELETE_MSG = "ConfirmKeyDelete.msg"; //$NON-NLS-1$
- private List keyList;
private ManageKeysPageModel model;
private class Key2IdConverter extends Converter {
@@ -123,33 +138,25 @@
setPageComplete(false);
}
- private void refreshKeys() {
- try {
- Job job = model.refreshKeys();
- WizardUtils.runInWizard(job, getContainer());
- } catch (Exception e) {
- // ignore since the job will report its failure
- }
- }
-
- public DeltaCloudKey getKey() {
- return model.getSelectedKey();
- }
-
@Override
public void createControl(Composite parent) {
DataBindingContext dbc = new DataBindingContext();
// WizardPageSupport.create(this, dbc);
+ bindWizardComplete(dbc);
- bindWizardComplete(dbc);
Composite container = new Composite(parent, SWT.NULL);
- GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false).applyTo(container);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(4).equalWidth(false).applyTo(container);
- this.keyList = createKeyList(dbc, container);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(4, 5).applyTo(keyList);
+ Label keyListLabel = new Label(container, SWT.NULL);
+ keyListLabel.setText("Keys available on the server:");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(keyListLabel);
+ List keyList = createKeyList(dbc, container);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).span(4, 8).hint(100, 200).applyTo(keyList);
+
Button refreshButton = new Button(container, SWT.NULL);
- // TODO: Internationalize strings
refreshButton.setText("Refresh keys");
refreshButton.addSelectionListener(onRefreshPressed());
GridDataFactory.fillDefaults().applyTo(refreshButton);
@@ -157,19 +164,73 @@
Label dummyLabel = new Label(container, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, false).applyTo(dummyLabel);
- Button createButton = new Button(container, SWT.NULL);
- createButton.setText(WizardMessages.getString(NEW));
- createButton.addSelectionListener(onNewPressed());
+ Button createButton = createNewButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(createButton);
Button deleteButton = createDeleteButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(deleteButton);
+ Group localStorageGroup = new Group(container, SWT.BORDER);
+ localStorageGroup.setText("Local Keystore");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(localStorageGroup);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(2).extendedMargins(10, 10, 10, 14).applyTo(localStorageGroup);
+
+ Text keyStoreText = new Text(localStorageGroup, SWT.BORDER);
+ bindKeyStoreText(keyStoreText, dbc);
+ GridDataFactory.fillDefaults()
+ .grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(keyStoreText);
+ addKeyStoreLocationDecoration(keyStoreText, dbc);
+
+ Button keyStoreBrowseButton = new Button(localStorageGroup, SWT.None);
+ keyStoreBrowseButton.addSelectionListener(onKeyStoreLocationBrowse());
+ keyStoreBrowseButton.setText("Choose...");
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER);
+
setControl(container);
refreshKeys();
}
+ private void addKeyStoreLocationDecoration(Text keyStoreText, DataBindingContext dbc) {
+ IObservableValue observable = new WritableValue();
+ Binding binding = dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ observable,
+ new UpdateValueStrategy().setBeforeSetValidator(new ValidWritableFilePathValidator()),
+ new UpdateValueStrategy().setBeforeSetValidator(new ValidWritableFilePathValidator()));
+ ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
+ }
+
+ private Button createNewButton(Composite container, DataBindingContext dbc) {
+ Button newButton = new Button(container, SWT.NULL);
+ newButton.setText(WizardMessages.getString(NEW));
+ newButton.addSelectionListener(onNewPressed());
+ return newButton;
+ }
+
+ private void bindKeyStoreText(Text keyStoreText, DataBindingContext dbc) {
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ BeanProperties.value(ManageKeysPageModel.PROP_KEY_STORE_PATH).observe(model));
+ }
+
+ private SelectionListener onKeyStoreLocationBrowse() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
+ dialog.setFilterPath(model.getKeyStorePath());
+ dialog.setText("Choose a directory to store new keys");
+ String keyStorePath = dialog.open();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ model.setKeyStorePath(keyStorePath);
+ }
+ }
+ };
+ }
+
private Button createDeleteButton(Composite container, DataBindingContext dbc) {
Button deleteButton = new Button(container, SWT.NULL);
deleteButton.setText(WizardMessages.getString(DELETE));
@@ -179,7 +240,7 @@
WidgetProperties.enabled().observe(deleteButton),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
return deleteButton;
}
@@ -188,7 +249,7 @@
BeanProperties.value("pageComplete").observe(this),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
}
private List createKeyList(DataBindingContext dbc, Composite container) {
@@ -200,7 +261,8 @@
new UpdateListStrategy(UpdateSetStrategy.POLICY_NEVER),
new UpdateListStrategy().setConverter(new Key2IdConverter()));
// bind selected key
- dbc.bindValue(WidgetProperties.selection().observe(keyList),
+ dbc.bindValue(
+ WidgetProperties.selection().observe(keyList),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy().setConverter(new Id2KeyConverter()),
new UpdateValueStrategy().setConverter(new Key2IdConverter()));
@@ -231,11 +293,31 @@
};
}
+ private void refreshKeys() {
+ Job job = new AbstractCloudElementJob("Get keys", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ model.refreshKeys();
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not get keys from cloud {0}", getCloud().getName()), e);
+ }
+ }
+ };
+ try {
+ WizardUtils.runInWizard(job, getContainer());
+ } catch (Exception e) {
+ // ignore since the job will report its failure
+ }
+ }
+
private SelectionListener onNewPressed() {
return new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent event) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
// String directoryText = directory.getText();
@@ -245,33 +327,92 @@
d.create();
if (d.open() == InputDialog.OK) {
String keyId = d.getValue();
- createKey(keyId);
+ DeltaCloudKey key = createKey(keyId);
+ storeKeyLocally(key);
}
}
+
};
}
- private void createKey(final String keyId) {
+ private DeltaCloudKey createKey(final String keyId) {
+ final DeltaCloudKey[] keyHolder = new DeltaCloudKey[1];
try {
- model.createKey(keyId);
+ Job job = new AbstractCloudElementJob("Create key", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ keyHolder[0] = model.createKey(keyId);
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not create key \"{0}\"", keyId), e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key \"{0}\"", keyId), e,
- getShell());
+ // ignore
}
+ return keyHolder[0];
}
+ private void storeKeyLocally(DeltaCloudKey key) {
+ try {
+ if (key != null) {
+ boolean store = MessageDialog.openConfirm(getShell(),
+ "Confirm to store the new key",
+ "Do you want to store the key locally and add it to the private keys?");
+ if (store) {
+ model.storeKeyLocally(key);
+ }
+ }
+ } catch (Exception e) {
+ ErrorUtils.handleError("Error", MessageFormat.format(
+ "Could not store key \"{0}\" locally and add it to the ssh private keys", key.getName()),
+ e, getShell());
+ }
+ }
+
private void deleteKey() {
try {
- model.deleteSelectedKey();
+ Job job = new AbstractCloudElementJob("Delete key", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ final DeltaCloudKey key = model.deleteSelectedKey();
+ final boolean[] isConfirmDelete = new boolean[] { false };
+ if (PemFileManager.exists(key.getName(), SshPrivateKeysPreferences.getSshKeyDirectory())) {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ isConfirmDelete[0] = MessageDialog.openConfirm(
+ getShell(),
+ "Delete key locally?",
+ MessageFormat.format(
+ "Shall the key \"{0}\" be deleted from local key store?",
+ key.getName()));
+ }
+ });
+ if (isConfirmDelete[0]) {
+ model.removeKeyLocally(key);
+ }
+ }
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not delete key", model.getSelectedKey().getId()), e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key \"{0}\"", model.getSelectedKey().getId()), e,
- getShell());
+ // ignore
}
}
+
+ public DeltaCloudKey getKey() {
+ return model.getSelectedKey();
+ }
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -10,22 +10,15 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.text.MessageFormat;
+import java.io.File;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
-import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObservableUIPojo;
/**
@@ -37,41 +30,71 @@
public static final String PROP_KEYS = "keys";
public static final String PROP_KEYS_ADDED = "keyAdded";
public static final String PROP_KEYS_REMOVED = "keyRemoved";
+ public static final String PROP_KEY_STORE_PATH = "keyStorePath";
private List<DeltaCloudKey> keys = new ArrayList<DeltaCloudKey>();
private DeltaCloud cloud;
private DeltaCloudKey selectedKey;
+ private String keyStorePath;
public ManageKeysPageModel(DeltaCloud cloud) {
this.cloud = cloud;
- // asyncGetKeys(cloud);
+ this.keyStorePath = initKeyStorePath();
}
- public void deleteSelectedKey() throws DeltaCloudException {
+ private String initKeyStorePath() {
+ try {
+ return SshPrivateKeysPreferences.getSshKeyDirectory();
+ } catch (FileNotFoundException e) {
+ return null;
+ }
+ }
+
+ public DeltaCloudKey deleteSelectedKey() throws DeltaCloudException {
if (selectedKey == null) {
- return;
+ return null;
}
cloud.deleteKey(selectedKey.getId());
int index = keys.indexOf(selectedKey);
keys.remove(selectedKey);
fireIndexedPropertyChange(PROP_KEYS, index, selectedKey, null);
- PemFileManager.delete(selectedKey, SshPrivateKeysPreferences.getKeyStorePath());
+ DeltaCloudKey key = selectedKey;
setSelectedKey(index - 1);
+ return key;
}
- public void createKey(String keyId) throws DeltaCloudException {
+ public void removeKeyLocally(DeltaCloudKey key) throws DeltaCloudException, FileNotFoundException {
+ if (key == null) {
+ return;
+ }
+
+ String keyStorePath = getKeyStorePath();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ File pemFile = PemFileManager.delete(key, keyStorePath);
+ SshPrivateKeysPreferences.remove(pemFile.getAbsolutePath());
+ }
+ }
+
+ public DeltaCloudKey createKey(String keyId) throws DeltaCloudException {
DeltaCloudKey key = cloud.createKey(keyId);
keys.add(key);
int index = keys.indexOf(key);
fireIndexedPropertyChange(PROP_KEYS, index, null, key);
setSelectedKey(key);
- PemFileManager.create(key, SshPrivateKeysPreferences.getKeyStorePath());
+ return key;
}
- public Job refreshKeys() {
- return asyncGetKeys();
+ public void storeKeyLocally(DeltaCloudKey key) throws DeltaCloudException, FileNotFoundException {
+ File pemFile = PemFileManager.create(key, getKeyStorePath());
+ SshPrivateKeysPreferences.add(pemFile.getAbsolutePath());
}
+ public void refreshKeys() throws DeltaCloudException {
+ java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
+ newKeys.addAll(Arrays.asList(cloud.getKeys()));
+ setKeys(newKeys);
+ }
+
public DeltaCloudKey getSelectedKey() {
return selectedKey;
}
@@ -119,7 +142,13 @@
public void setKeys(List<DeltaCloudKey> newKeys) {
firePropertyChange(PROP_KEYS, this.keys, this.keys = newKeys);
- setSelectedKey();
+ /*
+ * need to reset selection since widget looses selection (when items are
+ * set) and property may not fire if no change in selection
+ */
+ DeltaCloudKey key = getSelectedKey();
+ setSelectedKey(null);
+ setSelectedKey(key);
}
public DeltaCloudKey getKey(String keyId) {
@@ -137,24 +166,17 @@
return matchingKey;
}
- private Job asyncGetKeys() {
- Job job = new AbstractCloudElementJob("Get keys", cloud, CLOUDELEMENT.KEYS) {
+ public String getKeyStorePath() {
+ return keyStorePath;
+ }
- protected IStatus doRun(IProgressMonitor monitor) throws Exception {
- try {
- java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
- newKeys.addAll(Arrays.asList(getCloud().getKeys()));
- setKeys(newKeys);
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format("Could not get keys from cloud {0}", getCloud().getName()), e);
- }
- }
+ public void setKeyStorePath(String keyStorePath) {
+ System.err.println(keyStorePath);
+ firePropertyChange(PROP_KEY_STORE_PATH, this.keyStorePath, this.keyStorePath = keyStorePath);
+ }
- };
- job.schedule();
- return job;
+ public DeltaCloud getCloud() {
+ return cloud;
}
+
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -11,13 +11,12 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
+import java.io.FileNotFoundException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.tools.common.jobs.ChainedJob;
@@ -98,59 +97,23 @@
String memory = model.getMemory();
String storage = model.getStorage();
String keyId = model.getKeyId();
- String name = utf8Encode(model.getName());
+ String name = model.getName();
// Save persistent settings for this particular cloud
cloud.setLastImageId(imageId);
cloud.setLastKeyname(keyId);
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
-
boolean result = false;
Exception e = null;
try {
- boolean dontShowDialog = prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
- false);
- if (!dontShowDialog) {
- MessageDialogWithToggle dialog =
- MessageDialogWithToggle.openOkCancelConfirm(getShell(),
- WizardMessages.getString(CONFIRM_CREATE_TITLE),
- WizardMessages.getString(CONFIRM_CREATE_MSG),
- WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
- false, null, null);
- int retCode = dialog.getReturnCode();
- boolean toggleState = dialog.getToggleState();
- if (retCode == Dialog.CANCEL) {
- return true;
- }
- // If warning turned off by user, set the preference for future
- // usage
- if (toggleState) {
- prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
- }
- }
- instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory, storage);
- if (instance != null) {
- result = true;
- if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
- // TODO use chained job? Maybe. But chainedJob needs to be
- // moved
- ChainedJob first =
- new InstanceStateJob(
- WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
- instance,
- DeltaCloudInstance.State.RUNNING);
- first.setUser(true);
- ChainedJob last = first;
- ChainedJob temp;
- for (int i = 0; i < additionalPages.length; i++) {
- temp = additionalPages[i].getPerformFinishJob(instance);
- if (temp != null) {
- last.setNextJob(temp);
- last = temp;
- }
+ if (isProceed()) {
+ warnSshPrivateKey(keyId);
+ instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory, storage);
+ if (instance != null) {
+ result = true;
+ if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
+ scheduleJobs();
}
- first.schedule();
}
}
} catch (DeltaCloudException ex) {
@@ -162,32 +125,67 @@
WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG,
new String[] { name, imageId, realmId, profileId }),
e, getShell());
- } else {
- addToSshPrefs(keyId);
}
return result;
}
- private void addToSshPrefs(String keyId) {
+ private void warnSshPrivateKey(String keyId) {
try {
- File pemFile = PemFileManager.getFile(keyId, SshPrivateKeysPreferences.getKeyStorePath());
- if (pemFile != null) {
- SshPrivateKeysPreferences.add(pemFile.getName());
+ File file = PemFileManager.getFile(keyId, SshPrivateKeysPreferences.getSshKeyDirectory());
+ boolean isKnowPrivateKey = SshPrivateKeysPreferences.contains(file.getAbsolutePath());
+
+ if (!isKnowPrivateKey) {
+ MessageDialog
+ .openWarning(
+ getShell(),
+ "Instance key is not private key",
+ "The instance key is not a key that's know as private key to the ssh-subsystem. If the instance key is what you need to connect to you instance, you'll have to download it and add it to the private keys in the SSH preferences.");
}
- } catch (DeltaCloudException e) {
- ErrorUtils.handleError("Error",
- MessageFormat.format("Could not add key \"{0}\" to ssh preferences", keyId), e, getShell());
+ } catch (FileNotFoundException e) {
+
}
}
- private String utf8Encode(String string) {
- try {
- return URLEncoder.encode(string, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO: implement proper handling
- return "";
- } //$NON-NLS-1$
+ private void scheduleJobs() {
+ ChainedJob first =
+ new InstanceStateJob(
+ WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
+ instance,
+ DeltaCloudInstance.State.RUNNING);
+ first.setUser(true);
+ ChainedJob last = first;
+ ChainedJob temp;
+ for (int i = 0; i < additionalPages.length; i++) {
+ temp = additionalPages[i].getPerformFinishJob(instance);
+ if (temp != null) {
+ last.setNextJob(temp);
+ last = temp;
+ }
+ }
+ first.schedule();
}
+ private boolean isProceed() {
+ boolean proceed = true;
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ boolean dontShowDialog =
+ prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, false);
+ if (!dontShowDialog) {
+ MessageDialogWithToggle dialog =
+ MessageDialogWithToggle.openOkCancelConfirm(getShell(),
+ WizardMessages.getString(CONFIRM_CREATE_TITLE),
+ WizardMessages.getString(CONFIRM_CREATE_MSG),
+ WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
+ false, null, null);
+ proceed = dialog.getReturnCode() == Dialog.OK;
+ boolean toggleState = dialog.getToggleState();
+ // If warning turned off by user, set the preference for future
+ // usage
+ if (toggleState) {
+ prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
+ }
+ }
+ return proceed;
+ }
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -27,13 +27,14 @@
private static final String PEM_FILE_SUFFIX = "pem";
- public static void delete(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
+ public static File delete(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
try {
Assert.isLegal(key != null);
Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
File file = getFile(key.getId(), keyStorePath);
delete(file);
+ return file;
} catch (DeltaCloudException e) {
throw e;
} catch (Exception e) {
@@ -44,8 +45,8 @@
public static File create(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
try {
Assert.isLegal(key != null);
- Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
- File keyFile = create(getFile(key.getId(), keyStorePath), keyStorePath);
+ Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0, "key store path is not set.");
+ File keyFile = create(getFile(key.getId(), keyStorePath));
save(key.getPem(), keyFile);
keyFile.setWritable(false, false);
return keyFile;
@@ -62,11 +63,12 @@
}
}
- private static File create(File file, String keyStoreLocation)
- throws IOException {
- if (!file.exists()) {
- file.createNewFile();
+ private static File create(File file) throws IOException {
+ if (file.exists()) {
+ throw new IllegalStateException(
+ MessageFormat.format("File \"{0}\" already exists.", file.getAbsolutePath()));
}
+ file.createNewFile();
file.setReadable(false, false);
file.setWritable(true, true);
file.setReadable(true, true);
@@ -77,11 +79,16 @@
File keyFile =
Path.fromOSString(keyStoreLocation)
.append(keyId)
- .addFileExtension(PEM_FILE_SUFFIX) //$NON-NLS-1$
+ .addFileExtension(PEM_FILE_SUFFIX)
.toFile();
return keyFile;
}
+ public static boolean exists(String keyId, String keyStoreLocation) {
+ File file = getFile(keyId, keyStoreLocation);
+ return file != null && file.exists();
+ }
+
private static void delete(File file) throws DeltaCloudException {
try {
if (file == null
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17 09:47:42 UTC (rev 28287)
@@ -10,7 +10,12 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.client.utils.StringUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringEntriesPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
@@ -23,11 +28,14 @@
/**
* Preference keys defined by org.eclipse.jsch.
*
- * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
+ * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
*/
private static final String PRIVATEKEY = "PRIVATEKEY";
private static final String SSH2HOME = "SSH2HOME";
+ private static final String SSH_USERHOME = ".ssh";
+ private static final String SSH_USERHOME_WIN32 = "ssh";
+
private static StringEntriesPreferenceValue sshPrivateKeyPreference =
new StringEntriesPreferenceValue(",", PRIVATEKEY, PLUGIN_ID);
private static StringPreferenceValue sshHome = new StringPreferenceValue(SSH2HOME, PLUGIN_ID);
@@ -43,6 +51,21 @@
}
/**
+ * Adds the given keyName to the ssh-preferences
+ *
+ * @param keyName
+ * the name of the key to add
+ */
+ public static boolean contains(String keyName) {
+ for (String privateKey : sshPrivateKeyPreference.get()) {
+ if (privateKey.equals(keyName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Removes the given keyName from the ssh-preferences
*
* @param keyName
@@ -52,17 +75,37 @@
sshPrivateKeyPreference.remove(keyName);
}
- public static String getKeyStorePath() throws DeltaCloudException {
- // TODO: replace by code that queries the RSE preferences for its key
- // location setting
-// String userHomePath = System.getProperty("user.home");
-// if (userHomePath == null) {
-// throw new DeltaCloudException("Could not determine path to save pem file to");
-// }
-// return new StringBuilder(userHomePath)
-// .append(File.separatorChar).append(".ssh").append(File.separatorChar)
-// .toString();
- return sshHome.get();
+ /**
+ * Returns the path to the folder that ssh keys get stored to. It either
+ * gets the preferences value from org.eclipse.jsch or uses a ssh folder in
+ * the user home. This code was built according to what
+ * org.eclipse.jsch.internal.core.PreferenceInitializer is doing.
+ *
+ * @return the directory to store or load the ssh keys from
+ * @throws DeltaCloudException
+ * if the directory could not be determined
+ */
+ public static String getSshKeyDirectory() throws FileNotFoundException {
+ String sshHomePath = sshHome.get();
+ if (StringUtils.isEmpty(sshHomePath)) {
+ sshHomePath = getSshSystemHome();
+ }
+
+ if (StringUtils.isEmpty(sshHomePath)) {
+ throw new FileNotFoundException("Could not determine path to ssh keys directory.");
+ }
+ return sshHomePath;
}
+ private static String getSshSystemHome() {
+ String userHomePath = System.getProperty("user.home");
+ StringBuilder builder = new StringBuilder(userHomePath);
+ builder.append(File.separatorChar);
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ builder.append(SSH_USERHOME_WIN32); //$NON-NLS-1$
+ } else {
+ builder.append(SSH_USERHOME);
+ }
+ return builder.toString();
+ }
}
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17 09:46:55 UTC (rev 28286)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17 09:47:42 UTC (rev 28287)
@@ -88,7 +88,7 @@
NewInstance.title=Launch Instance
NewInstance.name=Launch Instance
-ManageKeys.desc=Select a key to use when creating an instance so that it may be accessed remotely.
+ManageKeys.desc=Select a key to use when creating an instance.
ManageKeys.title=Manage Keys
ManageKeys.name=Manage Keys
15 years, 2 months
JBoss Tools SVN: r28286 - in trunk/deltacloud/plugins: org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 04:46:55 -0500 (Mon, 17 Jan 2011)
New Revision: 28286
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
Log:
[JBIDE-8096]
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -396,7 +396,7 @@
}
public void deleteKey(String keyname) throws DeltaCloudClientException {
- requestStringResponse(new DeleteKeyRequest(baseUrl, keyname));
+ request(new DeleteKeyRequest(baseUrl, keyname));
}
public List<Key> listKeys() throws DeltaCloudClientException {
Deleted: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/BoundObjectPresentConverter.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
-
-import org.eclipse.core.databinding.conversion.Converter;
-
-/**
- * @author André Dietisheim
- */
-public class BoundObjectPresentConverter extends Converter {
-
- public BoundObjectPresentConverter() {
- super(Object.class, Boolean.class);
- }
-
- @Override
- public Object convert(Object fromObject) {
- return fromObject != null;
- }
-}
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class ObjectNotNullToBoolean extends Converter {
+
+ public ObjectNotNullToBoolean() {
+ super(Object.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null;
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ObjectNotNullToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import org.eclipse.core.databinding.conversion.Converter;
+
+/**
+ * @author André Dietisheim
+ */
+public class StringNotEmptyToBoolean extends Converter {
+
+ public StringNotEmptyToBoolean() {
+ super(String.class, Boolean.class);
+ }
+
+ @Override
+ public Object convert(Object fromObject) {
+ return fromObject != null
+ && !((String) fromObject).isEmpty();
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/StringNotEmptyToBoolean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java (rev 0)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.internal.deltacloud.ui.common.databinding.validator;
+
+import java.io.File;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @author André Dietisheim
+ */
+public class ValidWritableFilePathValidator implements IValidator {
+
+ @Override
+ public IStatus validate(Object value) {
+ if (value instanceof String) {
+ File file = new File((String) value);
+ if (file.exists() &&
+ file.canWrite()) {
+ return ValidationStatus.ok();
+ }
+ }
+ return ValidationStatus.error("You must choose a valid and writable location");
+ }
+}
Property changes on: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/common/databinding/validator/ValidWritableFilePathValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/preferences/StringEntriesPreferenceValue.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -85,17 +85,21 @@
* the values
*/
public void remove(String... valuesToRemove) {
+ boolean removed = false;
String[] currentValues = get();
if (valuesToRemove != null) {
for (int i = 0; i < currentValues.length; i++) {
for (String valueToRemove : valuesToRemove) {
if (valueToRemove.equals(currentValues[i])) {
currentValues[i] = null;
+ removed = true;
}
}
}
}
- store(currentValues);
+ if (removed) {
+ store(currentValues);
+ }
}
/**
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPage.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -12,14 +12,21 @@
import java.text.MessageFormat;
+import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.conversion.Converter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -33,15 +40,24 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
+import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
+import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.deltacloud.ui.ErrorUtils;
import org.jboss.tools.deltacloud.ui.SWTImagesFactory;
-import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.BoundObjectPresentConverter;
+import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObjectNotNullToBoolean;
+import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ValidWritableFilePathValidator;
import org.jboss.tools.internal.deltacloud.ui.utils.WizardUtils;
/**
@@ -60,7 +76,6 @@
private final static String CONFIRM_KEY_DELETE_TITLE = "ConfirmKeyDelete.title"; //$NON-NLS-1$
private final static String CONFIRM_KEY_DELETE_MSG = "ConfirmKeyDelete.msg"; //$NON-NLS-1$
- private List keyList;
private ManageKeysPageModel model;
private class Key2IdConverter extends Converter {
@@ -123,33 +138,25 @@
setPageComplete(false);
}
- private void refreshKeys() {
- try {
- Job job = model.refreshKeys();
- WizardUtils.runInWizard(job, getContainer());
- } catch (Exception e) {
- // ignore since the job will report its failure
- }
- }
-
- public DeltaCloudKey getKey() {
- return model.getSelectedKey();
- }
-
@Override
public void createControl(Composite parent) {
DataBindingContext dbc = new DataBindingContext();
// WizardPageSupport.create(this, dbc);
+ bindWizardComplete(dbc);
- bindWizardComplete(dbc);
Composite container = new Composite(parent, SWT.NULL);
- GridLayoutFactory.fillDefaults().numColumns(4).equalWidth(false).applyTo(container);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(4).equalWidth(false).applyTo(container);
- this.keyList = createKeyList(dbc, container);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(4, 5).applyTo(keyList);
+ Label keyListLabel = new Label(container, SWT.NULL);
+ keyListLabel.setText("Keys available on the server:");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(keyListLabel);
+ List keyList = createKeyList(dbc, container);
+ GridDataFactory.fillDefaults()
+ .align(SWT.FILL, SWT.FILL).grab(true, true).span(4, 8).hint(100, 200).applyTo(keyList);
+
Button refreshButton = new Button(container, SWT.NULL);
- // TODO: Internationalize strings
refreshButton.setText("Refresh keys");
refreshButton.addSelectionListener(onRefreshPressed());
GridDataFactory.fillDefaults().applyTo(refreshButton);
@@ -157,19 +164,73 @@
Label dummyLabel = new Label(container, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, false).applyTo(dummyLabel);
- Button createButton = new Button(container, SWT.NULL);
- createButton.setText(WizardMessages.getString(NEW));
- createButton.addSelectionListener(onNewPressed());
+ Button createButton = createNewButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(createButton);
Button deleteButton = createDeleteButton(container, dbc);
GridDataFactory.fillDefaults().applyTo(deleteButton);
+ Group localStorageGroup = new Group(container, SWT.BORDER);
+ localStorageGroup.setText("Local Keystore");
+ GridDataFactory.fillDefaults().span(4, 1).applyTo(localStorageGroup);
+ GridLayoutFactory.fillDefaults()
+ .numColumns(2).extendedMargins(10, 10, 10, 14).applyTo(localStorageGroup);
+
+ Text keyStoreText = new Text(localStorageGroup, SWT.BORDER);
+ bindKeyStoreText(keyStoreText, dbc);
+ GridDataFactory.fillDefaults()
+ .grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(keyStoreText);
+ addKeyStoreLocationDecoration(keyStoreText, dbc);
+
+ Button keyStoreBrowseButton = new Button(localStorageGroup, SWT.None);
+ keyStoreBrowseButton.addSelectionListener(onKeyStoreLocationBrowse());
+ keyStoreBrowseButton.setText("Choose...");
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER);
+
setControl(container);
refreshKeys();
}
+ private void addKeyStoreLocationDecoration(Text keyStoreText, DataBindingContext dbc) {
+ IObservableValue observable = new WritableValue();
+ Binding binding = dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ observable,
+ new UpdateValueStrategy().setBeforeSetValidator(new ValidWritableFilePathValidator()),
+ new UpdateValueStrategy().setBeforeSetValidator(new ValidWritableFilePathValidator()));
+ ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP);
+ }
+
+ private Button createNewButton(Composite container, DataBindingContext dbc) {
+ Button newButton = new Button(container, SWT.NULL);
+ newButton.setText(WizardMessages.getString(NEW));
+ newButton.addSelectionListener(onNewPressed());
+ return newButton;
+ }
+
+ private void bindKeyStoreText(Text keyStoreText, DataBindingContext dbc) {
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(keyStoreText),
+ BeanProperties.value(ManageKeysPageModel.PROP_KEY_STORE_PATH).observe(model));
+ }
+
+ private SelectionListener onKeyStoreLocationBrowse() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
+ dialog.setFilterPath(model.getKeyStorePath());
+ dialog.setText("Choose a directory to store new keys");
+ String keyStorePath = dialog.open();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ model.setKeyStorePath(keyStorePath);
+ }
+ }
+ };
+ }
+
private Button createDeleteButton(Composite container, DataBindingContext dbc) {
Button deleteButton = new Button(container, SWT.NULL);
deleteButton.setText(WizardMessages.getString(DELETE));
@@ -179,7 +240,7 @@
WidgetProperties.enabled().observe(deleteButton),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
return deleteButton;
}
@@ -188,7 +249,7 @@
BeanProperties.value("pageComplete").observe(this),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy(UpdateSetStrategy.POLICY_NEVER),
- new UpdateValueStrategy().setConverter(new BoundObjectPresentConverter()));
+ new UpdateValueStrategy().setConverter(new ObjectNotNullToBoolean()));
}
private List createKeyList(DataBindingContext dbc, Composite container) {
@@ -200,7 +261,8 @@
new UpdateListStrategy(UpdateSetStrategy.POLICY_NEVER),
new UpdateListStrategy().setConverter(new Key2IdConverter()));
// bind selected key
- dbc.bindValue(WidgetProperties.selection().observe(keyList),
+ dbc.bindValue(
+ WidgetProperties.selection().observe(keyList),
BeanProperties.value(ManageKeysPageModel.PROP_SELECTED_KEY).observe(model),
new UpdateValueStrategy().setConverter(new Id2KeyConverter()),
new UpdateValueStrategy().setConverter(new Key2IdConverter()));
@@ -231,11 +293,31 @@
};
}
+ private void refreshKeys() {
+ Job job = new AbstractCloudElementJob("Get keys", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ model.refreshKeys();
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not get keys from cloud {0}", getCloud().getName()), e);
+ }
+ }
+ };
+ try {
+ WizardUtils.runInWizard(job, getContainer());
+ } catch (Exception e) {
+ // ignore since the job will report its failure
+ }
+ }
+
private SelectionListener onNewPressed() {
return new SelectionAdapter() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent event) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
// String directoryText = directory.getText();
@@ -245,33 +327,92 @@
d.create();
if (d.open() == InputDialog.OK) {
String keyId = d.getValue();
- createKey(keyId);
+ DeltaCloudKey key = createKey(keyId);
+ storeKeyLocally(key);
}
}
+
};
}
- private void createKey(final String keyId) {
+ private DeltaCloudKey createKey(final String keyId) {
+ final DeltaCloudKey[] keyHolder = new DeltaCloudKey[1];
try {
- model.createKey(keyId);
+ Job job = new AbstractCloudElementJob("Create key", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ keyHolder[0] = model.createKey(keyId);
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not create key \"{0}\"", keyId), e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key \"{0}\"", keyId), e,
- getShell());
+ // ignore
}
+ return keyHolder[0];
}
+ private void storeKeyLocally(DeltaCloudKey key) {
+ try {
+ if (key != null) {
+ boolean store = MessageDialog.openConfirm(getShell(),
+ "Confirm to store the new key",
+ "Do you want to store the key locally and add it to the private keys?");
+ if (store) {
+ model.storeKeyLocally(key);
+ }
+ }
+ } catch (Exception e) {
+ ErrorUtils.handleError("Error", MessageFormat.format(
+ "Could not store key \"{0}\" locally and add it to the ssh private keys", key.getName()),
+ e, getShell());
+ }
+ }
+
private void deleteKey() {
try {
- model.deleteSelectedKey();
+ Job job = new AbstractCloudElementJob("Delete key", model.getCloud(), CLOUDELEMENT.KEYS) {
+
+ protected IStatus doRun(IProgressMonitor monitor) throws Exception {
+ try {
+ final DeltaCloudKey key = model.deleteSelectedKey();
+ final boolean[] isConfirmDelete = new boolean[] { false };
+ if (PemFileManager.exists(key.getName(), SshPrivateKeysPreferences.getSshKeyDirectory())) {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ isConfirmDelete[0] = MessageDialog.openConfirm(
+ getShell(),
+ "Delete key locally?",
+ MessageFormat.format(
+ "Shall the key \"{0}\" be deleted from local key store?",
+ key.getName()));
+ }
+ });
+ if (isConfirmDelete[0]) {
+ model.removeKeyLocally(key);
+ }
+ }
+ return Status.OK_STATUS;
+ } catch (DeltaCloudException e) {
+ return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
+ MessageFormat.format("Could not delete key", model.getSelectedKey().getId()), e);
+ }
+ }
+ };
+ WizardUtils.runInWizard(job, getContainer());
} catch (Exception e) {
- // TODO: internationalize strings
- ErrorUtils.handleError(
- "Error",
- MessageFormat.format("Error", "Could not create key \"{0}\"", model.getSelectedKey().getId()), e,
- getShell());
+ // ignore
}
}
+
+ public DeltaCloudKey getKey() {
+ return model.getSelectedKey();
+ }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/ManageKeysPageModel.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -10,22 +10,15 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
-import java.text.MessageFormat;
+import java.io.File;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.jboss.tools.common.log.StatusFactory;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
import org.jboss.tools.deltacloud.core.DeltaCloudKey;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob;
-import org.jboss.tools.deltacloud.core.job.AbstractCloudElementJob.CLOUDELEMENT;
-import org.jboss.tools.deltacloud.ui.Activator;
import org.jboss.tools.internal.deltacloud.ui.common.databinding.validator.ObservableUIPojo;
/**
@@ -37,41 +30,71 @@
public static final String PROP_KEYS = "keys";
public static final String PROP_KEYS_ADDED = "keyAdded";
public static final String PROP_KEYS_REMOVED = "keyRemoved";
+ public static final String PROP_KEY_STORE_PATH = "keyStorePath";
private List<DeltaCloudKey> keys = new ArrayList<DeltaCloudKey>();
private DeltaCloud cloud;
private DeltaCloudKey selectedKey;
+ private String keyStorePath;
public ManageKeysPageModel(DeltaCloud cloud) {
this.cloud = cloud;
- // asyncGetKeys(cloud);
+ this.keyStorePath = initKeyStorePath();
}
- public void deleteSelectedKey() throws DeltaCloudException {
+ private String initKeyStorePath() {
+ try {
+ return SshPrivateKeysPreferences.getSshKeyDirectory();
+ } catch (FileNotFoundException e) {
+ return null;
+ }
+ }
+
+ public DeltaCloudKey deleteSelectedKey() throws DeltaCloudException {
if (selectedKey == null) {
- return;
+ return null;
}
cloud.deleteKey(selectedKey.getId());
int index = keys.indexOf(selectedKey);
keys.remove(selectedKey);
fireIndexedPropertyChange(PROP_KEYS, index, selectedKey, null);
- PemFileManager.delete(selectedKey, SshPrivateKeysPreferences.getKeyStorePath());
+ DeltaCloudKey key = selectedKey;
setSelectedKey(index - 1);
+ return key;
}
- public void createKey(String keyId) throws DeltaCloudException {
+ public void removeKeyLocally(DeltaCloudKey key) throws DeltaCloudException, FileNotFoundException {
+ if (key == null) {
+ return;
+ }
+
+ String keyStorePath = getKeyStorePath();
+ if (keyStorePath != null && keyStorePath.length() > 0) {
+ File pemFile = PemFileManager.delete(key, keyStorePath);
+ SshPrivateKeysPreferences.remove(pemFile.getAbsolutePath());
+ }
+ }
+
+ public DeltaCloudKey createKey(String keyId) throws DeltaCloudException {
DeltaCloudKey key = cloud.createKey(keyId);
keys.add(key);
int index = keys.indexOf(key);
fireIndexedPropertyChange(PROP_KEYS, index, null, key);
setSelectedKey(key);
- PemFileManager.create(key, SshPrivateKeysPreferences.getKeyStorePath());
+ return key;
}
- public Job refreshKeys() {
- return asyncGetKeys();
+ public void storeKeyLocally(DeltaCloudKey key) throws DeltaCloudException, FileNotFoundException {
+ File pemFile = PemFileManager.create(key, getKeyStorePath());
+ SshPrivateKeysPreferences.add(pemFile.getAbsolutePath());
}
+ public void refreshKeys() throws DeltaCloudException {
+ java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
+ newKeys.addAll(Arrays.asList(cloud.getKeys()));
+ setKeys(newKeys);
+ }
+
public DeltaCloudKey getSelectedKey() {
return selectedKey;
}
@@ -119,7 +142,13 @@
public void setKeys(List<DeltaCloudKey> newKeys) {
firePropertyChange(PROP_KEYS, this.keys, this.keys = newKeys);
- setSelectedKey();
+ /*
+ * need to reset selection since widget looses selection (when items are
+ * set) and property may not fire if no change in selection
+ */
+ DeltaCloudKey key = getSelectedKey();
+ setSelectedKey(null);
+ setSelectedKey(key);
}
public DeltaCloudKey getKey(String keyId) {
@@ -137,24 +166,17 @@
return matchingKey;
}
- private Job asyncGetKeys() {
- Job job = new AbstractCloudElementJob("Get keys", cloud, CLOUDELEMENT.KEYS) {
+ public String getKeyStorePath() {
+ return keyStorePath;
+ }
- protected IStatus doRun(IProgressMonitor monitor) throws Exception {
- try {
- java.util.List<DeltaCloudKey> newKeys = new ArrayList<DeltaCloudKey>();
- newKeys.addAll(Arrays.asList(getCloud().getKeys()));
- setKeys(newKeys);
- return Status.OK_STATUS;
- } catch (DeltaCloudException e) {
- // TODO: internationalize strings
- return StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
- MessageFormat.format("Could not get keys from cloud {0}", getCloud().getName()), e);
- }
- }
+ public void setKeyStorePath(String keyStorePath) {
+ System.err.println(keyStorePath);
+ firePropertyChange(PROP_KEY_STORE_PATH, this.keyStorePath, this.keyStorePath = keyStorePath);
+ }
- };
- job.schedule();
- return job;
+ public DeltaCloud getCloud() {
+ return cloud;
}
+
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -11,13 +11,12 @@
package org.jboss.tools.internal.deltacloud.ui.wizards;
import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
+import java.io.FileNotFoundException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.tools.common.jobs.ChainedJob;
@@ -98,59 +97,23 @@
String memory = model.getMemory();
String storage = model.getStorage();
String keyId = model.getKeyId();
- String name = utf8Encode(model.getName());
+ String name = model.getName();
// Save persistent settings for this particular cloud
cloud.setLastImageId(imageId);
cloud.setLastKeyname(keyId);
- Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
-
boolean result = false;
Exception e = null;
try {
- boolean dontShowDialog = prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE,
- false);
- if (!dontShowDialog) {
- MessageDialogWithToggle dialog =
- MessageDialogWithToggle.openOkCancelConfirm(getShell(),
- WizardMessages.getString(CONFIRM_CREATE_TITLE),
- WizardMessages.getString(CONFIRM_CREATE_MSG),
- WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
- false, null, null);
- int retCode = dialog.getReturnCode();
- boolean toggleState = dialog.getToggleState();
- if (retCode == Dialog.CANCEL) {
- return true;
- }
- // If warning turned off by user, set the preference for future
- // usage
- if (toggleState) {
- prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
- }
- }
- instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory, storage);
- if (instance != null) {
- result = true;
- if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
- // TODO use chained job? Maybe. But chainedJob needs to be
- // moved
- ChainedJob first =
- new InstanceStateJob(
- WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
- instance,
- DeltaCloudInstance.State.RUNNING);
- first.setUser(true);
- ChainedJob last = first;
- ChainedJob temp;
- for (int i = 0; i < additionalPages.length; i++) {
- temp = additionalPages[i].getPerformFinishJob(instance);
- if (temp != null) {
- last.setNextJob(temp);
- last = temp;
- }
+ if (isProceed()) {
+ warnSshPrivateKey(keyId);
+ instance = cloud.createInstance(name, imageId, realmId, profileId, keyId, memory, storage);
+ if (instance != null) {
+ result = true;
+ if (instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
+ scheduleJobs();
}
- first.schedule();
}
}
} catch (DeltaCloudException ex) {
@@ -162,32 +125,67 @@
WizardMessages.getFormattedString(CREATE_INSTANCE_FAILURE_MSG,
new String[] { name, imageId, realmId, profileId }),
e, getShell());
- } else {
- addToSshPrefs(keyId);
}
return result;
}
- private void addToSshPrefs(String keyId) {
+ private void warnSshPrivateKey(String keyId) {
try {
- File pemFile = PemFileManager.getFile(keyId, SshPrivateKeysPreferences.getKeyStorePath());
- if (pemFile != null) {
- SshPrivateKeysPreferences.add(pemFile.getName());
+ File file = PemFileManager.getFile(keyId, SshPrivateKeysPreferences.getSshKeyDirectory());
+ boolean isKnowPrivateKey = SshPrivateKeysPreferences.contains(file.getAbsolutePath());
+
+ if (!isKnowPrivateKey) {
+ MessageDialog
+ .openWarning(
+ getShell(),
+ "Instance key is not private key",
+ "The instance key is not a key that's know as private key to the ssh-subsystem. If the instance key is what you need to connect to you instance, you'll have to download it and add it to the private keys in the SSH preferences.");
}
- } catch (DeltaCloudException e) {
- ErrorUtils.handleError("Error",
- MessageFormat.format("Could not add key \"{0}\" to ssh preferences", keyId), e, getShell());
+ } catch (FileNotFoundException e) {
+
}
}
- private String utf8Encode(String string) {
- try {
- return URLEncoder.encode(string, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO: implement proper handling
- return "";
- } //$NON-NLS-1$
+ private void scheduleJobs() {
+ ChainedJob first =
+ new InstanceStateJob(
+ WizardMessages.getFormattedString(STARTING_INSTANCE_TITLE, instance.getName()),
+ instance,
+ DeltaCloudInstance.State.RUNNING);
+ first.setUser(true);
+ ChainedJob last = first;
+ ChainedJob temp;
+ for (int i = 0; i < additionalPages.length; i++) {
+ temp = additionalPages[i].getPerformFinishJob(instance);
+ if (temp != null) {
+ last.setNextJob(temp);
+ last = temp;
+ }
+ }
+ first.schedule();
}
+ private boolean isProceed() {
+ boolean proceed = true;
+ Preferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);
+ boolean dontShowDialog =
+ prefs.getBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, false);
+ if (!dontShowDialog) {
+ MessageDialogWithToggle dialog =
+ MessageDialogWithToggle.openOkCancelConfirm(getShell(),
+ WizardMessages.getString(CONFIRM_CREATE_TITLE),
+ WizardMessages.getString(CONFIRM_CREATE_MSG),
+ WizardMessages.getString(DONT_SHOW_THIS_AGAIN_MSG),
+ false, null, null);
+ proceed = dialog.getReturnCode() == Dialog.OK;
+ boolean toggleState = dialog.getToggleState();
+ // If warning turned off by user, set the preference for future
+ // usage
+ if (toggleState) {
+ prefs.putBoolean(IDeltaCloudPreferenceConstants.DONT_CONFIRM_CREATE_INSTANCE, true);
+ }
+ }
+ return proceed;
+ }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/PemFileManager.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -27,13 +27,14 @@
private static final String PEM_FILE_SUFFIX = "pem";
- public static void delete(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
+ public static File delete(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
try {
Assert.isLegal(key != null);
Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
File file = getFile(key.getId(), keyStorePath);
delete(file);
+ return file;
} catch (DeltaCloudException e) {
throw e;
} catch (Exception e) {
@@ -44,8 +45,8 @@
public static File create(DeltaCloudKey key, String keyStorePath) throws DeltaCloudException {
try {
Assert.isLegal(key != null);
- Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0);
- File keyFile = create(getFile(key.getId(), keyStorePath), keyStorePath);
+ Assert.isLegal(keyStorePath != null && keyStorePath.length() > 0, "key store path is not set.");
+ File keyFile = create(getFile(key.getId(), keyStorePath));
save(key.getPem(), keyFile);
keyFile.setWritable(false, false);
return keyFile;
@@ -62,11 +63,12 @@
}
}
- private static File create(File file, String keyStoreLocation)
- throws IOException {
- if (!file.exists()) {
- file.createNewFile();
+ private static File create(File file) throws IOException {
+ if (file.exists()) {
+ throw new IllegalStateException(
+ MessageFormat.format("File \"{0}\" already exists.", file.getAbsolutePath()));
}
+ file.createNewFile();
file.setReadable(false, false);
file.setWritable(true, true);
file.setReadable(true, true);
@@ -77,11 +79,16 @@
File keyFile =
Path.fromOSString(keyStoreLocation)
.append(keyId)
- .addFileExtension(PEM_FILE_SUFFIX) //$NON-NLS-1$
+ .addFileExtension(PEM_FILE_SUFFIX)
.toFile();
return keyFile;
}
+ public static boolean exists(String keyId, String keyStoreLocation) {
+ File file = getFile(keyId, keyStoreLocation);
+ return file != null && file.exists();
+ }
+
private static void delete(File file) throws DeltaCloudException {
try {
if (file == null
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/SshPrivateKeysPreferences.java 2011-01-17 09:46:55 UTC (rev 28286)
@@ -10,7 +10,12 @@
******************************************************************************/
package org.jboss.tools.internal.deltacloud.ui.wizards;
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
+import org.jboss.tools.deltacloud.core.client.utils.StringUtils;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringEntriesPreferenceValue;
import org.jboss.tools.internal.deltacloud.ui.preferences.StringPreferenceValue;
@@ -23,11 +28,14 @@
/**
* Preference keys defined by org.eclipse.jsch.
*
- * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
+ * these keys are replicates from org.eclipse.jsch.internal.core.IConstants
*/
private static final String PRIVATEKEY = "PRIVATEKEY";
private static final String SSH2HOME = "SSH2HOME";
+ private static final String SSH_USERHOME = ".ssh";
+ private static final String SSH_USERHOME_WIN32 = "ssh";
+
private static StringEntriesPreferenceValue sshPrivateKeyPreference =
new StringEntriesPreferenceValue(",", PRIVATEKEY, PLUGIN_ID);
private static StringPreferenceValue sshHome = new StringPreferenceValue(SSH2HOME, PLUGIN_ID);
@@ -43,6 +51,21 @@
}
/**
+ * Adds the given keyName to the ssh-preferences
+ *
+ * @param keyName
+ * the name of the key to add
+ */
+ public static boolean contains(String keyName) {
+ for (String privateKey : sshPrivateKeyPreference.get()) {
+ if (privateKey.equals(keyName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Removes the given keyName from the ssh-preferences
*
* @param keyName
@@ -52,17 +75,37 @@
sshPrivateKeyPreference.remove(keyName);
}
- public static String getKeyStorePath() throws DeltaCloudException {
- // TODO: replace by code that queries the RSE preferences for its key
- // location setting
-// String userHomePath = System.getProperty("user.home");
-// if (userHomePath == null) {
-// throw new DeltaCloudException("Could not determine path to save pem file to");
-// }
-// return new StringBuilder(userHomePath)
-// .append(File.separatorChar).append(".ssh").append(File.separatorChar)
-// .toString();
- return sshHome.get();
+ /**
+ * Returns the path to the folder that ssh keys get stored to. It either
+ * gets the preferences value from org.eclipse.jsch or uses a ssh folder in
+ * the user home. This code was built according to what
+ * org.eclipse.jsch.internal.core.PreferenceInitializer is doing.
+ *
+ * @return the directory to store or load the ssh keys from
+ * @throws DeltaCloudException
+ * if the directory could not be determined
+ */
+ public static String getSshKeyDirectory() throws FileNotFoundException {
+ String sshHomePath = sshHome.get();
+ if (StringUtils.isEmpty(sshHomePath)) {
+ sshHomePath = getSshSystemHome();
+ }
+
+ if (StringUtils.isEmpty(sshHomePath)) {
+ throw new FileNotFoundException("Could not determine path to ssh keys directory.");
+ }
+ return sshHomePath;
}
+ private static String getSshSystemHome() {
+ String userHomePath = System.getProperty("user.home");
+ StringBuilder builder = new StringBuilder(userHomePath);
+ builder.append(File.separatorChar);
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ builder.append(SSH_USERHOME_WIN32); //$NON-NLS-1$
+ } else {
+ builder.append(SSH_USERHOME);
+ }
+ return builder.toString();
+ }
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17 09:41:58 UTC (rev 28285)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/WizardMessages.properties 2011-01-17 09:46:55 UTC (rev 28286)
@@ -88,7 +88,7 @@
NewInstance.title=Launch Instance
NewInstance.name=Launch Instance
-ManageKeys.desc=Select a key to use when creating an instance so that it may be accessed remotely.
+ManageKeys.desc=Select a key to use when creating an instance.
ManageKeys.title=Manage Keys
ManageKeys.name=Manage Keys
15 years, 2 months
JBoss Tools SVN: r28285 - branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/.settings.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 04:41:58 -0500 (Mon, 17 Jan 2011)
New Revision: 28285
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/.settings/org.eclipse.jdt.core.prefs
Log:
[JBIDE-8051]
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/.settings/org.eclipse.jdt.core.prefs 2011-01-17 09:41:44 UTC (rev 28284)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/.settings/org.eclipse.jdt.core.prefs 2011-01-17 09:41:58 UTC (rev 28285)
@@ -1,4 +1,4 @@
-#Wed Nov 10 16:16:08 CET 2010
+#Thu Jan 13 13:21:12 CET 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
@@ -10,3 +10,271 @@
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=false
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
15 years, 2 months
JBoss Tools SVN: r28284 - branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-01-17 04:41:44 -0500 (Mon, 17 Jan 2011)
New Revision: 28284
Modified:
branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils/StringUtils.java
Log:
[JBIDE-8051]
Modified: branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils/StringUtils.java
===================================================================
--- branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils/StringUtils.java 2011-01-17 09:41:30 UTC (rev 28283)
+++ branches/jbosstools-3.2.0.CR1/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils/StringUtils.java 2011-01-17 09:41:44 UTC (rev 28284)
@@ -91,6 +91,11 @@
return stringValue;
}
+ public static boolean isEmpty(String stringValue) {
+ return stringValue == null || stringValue.isEmpty();
+ }
+
+
public static String toString(InputStream inputStream) throws IOException {
StringBuilder builder = new StringBuilder();
for(int character = -1; (character = inputStream.read()) != -1; ) {
15 years, 2 months