JBoss Tools SVN: r16284 - workspace/yzhishko.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-06-30 08:18:51 -0400 (Tue, 30 Jun 2009)
New Revision: 16284
Added:
workspace/yzhishko/org.jboss.tools.jsf.ui.bot.test/
Removed:
workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test/
Log:
Copied: workspace/yzhishko/org.jboss.tools.jsf.ui.bot.test (from rev 16283, workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test)
15 years, 3 months
JBoss Tools SVN: r16283 - in trunk/hibernatetools/plugins: org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-06-30 07:46:40 -0400 (Tue, 30 Jun 2009)
New Revision: 16283
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4527
GenericGenerator parameters and composite
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context;
+
+import org.eclipse.jpt.core.context.JpaContextNode;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface Parameter extends JpaContextNode {
+
+ String getName();
+ void setName(String value);
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ String getValue();
+ void setValue(String value);
+ String VALUE_PROPERTY = "value"; //$NON-NLS-1$
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/Parameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGenerator.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jpt.core.context.Generator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
/**
* @author Dmitry Geraskov
@@ -22,7 +25,42 @@
String getStrategy();
- void setSpecifiedStrategy(String value);
+ void setStrategy(String value);
String GENERIC_STRATEGY_PROPERTY = "genericStrategyProperty"; //$NON-NLS-1$
-
+
+
+ //************************ parameters ***********************
+
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Return a list iterator of the parameters. This will not be null.
+ */
+ <T extends Parameter> ListIterator<T> parameters();
+
+ /**
+ * Return the number of parameters.
+ */
+ int parametersSize();
+
+ /**
+ * Add a parameter to the generator and return the object representing it.
+ */
+ Parameter addParameter(int index);
+
+ /**
+ * Remove the parameter from the generator.
+ */
+ void removeParameter(int index);
+
+ /**
+ * Remove the parameter at the index from the query.
+ */
+ void removeParameter(Parameter queryParameter);
+
+ /**
+ * Move the parameter from the source index to the target index.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -10,10 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -34,9 +37,46 @@
* Set to null to remove the strategy element.
*/
void setStrategy(String strategy);
- String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
+ String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterator<ParameterAnnotation> parameters();
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ int parametersSize();
/**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ ParameterAnnotation parameterAt(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ int indexOfParameter(ParameterAnnotation parameter);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ ParameterAnnotation addParameter(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ void removeParameter(int index);
+
+ /**
* Return the {@link TextRange} for the strategy element. If the strategy element
* does not exist return the {@link TextRange} for the GenericGenerator annotation.
*/
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -10,13 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+import java.util.Vector;
+
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationContainer;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.TextRange;
@@ -24,7 +29,13 @@
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.NestableParameterAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -43,13 +54,17 @@
private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter();
+ final ParametersAnnotationContainer parametersContainer = new ParametersAnnotationContainer();
+
private String name;
private String strategy;
+ final Vector<NestableParameterAnnotation> parameters = new Vector<NestableParameterAnnotation>();
+
private Integer initialValue = 1;
- private Integer allocationSize = 1;
+ private Integer allocationSize = 50;
/**
* @param parent
@@ -63,9 +78,16 @@
public void initialize(CompilationUnit astRoot) {
this.name = this.name(astRoot);
- this.strategy = this.strategy(astRoot);
+ this.strategy = this.strategy(astRoot);
+ AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
}
+ public void update(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ AnnotationContainerTools.update(this.parametersContainer, astRoot);
+ }
+
public String getAnnotationName() {
return ANNOTATION_NAME;
}
@@ -106,9 +128,6 @@
return this.getElementTextRange(STRATEGY_ADAPTER, astRoot);
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSize()
- */
public Integer getAllocationSize() {
return allocationSize;
}
@@ -153,11 +172,6 @@
}
// ********** java annotations -> persistence model **********
- public void updateFromJava(CompilationUnit astRoot) {
- this.setStrategy(this.strategy(astRoot));
- this.setName(this.name(astRoot));
- }
-
protected String strategy(CompilationUnit astRoot) {
//TODO: get Generator instead of String
//use buildJavaGenericGenerator method before thi will be done
@@ -166,12 +180,8 @@
protected String name(CompilationUnit astRoot) {
return this.nameAdapter.getValue(astRoot);
- }
+ }
- public void update(CompilationUnit astRoot) {
- updateFromJava(astRoot);
- }
-
// ********** static methods **********
private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() {
return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, Hibernate.GENERIC_GENERATOR__NAME, false);
@@ -231,4 +241,130 @@
}
}
+ //************************ parameters ***********************
+
+ public ParameterAnnotation addParameter(int index) {
+ return (NestableParameterAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation addParameterInternal() {
+ NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
+ this.parameters.add(parameter);
+ return parameter;
+ }
+
+ NestableParameterAnnotation buildParameter(int index) {
+ return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member, this.daa, index);
+ }
+
+ ListIterator<NestableParameterAnnotation> nestableParameters() {
+ return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
+ }
+
+ void parameterAdded(int index, NestableParameterAnnotation parameter) {
+ this.fireItemAdded(PARAMETERS_LIST, index, parameter);
+ }
+
+ NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.parameters, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ void parameterMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public int indexOfParameter(ParameterAnnotation parameter) {
+ return this.parameters.indexOf(parameter);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.parametersContainer);
+ }
+
+ public ParameterAnnotation parameterAt(int index) {
+ return this.parameters.get(index);
+ }
+
+ public ListIterator<ParameterAnnotation> parameters() {
+ return new CloneListIterator<ParameterAnnotation>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ public void removeParameter(int index) {
+ AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation removeParameterInternal(int index) {
+ return this.parameters.remove(index);
+ }
+
+ void hintRemoved(int index, NestableParameterAnnotation parameter) {
+ this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the override's join columns
+ */
+ class ParametersAnnotationContainer
+ implements AnnotationContainer<NestableParameterAnnotation>
+ {
+ public String getContainerAnnotationName() {
+ return GenericGeneratorAnnotationImpl.this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) {
+ return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.GENERIC_GENERATOR__PARAMETERS;
+ }
+
+ public String getNestableAnnotationName() {
+ return ParameterAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
+ return GenericGeneratorAnnotationImpl.this.nestableParameters();
+ }
+
+ public int nestedAnnotationsSize() {
+ return GenericGeneratorAnnotationImpl.this.parametersSize();
+ }
+
+ public NestableParameterAnnotation addNestedAnnotationInternal() {
+ return GenericGeneratorAnnotationImpl.this.addParameterInternal();
+ }
+
+ public void nestedAnnotationAdded(int index, NestableParameterAnnotation nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
+ }
+
+ public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) {
+ return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex, sourceIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
+ }
+
+ public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
+ return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, NestableParameterAnnotation nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.hintRemoved(index, nestedAnnotation);
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+
+
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -10,11 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import org.eclipse.jpt.core.context.GeneratorHolder;
+
/**
* @author Dmitry Geraskov
*
*/
-public interface GenericGeneratorHolder {
+public interface GenericGeneratorHolder extends GeneratorHolder {
String GENERIC_GENERATOR_PROPERTY = "genericGenerator"; //$NON-NLS-1$
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaParameter extends AbstractJavaJpaContextNode implements JavaParameter {
+
+ protected String name;
+
+ protected String value;
+
+ protected ParameterAnnotation resourceParameter;
+
+ public HibernateJavaParameter(JavaGenericGenerator parent) {
+ super(parent);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ String oldName = this.name;
+ this.name = newName;
+ this.resourceParameter.setName(newName);
+ firePropertyChanged(Parameter.NAME_PROPERTY, oldName, newName);
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String newValue) {
+ String oldValue = this.value;
+ this.value = newValue;
+ this.resourceParameter.setValue(newValue);
+ firePropertyChanged(Parameter.VALUE_PROPERTY, oldValue, newValue);
+ }
+
+ public void initialize(ParameterAnnotation resourceParameter) {
+ this.resourceParameter = resourceParameter;
+ this.name = resourceParameter.getName();
+ this.value = resourceParameter.getValue();
+ }
+
+ public void update(ParameterAnnotation resourceParameter) {
+ this.resourceParameter = resourceParameter;
+ this.setName(resourceParameter.getName());
+ this.setValue(resourceParameter.getValue());
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.resourceParameter.getTextRange(astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaParameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
+import org.eclipse.jpt.core.utility.TextRange;
/**
* @author Dmitry Geraskov
@@ -18,6 +22,15 @@
*/
public interface JavaGenericGenerator extends JavaGenerator, GenericGenerator {
+ @SuppressWarnings("unchecked")
+ ListIterator<JavaParameter> parameters();
+
+ JavaParameter addParameter(int index);
+
+ // **************** validation *********************************************
+
+ TextRange getNameTextRange(CompilationUnit astRoot);
+
void initialize(GenericGeneratorAnnotation generator);
void update(GenericGeneratorAnnotation generator);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -20,12 +21,16 @@
import org.eclipse.jpt.core.context.Generator;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaGenerator;
-import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
* @author Dmitry Geraskov
@@ -36,10 +41,12 @@
private String strategy;
- protected GeneratorAnnotation generatorResource;
+ protected final List<JavaParameter> parameters;
- private static List<String> generatorClasses = new ArrayList<String>();
+ protected GenericGeneratorAnnotation generatorResource;
+ public static List<String> generatorClasses = new ArrayList<String>();
+
//see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
static {
generatorClasses.add( "uuid");
@@ -61,17 +68,14 @@
*/
public JavaGenericGeneratorImpl(JavaJpaContextNode parent) {
super(parent);
+ this.parameters = new ArrayList<JavaParameter>();
}
-
- protected GenericGeneratorAnnotation getGeneratorResource() {
- return (GenericGeneratorAnnotation) generatorResource;
- }
public int getDefaultInitialValue() {
return GenericGenerator.DEFAULT_INITIAL_VALUE;
}
- protected GeneratorAnnotation getResourceGenerator() {
+ protected GenericGeneratorAnnotation getResourceGenerator() {
return this.generatorResource;
}
@@ -81,6 +85,7 @@
this.specifiedInitialValue = generator.getInitialValue();
this.specifiedAllocationSize = generator.getAllocationSize();
this.strategy = generator.getStrategy();
+ this.initializeParameters();
}
public void update(GenericGeneratorAnnotation generator) {
@@ -89,7 +94,8 @@
this.setSpecifiedInitialValue_(generator.getInitialValue());
this.setSpecifiedAllocationSize_(generator.getAllocationSize());
this.setSpecifiedStrategy_(generator.getStrategy());
- this.getPersistenceUnit().addGenerator(this);
+ this.updateParameters();
+ this.getPersistenceUnit().addGenerator(this);
}
public void setName(String name) {
@@ -125,10 +131,10 @@
return strategy;
}
- public void setSpecifiedStrategy(String strategy) {
+ public void setStrategy(String strategy) {
String oldStrategy = this.strategy;
this.strategy = strategy;
- getGeneratorResource().setStrategy(strategy);
+ getResourceGenerator().setStrategy(strategy);
firePropertyChanged(GENERIC_STRATEGY_PROPERTY, oldStrategy, strategy);
}
@@ -146,9 +152,6 @@
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.eclipse.jdt.core.dom.CompilationUnit)
- */
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
@@ -213,5 +216,89 @@
message.setLineNo(lineNum);
return message;
}
+
+ @Override
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) super.getJpaFactory();
+ }
+
+ //************************ parameters ***********************
+ public JavaParameter addParameter(int index) {
+ JavaParameter parameter = getJpaFactory().buildJavaParameter(this);
+ this.parameters.add(index, parameter);
+ this.getResourceGenerator().addParameter(index);
+ this.fireItemAdded(GenericGenerator.PARAMETERS_LIST, index, parameter);
+ return parameter;
+ }
+
+ protected void addParameter(int index, JavaParameter parameter) {
+ addItemToList(index, parameter, this.parameters, GenericGenerator.PARAMETERS_LIST);
+ }
+
+ protected void addParameter(JavaParameter parameter) {
+ addParameter(this.parameters.size(), parameter);
+ }
+
+ public void removeParameter(Parameter parameter) {
+ removeParameter(this.parameters.indexOf(parameter));
+ }
+
+ public void removeParameter(int index) {
+ JavaParameter removedParameter = this.parameters.remove(index);
+ this.getResourceGenerator().removeParameter(index);
+ fireItemRemoved(GenericGenerator.PARAMETERS_LIST, index, removedParameter);
+ }
+
+ protected void removeParameter_(JavaParameter parameter) {
+ removeItemFromList(parameter, this.parameters, GenericGenerator.PARAMETERS_LIST);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.parameters, targetIndex, sourceIndex);
+ this.getResourceGenerator().moveParameter(targetIndex, sourceIndex);
+ fireItemMoved(GenericGenerator.PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public ListIterator<JavaParameter> parameters() {
+ return new CloneListIterator<JavaParameter>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ protected void initializeParameters() {
+ ListIterator<ParameterAnnotation> resourceParameters = this.generatorResource.parameters();
+
+ while(resourceParameters.hasNext()) {
+ this.parameters.add(createParameter(resourceParameters.next()));
+ }
+ }
+
+ protected void updateParameters() {
+ ListIterator<JavaParameter> contextParameters = parameters();
+ ListIterator<ParameterAnnotation> resourceParameters = this.generatorResource.parameters();
+
+ while (contextParameters.hasNext()) {
+ JavaParameter parameter = contextParameters.next();
+ if (resourceParameters.hasNext()) {
+ parameter.update(resourceParameters.next());
+ }
+ else {
+ removeParameter_(parameter);
+ }
+ }
+
+ while (resourceParameters.hasNext()) {
+ addParameter(createParameter(resourceParameters.next()));
+ }
+ }
+
+ protected JavaParameter createParameter(ParameterAnnotation resourceParameter) {
+ JavaParameter parameter = getJpaFactory().buildJavaParameter(this);
+ parameter.initialize(resourceParameter);
+ return parameter;
+ }
+
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaParameter extends Parameter, JavaJpaContextNode {
+
+ void initialize(ParameterAnnotation parameterResource);
+
+ /**
+ * Update the JavaParameter context model object to match the ParameterAnnotation
+ * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
+ */
+ void update(ParameterAnnotation parameterResource);
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaParameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface NestableParameterAnnotation extends
+ ParameterAnnotation, NestableAnnotation {
+
+ // combine two interfaces
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/NestableParameterAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,55 @@
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * Corresponds to the JPA annotation
+ * org.hibernate.annotations.Parameter
+ */
+
+public interface ParameterAnnotation extends Annotation {
+ String ANNOTATION_NAME = Hibernate.GENERATOR_PARAMETER;
+
+ /**
+ * Corresponds to the 'name' element of the ParameterAnnotation annotation.
+ * Return null if the element does not exist in the annotation
+ */
+ String getName();
+ String NAME_PROPERTY = Hibernate.GENERATOR_PARAMETER__NAME;
+
+ /**
+ * Corresponds to the 'name' element of the ParameterAnnotation annotation.
+ * Setting to null will remove the element.
+ */
+ void setName(String name);
+
+ /**
+ * Return the {@link TextRange} for the 'name' element. If the element
+ * does not exist return the {@link TextRange} for the QueryHint annotation.
+ */
+ TextRange getNameTextRange(CompilationUnit astRoot);
+
+
+ /**
+ * Corresponds to the 'value' element of the ParameterAnnotation annotation.
+ * Return null if the element does not exist in the annotation
+ */
+ String getValue();
+ String VALUE_PROPERTY = Hibernate.GENERATOR_PARAMETER__VALUE;
+
+ /**
+ * Corresponds to the 'value' element of the ParameterAnnotation annotation.
+ * Setting to null will remove the element.
+ */
+ void setValue(String value);
+
+ /**
+ * Return the {@link TextRange} for the 'value' element. If the element
+ * does not exist return the {@link TextRange} for the QueryHint annotation.
+ */
+ TextRange getValueTextRange(CompilationUnit astRoot);
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/ParameterAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class SourceParameterAnnotation extends SourceAnnotation<Member> implements
+ NestableParameterAnnotation {
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter;
+ private final AnnotationElementAdapter<String> valueAdapter;
+ private String value;
+
+
+ public SourceParameterAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) {
+ super(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa));
+ this.nameDeclarationAdapter = this.buildNameAdapter(idaa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.valueDeclarationAdapter = this.buildValueAdapter(idaa);
+ this.valueAdapter = this.buildAdapter(this.valueDeclarationAdapter);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, NAME_PROPERTY);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildValueAdapter(DeclarationAnnotationAdapter adapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, VALUE_PROPERTY);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.value = this.buildValue(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setValue(this.buildValue(astRoot));
+ }
+
+ public IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+
+ // ********** ParameterAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** value
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ if (this.attributeValueHasNotChanged(this.value, value)) {
+ return;
+ }
+ String old = this.value;
+ this.value = value;
+ this.valueAdapter.setValue(value);
+ this.firePropertyChanged(VALUE_PROPERTY, old, value);
+ }
+
+ private String buildValue(CompilationUnit astRoot) {
+ return this.valueAdapter.getValue(astRoot);
+ }
+
+ public TextRange getValueTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.valueDeclarationAdapter, astRoot);
+ }
+
+
+ // ********** NestableAnnotation implementation **********
+
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ ParameterAnnotation oldParameter = (ParameterAnnotation) oldAnnotation;
+ this.setName(oldParameter.getName());
+ this.setValue(oldParameter.getValue());
+ }
+
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ // ********** static methods **********
+
+ public static SourceParameterAnnotation createGenericGeneratorParameter(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter genericGeneratorAdapter, int index) {
+ return new SourceParameterAnnotation(parent, member, buildGenericGeneratorParameterAnnotationAdapter(genericGeneratorAdapter, index));
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildGenericGeneratorParameterAnnotationAdapter(DeclarationAnnotationAdapter genericGeneratorAdapter, int index) {
+ return new NestedIndexedDeclarationAnnotationAdapter(genericGeneratorAdapter, Hibernate.GENERIC_GENERATOR__PARAMETERS, index, Hibernate.GENERATOR_PARAMETER);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2009-06-30 11:46:40 UTC (rev 16283)
@@ -18,7 +18,8 @@
org.eclipse.ui.ide,
org.eclipse.jpt.core,
org.eclipse.jpt.ui,
- org.eclipse.jpt.utility
+ org.eclipse.jpt.utility,
+ org.eclipse.jpt.db;bundle-version="1.2.100"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %Bundle-Vendor.0
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.ui.internal.java.details;
+
+import org.eclipse.jpt.core.context.java.JavaEntity;
+import org.eclipse.jpt.ui.WidgetFactory;
+import org.eclipse.jpt.ui.internal.java.details.JavaEntityComposite;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaEntityComposite<HibernateJavaEntity> extends JavaEntityComposite {
+
+ /**
+ * @param subjectHolder
+ * @param parent
+ * @param widgetFactory
+ */
+ public HibernateJavaEntityComposite(PropertyValueModel<? extends JavaEntity> subjectHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ super(subjectHolder, parent, widgetFactory);
+ }
+
+ @Override
+ protected void initializeGeneratorsPane(Composite container) {
+ container = addCollapsableSection(
+ container,
+ JptUiMappingsMessages.IdMappingComposite_primaryKeyGenerationSection
+ );
+
+ new HibernateGeneratorsComposite(this, container);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.ui.internal.mappings.details.GeneratorComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorComposite extends GeneratorComposite<GenericGenerator> {
+
+ public GenericGeneratorComposite(Pane<? extends GeneratorHolder> parentPane, Composite parent) {
+ super(parentPane, parent);
+ }
+
+ @Override
+ protected GenericGenerator buildGenerator(GeneratorHolder subject) {
+ return ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+
+ protected GenericGenerator buildGenerator() {
+ return this.buildGenerator(this.getSubject());
+ }
+
+ @Override
+ protected GenericGenerator getGenerator(GeneratorHolder subject) {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator();
+ }
+
+ @Override
+ protected String getPropertyName() {
+ return GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY;
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ // Name widgets
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_name,
+ buildGeneratorNameHolder(),
+ null//TODO add help
+ );
+
+ addLabeledEditableCombo(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_strategy,
+ new SimpleListValueModel<String>(JavaGenericGeneratorImpl.generatorClasses),
+ buildStrategyHolder(),
+ StringConverter.Default.<String>instance(),
+ null);//TODO add help
+
+ new ParametersComposite(this, container);
+ }
+
+ protected WritablePropertyValueModel<String> buildStrategyHolder() {
+ return new PropertyAspectAdapter<GeneratorHolder, String>(getSubjectHolder(),
+ GenericGenerator.GENERIC_STRATEGY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator() == null ?
+ null : ((GenericGeneratorHolder)subject).getGenericGenerator().getStrategy();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value))value = null; //$NON-NLS-1$
+ GenericGenerator generator = ((GenericGeneratorHolder)subject).getGenericGenerator();
+ if (generator == null){
+ generator = ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+ generator.setStrategy(value);
+ }
+ };
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.ui.internal.mappings.details.GeneratorsComposite;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateGeneratorsComposite extends GeneratorsComposite {
+
+ public HibernateGeneratorsComposite(Pane<? extends GeneratorHolder> parentPane, Composite parent) {
+ super(parentPane, parent);
+ }
+
+ private WritablePropertyValueModel<Boolean> genericGeneratorExpansionStateHolder;
+
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ genericGeneratorExpansionStateHolder = new SimplePropertyValueModel<Boolean>(false);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ super.initializeLayout(container);
+ initializeGenericGeneratorPane(container);
+ }
+
+ protected void initializeGenericGeneratorPane(Composite container) {
+
+ // Sequence Generator sub-section
+ container = addCollapsableSubSection(
+ addSubPane(container, 10),
+ "Generic Generator",
+ genericGeneratorExpansionStateHolder
+ );
+
+ // Sequence Generator check box
+ Button genericGeneratorCheckBox = addCheckBox(
+ addSubPane(container, 5),
+ "Generic generator",
+ buildGenericGeneratorBooleanHolder(),
+ null//TODO add help
+ );
+
+ // Sequence Generator pane
+ new GenericGeneratorComposite(
+ this,
+ addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16)
+ );
+
+ }
+
+ private WritablePropertyValueModel<Boolean> buildGenericGeneratorBooleanHolder() {
+ return new PropertyAspectAdapter<GeneratorHolder, Boolean>(getSubjectHolder(), GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ return ((GenericGeneratorHolder)subject).getGenericGenerator() != null;
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+
+ if (value && (((GenericGeneratorHolder)subject).getGenericGenerator() == null)) {
+ ((GenericGeneratorHolder)subject).addGenericGenerator();
+ }
+ else if (!value && (((GenericGeneratorHolder)subject).getGenericGenerator() != null)) {
+ ((GenericGeneratorHolder)subject).removeGenericGenerator();
+ }
+ }
+ };
+ }
+
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.ui.internal.mapping.details;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateUIMappingMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.messages"; //$NON-NLS-1$
+
+ public static String GenericGeneratorComposite_name;
+ public static String GenericGeneratorComposite_strategy;
+
+ private HibernateUIMappingMessages() {}
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, HibernateUIMappingMessages.class);
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,351 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.ui.internal.mapping.details;
+
+import java.util.ListIterator;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.GeneratorHolder;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.swt.ColumnAdapter;
+import org.eclipse.jpt.ui.internal.util.PaneEnabler;
+import org.eclipse.jpt.ui.internal.widgets.AddRemoveTablePane;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ParametersComposite extends Pane<GeneratorHolder> {
+
+ private PropertyValueModel<Generator> generatorHolder;
+
+ private WritablePropertyValueModel<Parameter> parameterHolder;
+
+ /**
+ * Creates a new <code>ParametersComposite</code>.
+ *
+ * @param parentPane The parent pane of this one
+ * @param parent The parent container
+ */
+ public ParametersComposite(Pane<? extends GeneratorHolder> parentPane,
+ Composite container) {
+
+ super(parentPane,container);
+ }
+
+ protected GenericGenerator getGenericGenerator(){
+ return ((GenericGeneratorHolder) getSubject()).getGenericGenerator();
+ }
+
+ private PropertyValueModel<Boolean> buildPaneEnableHolder() {
+ return new TransformationPropertyValueModel<GeneratorHolder, Boolean>(getSubjectHolder()) {
+ @Override
+ protected Boolean transform(GeneratorHolder generator) {
+ return (generator != null);
+ }
+ };
+ }
+
+ private Adapter buildParameterAdapter() {
+ return new AddRemoveTablePane.AbstractAdapter() {
+ public void addNewItem(ObjectListSelectionModel listSelectionModel) {
+ Parameter parameter = getGenericGenerator().addParameter(getGenericGenerator().parametersSize());
+ parameterHolder.setValue(parameter);
+ }
+
+ public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
+ for (Object item : listSelectionModel.selectedValues()) {
+ getGenericGenerator().removeParameter((Parameter) item);
+ }
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Parameter> buildParameterHolder() {
+ return new SimplePropertyValueModel<Parameter>();
+ };
+
+ private ITableLabelProvider buildParameterLabelProvider() {
+ return new TableLabelProvider();
+ }
+
+ private ListValueModel<Parameter> buildParameterListHolder() {
+ return new ListAspectAdapter<Generator, Parameter>(
+ generatorHolder,
+ GenericGenerator.PARAMETERS_LIST) {
+ @Override
+ protected ListIterator<Parameter> listIterator_() {
+ GenericGenerator generator = (GenericGenerator) subject;
+ if (generator == null ){
+ return EmptyListIterator.instance();
+ } else {
+ return generator.parameters();
+ }
+ }
+
+ @Override
+ protected int size_() {
+ GenericGenerator generator = (GenericGenerator) subject;
+ return generator == null ? 0 : generator.parametersSize();
+ }
+ };
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.generatorHolder = buildGeneratorHolder();
+ parameterHolder = buildParameterHolder();
+ }
+
+ private PropertyValueModel<Generator> buildGeneratorHolder() {
+ return new PropertyAspectAdapter<GeneratorHolder, Generator>(getSubjectHolder(),
+ GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
+ @Override
+ protected Generator buildValue_() {
+ return ParametersComposite.this.getGenericGenerator();
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ TablePane tablePane = new TablePane(container);
+ installPaneEnabler(tablePane);
+ }
+
+ private PaneEnabler installPaneEnabler(TablePane tablePane) {
+ return new PaneEnabler(buildPaneEnableHolder(), tablePane);
+ }
+
+ private static class ParameterColumnAdapter implements ColumnAdapter<Parameter> {
+
+ static final int COLUMN_COUNT = 2;
+ static final int NAME_COLUMN_INDEX = 0;
+ static final int VALUE_COLUMN_INDEX = 1;
+
+ private WritablePropertyValueModel<String> buildNameHolder(Parameter subject) {
+ return new PropertyAspectAdapter<Parameter, String>(Parameter.NAME_PROPERTY, subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setName(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<?> buildValueHolder(Parameter subject) {
+ return new PropertyAspectAdapter<Parameter, String>(Parameter.VALUE_PROPERTY, subject) {
+ @Override
+ protected String buildValue_() {
+ return subject.getValue();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setValue(value);
+ }
+ };
+ }
+
+ public WritablePropertyValueModel<?>[] cellModels(Parameter subject) {
+ WritablePropertyValueModel<?>[] models = new WritablePropertyValueModel<?>[COLUMN_COUNT];
+ models[NAME_COLUMN_INDEX] = buildNameHolder(subject);
+ models[VALUE_COLUMN_INDEX] = buildValueHolder(subject);
+ return models;
+ }
+
+ public int columnCount() {
+ return COLUMN_COUNT;
+ }
+
+ public String columnName(int columnIndex) {
+
+ switch (columnIndex) {
+ case ParameterColumnAdapter.NAME_COLUMN_INDEX: {
+ return JptUiMappingsMessages.QueryHintsComposite_nameColumn;
+ }
+
+ case ParameterColumnAdapter.VALUE_COLUMN_INDEX: {
+ return JptUiMappingsMessages.QueryHintsComposite_valueColumn;
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
+ }
+
+ private class TableLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+
+ Parameter parameter = (Parameter) element;
+ String value = "";
+
+ switch (columnIndex) {
+ case ParameterColumnAdapter.NAME_COLUMN_INDEX: {
+ value = parameter.getName();
+ break;
+ }
+
+ case ParameterColumnAdapter.VALUE_COLUMN_INDEX: {
+ value = parameter.getValue();
+ break;
+ }
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+ }
+
+ private class TablePane extends AddRemoveTablePane<GeneratorHolder> {
+
+ private TablePane(Composite parent) {
+ super(ParametersComposite.this,
+ parent,
+ buildParameterAdapter(),
+ buildParameterListHolder(),
+ parameterHolder,
+ buildParameterLabelProvider());
+ }
+
+ private CellEditor[] buildCellEditors(Table table) {
+ return new CellEditor[] {
+ new TextCellEditor(table),
+ new TextCellEditor(table)
+ };
+ }
+
+ private ICellModifier buildCellModifier() {
+ return new ICellModifier() {
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ Parameter parameter = (Parameter) element;
+ String value = "";
+
+ if (property == Parameter.NAME_PROPERTY) {
+ value = parameter.getName();
+ }
+ else if (property == Parameter.VALUE_PROPERTY) {
+ value = parameter.getValue();
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ Parameter parameter;
+
+ if (element instanceof TableItem) {
+ TableItem tableItem = (TableItem) element;
+ parameter = (Parameter) tableItem.getData();
+ }
+ else {
+ parameter = (Parameter) element;
+ }
+
+ if (property == Parameter.NAME_PROPERTY) {
+ parameter.setName(value.toString());
+ }
+ else if (property == Parameter.VALUE_PROPERTY) {
+ parameter.setValue(value.toString());
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ColumnAdapter<?> buildColumnAdapter() {
+ return new ParameterColumnAdapter();
+ }
+
+ private String[] buildColumnProperties() {
+ return new String[] {
+ Parameter.NAME_PROPERTY,
+ Parameter.VALUE_PROPERTY
+ };
+ }
+
+ @Override
+ protected void initializeMainComposite(Composite container,
+ Adapter adapter,
+ ListValueModel<?> listHolder,
+ WritablePropertyValueModel<?> selectedItemHolder,
+ IBaseLabelProvider labelProvider,
+ String helpId) {
+
+ super.initializeMainComposite(
+ container,
+ adapter,
+ listHolder,
+ selectedItemHolder,
+ labelProvider,
+ helpId
+ );
+
+ Table table = getMainControl();
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setCellEditors(buildCellEditors(table));
+ tableViewer.setCellModifier(buildCellModifier());
+ tableViewer.setColumnProperties(buildColumnProperties());
+ }
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-06-30 11:46:40 UTC (rev 16283)
@@ -0,0 +1,2 @@
+GenericGeneratorComposite_strategy=Strategy:
+GenericGeneratorComposite_name=Name:
\ No newline at end of file
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-06-30 11:44:20 UTC (rev 16282)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernateJpaUiFactory.java 2009-06-30 11:46:40 UTC (rev 16283)
@@ -14,8 +14,10 @@
import java.util.List;
import java.util.ListIterator;
+import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.ui.WidgetFactory;
+import org.eclipse.jpt.ui.details.JpaComposite;
import org.eclipse.jpt.ui.details.JpaPageComposite;
import org.eclipse.jpt.ui.internal.GenericJpaUiFactory;
import org.eclipse.jpt.ui.internal.persistence.details.GenericPersistenceUnitGeneralComposite;
@@ -26,6 +28,8 @@
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.BasicHibernateProperties;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
+import org.jboss.tools.hibernate.jpt.ui.internal.java.details.HibernateJavaEntityComposite;
import org.jboss.tools.hibernate.jpt.ui.internal.persistence.details.HibernatePropertiesComposite;
/**
@@ -53,6 +57,12 @@
return pages.listIterator();
}
+
+ @Override
+ public JpaComposite createJavaEntityComposite(PropertyValueModel<JavaEntity> subjectHolder,
+ Composite parent, WidgetFactory widgetFactory) {
+ return new HibernateJavaEntityComposite<HibernateJavaEntity>(subjectHolder, parent, widgetFactory);
+ }
private PropertyValueModel<BasicHibernateProperties> buildBasicHolder(
PropertyValueModel<HibernatePersistenceUnit> subjectHolder) {
15 years, 3 months
JBoss Tools SVN: r16282 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal: context/basic and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-06-30 07:44:20 -0400 (Tue, 30 Jun 2009)
New Revision: 16282
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJavaNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaNamedQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4521
Hibernate NameQuery support
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJavaNamedQueryImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJavaNamedQueryImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJavaNamedQueryImpl.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaNamedQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateJavaNamedQueryImpl extends GenericJavaNamedQuery
+ implements HibernateJavaNamedQuery {
+
+ /**
+ * @param parent
+ */
+ public HibernateJavaNamedQueryImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJavaNamedQueryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-06-30 11:43:09 UTC (rev 16281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -15,6 +15,7 @@
import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider;
import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
/**
@@ -47,6 +48,7 @@
@Override
protected void addTypeSupportingAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) {
definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-06-30 11:43:09 UTC (rev 16281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -13,6 +13,7 @@
import org.eclipse.jpt.core.context.java.JavaEntity;
import org.eclipse.jpt.core.context.java.JavaIdMapping;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.persistence.Persistence;
@@ -22,8 +23,10 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
/**
@@ -42,9 +45,6 @@
return new HibernateJavaEntity(parent);
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.internal.platform.GenericJpaFactory#buildJavaIdMapping(org.eclipse.jpt.core.context.java.JavaPersistentAttribute)
- */
@Override
public JavaIdMapping buildJavaIdMapping(JavaPersistentAttribute parent) {
return new HibernateJavaIdMapping(parent);
@@ -53,5 +53,13 @@
public JavaGenericGenerator buildJavaGenericGenerator(JavaJpaContextNode parent) {
return new JavaGenericGeneratorImpl(parent);
}
+
+ public JavaNamedQuery buildHibernateJavaNamedQuery(JavaJpaContextNode parent) {
+ return new HibernateJavaNamedQueryImpl(parent);
+ }
+ public JavaParameter buildJavaParameter(JavaGenericGeneratorImpl javaGenericGeneratorImpl) {
+ return new HibernateJavaParameter(javaGenericGeneratorImpl);
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-06-30 11:43:09 UTC (rev 16281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -26,6 +26,18 @@
String GENERIC_GENERATOR = PACKAGE_ + "GenericGenerator"; //$NON-NLS-1$
String GENERIC_GENERATOR__NAME = "name"; //$NON-NLS-1$
String GENERIC_GENERATOR__STRATEGY = "strategy"; //$NON-NLS-1$
+ String GENERIC_GENERATOR__PARAMETERS = "parameters"; //$NON-NLS-1$
+ String GENERATOR_PARAMETER = PACKAGE_ + "Parameter"; //$NON-NLS-1$
+ String GENERATOR_PARAMETER__NAME = "name"; //$NON-NLS-1$
+ String GENERATOR_PARAMETER__VALUE = "value"; //$NON-NLS-1$
+
+ String NAMED_QUERY = PACKAGE_ + "NamedQuery";
+ String NAMED_QUERY__NAME = "name";
+ String NAMED_QUERY__QUERY = "query";
+ String NAMED_QUERY__HINTS = "hints";
+
+ String NAMED_QUERIES = PACKAGE_ + "NamedQueries";
+ String NAMED_QUERIES__VALUE = "value";
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-06-30 11:43:09 UTC (rev 16281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -13,12 +13,17 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
+import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -55,6 +60,10 @@
firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator, newGenericGenerator);
}
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
+ }
+
protected void initializeGenericGenerator() {
GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
if (genericGeneratorResource != null) {
@@ -62,12 +71,26 @@
}
}
+ @Override
+ protected void initializeNamedQueries() {
+ super.initializeNamedQueries();
+ for (ListIterator<NestableAnnotation> stream = this.javaResourcePersistentType.supportingAnnotations(Hibernate.NAMED_QUERY, Hibernate.NAMED_QUERIES); stream.hasNext(); ) {
+ this.namedQueries.add(buildHibernateNamedQuery((HibernateNamedQueryAnnotation) stream.next()));
+ }
+ }
+
+ protected JavaNamedQuery buildHibernateNamedQuery(HibernateNamedQueryAnnotation namedQueryResource) {
+ JavaNamedQuery namedQuery = getJpaFactory().buildHibernateJavaNamedQuery(this);
+ namedQuery.initialize(namedQueryResource);
+ return namedQuery;
+ }
+
protected GenericGeneratorAnnotation getResourceGenericGenerator() {
return (GenericGeneratorAnnotation) this.javaResourcePersistentType.getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
}
protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation genericGeneratorResource) {
- JavaGenericGenerator generator = ((HibernateJpaFactory) getJpaFactory()).buildJavaGenericGenerator(this);
+ JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
generator.initialize(genericGeneratorResource);
return generator;
}
@@ -76,7 +99,7 @@
if (getGenericGenerator() != null) {
throw new IllegalStateException("genericGenerator already exists"); //$NON-NLS-1$
}
- this.genericGenerator = ((HibernateJpaFactory)getJpaFactory()).buildJavaGenericGenerator(this);
+ this.genericGenerator = getJpaFactory().buildJavaGenericGenerator(this);
GenericGeneratorAnnotation genericGeneratorResource = (GenericGeneratorAnnotation)javaResourcePersistentType
.addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
this.genericGenerator.initialize(genericGeneratorResource);
@@ -128,11 +151,41 @@
}
}
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.eclipse.jdt.core.dom.CompilationUnit)
- */
+
@Override
+ protected void updateNamedQueries() {
+ ListIterator<JavaNamedQuery> queries = namedQueries();
+ ListIterator<NestableAnnotation> resourceNamedQueries = this.javaResourcePersistentType.supportingAnnotations(NamedQueryAnnotation.ANNOTATION_NAME, NamedQueriesAnnotation.ANNOTATION_NAME);
+
+ ListIterator<NestableAnnotation> hibernateNamedQueries = this.javaResourcePersistentType.supportingAnnotations(Hibernate.NAMED_QUERY, Hibernate.NAMED_QUERIES);
+
+ while (queries.hasNext()) {
+ JavaNamedQuery namedQuery = queries.next();
+ if (namedQuery instanceof HibernateJavaNamedQuery) {
+ if (hibernateNamedQueries.hasNext()) {
+ namedQuery.update((HibernateNamedQueryAnnotation) hibernateNamedQueries.next());
+ } else {
+ removeNamedQuery_(namedQuery);
+ }
+ } else {
+ if (resourceNamedQueries.hasNext()) {
+ namedQuery.update((NamedQueryAnnotation) resourceNamedQueries.next());
+ } else {
+ removeNamedQuery_(namedQuery);
+ }
+ }
+ }
+
+ while (resourceNamedQueries.hasNext()) {
+ addNamedQuery(buildNamedQuery((NamedQueryAnnotation) resourceNamedQueries.next()));
+ }
+
+ while (hibernateNamedQueries.hasNext()) {
+ addNamedQuery(buildHibernateNamedQuery((HibernateNamedQueryAnnotation) hibernateNamedQueries.next()));
+ }
+ }
+
+ @Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
validateGenericGenerator(messages, reporter, astRoot);
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-06-30 11:43:09 UTC (rev 16281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -17,13 +17,13 @@
import org.eclipse.jpt.core.context.java.JavaGenerator;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.internal.context.java.GenericJavaIdMapping;
+import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
-import org.logicalcobwebs.cglib.reflect.FastClass.Generator;
/**
* @author Dmitry Geraskov
@@ -41,9 +41,6 @@
super(parent);
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.internal.context.java.GenericJavaIdMapping#initialize()
- */
@Override
protected void initialize() {
super.initialize();
@@ -129,9 +126,6 @@
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.internal.context.java.GenericJavaIdMapping#validate(java.util.List, org.eclipse.wst.validation.internal.provisional.core.IReporter, org.eclipse.jdt.core.dom.CompilationUnit)
- */
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
@@ -143,5 +137,21 @@
genericGenerator.validate(messages, reporter, astRoot);
}
}
+
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter,
+ CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ if (this.getGenericGenerator() != null) {
+ result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaNamedQuery.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaNamedQuery.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaNamedQuery.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaNamedQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateJavaNamedQuery extends JavaNamedQuery {
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaNamedQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation {
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedQueryAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new HibernateNamedQueryAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ //TODO return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return Hibernate.NAMED_QUERY;
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-06-30 11:44:20 UTC (rev 16282)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jpt.core.internal.context.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
+ implements BaseNamedQueryAnnotation, HibernateNamedQueryAnnotation {
+
+ public static String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
+
+ final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ final AnnotationElementAdapter<String> nameAdapter;
+ String name;
+
+ final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
+ final AnnotationElementAdapter<String> queryAdapter;
+ String query;
+
+ //FIXME: can't have hints
+ final Vector<NestableQueryHintAnnotation> hints = new Vector<NestableQueryHintAnnotation>();
+ //final HintsAnnotationContainer hintsContainer = new HintsAnnotationContainer();
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ //AnnotationContainerTools.initialize(this.hintsContainer, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ //AnnotationContainerTools.update(this.hintsContainer, astRoot);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+
+ // ********** BaseNamedQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getNameElementName());
+ }
+
+ String getNameElementName() {
+ return Hibernate.NAMED_QUERY__NAME;
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getQueryElementName());
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return new CloneListIterator<QueryHintAnnotation>(this.hints);
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return new CloneListIterator<NestableQueryHintAnnotation>(this.hints);
+ }
+
+ public int hintsSize() {
+ return this.hints.size();
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ return this.hints.get(index);
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return this.hints.indexOf(queryHint);
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ NestableQueryHintAnnotation addHintInternal() {
+ return null;
+ }
+
+ void hintAdded(int index, NestableQueryHintAnnotation hint) {
+ this.fireItemAdded(HINTS_LIST, index, hint);
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
+ }
+
+ NestableQueryHintAnnotation moveHintInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.hints, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ void hintMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(HINTS_LIST, targetIndex, sourceIndex);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ NestableQueryHintAnnotation removeHintInternal(int index) {
+ return this.hints.remove(index);
+ }
+
+ void hintRemoved(int index, NestableQueryHintAnnotation hint) {
+ this.fireItemRemoved(HINTS_LIST, index, hint);
+ }
+
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ BaseNamedQueryAnnotation oldQuery = (BaseNamedQueryAnnotation) oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ for (QueryHintAnnotation oldQueryHint : CollectionTools.iterable(oldQuery.hints())) {
+ NestableQueryHintAnnotation newQueryHint = this.addHint(oldQuery.indexOfHint(oldQueryHint));
+ newQueryHint.initializeFrom((NestableQueryHintAnnotation) oldQueryHint);
+ }
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static NamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Tools SVN: r16281 - in trunk/jst/plugins/org.jboss.tools.jst.css: .settings and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-06-30 07:43:09 -0400 (Tue, 30 Jun 2009)
New Revision: 16281
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/.classpath
trunk/jst/plugins/org.jboss.tools.jst.css/.project
trunk/jst/plugins/org.jboss.tools.jst.css/.settings/
trunk/jst/plugins/org.jboss.tools.jst.css/.settings/org.eclipse.jdt.core.prefs
trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/
trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.css/build.properties
trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.css/src/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CssPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/CSSUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/messages.properties
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/AbstractCssSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BackgroundSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BoxesSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/QuickEditSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TextSection.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSViewUtil.java
Log:
Added: trunk/jst/plugins/org.jboss.tools.jst.css/.classpath
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/.classpath (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/.classpath 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/.project
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/.project (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/.project 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.jst.css</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/.project
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/.settings/org.eclipse.jdt.core.prefs 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,8 @@
+#Tue Jun 09 11:54:10 EEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.jboss.tools.jst.css;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.jst.css.CssPlugin
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.jboss.tools.jst.jsp;bundle-version="2.0.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.0",
+ org.eclipse.ui.views.log;bundle-version="1.0.100",
+ org.eclipse.core.databinding;bundle-version="1.2.0",
+ org.eclipse.wst.css.core;bundle-version="1.1.300",
+ org.eclipse.core.resources;bundle-version="3.5.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Eclipse-LazyStart: true
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/build.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/build.properties (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/build.properties 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ plugin.properties
+jars.compile.order = .
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,9 @@
+Bundle-Vendor = JBoss, a division of Red Hat
+Bundle-Name = CSS Test Plug-in
+css.tabs.textFont.label=Text/Font
+css.tabs.background.label=Background
+css.tabs.boxes.label=Boxes
+css.tabs.property.label=Property Sheet
+css.tabs.quickEdit.label=Edited Properties
+css.editor_name=CSS Editor View
+css.preview_name=CSS Preview View
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
+ <propertyContributor contributorId="org.eclipse.wst.css.core.csssource.source"
+ typeMapper="org.jboss.tools.jst.css.properties.TypeMapper">
+ <propertyCategory category="general">
+ </propertyCategory>
+ </propertyContributor>
+ </extension>
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs contributorId="org.eclipse.wst.css.core.csssource.source">
+ <propertyTab category="general"
+ id="org.jboss.tools.jst.css.textFontTab" label="%css.tabs.textFont.label">
+ </propertyTab>
+ <propertyTab category="general"
+ id="org.jboss.tools.jst.css.backgroundTab" label="%css.tabs.background.label"
+ afterTab="org.jboss.tools.jst.css.textFontTab">
+ </propertyTab>
+ <propertyTab category="general" id="org.jboss.tools.jst.css.boxesTab"
+ label="%css.tabs.boxes.label" afterTab="org.jboss.tools.jst.css.backgroundTab">
+ </propertyTab>
+ <propertyTab category="general"
+ id="org.jboss.tools.jst.css.propertyTab" label="%css.tabs.property.label"
+ afterTab="org.jboss.tools.jst.css.boxesTab">
+ </propertyTab>
+ <propertyTab category="general"
+ id="org.jboss.tools.jst.css.quickEditTab" label="%css.tabs.quickEdit.label"
+ afterTab="org.jboss.tools.jst.css.propertyTab">
+ </propertyTab>
+ </propertyTabs>
+ </extension>
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.eclipse.wst.css.core.csssource.source">
+ <propertySection class="org.jboss.tools.jst.css.properties.TextSection"
+ id="org.jboss.tools.jst.css.textFontTab" tab="org.jboss.tools.jst.css.textFontTab">
+ <input
+ type="org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule">
+ </input>
+ </propertySection>
+
+ <propertySection
+ class="org.jboss.tools.jst.css.properties.BackgroundSection" id="org.jboss.tools.jst.css.backgroundTab"
+ tab="org.jboss.tools.jst.css.backgroundTab" >
+ <input
+ type="org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule">
+ </input>
+ </propertySection>
+ <propertySection class="org.jboss.tools.jst.css.properties.BoxesSection"
+ id="org.jboss.tools.jst.css.boxesTab" tab="org.jboss.tools.jst.css.boxesTab">
+ <input
+ type="org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule">
+ </input>
+ </propertySection>
+ <propertySection
+ class="org.jboss.tools.jst.css.properties.PropertiesSection" id="org.jboss.tools.jst.css.propertyTab"
+ tab="org.jboss.tools.jst.css.propertyTab">
+ <input
+ type="org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule">
+ </input>
+ </propertySection>
+ <propertySection
+ class="org.jboss.tools.jst.css.properties.QuickEditSection" id="org.jboss.tools.jst.css.quickEditTab"
+ tab="org.jboss.tools.jst.css.quickEditTab">
+ <input
+ type="org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule">
+ </input>
+ </propertySection>
+ </propertySections>
+
+ </extension>
+ <extension point="org.eclipse.ui.views">
+ <view class="org.jboss.tools.jst.css.view.CSSEditorView" id="org.jboss.tools.jst.css.view.editor"
+ name="%css.editor_name" restorable="true">
+ </view>
+ <view
+ class="org.jboss.tools.jst.css.view.CSSPreview"
+ id="org.jboss.tools.jst.css.view.preview"
+ name="%css.preview_name"
+ restorable="true">
+ </view>
+ </extension>
+</plugin>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CssPlugin.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CssPlugin.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CssPlugin.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CssPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.jst.css";
+
+ // The shared instance
+ private static CssPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public CssPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static CssPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/CssPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/CSSUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/CSSUIMessages.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/CSSUIMessages.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,15 @@
+package org.jboss.tools.jst.css.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CSSUIMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.jst.css.messages.messages"; //$NON-NLS-1$
+ public static String CSSViewDefaultPreviewText;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, CSSUIMessages.class);
+ }
+
+ private CSSUIMessages() {
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/CSSUIMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/messages.properties (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/messages.properties 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1 @@
+CSSViewDefaultPreviewText=Double click to edit preview. To save changes press Enter button.
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/messages/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/AbstractCssSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/AbstractCssSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/AbstractCssSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.StyleAttributes;
+import org.w3c.dom.css.CSSStyleDeclaration;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public abstract class AbstractCssSection extends AbstractPropertySection {
+ private DataBindingContext bindingContext;
+ private StyleAttributes styleAttributes;
+
+ @Override
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ if (aTabbedPropertySheetPage instanceof CSSPropertyPage) {
+ bindingContext = ((CSSPropertyPage) aTabbedPropertySheetPage)
+ .getBindingContext();
+ styleAttributes = ((CSSPropertyPage) aTabbedPropertySheetPage)
+ .getStyleAttributes();
+ }
+ createTabControl(parent);
+ }
+
+ abstract public void createTabControl(Composite parent);
+
+ public DataBindingContext getBindingContext() {
+ return bindingContext;
+ }
+
+ public StyleAttributes getStyleAttributes() {
+ return styleAttributes;
+ }
+
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/AbstractCssSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BackgroundSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BackgroundSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BackgroundSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBackgroundControl;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class BackgroundSection extends AbstractCssSection {
+
+ @Override
+ public void createTabControl(Composite parent) {
+ new TabBackgroundControl(parent, getStyleAttributes(),
+ getBindingContext());
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BackgroundSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BoxesSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BoxesSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BoxesSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabBoxesControl;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class BoxesSection extends AbstractCssSection {
+
+ @Override
+ public void createTabControl(Composite parent) {
+
+ new TabBoxesControl(parent, getStyleAttributes(),
+ getBindingContext());
+
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/BoxesSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.jboss.tools.jst.css.view.CSSEditorView;
+import org.jboss.tools.jst.css.view.CSSViewUtil;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.StyleAttributes;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSPropertyPage extends TabbedPropertySheetPage implements
+ IChangeListener {
+
+ private DataBindingContext bindingContext;
+
+ private StyleAttributes styleAttributes;
+
+ private CSSEditorView part;
+
+ private Object selectedObject;
+
+ public CSSPropertyPage(
+ ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor,
+ CSSEditorView part) {
+ super(tabbedPropertySheetPageContributor);
+ bindingContext = new DataBindingContext();
+ styleAttributes = new StyleAttributes();
+ ((IObservable) styleAttributes.getAttributeMap())
+ .addChangeListener(this);
+ this.part = part;
+
+ }
+
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ pageSite.getWorkbenchWindow().getSelectionService()
+ .addPostSelectionListener(this);
+ }
+
+ @Override
+ public void dispose() {
+ getSite().getWorkbenchWindow().getSelectionService()
+ .removePostSelectionListener(this);
+ super.dispose();
+ }
+
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ if ((this.part != part) && (selection instanceof IStructuredSelection)) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object newSelectedObject = structuredSelection.getFirstElement();
+ if (structuredSelection.getFirstElement() instanceof ICSSNode) {
+
+ CSSStyleRule styleRule = CSSViewUtil
+ .getStyleRule((ICSSNode) structuredSelection
+ .getFirstElement());
+
+ if (styleRule != null) {
+ // if (styleRule != selectedObject) {
+ ((IObservable) styleAttributes.getAttributeMap())
+ .removeChangeListener(this);
+ updateStyleAttributes(styleRule);
+ ((IObservable) styleAttributes.getAttributeMap())
+ .addChangeListener(this);
+ // }
+ newSelectedObject = styleRule;
+ }
+
+ }
+ // if (newSelectedObject != selectedObject) {
+ super.selectionChanged(part, selection);
+ selectedObject = newSelectedObject;
+ // }
+
+ }
+
+ }
+
+ private void updateStyleAttributes(CSSStyleRule styleRule) {
+
+ getStyleAttributes().setStyleProperties(
+ CSSViewUtil.getStyleAttributes(styleRule));
+
+ }
+
+ public void handleChange(ChangeEvent event) {
+
+ if (selectedObject instanceof CSSStyleRule) {
+
+ final CSSStyleDeclaration declaration = ((CSSStyleRule) selectedObject)
+ .getStyle();
+
+ // set properties
+ final Set<Entry<String, String>> set = styleAttributes.entrySet();
+
+ if ((set.size() == 0) && (declaration.getLength() > 0)) {
+ declaration.setCssText(Constants.EMPTY);
+ } else {
+ for (final Map.Entry<String, String> me : set) {
+ if ((me.getValue() == null)
+ || (me.getValue().length() == 0)) {
+ declaration.removeProperty(me.getKey());
+ } else {
+ declaration.setProperty(me.getKey(), me.getValue(),
+ Constants.EMPTY);
+ }
+ }
+ }
+ }
+
+ StructuredSelection selection = new StructuredSelection(
+ new Object[] { selectedObject });
+ part.postSelectionChanged(new SelectionChangedEvent(part
+ .getSelectionProvider(), selection));
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public DataBindingContext getBindingContext() {
+ return bindingContext;
+ }
+
+ public StyleAttributes getStyleAttributes() {
+ return styleAttributes;
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/CSSPropertyPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabPropertySheetControl;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class PropertiesSection extends AbstractCssSection {
+
+ @Override
+ public void createTabControl(Composite parent) {
+
+ new TabPropertySheetControl(parent, getStyleAttributes(),
+ getBindingContext());
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/PropertiesSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/QuickEditSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/QuickEditSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/QuickEditSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabQuickEditControl;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class QuickEditSection extends AbstractCssSection {
+
+ @Override
+ public void createTabControl(Composite parent) {
+ new TabQuickEditControl(parent, getStyleAttributes(),
+ getBindingContext());
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/QuickEditSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TextSection.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TextSection.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TextSection.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.jst.jsp.outline.cssdialog.tabs.TabTextControl;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class TextSection extends AbstractCssSection {
+
+ @Override
+ public void createTabControl(Composite parent) {
+ new TabTextControl(parent, getStyleAttributes(),
+ getBindingContext());
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TextSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.properties;
+
+import org.eclipse.ui.views.properties.tabbed.ITypeMapper;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class TypeMapper implements ITypeMapper {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.views.properties.tabbed.ITypeMapper#mapType(java.lang.
+ * Object)
+ */
+ public Class mapType(Object object) {
+
+ while (object instanceof ICSSNode) {
+ if ((object instanceof ICSSStyleRule)
+ || (((ICSSNode) object).getParentNode() == null)) {
+ break;
+ } else {
+ object = ((ICSSNode) object).getParentNode();
+ }
+ }
+ return object.getClass();
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/properties/TypeMapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.view;
+
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.jboss.tools.jst.css.properties.CSSPropertyPage;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSEditorView extends PropertySheet {
+
+ static public String CONTRIBUTOR_ID = "org.eclipse.wst.css.core.csssource.source"; //$NON-NLS-1$
+
+ @Override
+ protected PageRec doCreatePage(final IWorkbenchPart part) {
+ if (part instanceof PropertySheet) {
+ return null;
+ }
+ IPropertySheetPage page = new CSSPropertyPage(
+ new ITabbedPropertySheetPageContributor() {
+
+ public String getContributorId() {
+ return CONTRIBUTOR_ID;
+ }
+ }, this);
+ if (page != null) {
+ if (page instanceof IPageBookViewPage) {
+ initPage((IPageBookViewPage) page);
+ }
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+
+ // Use the default page
+ return null;
+ }
+
+ @Override
+ public SelectionProvider getSelectionProvider() {
+ // TODO Auto-generated method stub
+ return super.getSelectionProvider();
+ }
+ public void postSelectionChanged(SelectionChangedEvent event){
+ getSelectionProvider().postSelectionChanged(event);
+ }
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSEditorView.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.view;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.jboss.tools.jst.css.messages.CSSUIMessages;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.w3c.dom.css.CSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSPreview extends ViewPart implements ISelectionListener {
+
+ private Browser browser;
+
+ private Text previewText;
+
+ private String previewContent = CSSUIMessages.CSSViewDefaultPreviewText;
+
+ private Map<String, String> styleAttributes = new HashMap<String, String>();
+
+// private String location;
+// private String selectorName;
+
+ @Override
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ site.getWorkbenchWindow().getSelectionService()
+ .addPostSelectionListener(this);
+ }
+
+ @Override
+ public void dispose() {
+ getSite().getWorkbenchWindow().getSelectionService()
+ .removePostSelectionListener(this);
+ super.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ final SashForm previewComposite = new SashForm(parent, SWT.None);
+ previewComposite.setLayout(new GridLayout());
+ GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
+ true);
+ previewComposite.setLayoutData(gridData);
+
+ browser = new Browser(previewComposite, SWT.BORDER | SWT.MOZILLA);
+ browser.setText(generateBrowserPage());
+ browser.setLayoutData(gridData);
+ browser.addMouseListener(new MouseAdapter() {
+ public void mouseDoubleClick(MouseEvent e) {
+ if (e.widget == browser) {
+ browser.setEnabled(false);
+ previewComposite.setMaximizedControl(previewText);
+ previewText.setFocus();
+ }
+ }
+ });
+
+ previewText = new Text(previewComposite, SWT.NONE | SWT.H_SCROLL);
+ previewText.setLayoutData(gridData);
+ previewText.setText(getPreviewContent());
+ previewText.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent e) {
+ if (e.widget == previewText) {
+ String text = previewText.getText();
+ if (text == null || text.equals(Constants.EMPTY)) {
+ setPreviewContent(CSSUIMessages.CSSViewDefaultPreviewText);
+ } else {
+ setPreviewContent(text);
+ }
+
+ browser.setEnabled(true);
+ browser.setText(generateBrowserPage());
+ previewComposite.setMaximizedControl(browser);
+ }
+ }
+ });
+
+ previewComposite.setMaximizedControl(browser);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ browser.setFocus();
+ }
+
+ /**
+ * /** Method is used to build html body that is appropriate to browse.
+ *
+ * @return String html text representation
+ */
+ public String generateBrowserPage() {
+
+ StringBuffer html = new StringBuffer(Constants.OPEN_DIV_TAG);
+
+ for (Map.Entry<String, String> styleItem :
+ styleAttributes.entrySet()) {
+
+ html.append(styleItem.getKey() + Constants.COLON
+ + styleItem.getValue() + Constants.SEMICOLON);
+ }
+
+ html.append("\">" + getPreviewContent() + Constants.CLOSE_DIV_TAG); //$NON-NLS-1$
+
+// String html = "<html><head><link type=\"text/css\" rel=\"stylesheet\" href=\""
+// + location
+// + "\" /></head><body > <span class=\""
+// + selectorName
+// + "\" >"
+// + getPreviewContent() + "</span></body></html>";
+
+ return html.toString();
+ }
+
+ public String getPreviewContent() {
+ return previewContent;
+ }
+
+ public void setPreviewContent(String previewContent) {
+ this.previewContent = previewContent;
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.getFirstElement() instanceof ICSSNode) {
+
+ CSSStyleRule styleRule = CSSViewUtil
+ .getStyleRule((ICSSNode) structuredSelection
+ .getFirstElement());
+
+ if (styleRule != null) {
+// selectorName = styleRule.getSelectorText();
+// location = ResourcesPlugin.getWorkspace().getRoot()
+// .getLocation().toString()
+// + styleRule.getParentStyleSheet().getHref();
+ styleAttributes = CSSViewUtil.getStyleAttributes(styleRule);
+
+ } else {
+// selectorName = null;
+// location = null;
+ styleAttributes.clear();
+ }
+
+ updateBrowser();
+
+ }
+
+ }
+ }
+
+ public void updateBrowser() {
+ browser.setText(generateBrowserPage());
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSPreview.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSViewUtil.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSViewUtil.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSViewUtil.java 2009-06-30 11:43:09 UTC (rev 16281)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jst.css.view;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSViewUtil {
+
+ public static CSSStyleRule getStyleRule(ICSSNode node) {
+
+ while (node != null) {
+
+ if (node instanceof CSSStyleRule)
+ return (CSSStyleRule) node;
+
+ node = node.getParentNode();
+ }
+
+ return null;
+ }
+
+ public static Map<String, String> getStyleAttributes(CSSStyleRule styleRule) {
+
+ CSSStyleDeclaration declaration = styleRule.getStyle();
+ Map<String, String> styleMap = new HashMap<String, String>();
+ for (int i = 0; i < declaration.getLength(); i++) {
+ String propperty = declaration.item(i);
+ String value = declaration.getPropertyValue(propperty);
+ styleMap.put(propperty, value);
+ }
+
+ return styleMap;
+
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/view/CSSViewUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Tools SVN: r16280 - trunk/jst/plugins.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-06-30 07:40:32 -0400 (Tue, 30 Jun 2009)
New Revision: 16280
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/
Log:
Initial import.
15 years, 3 months
JBoss Tools SVN: r16279 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors: uitls and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-06-30 06:37:00 -0400 (Tue, 30 Jun 2009)
New Revision: 16279
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
Log:
JBIDE-4540
Create Json reader config wizard page
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -10,32 +10,443 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.json;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
/**
* @author Dart (dpeng(a)redhat.com)
- *
+ *
*/
public class JsonDataConfiguraitonWizardPage extends WizardPage {
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ private String rootName = null;
+
+ private String arrayElementName = "element";
+
+ private String keyWhitspaceReplacement = "-";
+
+ private String keyPrefixOnNumeric;
+
+ private String illegalElementNameCharReplacement;
+
+ private String nullValueReplacement = "";
+
+ private Map<String, String> keyMap;
+
+ private String encoding = "UTF-8";
+
+ private Text rootNameText;
+
+ private Text arrayElementNameText;
+
+ private Text keyWhitspaceReplacementText;
+
+ private Text keyPrefixOnNumericText;
+
+ private Text illegalElementNameCharReplacementText;
+
+ private Text nullValueReplacementText;
+
+ private Text encodingText;
+
+ private TableViewer keyMapViewer;
+
+ private ArrayList<KeyValueModel> keyValueList;
+
+ private void initValue() {
+ rootName = null;
+
+ arrayElementName = "element";
+
+ keyWhitspaceReplacement = "-";
+
+ keyPrefixOnNumeric = null;
+
+ illegalElementNameCharReplacement = null;
+ nullValueReplacement = "";
+ keyMap = new HashMap<String, String>();
+ encoding = "UTF-8";
+ keyValueList = new ArrayList<KeyValueModel>();
+
+ keyValueList.add(new KeyValueModel("ket", "aaaa"));
+ keyValueList.add(new KeyValueModel("12", "4"));
+ keyValueList.add(new KeyValueModel("fg", "1a"));
+ keyValueList.add(new KeyValueModel("g", "y4"));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
*/
public void createControl(Composite parent) {
+ initValue();
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ mainComposite.setLayout(layout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ mainComposite.setLayoutData(gd);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ /**
+ * String rootName, String arrayElementName, String
+ * keyWhitspaceReplacement, String keyPrefixOnNumeric, String
+ * illegalElementNameCharReplacement, String nullValueReplacement,
+ * Map<String, String> keyMap, String encoding
+ */
+ Label rootnameLabel = new Label(mainComposite, SWT.NONE);
+ rootnameLabel.setText("Root Element Name");
+ rootNameText = new Text(mainComposite, SWT.BORDER);
+ rootNameText.setLayoutData(gd);
+
+ Label arrayElementNameLabel = new Label(mainComposite, SWT.NONE);
+ arrayElementNameLabel.setText("Array Element Name");
+ arrayElementNameText = new Text(mainComposite, SWT.BORDER);
+ arrayElementNameText.setLayoutData(gd);
+ arrayElementNameText.setText(arrayElementName);
+
+ Label keyWhitspaceReplacementLabel = new Label(mainComposite, SWT.NONE);
+ keyWhitspaceReplacementLabel.setText("Space Replacement");
+ keyWhitspaceReplacementText = new Text(mainComposite, SWT.BORDER);
+ keyWhitspaceReplacementText.setLayoutData(gd);
+ if (keyWhitspaceReplacement == null) {
+ keyWhitspaceReplacement = "";
+ }
+ keyWhitspaceReplacementText.setText(keyWhitspaceReplacement);
+
+ Label keyPrefixOnNumeric = new Label(mainComposite, SWT.NONE);
+ keyPrefixOnNumeric.setText("Prefix On Numeric");
+ keyPrefixOnNumericText = new Text(mainComposite, SWT.BORDER);
+ keyPrefixOnNumericText.setLayoutData(gd);
+
+ Label illegalElementNameCharReplacementLabel = new Label(mainComposite,
+ SWT.NONE);
+ illegalElementNameCharReplacementLabel
+ .setText("IllegalChar Replacement");
+ illegalElementNameCharReplacementText = new Text(mainComposite,
+ SWT.BORDER);
+ illegalElementNameCharReplacementText.setLayoutData(gd);
+
+ Label nullValueReplacementlabel = new Label(mainComposite, SWT.NONE);
+ nullValueReplacementlabel.setText("NullValue Replacement");
+ nullValueReplacementText = new Text(mainComposite, SWT.BORDER);
+ nullValueReplacementText.setLayoutData(gd);
+ nullValueReplacementText.setText(nullValueReplacement);
+
+ Label encodingLabel = new Label(mainComposite, SWT.NONE);
+ encodingLabel.setText("Encoding");
+ encodingText = new Text(mainComposite, SWT.BORDER);
+ encodingText.setLayoutData(gd);
+ encodingText.setText(encoding);
+
+ Label keyMapLabel = new Label(mainComposite, SWT.NONE);
+ keyMapLabel.setText("Key Map:");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ keyMapLabel.setLayoutData(gd);
+
+ keyMapViewer = new TableViewer(mainComposite, SWT.BORDER);
+
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ keyMapViewer.getControl().setLayoutData(gd);
+ keyMapViewer.getTable().setHeaderVisible(true);
+ keyMapViewer.getTable().setLinesVisible(true);
+ keyMapViewer.setContentProvider(new KeyMapContentProvider());
+ keyMapViewer.setLabelProvider(new KeyMapLabelProvider());
+ keyMapViewer.setInput(keyValueList);
+
+ CellEditor keyCellEditor = new TextCellEditor(keyMapViewer.getTable(),SWT.BORDER);
+
+ CellEditor valueCellEditor = new TextCellEditor(keyMapViewer.getTable(),SWT.BORDER);
+
+
+ keyMapViewer.setCellEditors(new CellEditor[]{keyCellEditor,valueCellEditor});
+
+ keyMapViewer.setColumnProperties(new String[]{"key","value"});
+
+ keyMapViewer.setCellModifier(new ICellModifier() {
+
+ public void modify(Object element, String property, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object getValue(Object element, String property) {
+ // TODO Auto-generated method stub
+ return "ggg";
+ }
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+ });
+
+ TableColumn keyColumn = new TableColumn(keyMapViewer.getTable(),
+ SWT.NONE);
+ keyColumn.setWidth(150);
+ keyColumn.setText("Key");
+ TableColumn replaceColumn = new TableColumn(keyMapViewer.getTable(),
+ SWT.NONE);
+ replaceColumn.setWidth(150);
+ replaceColumn.setText("Replace");
+
+ hookControls();
+ changePageStatus();
+ this.setControl(mainComposite);
}
- public JsonDataConfiguraitonWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+ private void hookControls() {
+ encodingText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ encoding = encodingText.getText();
+ changePageStatus();
+ }
+ });
+
+ nullValueReplacementText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ nullValueReplacement = nullValueReplacementText.getText();
+ changePageStatus();
+ }
+ });
+
+ illegalElementNameCharReplacementText
+ .addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ illegalElementNameCharReplacement = illegalElementNameCharReplacementText
+ .getText();
+ changePageStatus();
+ }
+ });
+
+ keyPrefixOnNumericText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ keyPrefixOnNumeric = keyPrefixOnNumericText.getText();
+ changePageStatus();
+ }
+ });
+
+ keyWhitspaceReplacementText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ keyWhitspaceReplacement = keyWhitspaceReplacementText.getText();
+ changePageStatus();
+ }
+ });
+
+ arrayElementNameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ arrayElementName = arrayElementNameText.getText();
+ changePageStatus();
+ }
+ });
+
+ rootNameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ rootName = rootNameText.getText();
+ changePageStatus();
+ }
+ });
+ }
+
+ private void changePageStatus() {
+ String error = null;
+ rootName = rootNameText.getText();
+ if (rootName == null || rootName.length() == 0) {
+ error = "Root Name can't be null";
+ }
+
+ arrayElementName = arrayElementNameText.getText();
+ if (arrayElementName == null || arrayElementName.length() == 0) {
+ error = "Array Element Name can't be null";
+ }
+
+ // if (keyWhitspaceReplacement == null
+ // || keyWhitspaceReplacement.length() == 0) {
+ // error = "Space replacement string can't be null";
+ // }
+
+ encoding = encodingText.getText();
+ if (encoding == null || encoding.length() == 0) {
+ error = "Encoding can't be null";
+ }
+
+ setErrorMessage(error);
+ setPageComplete(error == null);
+ }
+
+ public JsonDataConfiguraitonWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
super(pageName, title, titleImage);
// TODO Auto-generated constructor stub
}
public JsonDataConfiguraitonWizardPage(String pageName) {
super(pageName);
- // TODO Auto-generated constructor stub
}
+ public String getRootName() {
+ return rootName;
+ }
+
+ public void setRootName(String rootName) {
+ this.rootName = rootName;
+ }
+
+ public String getArrayElementName() {
+ return arrayElementName;
+ }
+
+ public void setArrayElementName(String arrayElementName) {
+ this.arrayElementName = arrayElementName;
+ }
+
+ public String getKeyWhitspaceReplacement() {
+ return keyWhitspaceReplacement;
+ }
+
+ public void setKeyWhitspaceReplacement(String keyWhitspaceReplacement) {
+ this.keyWhitspaceReplacement = keyWhitspaceReplacement;
+ }
+
+ public String getKeyPrefixOnNumeric() {
+ return keyPrefixOnNumeric;
+ }
+
+ public void setKeyPrefixOnNumeric(String keyPrefixOnNumeric) {
+ this.keyPrefixOnNumeric = keyPrefixOnNumeric;
+ }
+
+ public String getIllegalElementNameCharReplacement() {
+ return illegalElementNameCharReplacement;
+ }
+
+ public void setIllegalElementNameCharReplacement(
+ String illegalElementNameCharReplacement) {
+ this.illegalElementNameCharReplacement = illegalElementNameCharReplacement;
+ }
+
+ public String getNullValueReplacement() {
+ return nullValueReplacement;
+ }
+
+ public void setNullValueReplacement(String nullValueReplacement) {
+ this.nullValueReplacement = nullValueReplacement;
+ }
+
+ public Map<String, String> getKeyMap() {
+ return keyMap;
+ }
+
+ public void setKeyMap(Map<String, String> keyMap) {
+ this.keyMap = keyMap;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ private class KeyMapLabelProvider extends LabelProvider implements ITableLabelProvider{
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+// if(element instanceof KeyValueModel){
+// switch(columnIndex){
+// case 0:
+// return ((KeyValueModel)element).getKey();
+// case 1:
+// return ((KeyValueModel)element).getValue();
+// }
+// }
+ return getText(element);
+ }
+
+ }
+
+ private class KeyMapContentProvider implements IStructuredContentProvider{
+
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof List<?>){
+ return ((List<?>)inputElement).toArray();
+ }
+ // TODO Auto-generated method stub
+ return new Object[]{};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ private class KeyValueModel{
+ private String key;
+ private String value;
+
+ public KeyValueModel(String key , String value){
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -24,13 +24,13 @@
public JsonDataPathWizardPage(String pageName, boolean multiSelect, Object[] initSelections,
List<ViewerFilter> filters) {
super(pageName, multiSelect, initSelections, filters);
- // TODO Auto-generated constructor stub
}
public JsonDataPathWizardPage(String pageName, String[] fileExtensionNames) {
super(pageName, fileExtensionNames);
- // TODO Auto-generated constructor stub
}
+
+
/* (non-Javadoc)
* @see org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
@@ -39,5 +39,22 @@
protected Object loadedTheObject(String path) throws Exception {
return null;
}
-
+
+ @Override
+ protected void changeWizardPageStatus() {
+ super.changeWizardPageStatus();
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return super.canFlipToNextPage();
+// String filePath = this.getFilePath();
+// try {
+// filePath = SmooksUIUtils.parseFilePath(filePath);
+// if(filePath == null) return false;
+// return new File(filePath).exists();
+// } catch (InvocationTargetException e) {
+// return false;
+// }
+ }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -19,12 +19,14 @@
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
* @author Dart (dpeng(a)redhat.com)
*
*/
-public class JsonDataWizard extends Wizard implements IStructuredDataSelectionWizard, INewWizard {
+public class JsonDataWizard extends Wizard implements
+ IStructuredDataSelectionWizard, INewWizard {
private JsonDataPathWizardPage pathPage = null;
@@ -32,24 +34,37 @@
public JsonDataWizard() {
super();
- pathPage = new JsonDataPathWizardPage("Json Input Data Selection ", new String[]{});
- configPage = new JsonDataConfiguraitonWizardPage("Json data configuration page");
}
-
-
- /* (non-Javadoc)
+ public boolean canFinish() {
+ if (configPage != null && pathPage != null) {
+ if (configPage.isPageComplete() && pathPage.isPageComplete())
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
public void addPages() {
super.addPages();
+ if (pathPage == null) {
+ pathPage = new JsonDataPathWizardPage("Json Input Data Selection ",
+ new String[] {});
+
+ }
+ if (configPage == null) {
+ configPage = new JsonDataConfiguraitonWizardPage(
+ "Json data configuration page");
+ }
this.addPage(pathPage);
this.addPage(configPage);
}
-
-
/*
* (non-Javadoc)
*
@@ -80,7 +95,7 @@
*/
public String getInputDataTypeID() {
// TODO Auto-generated method stub
- return null;
+ return SmooksModelUtils.INPUT_TYPE_JSON;
}
/*
@@ -90,10 +105,50 @@
* IStructuredDataSelectionWizard#getProperties()
*/
public Properties getProperties() {
- // TODO Auto-generated method stub
- return null;
+ Properties properties = new Properties();
+ fillProperties(properties);
+ return properties;
}
+ private void fillProperties(Properties p) {
+ if (configPage != null) {
+ String aen = configPage.getArrayElementName();
+ if (aen != null && aen.length() != 0) {
+ p.setProperty("arrayElementName", aen);
+ }
+
+ String rn = configPage.getRootName();
+ if (rn != null && rn.length() != 0) {
+ p.setProperty("rootName", rn);
+ }
+
+ String encoding = configPage.getEncoding();
+ if (encoding != null && encoding.length() != 0) {
+ p.setProperty("encoding", encoding);
+ }
+
+ String sr = configPage.getKeyWhitspaceReplacement();
+ if (sr != null && sr.length() != 0) {
+ p.setProperty("spaceReplace", sr);
+ }
+
+ String pon = configPage.getKeyPrefixOnNumeric();
+ if (pon != null && pon.length() != 0) {
+ p.setProperty("prefixOnNumeric", pon);
+ }
+
+ String nvr = configPage.getNullValueReplacement();
+ if (nvr != null && nvr.length() != 0) {
+ p.setProperty("nullReplace", nvr);
+ }
+
+ String ier = configPage.getIllegalElementNameCharReplacement();
+ if (ier != null && ier.length() != 0) {
+ p.setProperty("illegalReplace", ier);
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -112,6 +167,9 @@
* IStructuredDataSelectionWizard#getStructuredDataSourcePath()
*/
public String getStructuredDataSourcePath() {
+ if (pathPage != null) {
+ return pathPage.getFilePath();
+ }
return null;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -402,6 +402,7 @@
}
public static String parseFilePath(String path) throws InvocationTargetException {
+ if(path == null) return null;
if (new File(path).exists()) {
return path;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -55,15 +55,16 @@
if (initor == null)
return null;
IStructuredDataSelectionWizard wizard = initor.getStructuredDataLoadWizard();
- if(wizard != null){
- try {
- return wizard.getClass().newInstance();
- } catch (Throwable t){
- t.printStackTrace();
- return wizard;
- }
- }
- return null;
+ return wizard;
+// if(wizard != null){
+// try {
+// return wizard.getClass().newInstance();
+// } catch (Throwable t){
+// t.printStackTrace();
+// return wizard;
+// }
+// }
+// return null;
}
public ILabelProvider getLabelProvider(String typeID) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-06-30 10:05:39 UTC (rev 16278)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2009-06-30 10:37:00 UTC (rev 16279)
@@ -66,7 +66,7 @@
public AbstractFileSelectionWizardPage(String pageName, String[] fileExtensionNames) {
this(pageName, false, null, Collections.EMPTY_LIST);
this.fileExtensionNames = fileExtensionNames;
- if (this.fileExtensionNames != null) {
+ if (this.fileExtensionNames != null && fileExtensionNames.length != 0) {
ViewerFilter extensionNameFilter = new ViewerFilter() {
/*
* (non-Javadoc)
@@ -332,7 +332,7 @@
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.END;
fileSystemBrowseButton.setLayoutData(gd);
-
+ changeWizardPageStatus();
return xsdComposite;
}
@@ -411,7 +411,6 @@
// }
this.setErrorMessage(error);
this.setPageComplete(error == null);
-
}
public void widgetDefaultSelected(SelectionEvent e) {
15 years, 3 months
JBoss Tools SVN: r16278 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core/refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-06-30 06:05:39 -0400 (Tue, 30 Jun 2009)
New Revision: 16278
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-30 09:41:11 UTC (rev 16277)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreMessages.java 2009-06-30 10:05:39 UTC (rev 16278)
@@ -49,4 +49,6 @@
public static String SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
public static String SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
public static String SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
+ public static String SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND;
+ public static String SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND;
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-30 09:41:11 UTC (rev 16277)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/messages.properties 2009-06-30 10:05:39 UTC (rev 16278)
@@ -34,7 +34,9 @@
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_TITLE=Rename Seam Context Variable
RENAME_SEAM_CONTEXT_VARIABLE_PROCESSOR_CAN_NOT_FIND_CONTEXT_VARIABLE=Can not find Seam Context Variable: ''{0}''.
SEAM_RENAME_PROCESSOR_COMPONENT_HAS_DECLARATION_FROM_JAR=Component ''{0}'' has a declaration which is located in jar file: ''{1}''. Press next to force rename.
-SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=File ''{0}'' is not in sync. Press next to force rename.
+SEAM_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is not in sync.
+SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND=Location for declaration or annotation not found in file: ''{0}''
+SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND=Component: ''{0}'' does not have any declarations
SEAM_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file: ''{0}''.
SEAM_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file: ''{0}''.
SEAM_INSTALL_WIZARD_PROJECT_NAME_WITH_UPPERCASE=Project names which start with a capital letter may break Seam/JSF applications; use lower case.
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-30 09:41:11 UTC (rev 16277)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-30 10:05:39 UTC (rev 16278)
@@ -154,8 +154,10 @@
}
protected void findAnnotations(){
- if(declarationFile == null)
+ if(declarationFile == null){
+ status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_DECLARATION_NOT_FOUND, getOldName()));
return;
+ }
ISeamProject seamProject = SeamCorePlugin.getSeamProject(declarationFile.getProject(), true);
@@ -217,12 +219,15 @@
}
}
- private boolean isBadLocation(ITextSourceReference location){
- return location.getStartPosition() == 0 && location.getLength() == 0;
+ private boolean isBadLocation(ITextSourceReference location, IFile file){
+ boolean flag = location.getStartPosition() == 0 && location.getLength() == 0;
+ if(flag)
+ status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND, file.getFullPath().toString()));
+ return flag;
}
private void changeXMLNode(ITextSourceReference location, IFile file){
- if(isBadLocation(location))
+ if(isBadLocation(location, file))
return;
if(!isFileCorrect(file))
@@ -249,7 +254,7 @@
}
private void changeAnnotation(ITextSourceReference location, IFile file){
- if(isBadLocation(location))
+ if(isBadLocation(location, file))
return;
if(!isFileCorrect(file))
@@ -336,7 +341,7 @@
if(file != null && !coreHelper.isJar(javaDecl)){
ITextSourceReference location = ((SeamComponentDeclaration)javaDecl).getLocationFor(ISeamXmlComponentDeclaration.NAME);
- if(location != null && !isBadLocation(location))
+ if(location != null && !isBadLocation(location, file))
change(file, location.getStartPosition(), location.getLength(), "\""+getNewName()+"\""); //$NON-NLS-1$ //$NON-NLS-2$
}
declarationFile = file;
@@ -347,7 +352,7 @@
if(file != null && !coreHelper.isJar(xmlDecl)){
ITextSourceReference location = ((SeamComponentDeclaration)xmlDecl).getLocationFor(ISeamXmlComponentDeclaration.NAME);
- if(location != null && !isBadLocation(location))
+ if(location != null && !isBadLocation(location, file))
changeXMLNode(location, file);
}
if(declarationFile == null)
15 years, 3 months
JBoss Tools SVN: r16277 - in workspace/yzhishko: org.jboss.tools.ui.auto.test/src/org/jboss/tools/ui/auto/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: yzhishko
Date: 2009-06-30 05:41:11 -0400 (Tue, 30 Jun 2009)
New Revision: 16277
Modified:
workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test/src/org/jboss/tools/jsf/ui/auto/test/cssdialog/jbide/JBIDE3890Test.java
workspace/yzhishko/org.jboss.tools.ui.auto.test/src/org/jboss/tools/ui/auto/test/JBTSWTBotTestCase.java
workspace/yzhishko/org.jboss.tools.vpe.ui.auto.test/src/org/jboss/tools/vpe/ui/auto/test/VPEAutoTestCase.java
Log:
New method waitForJobs() has been added as a new delay mechanism.
Modified: workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test/src/org/jboss/tools/jsf/ui/auto/test/cssdialog/jbide/JBIDE3890Test.java
===================================================================
--- workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test/src/org/jboss/tools/jsf/ui/auto/test/cssdialog/jbide/JBIDE3890Test.java 2009-06-30 08:57:31 UTC (rev 16276)
+++ workspace/yzhishko/org.jboss.tools.jsf.ui.auto.test/src/org/jboss/tools/jsf/ui/auto/test/cssdialog/jbide/JBIDE3890Test.java 2009-06-30 09:41:11 UTC (rev 16277)
@@ -26,9 +26,9 @@
SWTBotEclipseEditor editor = bot.editorByTitle("hello.jsp").toTextEditor();
editor.selectLine(10);
editor.insertText("<body id=\"bodyId\">");
- delay();
+ waitForJobs();
editor.save();
- longDelay();
+ waitForJobs();
SWTBotMultiPageEditor multiPageEditor = bot.multiPageEditorByTitle("hello.jsp");
performContentTest("test.xml", multiPageEditor);
}
Modified: workspace/yzhishko/org.jboss.tools.ui.auto.test/src/org/jboss/tools/ui/auto/test/JBTSWTBotTestCase.java
===================================================================
--- workspace/yzhishko/org.jboss.tools.ui.auto.test/src/org/jboss/tools/ui/auto/test/JBTSWTBotTestCase.java 2009-06-30 08:57:31 UTC (rev 16276)
+++ workspace/yzhishko/org.jboss.tools.ui.auto.test/src/org/jboss/tools/ui/auto/test/JBTSWTBotTestCase.java 2009-06-30 09:41:11 UTC (rev 16277)
@@ -6,6 +6,7 @@
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
@@ -96,6 +97,10 @@
protected void delay() {
bot.sleep(1000);
}
+
+ protected void shortDelay(){
+ bot.sleep(3000);
+ }
protected void longDelay() {
bot.sleep(10000);
@@ -141,4 +146,11 @@
}
}
+ protected void waitForJobs(){
+ delay();
+ while (!Job.getJobManager().isIdle()) {
+ delay();
+ }
+ }
+
}
Modified: workspace/yzhishko/org.jboss.tools.vpe.ui.auto.test/src/org/jboss/tools/vpe/ui/auto/test/VPEAutoTestCase.java
===================================================================
--- workspace/yzhishko/org.jboss.tools.vpe.ui.auto.test/src/org/jboss/tools/vpe/ui/auto/test/VPEAutoTestCase.java 2009-06-30 08:57:31 UTC (rev 16276)
+++ workspace/yzhishko/org.jboss.tools.vpe.ui.auto.test/src/org/jboss/tools/vpe/ui/auto/test/VPEAutoTestCase.java 2009-06-30 09:41:11 UTC (rev 16277)
@@ -84,7 +84,7 @@
} catch (Exception e2) {
}
}
-
+ waitForJobs();
}
protected void performContentTest(String expectedVPEContent, SWTBotMultiPageEditor editor) throws Throwable{
15 years, 3 months
JBoss Tools SVN: r16276 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-06-30 04:57:31 -0400 (Tue, 30 Jun 2009)
New Revision: 16276
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-30 08:36:59 UTC (rev 16275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameSeamContextVariableProcessor.java 2009-06-30 08:57:31 UTC (rev 16276)
@@ -185,7 +185,8 @@
private boolean checkFactories(ISeamProject seamProject){
if (seamProject != null) {
- return seamProject.getFactoriesByName(getOldName()) != null;
+ Set<ISeamFactory> factories = seamProject.getFactoriesByName(getOldName());
+ return factories.size() > 0;
}
return false;
}
@@ -194,7 +195,7 @@
if (seamProject != null) {
Set<IBijectedAttribute> variables = seamProject.getBijectedAttributesByName(getOldName(), BijectedAttributeType.OUT);
- return variables != null;
+ return variables.size() > 0;
}
return false;
}
@@ -203,7 +204,7 @@
if (seamProject != null) {
Set<IBijectedAttribute> variables = seamProject.getBijectedAttributesByName(getOldName(), BijectedAttributeType.DATA_BINDER);
- return variables != null;
+ return variables.size() > 0;
}
return false;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-30 08:36:59 UTC (rev 16275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-30 08:57:31 UTC (rev 16276)
@@ -192,12 +192,12 @@
}
private void findAnnotations(ISeamProject seamProject, BijectedAttributeType type, String locationPath){
- Set<IBijectedAttribute> inSet = seamProject.getBijectedAttributesByName(getOldName(), type);
+ Set<IBijectedAttribute> attributes = seamProject.getBijectedAttributesByName(getOldName(), type);
- for(IBijectedAttribute inAtt : inSet){
- ITextSourceReference location = inAtt.getLocationFor(locationPath);
+ for(IBijectedAttribute attribute : attributes){
+ ITextSourceReference location = attribute.getLocationFor(locationPath);
if(location != null)
- changeAnnotation(location, (IFile)inAtt.getResource());
+ changeAnnotation(location, (IFile)attribute.getResource());
}
}
@@ -681,8 +681,8 @@
for (IProject project : projects) {
ISeamProject sProject = SeamCorePlugin.getSeamProject(project, true);
if(sProject != null){
- findAnnotations(sProject, BijectedAttributeType.OUT, SeamAnnotations.OUT_ANNOTATION_TYPE);
- findAnnotations(sProject, BijectedAttributeType.DATA_BINDER, "name"/*SeamAnnotations.DATA_MODEL_ANNOTATION_TYPE*/);
+ findAnnotations(sProject, BijectedAttributeType.OUT, ISeamXmlComponentDeclaration.NAME/*SeamAnnotations.OUT_ANNOTATION_TYPE*/);
+ findAnnotations(sProject, BijectedAttributeType.DATA_BINDER, ISeamXmlComponentDeclaration.NAME/*SeamAnnotations.DATA_MODEL_ANNOTATION_TYPE*/);
findFactories(sProject);
}
}
15 years, 3 months
JBoss Tools SVN: r16275 - in trunk/smooks/plugins: org.jboss.tools.smooks.ui/META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-06-30 04:36:59 -0400 (Tue, 30 Jun 2009)
New Revision: 16275
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
Log:
JBIDE-4540
Add json data wizard and wizard page
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java 2009-06-30 08:29:52 UTC (rev 16274)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks10/model/smooks/util/SmooksModelUtils.java 2009-06-30 08:36:59 UTC (rev 16275)
@@ -48,6 +48,8 @@
public class SmooksModelUtils {
public static final String INPUT_TYPE_JAVA = "java";
+
+ public static final String INPUT_TYPE_JSON = "json";
public static final String PARAM_NAME_CLASS = "class";
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-06-30 08:29:52 UTC (rev 16274)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2009-06-30 08:36:59 UTC (rev 16275)
@@ -24,7 +24,8 @@
org.eclipse.xsd,
org.eclipse.wst.wsdl,
org.apache.xerces,
- javax.wsdl
+ javax.wsdl,
+ org.jboss.tools.milyn.smooks1_1_2;bundle-version="1.1.2"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java 2009-06-30 08:36:59 UTC (rev 16275)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.configuration.editors.json;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class JsonDataConfiguraitonWizardPage extends WizardPage {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+
+ }
+
+ public JsonDataConfiguraitonWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ // TODO Auto-generated constructor stub
+ }
+
+ public JsonDataConfiguraitonWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataConfiguraitonWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java 2009-06-30 08:36:59 UTC (rev 16275)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.configuration.editors.json;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class JsonDataPathWizardPage extends AbstractFileSelectionWizardPage {
+
+ public JsonDataPathWizardPage(String pageName, boolean multiSelect, Object[] initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName, multiSelect, initSelections, filters);
+ // TODO Auto-generated constructor stub
+ }
+
+ public JsonDataPathWizardPage(String pageName, String[] fileExtensionNames) {
+ super(pageName, fileExtensionNames);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.configuration.editors.xml.AbstractFileSelectionWizardPage#loadedTheObject(java.lang.String)
+ */
+ @Override
+ protected Object loadedTheObject(String path) throws Exception {
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataPathWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java 2009-06-30 08:36:59 UTC (rev 16275)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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.smooks.configuration.editors.json;
+
+import java.util.Properties;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class JsonDataWizard extends Wizard implements IStructuredDataSelectionWizard, INewWizard {
+
+ private JsonDataPathWizardPage pathPage = null;
+
+ private JsonDataConfiguraitonWizardPage configPage = null;
+
+ public JsonDataWizard() {
+ super();
+ pathPage = new JsonDataPathWizardPage("Json Input Data Selection ", new String[]{});
+ configPage = new JsonDataConfiguraitonWizardPage("Json data configuration page");
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ super.addPages();
+ this.addPage(pathPage);
+ this.addPage(configPage);
+ }
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getInputDataTypeID()
+ */
+ public String getInputDataTypeID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getProperties()
+ */
+ public Properties getProperties() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getReturnData()
+ */
+ public Object getReturnData() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#getStructuredDataSourcePath()
+ */
+ public String getStructuredDataSourcePath() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.wizard.
+ * IStructuredDataSelectionWizard#init(org.eclipse.ui.IEditorSite,
+ * org.eclipse.ui.IEditorInput)
+ */
+ public void init(IEditorSite site, IEditorInput input) {
+
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/json/JsonDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-30 08:29:52 UTC (rev 16274)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-06-30 08:36:59 UTC (rev 16275)
@@ -20,6 +20,7 @@
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanContentProvider;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
+import org.jboss.tools.smooks.configuration.editors.json.JsonDataWizard;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataContentProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataLabelProvider;
import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataWizard;
@@ -53,7 +54,16 @@
IViewerInitor initor = this.getInitorMap().get(typeID);
if (initor == null)
return null;
- return initor.getStructuredDataLoadWizard();
+ IStructuredDataSelectionWizard wizard = initor.getStructuredDataLoadWizard();
+ if(wizard != null){
+ try {
+ return wizard.getClass().newInstance();
+ } catch (Throwable t){
+ t.printStackTrace();
+ return wizard;
+ }
+ }
+ return null;
}
public ILabelProvider getLabelProvider(String typeID) {
@@ -125,13 +135,31 @@
protected HashMap<String, IViewerInitor> createNewInitorMap() {
HashMap<String, IViewerInitor> map = new HashMap<String, IViewerInitor>();
+
+ // for json
+ BaseViewerInitor jsonViewerInitor = new BaseViewerInitor();
+ String name = "Json";
+ String description = "Select Json data file as the input data.";
+ String iconPath = null;
+ String typeID = SmooksModelUtils.INPUT_TYPE_JSON;
+ jsonViewerInitor.setName(name);
+ jsonViewerInitor.setDescription(description);
+ jsonViewerInitor.setWizardIconPath(iconPath);
+ jsonViewerInitor.setTypeID(typeID);
+ jsonViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+ jsonViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+ jsonViewerInitor.setStructuredDataLoadWizard(new JsonDataWizard());
+// jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+ map.put(typeID, jsonViewerInitor);
+
+
// for java
BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
- String name = "Java";
- String description = "Select a Java type(class,interface) as the input data.";
- String iconPath = null;
- String typeID = SmooksModelUtils.INPUT_TYPE_JAVA;
+ name = "Java";
+ description = "Select a Java type(class,interface) as the input data.";
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_JAVA;
javabeanViewerInitor.setName(name);
javabeanViewerInitor.setDescription(description);
15 years, 3 months