JBoss Tools SVN: r43576 - trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-09-11 03:21:40 -0400 (Tue, 11 Sep 2012)
New Revision: 43576
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeModel.java
Log:
JBIDE-12549 to trunk missing file
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeModel.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeModel.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeModel.java 2012-09-11 07:21:40 UTC (rev 43576)
@@ -0,0 +1,98 @@
+package org.jboss.tools.runtime.core.model;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.util.RuntimePathPreferenceIO;
+
+public class RuntimeModel {
+ public static final String RUNTIME_PATHS = "runtimePaths";
+
+ private ListenerList runtimePathChangeChangeListeners;
+ private Set<RuntimePath> runtimePaths;
+ private IEclipsePreferences preferences;
+
+ public RuntimeModel() {
+ runtimePaths = new HashSet<RuntimePath>();
+ }
+
+ public RuntimeModel(IEclipsePreferences preferences) {
+ this.preferences = preferences;
+ reloadRuntimePathsFromPreferences();
+ }
+
+ public void reloadRuntimePathsFromPreferences() {
+ String runtimes = preferences.get(RUNTIME_PATHS, null);
+ if (runtimes != null && !runtimes.isEmpty()) {
+ runtimePaths = RuntimePathPreferenceIO.loadRuntimePathsFromPreferenceString(runtimes);
+ } else {
+ runtimePaths = new HashSet<RuntimePath>();
+ }
+ fireRuntimePathsChanged();
+ }
+
+ public void saveRuntimePaths() {
+ if (runtimePaths == null || preferences == null)
+ return;
+
+ try {
+ String runtimes = RuntimePathPreferenceIO.getPreferenceOutputString(runtimePaths);
+ preferences.put(RUNTIME_PATHS, runtimes);
+ preferences.flush();
+ fireRuntimePathsChanged();
+ } catch (Exception e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ }
+ }
+
+ public synchronized void setRuntimePaths(RuntimePath[] set) {
+ if( set == null ) {
+ reloadRuntimePathsFromPreferences();
+ } else {
+ HashSet<RuntimePath> s = new HashSet<RuntimePath>();
+ s.addAll(Arrays.asList(set));
+ runtimePaths = s;
+ saveRuntimePaths();
+ }
+ }
+
+ public void addRuntimePath(RuntimePath path) {
+ runtimePaths.add(path);
+ saveRuntimePaths();
+ }
+ public void removeRuntimePath(RuntimePath path) {
+ runtimePaths.remove(path);
+ saveRuntimePaths();
+ }
+
+ public synchronized RuntimePath[] getRuntimePaths() {
+ return (RuntimePath[]) runtimePaths.toArray(new RuntimePath[runtimePaths.size()]);
+ }
+
+ public synchronized void addRuntimePathChangeListener(IRuntimePathChangeListener listener) {
+ if (runtimePathChangeChangeListeners == null)
+ runtimePathChangeChangeListeners = new ListenerList();
+ runtimePathChangeChangeListeners.add(listener);
+ }
+
+ public synchronized void removeRuntimePathChangeListener(IRuntimePathChangeListener listener) {
+ if (runtimePathChangeChangeListeners == null)
+ return;
+ runtimePathChangeChangeListeners.remove(listener);
+ }
+
+ private void fireRuntimePathsChanged() {
+ if (runtimePathChangeChangeListeners != null) {
+ Object[] listeners = runtimePathChangeChangeListeners.getListeners();
+ for (Object listener:listeners ) {
+ IRuntimePathChangeListener runtimePathChangeChangeListener = (IRuntimePathChangeListener) listener;
+ runtimePathChangeChangeListener.changed();
+ }
+ }
+ }
+
+}
13 years, 3 months
JBoss Tools SVN: r43575 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-09-10 23:26:13 -0400 (Mon, 10 Sep 2012)
New Revision: 43575
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
Log:
Cleaned up the Windows dir path finally
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-11 00:10:28 UTC (rev 43574)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-11 03:26:13 UTC (rev 43575)
@@ -65,36 +65,18 @@
SWTBotTreeItem theProject = bot.tree(0).getTreeItem(projectName).select();
bot.menu("File").menu("Properties").click();
- bot.sleep(60000l);
-
if (System.getProperty("file.separator").equals("/")) {
baseDir = bot.textWithLabel("Location:").getText() + System.getProperty("file.separator");
}
else {
/* Needed to avoid a syntax error with Windows \ dir path characters */
- //baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), System.getProperty("file.separator") + System.getProperty("file.separator")) + System.getProperty("file.separator");
baseDir = bot.textWithLabel("Location:").getText();
System.out.println("DEBUG baseDir = " + baseDir) ;
-
- try {
- //baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), "zzz");
- // http://stackoverflow.com/questions/1701839/backslash-problem-with-string-...
- baseDir = bot.textWithLabel("Location:").getText().replace("\\", "\\\\") + "\\\\";
- }
- catch (Exception E) {
- System.out.println ("replaceAll failing with " + E.getMessage() );
- }
+ // http://stackoverflow.com/questions/1701839/backslash-problem-with-string-...
+ baseDir = bot.textWithLabel("Location:").getText().replace("\\", "\\\\") + "\\\\";
System.out.println("DEBUG baseDir = " + baseDir) ;
-
-
- }
-// if (System.getProperty("file.separator").equals("/")) {
-// baseDir = bot.textWithLabel("Location:").getText() + System.getProperty("file.separator");
-// }
-// else {
-// baseDir = bot.textWithLabel("Location:").getText().replaceAll("\\", "\\\\") + System.getProperty("file.separator");
-// }
+ }
bot.button("OK").click();
theSWTBotView = open.viewOpen(ActionItem.View.GeneralNavigator.LABEL);
13 years, 3 months
JBoss Tools SVN: r43574 - in workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db: entity and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-09-10 20:10:28 -0400 (Mon, 10 Sep 2012)
New Revision: 43574
Modified:
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
Log:
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 23:22:37 UTC (rev 43573)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-11 00:10:28 UTC (rev 43574)
@@ -103,57 +103,65 @@
* @see org.jboss.tools.cdi.core.ICDICache#rebuild(org.jboss.tools.cdi.core.ICDIProject, java.util.Collection)
*/
@Override
- public void rebuild(ICDIProject project, Collection<IBean> beans) {
+ public synchronized void rebuild(ICDIProject project, Collection<IBean> beans) {
Context context = null;
- synchronized (currentContext) {
+// synchronized (currentContext) {
context = (Context)currentContext.clone();
- }
+// }
Short projectIndex = context.removeProjectIndex(project);
EntityManager em = CDIDBManager.getInstance().getEntityManager();
EntityTransaction transaction = em.getTransaction();
transaction.begin();
- if(projectIndex!=null) {
- em.createQuery("DELETE FROM BeanEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
- em.createQuery("DELETE FROM QualifierEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
- em.createQuery("DELETE FROM TypeEntity b WHERE b.bean.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
- }
- projectIndex = context.generateProjectIndex(project);
+ try {
+ if(projectIndex!=null) {
+ em.createQuery("DELETE FROM TypeEntity t WHERE t.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
+ em.createQuery("DELETE FROM QualifierEntity q WHERE q.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
+ em.createQuery("DELETE FROM BeanEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
+ }
+ projectIndex = context.generateProjectIndex(project);
- Map<Integer, QualifierEntity> qualifiers = new HashMap<Integer, QualifierEntity>();
- for (IBean bean : beans) {
- context.getAllBeans().put(bean.getId(), bean);
- BeanEntity beanEntity = new BeanEntity();
- beanEntity.setIndex(bean.getId());
- beanEntity.setProjectIndex(projectIndex);
+ Map<Integer, QualifierEntity> qualifiers = new HashMap<Integer, QualifierEntity>();
+ for (IBean bean : beans) {
+ context.getAllBeans().put(bean.getId(), bean);
+ BeanEntity beanEntity = new BeanEntity();
+ beanEntity.setIndex(bean.getId());
+ beanEntity.setProjectIndex(projectIndex);
- Collection<IQualifier> beanQualifiers = bean.getQualifiers();
- List<QualifierEntity> qualifierEntities = new ArrayList<QualifierEntity>();
- for (IQualifier beanQualifier : beanQualifiers) {
- int id = beanQualifier.getId();
- QualifierEntity qualifierEntity = qualifiers.get(id);
- if(qualifierEntity==null) {
- qualifierEntity = new QualifierEntity();
- qualifierEntity.setIndex(id);
- qualifierEntity.setProjectIndex(projectIndex);
- em.persist(qualifierEntity);
+ Collection<IQualifier> beanQualifiers = bean.getQualifiers();
+ List<QualifierEntity> qualifierEntities = new ArrayList<QualifierEntity>();
+ for (IQualifier beanQualifier : beanQualifiers) {
+ int id = beanQualifier.getId();
+ QualifierEntity qualifierEntity = qualifiers.get(id);
+ if(qualifierEntity==null) {
+ qualifierEntity = new QualifierEntity();
+ qualifierEntity.setIndex(id);
+ qualifierEntity.setProjectIndex(projectIndex);
+ em.persist(qualifierEntity);
+ }
+ qualifierEntities.add(qualifierEntity);
}
- qualifierEntities.add(qualifierEntity);
- }
- beanEntity.setQualifiers(qualifierEntities);
- em.persist(beanEntity);
+ beanEntity.setQualifiers(qualifierEntities);
+ em.persist(beanEntity);
- Collection<IParametedType> beanTypes = bean.getLegalTypes();
- for (IParametedType beanType : beanTypes) {
- long id = context.getTypeIndex(beanType);
- TypeEntity typeEntity = new TypeEntity();
- typeEntity.setIndex(id);
- typeEntity.setBean(beanEntity);
- em.persist(typeEntity);
+ Collection<IParametedType> beanTypes = bean.getLegalTypes();
+ for (IParametedType beanType : beanTypes) {
+ long id = context.getTypeIndex(beanType);
+ TypeEntity typeEntity = new TypeEntity();
+ typeEntity.setIndex(id);
+ typeEntity.setBean(beanEntity);
+ typeEntity.setProjectIndex(projectIndex);
+ em.persist(typeEntity);
+ }
}
+ } finally {
+ if(transaction.getRollbackOnly()) {
+ transaction.rollback();
+ } else {
+ transaction.commit();
+ }
}
- transaction.commit();
currentContext = context;
}
@@ -163,30 +171,31 @@
* @see org.jboss.tools.cdi.core.ICDICache#getBeansByLegalType(org.jboss.tools.cdi.core.ICDIProject, java.lang.String)
*/
@Override
- public Collection<IBean> getBeansByLegalType(ICDIProject project, String legalType) {
+ public synchronized Collection<IBean> getBeansByLegalType(ICDIProject project, String legalType) {
List<IBean> beans = new ArrayList<IBean>();
- synchronized (currentContext) {
+// synchronized (currentContext) {
Short projectIndex = currentContext.getProjectIndex(project);
EntityManager em = CDIDBManager.getInstance().getEntityManager();
EntityTransaction transaction = em.getTransaction();
- if(!transaction.isActive())
- transaction.begin();
+ transaction.begin();
- long typeIndex = currentContext.getTypeIndex(legalType);
- List results = em.createQuery("SELECT t.bean FROM TypeEntity t WHERE t.index = :b AND t.bean.projectIndex = :p").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
- for (Object result : results) {
- BeanEntity beanEntity = (BeanEntity)result;
- int index = beanEntity.getIndex();
- IBean bean = currentContext.allBeans.get(index);
- if(bean != null) {
- beans.add(bean);
- } else {
- //report a problem
+ try {
+ long typeIndex = currentContext.getTypeIndex(legalType);
+ List results = em.createQuery("SELECT t.bean FROM TypeEntity t WHERE t.index = :b AND t.bean.projectIndex = :p").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
+ for (Object result : results) {
+ BeanEntity beanEntity = (BeanEntity)result;
+ int index = beanEntity.getIndex();
+ IBean bean = currentContext.allBeans.get(index);
+ if(bean != null) {
+ beans.add(bean);
+ } else {
+ //report a problem
+ }
}
+ } finally {
+ transaction.rollback();
}
-// transaction.commit();
- transaction.rollback();
- }
+// }
return beans;
}
}
\ No newline at end of file
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java 2012-09-10 23:22:37 UTC (rev 43573)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java 2012-09-11 00:10:28 UTC (rev 43574)
@@ -27,6 +27,7 @@
private long id;
private long index;
private BeanEntity bean;
+ private short projectIndex;
/**
* @return the id
@@ -64,6 +65,21 @@
this.bean = bean;
}
+ /**
+ * @return the projectIndex
+ */
+ @Column(nullable=false)
+ public short getProjectIndex() {
+ return projectIndex;
+ }
+
+ /**
+ * @param projectIndex the projectIndex to set
+ */
+ public void setProjectIndex(short projectIndex) {
+ this.projectIndex = projectIndex;
+ }
+
@Override
public int hashCode() {
return ("" + index).hashCode();
13 years, 3 months
JBoss Tools SVN: r43573 - in workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db: entity and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-09-10 19:22:37 -0400 (Mon, 10 Sep 2012)
New Revision: 43573
Modified:
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
Log:
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 22:50:09 UTC (rev 43572)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 23:22:37 UTC (rev 43573)
@@ -116,7 +116,7 @@
if(projectIndex!=null) {
em.createQuery("DELETE FROM BeanEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
em.createQuery("DELETE FROM QualifierEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
- em.createQuery("DELETE FROM TypeEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
+ em.createQuery("DELETE FROM TypeEntity b WHERE b.bean.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
}
projectIndex = context.generateProjectIndex(project);
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java 2012-09-10 22:50:09 UTC (rev 43572)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java 2012-09-10 23:22:37 UTC (rev 43573)
@@ -18,7 +18,6 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
/**
@@ -50,6 +49,7 @@
this.id = id;
}
+// @Index(name="beanIndex")
@Column(unique=true)
public int getIndex() {
return index;
@@ -77,7 +77,7 @@
/**
* @return the qualifiers
*/
- @OneToMany
+ @OneToMany(cascade={CascadeType.REMOVE})
@JoinColumn(nullable=true)
public List<QualifierEntity> getQualifiers() {
return qualifiers;
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java 2012-09-10 22:50:09 UTC (rev 43572)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/TypeEntity.java 2012-09-10 23:22:37 UTC (rev 43573)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.db.entity;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -53,7 +54,7 @@
this.index = index;
}
- @ManyToOne
+ @ManyToOne(cascade={CascadeType.REMOVE})
@JoinColumn(nullable=false)
public BeanEntity getBean() {
return bean;
13 years, 3 months
JBoss Tools SVN: r43572 - in workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db: entity and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-09-10 18:50:09 -0400 (Mon, 10 Sep 2012)
New Revision: 43572
Modified:
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/QualifierEntity.java
Log:
JBIDE-12446
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java 2012-09-10 22:49:54 UTC (rev 43571)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDBManager.java 2012-09-10 22:50:09 UTC (rev 43572)
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.cdi.db.entity.BeanEntity;
+import org.jboss.tools.cdi.db.entity.QualifierEntity;
import org.jboss.tools.cdi.db.entity.TypeEntity;
import org.jboss.tools.common.db.AbstractDBManager;
@@ -61,6 +62,6 @@
*/
@Override
protected Class[] getAnnotatedClasses() {
- return new Class[]{BeanEntity.class, TypeEntity.class};
+ return new Class[]{BeanEntity.class, TypeEntity.class, QualifierEntity.class};
}
}
\ No newline at end of file
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 22:49:54 UTC (rev 43571)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 22:50:09 UTC (rev 43572)
@@ -169,17 +169,23 @@
Short projectIndex = currentContext.getProjectIndex(project);
EntityManager em = CDIDBManager.getInstance().getEntityManager();
EntityTransaction transaction = em.getTransaction();
- transaction.begin();
+ if(!transaction.isActive())
+ transaction.begin();
long typeIndex = currentContext.getTypeIndex(legalType);
- List results = em.createQuery("SELECT FROM t.bean TypeEntity t WHERE t.index = :b AND t.bean.projectIndex = :p").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
+ List results = em.createQuery("SELECT t.bean FROM TypeEntity t WHERE t.index = :b AND t.bean.projectIndex = :p").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
for (Object result : results) {
BeanEntity beanEntity = (BeanEntity)result;
int index = beanEntity.getIndex();
IBean bean = currentContext.allBeans.get(index);
- beans.add(bean);
+ if(bean != null) {
+ beans.add(bean);
+ } else {
+ //report a problem
+ }
}
- transaction.commit();
+// transaction.commit();
+ transaction.rollback();
}
return beans;
}
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/QualifierEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/QualifierEntity.java 2012-09-10 22:49:54 UTC (rev 43571)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/QualifierEntity.java 2012-09-10 22:50:09 UTC (rev 43572)
@@ -11,12 +11,14 @@
package org.jboss.tools.cdi.db.entity;
import javax.persistence.Column;
+import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
* @author Alexey Kazakov
*/
+@Entity
public class QualifierEntity {
private long id;
13 years, 3 months
JBoss Tools SVN: r43571 - workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-09-10 18:49:54 -0400 (Mon, 10 Sep 2012)
New Revision: 43571
Modified:
workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
Log:
JBIDE-12446
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java 2012-09-10 20:38:43 UTC (rev 43570)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java 2012-09-10 22:49:54 UTC (rev 43571)
@@ -46,13 +46,19 @@
if(started) {
return;
}
- CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
- Properties props = new Properties();
- url = protocol + getDBPath();
- Connection conn = DriverManager.getConnection(url + ";create=true", props);
- conn.close();
- init();
- started = true;
+ ClassLoader l = Thread.currentThread().getContextClassLoader();
+ try {
+ CommonDbPlugin.getDefault().getBundle().loadClass(driver).newInstance();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ Properties props = new Properties();
+ url = protocol + getDBPath();
+ Connection conn = DriverManager.getConnection(url + ";create=true", props);
+ conn.close();
+ init();
+ started = true;
+ } finally {
+ Thread.currentThread().setContextClassLoader(l);
+ }
}
public EntityManager getEntityManager() {
13 years, 3 months
JBoss Tools SVN: r43570 - in workspace/akazakov/db: org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-09-10 16:38:43 -0400 (Mon, 10 Sep 2012)
New Revision: 43570
Modified:
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
Log:
https://issues.jboss.org/browse/JBIDE-12446
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 20:33:09 UTC (rev 43569)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/CDIDataBase.java 2012-09-10 20:38:43 UTC (rev 43570)
@@ -34,9 +34,66 @@
*/
public class CDIDataBase implements ICDICache {
- private Map<String, Short> projects = new HashMap<String, Short>();
- private short nextIndex = 0;
+ private Context currentContext = new Context();
+ private static class Context {
+ private Map<String, Short> projects = new HashMap<String, Short>();
+ private Map<Integer, IBean> allBeans = new HashMap<Integer, IBean>();
+ private short nextIndex = 0;
+
+ long getTypeIndex(IParametedType type) {
+ IType iType = type.getType();
+ String name = iType!=null?iType.getFullyQualifiedName():type.getSimpleName();
+ return getTypeIndex(name);
+ }
+
+ long getTypeIndex(String typeName) {
+ long result = ((long)typeName.hashCode() << 32);
+ if(typeName.length() > 1) {
+ result += (typeName.substring(1) + typeName.substring(0, 1)).hashCode();
+ }
+ return result;
+ }
+
+ Short getProjectIndex(ICDIProject project) {
+ String projectName = project.getNature().getProject().getName();
+ return projects.get(projectName);
+ }
+
+ Short removeProjectIndex(ICDIProject project) {
+ String projectName = project.getNature().getProject().getName();
+ Short index = projects.get(projectName);
+ if(index!=null) {
+ projects.remove(projectName);
+ }
+ return index;
+ }
+
+ short generateProjectIndex(ICDIProject project) {
+ String projectName = project.getNature().getProject().getName();
+ short index = nextIndex;
+ projects.put(projectName, nextIndex++);
+ return index;
+ }
+
+ Map<Integer, IBean> getAllBeans() {
+ return allBeans;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ protected Object clone() {
+ Context context = new Context();
+ context.nextIndex = this.nextIndex;
+ for (Map.Entry<String, Short> project : this.projects.entrySet()) {
+ context.projects.put(project.getKey(), project.getValue());
+ }
+ return context;
+ }
+ }
+
public CDIDataBase() {
CDIDBManager.getInstance().getEntityManager();
}
@@ -47,7 +104,12 @@
*/
@Override
public void rebuild(ICDIProject project, Collection<IBean> beans) {
- Short projectIndex = removeProjectIndex(project);
+ Context context = null;
+ synchronized (currentContext) {
+ context = (Context)currentContext.clone();
+ }
+
+ Short projectIndex = context.removeProjectIndex(project);
EntityManager em = CDIDBManager.getInstance().getEntityManager();
EntityTransaction transaction = em.getTransaction();
transaction.begin();
@@ -56,11 +118,11 @@
em.createQuery("DELETE FROM QualifierEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
em.createQuery("DELETE FROM TypeEntity b WHERE b.projectIndex = :p").setParameter("p", projectIndex).executeUpdate();
}
- projectIndex = generateProjectIndex(project);
+ projectIndex = context.generateProjectIndex(project);
Map<Integer, QualifierEntity> qualifiers = new HashMap<Integer, QualifierEntity>();
- Map<Integer, TypeEntity> types = new HashMap<Integer, TypeEntity>();
for (IBean bean : beans) {
+ context.getAllBeans().put(bean.getId(), bean);
BeanEntity beanEntity = new BeanEntity();
beanEntity.setIndex(bean.getId());
beanEntity.setProjectIndex(projectIndex);
@@ -79,19 +141,21 @@
qualifierEntities.add(qualifierEntity);
}
+ beanEntity.setQualifiers(qualifierEntities);
+ em.persist(beanEntity);
+
Collection<IParametedType> beanTypes = bean.getLegalTypes();
for (IParametedType beanType : beanTypes) {
- long id = getTypeIndex(beanType);
+ long id = context.getTypeIndex(beanType);
TypeEntity typeEntity = new TypeEntity();
typeEntity.setIndex(id);
typeEntity.setBean(beanEntity);
em.persist(typeEntity);
}
-
- beanEntity.setQualifiers(qualifierEntities);
- em.persist(beanEntity);
}
transaction.commit();
+
+ currentContext = context;
}
/*
@@ -100,51 +164,23 @@
*/
@Override
public Collection<IBean> getBeansByLegalType(ICDIProject project, String legalType) {
- Short projectIndex = getProjectIndex(project);
- EntityManager em = CDIDBManager.getInstance().getEntityManager();
- EntityTransaction transaction = em.getTransaction();
- transaction.begin();
+ List<IBean> beans = new ArrayList<IBean>();
+ synchronized (currentContext) {
+ Short projectIndex = currentContext.getProjectIndex(project);
+ EntityManager em = CDIDBManager.getInstance().getEntityManager();
+ EntityTransaction transaction = em.getTransaction();
+ transaction.begin();
- long typeIndex = getTypeIndex(legalType);
- //TODO
- List result = em.createQuery("SELECT FROM TypeEntity t, BeanEntity b WHERE t.index = :b AND t.bean.projectIndex = :p AND t.bean.id = b.id ").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
-
- transaction.commit();
- return null;
- }
-
- private long getTypeIndex(IParametedType type) {
- IType iType = type.getType();
- String name = iType!=null?iType.getFullyQualifiedName():type.getSimpleName();
- return getTypeIndex(name);
- }
-
- private long getTypeIndex(String typeName) {
- long result = ((long)typeName.hashCode() << 32);
- if(typeName.length() > 1) {
- result += (typeName.substring(1) + typeName.substring(0, 1)).hashCode();
+ long typeIndex = currentContext.getTypeIndex(legalType);
+ List results = em.createQuery("SELECT FROM t.bean TypeEntity t WHERE t.index = :b AND t.bean.projectIndex = :p").setParameter("p", projectIndex).setParameter("b", typeIndex).getResultList();
+ for (Object result : results) {
+ BeanEntity beanEntity = (BeanEntity)result;
+ int index = beanEntity.getIndex();
+ IBean bean = currentContext.allBeans.get(index);
+ beans.add(bean);
+ }
+ transaction.commit();
}
- return result;
+ return beans;
}
-
- private Short getProjectIndex(ICDIProject project) {
- String projectName = project.getNature().getProject().getName();
- return projects.get(projectName);
- }
-
- private Short removeProjectIndex(ICDIProject project) {
- String projectName = project.getNature().getProject().getName();
- Short index = projects.get(projectName);
- if(index!=null) {
- projects.remove(projectName);
- }
- return index;
- }
-
- private short generateProjectIndex(ICDIProject project) {
- String projectName = project.getNature().getProject().getName();
- short index = nextIndex;
- projects.put(projectName, nextIndex++);
- return index;
- }
}
\ No newline at end of file
Modified: workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java 2012-09-10 20:33:09 UTC (rev 43569)
+++ workspace/akazakov/db/org.jboss.tools.cdi.db/src/org/jboss/tools/cdi/db/entity/BeanEntity.java 2012-09-10 20:38:43 UTC (rev 43570)
@@ -30,7 +30,7 @@
private long id;
private int index;
private short projectIndex;
- private List<TypeEntity> types;
+// private List<TypeEntity> types;
private List<QualifierEntity> qualifiers;
/**
@@ -59,25 +59,25 @@
this.index = index;
}
- /**
- * @return the types
- */
- @OneToMany(cascade={CascadeType.REMOVE}, mappedBy="bean")
- public List<TypeEntity> getTypes() {
- return types;
- }
+// /**
+// * @return the types
+// */
+// @OneToMany(cascade={CascadeType.REMOVE}, mappedBy="bean")
+// public List<TypeEntity> getTypes() {
+// return types;
+// }
+//
+// /**
+// * @param types the types to set
+// */
+// public void setTypes(List<TypeEntity> types) {
+// this.types = types;
+// }
/**
- * @param types the types to set
- */
- public void setTypes(List<TypeEntity> types) {
- this.types = types;
- }
-
- /**
* @return the qualifiers
*/
- @ManyToOne
+ @OneToMany
@JoinColumn(nullable=true)
public List<QualifierEntity> getQualifiers() {
return qualifiers;
Modified: workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java
===================================================================
--- workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java 2012-09-10 20:33:09 UTC (rev 43569)
+++ workspace/akazakov/db/org.jboss.tools.common.db/src/org/jboss/tools/common/db/AbstractDBManager.java 2012-09-10 20:38:43 UTC (rev 43570)
@@ -51,8 +51,8 @@
url = protocol + getDBPath();
Connection conn = DriverManager.getConnection(url + ";create=true", props);
conn.close();
+ init();
started = true;
- init();
}
public EntityManager getEntityManager() {
13 years, 3 months
JBoss Tools SVN: r43569 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-09-10 16:33:09 -0400 (Mon, 10 Sep 2012)
New Revision: 43569
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
Log:
Still fighting with dir paths on Windows
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-10 20:14:07 UTC (rev 43568)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-10 20:33:09 UTC (rev 43569)
@@ -79,7 +79,7 @@
try {
//baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), "zzz");
// http://stackoverflow.com/questions/1701839/backslash-problem-with-string-...
- baseDir = bot.textWithLabel("Location:").getText().replace("\\", "\\\\") + "\\";
+ baseDir = bot.textWithLabel("Location:").getText().replace("\\", "\\\\") + "\\\\";
}
catch (Exception E) {
System.out.println ("replaceAll failing with " + E.getMessage() );
13 years, 3 months
JBoss Tools SVN: r43567 - trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples.
by jbosstools-commits@lists.jboss.org
Author: ldimaggio
Date: 2012-09-10 15:30:01 -0400 (Mon, 10 Sep 2012)
New Revision: 43567
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
Log:
Replacing call to replaceAll to replace - Windows dir - http://stackoverflow.com/questions/1701839/backslash-problem-with-string-...
Modified: trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-10 19:02:15 UTC (rev 43566)
+++ trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/HelloWorldFileAction.java 2012-09-10 19:30:01 UTC (rev 43567)
@@ -74,14 +74,18 @@
/* Needed to avoid a syntax error with Windows \ dir path characters */
//baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), System.getProperty("file.separator") + System.getProperty("file.separator")) + System.getProperty("file.separator");
baseDir = bot.textWithLabel("Location:").getText();
- System.out.println("DEBUG baseDir = " + bot.textWithLabel("Location:").getText()) ;
+ System.out.println("DEBUG baseDir = " + baseDir) ;
try {
- baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), "zzz");
+ //baseDir = bot.textWithLabel("Location:").getText().replaceAll(System.getProperty("file.separator"), "zzz");
+ // http://stackoverflow.com/questions/1701839/backslash-problem-with-string-...
+ baseDir = bot.textWithLabel("Location:").getText().replace("\\", "\\\\") + "\\";
}
catch (Exception E) {
System.out.println ("replaceAll failing with " + E.getMessage() );
}
+
+ System.out.println("DEBUG baseDir = " + baseDir) ;
}
13 years, 3 months