JBoss Tools SVN: r2282 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors: autolayout/impl and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-07-04 09:08:36 -0400 (Wed, 04 Jul 2007)
New Revision: 2282
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IDiagramInfo.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IProcessInfo.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/AutoLayout.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/Example.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/AutoLayoutImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/Items.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/parts/DiagramEditPart.java
Log:
http://jira.jboss.com/jira/browse/EXIN-368
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/AutoLayout.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/AutoLayout.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/AutoLayout.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -37,7 +37,7 @@
engine.setOverride(b);
}
- public void setProcess(IProcessInfo process) {
+ public void setProcess(IDiagramInfo process) {
engine.setProcess(process);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/Example.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/Example.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/Example.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -14,7 +14,7 @@
public class Example {
- public static IProcessInfo generateRandomProcess(int nodeCount, int linkCount) {
+ public static IDiagramInfo generateRandomProcess(int nodeCount, int linkCount) {
ProcessInfoImpl process = new ProcessInfoImpl();
for (int i = 0; i < nodeCount; i++) {
ItemInfoImpl item = new ItemInfoImpl();
@@ -33,7 +33,7 @@
return process;
}
- static void printProcess(IProcessInfo process) {
+ static void printProcess(IDiagramInfo process) {
IItemInfo[] items = process.getItems();
for (int i = 0; i < items.length; i++) printItem(items[i]);
}
@@ -55,7 +55,7 @@
}
public static void main(String[] args) {
- IProcessInfo process = generateRandomProcess(10, 17);
+ IDiagramInfo process = generateRandomProcess(10, 17);
System.out.println("Before Layout");
printProcess(process);
AutoLayout layout = new AutoLayout();
@@ -67,7 +67,7 @@
}
}
-class ProcessInfoImpl implements IProcessInfo {
+class ProcessInfoImpl implements IDiagramInfo {
ArrayList items = new ArrayList();
public IItemInfo[] getItems() {
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IDiagramInfo.java (from rev 2257, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IProcessInfo.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IDiagramInfo.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IDiagramInfo.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -0,0 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.veditor.editors.autolayout;
+
+public interface IDiagramInfo {
+ IItemInfo[] getItems();
+}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IProcessInfo.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IProcessInfo.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/IProcessInfo.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.veditor.editors.autolayout;
-
-public interface IProcessInfo {
- IItemInfo[] getItems();
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/AutoLayoutImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/AutoLayoutImpl.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/AutoLayoutImpl.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -12,7 +12,7 @@
import org.jboss.tools.hibernate.veditor.editors.autolayout.IItemInfo;
import org.jboss.tools.hibernate.veditor.editors.autolayout.ILinkInfo;
-import org.jboss.tools.hibernate.veditor.editors.autolayout.IProcessInfo;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.IDiagramInfo;
public class AutoLayoutImpl {
@@ -34,7 +34,7 @@
items.setOverride(b);
}
- public void setProcess(IProcessInfo process) {
+ public void setProcess(IDiagramInfo process) {
// constants.update();
items.setProcess(process);
apply();
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/Items.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/Items.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/autolayout/impl/Items.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -14,12 +14,12 @@
import org.jboss.tools.hibernate.veditor.editors.autolayout.IItemInfo;
import org.jboss.tools.hibernate.veditor.editors.autolayout.ILinkInfo;
-import org.jboss.tools.hibernate.veditor.editors.autolayout.IProcessInfo;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.IDiagramInfo;
public class Items {
protected LayuotConstants constants;
- protected IProcessInfo process;
+ protected IDiagramInfo process;
protected Item[] items;
protected Map paths = new HashMap();
protected Groups groups = new Groups();
@@ -36,7 +36,7 @@
override = b;
}
- public void setProcess(IProcessInfo process) {
+ public void setProcess(IDiagramInfo process) {
this.process = process;
try { load(); } catch (Exception e) { e.printStackTrace(); }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/model/OrmDiagram.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -45,7 +45,6 @@
import org.jboss.tools.hibernate.veditor.VizualEditorPlugin;
import org.jboss.tools.hibernate.veditor.editors.autolayout.IItemInfo;
import org.jboss.tools.hibernate.veditor.editors.autolayout.ILinkInfo;
-import org.jboss.tools.hibernate.veditor.editors.autolayout.IProcessInfo;
/**
@@ -376,158 +375,4 @@
}
return classShape;
}
-
- class DiagramInfo implements IProcessInfo {
-
- ArrayList items = new ArrayList();
-
- /**
- *
- * @param flow
- */
- public DiagramInfo() {
- IItemInfo item;
-
- for (int i = 0; i < getChildren().size(); i++) {
- item = new DiagramElementInfo((OrmShape) getChildren().get(i));
- addItem(item);
- }
- }
-
- /**
- *
- */
- public IItemInfo[] getItems() {
- return (IItemInfo[]) items.toArray(new IItemInfo[0]);
- }
-
- /**
- *
- * @param item
- */
- public void addItem(IItemInfo item) {
- items.add(item);
- }
- }
-
- class DiagramElementInfo implements IItemInfo {
- OrmShape element;
-
- ArrayList links = new ArrayList();
-
- /**
- *
- * @param element
- */
- public DiagramElementInfo(OrmShape element) {
- ILinkInfo link;
- this.element = element;
- for (int i = 0; i < element.getSourceConnections().size(); i++) {
- link = new LinkInfo((Connection) element.getSourceConnections().get(i));
- addLink(link);
- }
- Shape child;
- for (int j = 0; j < element.getChildren().size(); j++) {
- child = (Shape) element.getChildren().get(j);
- if (child.getSourceConnections().size() == 0) {
- link = new LinkInfo(getID());
- addLink(link);
- }
- for (int i = 0; i < child.getSourceConnections().size(); i++) {
- link = new LinkInfo((Connection) child.getSourceConnections().get(i));
- addLink(link);
- }
- }
- }
-
- /**
- *
- */
- public String getID() {
- return element.toString();
- }
-
- /**
- *
- */
- public boolean isComment() {
- return false;
- }
-
- /**
- *
- */
- public int[] getShape() {
- int[] shape = new int[4];
- shape[0] = element.getLocation().x;
- shape[1] = element.getLocation().y;
- shape[2] = 100;
- shape[3] = 100;
- return shape;
- }
-
- /**
- *
- */
- public ILinkInfo[] getLinks() {
- return (ILinkInfo[]) links.toArray(new ILinkInfo[0]);
- }
-
- /**
- *
- * @param link
- */
- public void addLink(ILinkInfo link) {
- links.add(link);
- }
-
- /**
- *
- */
- public void setShape(int[] s) {
- element.setLocation(new Point(s[0], s[1]));
- }
-
- }
-
- class LinkInfo implements ILinkInfo {
- Connection link = null;
-
- String id = null;
-
- /**
- *
- * @param link
- */
- public LinkInfo(Connection link) {
- this.link = link;
- }
-
- /**
- *
- * @param id
- */
- public LinkInfo(String id) {
- this.id = id;
- }
-
- /**
- *
- */
- public String getTargetID() {
- if (id != null)
- return id;
- if (link.getTarget() != null)
- return link.getTarget().toString();
- else
- return "";
- }
-
- /**
- *
- */
- public void setLinkShape(int[] vs) {
- }
- }
-
}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/parts/DiagramEditPart.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/parts/DiagramEditPart.java 2007-07-04 12:53:38 UTC (rev 2281)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/veditor/editors/parts/DiagramEditPart.java 2007-07-04 13:08:36 UTC (rev 2282)
@@ -7,11 +7,12 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.hibernate.veditor.editors.parts;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -43,128 +44,151 @@
import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.Table;
import org.jboss.tools.hibernate.veditor.editors.VizualEditor;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.AutoLayout;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.IItemInfo;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.ILinkInfo;
+import org.jboss.tools.hibernate.veditor.editors.autolayout.IDiagramInfo;
import org.jboss.tools.hibernate.veditor.editors.command.ShapeSetConstraintCommand;
+import org.jboss.tools.hibernate.veditor.editors.model.Connection;
import org.jboss.tools.hibernate.veditor.editors.model.ModelElement;
import org.jboss.tools.hibernate.veditor.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.veditor.editors.model.OrmShape;
+import org.jboss.tools.hibernate.veditor.editors.model.Shape;
import org.jboss.tools.hibernate.veditor.editors.model.SpecialOrmShape;
import org.jboss.tools.hibernate.veditor.editors.model.SpecialRootClass;
-
/**
* @author Konstantin Mishin
- *
+ *
*/
-class DiagramEditPart extends OrmEditPart implements PropertyChangeListener{
-
+class DiagramEditPart extends OrmEditPart implements PropertyChangeListener {
+
protected void createEditPolicies() {
- installEditPolicy(EditPolicy.LAYOUT_ROLE, new ShapesXYLayoutEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE,
+ new ShapesXYLayoutEditPolicy());
}
-
+
protected IFigure createFigure() {
Figure f = new FreeformLayer();
f.setBorder(new MarginBorder(3));
f.setLayoutManager(new FreeformLayout());
-
- ConnectionLayer connLayer = (ConnectionLayer)getLayer(LayerConstants.CONNECTION_LAYER);
+
+ ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
connLayer.setConnectionRouter(new ManhattanConnectionRouter());
-
+
return f;
}
-
+
public void propertyChange(PropertyChangeEvent evt) {
String prop = evt.getPropertyName();
if (OrmDiagram.REFRESH.equals(prop)) {
refresh();
- restore();
+ autolayout();
+ // restore();
} else if (OrmDiagram.DIRTY.equals(prop))
- ((VizualEditor)((DefaultEditDomain)getViewer().getEditDomain()).getEditorPart()).refreshDirty();
+ ((VizualEditor) ((DefaultEditDomain) getViewer().getEditDomain())
+ .getEditorPart()).refreshDirty();
}
-
+
public void restore() {
boolean dirty = getCastedModel().isDirty();
HashMap hashMap = getCastedModel().getCloneElements();
- String childrenLocations[] = getCastedModel().getChildrenLocations();
+ String childrenLocations[] = getCastedModel().getChildrenLocations();
int tempPoint = 1;
OrmShape ormShape;
int point = 1;
int pointX = calculateTableLocation();
String string, xy[];
for (int i = 0; i < childrenLocations.length; i++)
- if (childrenLocations[i].indexOf('@') != -1 && childrenLocations[i].indexOf(';') != -1){
- string = childrenLocations[i].substring(0,childrenLocations[i].indexOf('@'));
- ormShape = (OrmShape)hashMap.remove(string);
+ if (childrenLocations[i].indexOf('@') != -1
+ && childrenLocations[i].indexOf(';') != -1) {
+ string = childrenLocations[i].substring(0, childrenLocations[i]
+ .indexOf('@'));
+ ormShape = (OrmShape) hashMap.remove(string);
if (ormShape != null) {
- string = childrenLocations[i].substring(childrenLocations[i].indexOf('@')+1);
+ string = childrenLocations[i]
+ .substring(childrenLocations[i].indexOf('@') + 1);
xy = string.split(";");
- if(xy.length>1)
+ if (xy.length > 1)
try {
- ormShape.setLocation(new Point(Integer.parseInt(xy[0]),Integer.parseInt(xy[1])));
- } catch (NumberFormatException e) {}
- if(xy.length>2)
- if((new Boolean(xy[2])).booleanValue())
+ ormShape.setLocation(new Point(Integer
+ .parseInt(xy[0]), Integer.parseInt(xy[1])));
+ } catch (NumberFormatException e) {
+ }
+ if (xy.length > 2)
+ if ((new Boolean(xy[2])).booleanValue())
ormShape.refreshHiden();
- tempPoint = ormShape.getLocation().y + getChildrenFigurePreferredHeight(ormShape) + 20;
- if(tempPoint > point)
+ tempPoint = ormShape.getLocation().y
+ + getChildrenFigurePreferredHeight(ormShape) + 20;
+ if (tempPoint > point)
point = tempPoint;
}
}
if (getCastedModel().getOrmElement() instanceof RootClass) {
- RootClass persistentClass = (RootClass)getCastedModel().getOrmElement();
- ormShape = (OrmShape)hashMap.remove(persistentClass.getClassName());
+ RootClass persistentClass = (RootClass) getCastedModel()
+ .getOrmElement();
+ ormShape = (OrmShape) hashMap
+ .remove(persistentClass.getClassName());
if (ormShape != null) {
- ormShape.setLocation(new Point(20,20));
- tempPoint = 40 + getChildrenFigurePreferredHeight(ormShape);
+ ormShape.setLocation(new Point(20, 20));
+ tempPoint = 40 + getChildrenFigurePreferredHeight(ormShape);
}
Table table = persistentClass.getTable();
- ormShape = (OrmShape)hashMap.remove(table.getSchema() + "." + table.getName());
+ ormShape = (OrmShape) hashMap.remove(table.getSchema() + "."
+ + table.getName());
if (ormShape != null) {
- ormShape.setLocation(new Point(pointX,20));
+ ormShape.setLocation(new Point(pointX, 20));
point = 40 + getChildrenFigurePreferredHeight(ormShape);
}
- if(tempPoint > point)
+ if (tempPoint > point)
point = tempPoint;
}
Object objects[] = hashMap.keySet().toArray();
for (int i = 0; i < objects.length; i++) {
- ormShape = (OrmShape)hashMap.get(objects[i]);
- if (ormShape != null && (ormShape.getOrmElement() instanceof RootClass || ormShape.getOrmElement() instanceof SpecialOrmShape)) {
- ormShape.setLocation(new Point(20,point));
- tempPoint = point + getChildrenFigurePreferredHeight(ormShape) + 20;
- if (ormShape.getOrmElement() instanceof SpecialRootClass) {
- Component component = (Component)((Collection)((SpecialRootClass)(ormShape.getOrmElement())).getProperty().getValue()).getElement();
- Table ownerTable = component.getOwner().getTable();
- ormShape = (OrmShape)hashMap.remove(ownerTable.getSchema() + "." + ownerTable.getName());
- }
- if (ormShape != null ) {
- ormShape.setLocation(new Point(pointX,point));
- point = point + getChildrenFigurePreferredHeight(ormShape) + 20;
- }
- if(tempPoint > point)
+ ormShape = (OrmShape) hashMap.get(objects[i]);
+ if (ormShape != null
+ && (ormShape.getOrmElement() instanceof RootClass || ormShape
+ .getOrmElement() instanceof SpecialOrmShape)) {
+ ormShape.setLocation(new Point(20, point));
+ tempPoint = point + getChildrenFigurePreferredHeight(ormShape)
+ + 20;
+ // if (ormShape.getOrmElement() instanceof SpecialRootClass) {
+ Component component = (Component) ((Collection) ((SpecialRootClass) (ormShape
+ .getOrmElement())).getProperty().getValue())
+ .getElement();
+ Table ownerTable = component.getOwner().getTable();
+ ormShape = (OrmShape) hashMap.remove(ownerTable.getSchema()
+ + "." + ownerTable.getName());
+ // }
+ // if (ormShape != null ) {
+ // ormShape.setLocation(new Point(pointX,point));
+ // point = point + getChildrenFigurePreferredHeight(ormShape) +
+ // 20;
+ // }
+ if (tempPoint > point)
point = tempPoint;
}
}
Iterator iterator = hashMap.values().iterator();
while (iterator.hasNext()) {
ormShape = (OrmShape) iterator.next();
- if (ormShape.getOrmElement() instanceof Table) {
- ormShape.setLocation(new Point(pointX,point));
+ if (ormShape.getOrmElement() instanceof Table) {
+ ormShape.setLocation(new Point(pointX, point));
point = point + getChildrenFigurePreferredHeight(ormShape) + 20;
}
}
getCastedModel().setDirty(dirty);
}
-
private OrmDiagram getCastedModel() {
return (OrmDiagram) getModel();
}
-
+
private int getChildrenFigurePreferredHeight(OrmShape ormShape) {
GraphicalEditPart part;
for (int i = 0; i < getChildren().size(); i++) {
- part = (GraphicalEditPart)getChildren().get(i);
+ part = (GraphicalEditPart) getChildren().get(i);
if (ormShape.equals(part.getModel()))
return part.getFigure().getPreferredSize().height;
}
@@ -175,7 +199,7 @@
int j = 0;
IFigure figure;
for (int i = 0; i < getFigure().getChildren().size(); i++) {
- figure = (IFigure)getFigure().getChildren().get(i);
+ figure = (IFigure) getFigure().getChildren().get(i);
if (figure.getPreferredSize().width > j)
j = figure.getPreferredSize().width;
}
@@ -183,22 +207,32 @@
}
protected List getModelChildren() {
- return getCastedModel().getChildren();
+ return getCastedModel().getChildren();
}
-
+
public void activate() {
if (!isActive()) {
super.activate();
((ModelElement) getModel()).addPropertyChangeListener(this);
- restore();
+ autolayout();
+ // restore();
}
}
-
- public void setToFront(EditPart ep){
+
+ public void autolayout() {
+ IDiagramInfo process = new DiagramInfo(getCastedModel());
+ AutoLayout layout = new AutoLayout();
+ layout.setGridStep("" + 5);
+ layout.setOverride(true);
+ layout.setProcess(process);
+ }
+
+ public void setToFront(EditPart ep) {
int index = getChildren().indexOf(ep);
- if(index == -1) return;
- if(index != getChildren().size()-1)
- reorderChild(ep, getChildren().size()-1);
+ if (index == -1)
+ return;
+ if (index != getChildren().size() - 1)
+ reorderChild(ep, getChildren().size() - 1);
}
public void deactivate() {
@@ -207,36 +241,198 @@
((ModelElement) getModel()).removePropertyChangeListener(this);
}
}
-
+
private static class ShapesXYLayoutEditPolicy extends XYLayoutEditPolicy {
-
- protected Command createChangeConstraintCommand(ChangeBoundsRequest request,
- EditPart child, Object constraint) {
- if (child instanceof OrmShapeEditPart && constraint instanceof Rectangle) {
- return new ShapeSetConstraintCommand(
- (OrmShape) child.getModel(), request, ((Rectangle) constraint).getLocation());
+
+ protected Command createChangeConstraintCommand(
+ ChangeBoundsRequest request, EditPart child, Object constraint) {
+ if (child instanceof OrmShapeEditPart
+ && constraint instanceof Rectangle) {
+ return new ShapeSetConstraintCommand((OrmShape) child
+ .getModel(), request, ((Rectangle) constraint)
+ .getLocation());
}
- return super.createChangeConstraintCommand(request, child, constraint);
+ return super.createChangeConstraintCommand(request, child,
+ constraint);
}
-
+
protected Command createAddCommand(EditPart child, Object constraint) {
return null;
}
-
- protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
+
+ protected Command createChangeConstraintCommand(EditPart child,
+ Object constraint) {
return null;
}
-
+
protected Command getCreateCommand(CreateRequest request) {
return null;
}
-
+
protected Command getDeleteDependantCommand(Request request) {
return null;
}
-
+
protected EditPolicy createChildEditPolicy(EditPart child) {
return new NonResizableEditPolicy();
}
}
-}
\ No newline at end of file
+
+
+class DiagramInfo implements IDiagramInfo {
+
+ ArrayList items = new ArrayList();
+ OrmDiagram diagram;
+
+ public DiagramInfo(OrmDiagram diagram) {
+ IItemInfo item;
+ this.diagram = diagram;
+
+ for (int i = 0; i < diagram.getChildren().size(); i++) {
+ item = new DiagramElementInfo((OrmShape) diagram.getChildren().get(
+ i));
+ addItem(item);
+ }
+ }
+
+ /**
+ *
+ */
+ public IItemInfo[] getItems() {
+ return (IItemInfo[]) items.toArray(new IItemInfo[0]);
+ }
+
+ /**
+ *
+ * @param item
+ */
+ public void addItem(IItemInfo item) {
+ items.add(item);
+ }
+
+ class DiagramElementInfo implements IItemInfo {
+ OrmShape element;
+
+ ArrayList links = new ArrayList();
+
+ /**
+ *
+ * @param element
+ */
+ public DiagramElementInfo(OrmShape element) {
+ ILinkInfo link;
+ this.element = element;
+ for (int i = 0; i < element.getSourceConnections().size(); i++) {
+ link = new LinkInfo((Connection) element.getSourceConnections()
+ .get(i));
+ addLink(link);
+ }
+ Shape child;
+ for (int j = 0; j < element.getChildren().size(); j++) {
+ child = (Shape) element.getChildren().get(j);
+ if (child.getSourceConnections().size() == 0) {
+ link = new LinkInfo(getID());
+ addLink(link);
+ }
+ for (int i = 0; i < child.getSourceConnections().size(); i++) {
+ link = new LinkInfo((Connection) child
+ .getSourceConnections().get(i));
+ addLink(link);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public String getID() {
+ return element.toString();
+ }
+
+ /**
+ *
+ */
+ public boolean isComment() {
+ return false;
+ }
+
+ /**
+ *
+ */
+ public int[] getShape() {
+ int[] shape = new int[4];
+ shape[0] = element.getLocation().x;
+ shape[1] = element.getLocation().y;
+ //OrmShapeEditPart part = (OrmShapeEditPart)getViewer().getEditPartRegistry().get(element);
+ //if(part != null)
+ // shape[2] = part.getFigure().getSize().width;
+ //else
+ shape[2] = 600;
+ shape[3] = 100;
+ return shape;
+ }
+
+ /**
+ *
+ */
+ public ILinkInfo[] getLinks() {
+ return (ILinkInfo[]) links.toArray(new ILinkInfo[0]);
+ }
+
+ /**
+ *
+ * @param link
+ */
+ public void addLink(ILinkInfo link) {
+ links.add(link);
+ }
+
+ /**
+ *
+ */
+ public void setShape(int[] s) {
+ element.setLocation(new Point(s[0], s[1]));
+ }
+
+ }
+
+ class LinkInfo implements ILinkInfo {
+ Connection link = null;
+
+ String id = null;
+
+ /**
+ *
+ * @param link
+ */
+ public LinkInfo(Connection link) {
+ this.link = link;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public LinkInfo(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ */
+ public String getTargetID() {
+ if (id != null)
+ return id;
+ if (link.getTarget() != null)
+ return link.getTarget().toString();
+ else
+ return "";
+ }
+
+ /**
+ *
+ */
+ public void setLinkShape(int[] vs) {
+ }
+ }
+}}
17 years, 6 months
JBoss Tools SVN: r2281 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-07-04 08:53:38 -0400 (Wed, 04 Jul 2007)
New Revision: 2281
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/plugin.xml
Log:
fix broken commons.log dependency for hibernate diagrams.
removed leftover perspective and view definitions from old hibernate plugins to avoid conflicts when running them at the same time.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-04 12:27:45 UTC (rev 2280)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-04 12:53:38 UTC (rev 2281)
@@ -3,6 +3,5 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="/org.jboss.tools.common"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-07-04 12:27:45 UTC (rev 2280)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/META-INF/MANIFEST.MF 2007-07-04 12:53:38 UTC (rev 2281)
@@ -14,7 +14,8 @@
org.eclipse.ui.editors,
org.eclipse.core.resources,
org.hibernate.eclipse,
- org.jboss.tools.hibernate.ui.view
+ org.jboss.tools.hibernate.ui.view,
+ org.jboss.tools.common
Bundle-Version: 2.0.0
Export-Package: org.jboss.tools.hibernate.veditor,
org.jboss.tools.hibernate.veditor.editors,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/plugin.xml 2007-07-04 12:27:45 UTC (rev 2280)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/plugin.xml 2007-07-04 12:53:38 UTC (rev 2281)
@@ -8,8 +8,8 @@
contributorClass="org.jboss.tools.hibernate.veditor.editors.EditorActionContributor"
icon="icons/sample.gif"
id="org.jboss.tools.hibernate.veditor.editors.vizualeditor"
- name="Vizual Editor">
+ name="Hibernate Diagram Viewer">
</editor>
</extension>
-</plugin>
\ No newline at end of file
+</plugin>
17 years, 6 months
JBoss Tools SVN: r2280 - trunk/common/plugins/org.jboss.tools.common/META-INF.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-07-04 08:27:45 -0400 (Wed, 04 Jul 2007)
New Revision: 2280
Modified:
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
Log:
EXIN-365: Add Provide-Package: org.jboss.tools.common.log.
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2007-07-04 12:25:44 UTC (rev 2279)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2007-07-04 12:27:45 UTC (rev 2280)
@@ -17,6 +17,7 @@
org.jboss.tools.common.reporting,
org.jboss.tools.common.util,
org.jboss.tools.common.xml,
+ org.jboss.tools.common.log,
org.apache.commons.codec,
org.apache.commons.codec.binary,
org.apache.commons.codec.digest,
17 years, 6 months
JBoss Tools SVN: r2279 - trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2007-07-04 08:25:44 -0400 (Wed, 04 Jul 2007)
New Revision: 2279
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorDefinition.java
Log:
http://jira.jboss.org/jira/browse/EXIN-330
The schema added due to allow the xml-editor configuration to load and use custom content assist processors dependig on the partition type.
Added: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorDefinition.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorDefinition.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorDefinition.java 2007-07-04 12:25:44 UTC (rev 2279)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.common.text.ext.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.osgi.framework.Bundle;
+
+public class ContentAssistProcessorDefinition {
+ private String fId = null;
+ private String fClassName = null;
+
+ // a list of partition types (String)
+ private List fPartitionTypes = null;
+
+ private IConfigurationElement fConfigurationElement = null;
+
+ /**
+ * @param id
+ * @param class1
+ * @param configurationElement
+ */
+ public ContentAssistProcessorDefinition(String id, String class1, IConfigurationElement configurationElement) {
+ super();
+ fId = id;
+ fClassName = class1;
+ fConfigurationElement = configurationElement;
+ fPartitionTypes = new ArrayList();
+ }
+
+ public void addPartitionType(String partitionType) {
+ if (!fPartitionTypes.contains(partitionType))
+ fPartitionTypes.add(partitionType);
+ }
+
+ /**
+ * @return Returns the fClass.
+ */
+ public String getClassName() {
+ return fClassName;
+ }
+
+ /**
+ * @return Returns the fConfigurationElement.
+ */
+ public IConfigurationElement getConfigurationElement() {
+ return fConfigurationElement;
+ }
+
+ /**
+ * @return Returns the fId.
+ */
+ public String getId() {
+ return fId;
+ }
+
+ /**
+ * @return IContentAssistProcessor for this definition
+ */
+ public IContentAssistProcessor createContentAssistProcessor() {
+ IContentAssistProcessor contentAssistProcessor = null;
+
+ if (getClassName() != null) {
+ contentAssistProcessor = (IContentAssistProcessor) createExtension(ContentAssistProcessorBuilder.ATT_CLASS);
+ }
+
+ return contentAssistProcessor;
+ }
+
+ /**
+ * Creates an extension. If the extension plugin has not
+ * been loaded a busy cursor will be activated during the duration of
+ * the load.
+ * @param propertyName
+ * @return Object
+ */
+ private Object createExtension(String propertyName) {
+ // If plugin has been loaded create extension.
+ // Otherwise, show busy cursor then create extension.
+ final IConfigurationElement element = getConfigurationElement();
+ final String name = propertyName;
+
+ final Object[] result = new Object[1];
+ Bundle bundle = Platform.getBundle(element.getDeclaringExtension().getNamespaceIdentifier());
+ if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
+ try {
+ return element.createExecutableExtension(name);
+ }
+ catch (CoreException e) {
+ handleCreateExecutableException(result, e);
+ }
+ }
+ else {
+ BusyIndicator.showWhile(null, new Runnable() {
+ public void run() {
+ try {
+ result[0] = element.createExecutableExtension(name);
+ }
+ catch (Exception e) {
+ handleCreateExecutableException(result, e);
+ }
+ }
+ });
+ }
+ return result[0];
+ }
+
+ /**
+ * @param result
+ * @param e
+ */
+ private void handleCreateExecutableException(Object[] result, Exception x) {
+ ExtensionsPlugin.getPluginLog().logError("Error in creating extension", x);
+ result[0] = null;
+ }
+
+ /**
+ * @return Returns the fPartitionTypes.
+ */
+ public List getPartitionTypes() {
+ return fPartitionTypes;
+ }
+}
17 years, 6 months
JBoss Tools SVN: r2278 - in trunk/common/plugins/org.jboss.tools.common.text.ext: META-INF and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2007-07-04 08:21:41 -0400 (Wed, 04 Jul 2007)
New Revision: 2278
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/schema/contentAssistProcessor.exsd
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorBuilder.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml
Log:
http://jira.jboss.org/jira/browse/EXIN-330
The schema added due to allow the xml-editor configuration to load and use custom content assist processors dependig on the partition type.
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2007-07-04 10:12:06 UTC (rev 2277)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2007-07-04 12:21:41 UTC (rev 2278)
@@ -2,6 +2,7 @@
Eclipse-LazyStart: true
Bundle-Activator: org.jboss.tools.common.text.ext.ExtensionsPlugin
Export-Package: org.jboss.tools.common.text.ext,
+ org.jboss.tools.common.text.ext.contentassist,
org.jboss.tools.common.text.ext.hyperlink,
org.jboss.tools.common.text.ext.hyperlink.jsp,
org.jboss.tools.common.text.ext.hyperlink.xml,
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml 2007-07-04 10:12:06 UTC (rev 2277)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml 2007-07-04 12:21:41 UTC (rev 2278)
@@ -4,6 +4,7 @@
<extension-point id="hyperlink" name="Hyperlink Extension Point Extension" schema="schema/hyperlink.exsd"/>
<extension-point id="hyperlinkPartitioner" name="Hyperlink Partitioner Extension Point Extension" schema="schema/hyperlinkPartitioner.exsd"/>
+ <extension-point id="contentAssistProcessor" name="Content Assist Processor Extension Point Extension" schema="schema/contentAssistProcessor.exsd"/>
<extension
point="org.jboss.tools.common.text.ext.hyperlinkPartitioner"
Added: trunk/common/plugins/org.jboss.tools.common.text.ext/schema/contentAssistProcessor.exsd
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/schema/contentAssistProcessor.exsd (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/schema/contentAssistProcessor.exsd 2007-07-04 12:21:41 UTC (rev 2278)
@@ -0,0 +1,153 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.text.ext">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.common.text.ext" id="contentAssistProcessor" name="Content Assist Processor Extension Point Extension"/>
+ </appInfo>
+ <documentation>
+ Content Assist Processor
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ Defines an extension point for the Content Assist Processor definitions.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="contentAssistProcessor" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique ID for this extension point. It is recommended that the plugin ID be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ A unique ID for this extension. It is recommended that the plugin ID be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ A brief name to show to the user.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contentAssistProcessor">
+ <annotation>
+ <documentation>
+ Defines a Content Assist Processor item. Contains information on a class to be used to perform content assist depending on the content and partition types.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="partitiontype" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique ID for this Content Assist Processor.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ An implementor of org.eclipse.jface.text.contentassist.IContentAssistProcessor, it controls the content assist within text editor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="partitiontype">
+ <annotation>
+ <documentation>
+ Defined the editor's partition type to be assotiated with the Content Assist Processor. The value is either one of the WTP structured model partition type ID or any other structured text partition ID
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique ID for this partitiontype. The value is either one of the WTP structured model partition type ID or any other structured text partition ID.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ V3.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <pre>
+ <extension-point id="contentAssistProcessor" name="Content Assist Processor Extension Point Extension"/>
+
+ <extension
+ point="org.jboss.tools.common.text.ext.contentAssistProcesor"
+ id="org.jboss.tools.common.text.ext.contentAssistProcessor"
+ name="org.jboss.tools.common.text.ext.contentAssistProcessor">
+
+ <contentAssistProcessor
+ class="org.jboss.tools.common.text.xml.contentassist.MyContentAssistProcessor"
+ id="org.jboss.tools.common.text.xml.contentassist.MyContentAssistProcessorID">
+ <partitiontype id="org.jboss.tools.common.text.xml.XML_DOCTYPE" />
+ </contentAssistProcessor>
+ </extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The baseline for API and extension point stability is RedHat Developer Studio
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The supplied implementation of the contentAssistProcessor functionality requires the WTP components.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ RedHat
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorBuilder.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorBuilder.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/contentassist/ContentAssistProcessorBuilder.java 2007-07-04 12:21:41 UTC (rev 2278)
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.common.text.ext.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.jboss.tools.common.text.ext.util.xpl.RegistryReader;
+
+public class ContentAssistProcessorBuilder extends RegistryReader{
+ // extension point ID
+ public static final String PL_CONTENTASSISTPROCESSOR = "contentAssistProcessor"; //$NON-NLS-1$
+
+ public static final String TAG_CONTENTASSISTPROCESSOR = "contentAssistProcessor"; //$NON-NLS-1$
+ public static final String TAG_PARTITION_TYPE = "partitiontype"; //$NON-NLS-1$
+
+ public static final String ATT_ID = "id"; //$NON-NLS-1$
+ public static final String ATT_CLASS = "class"; //$NON-NLS-1$
+
+ protected String targetContributionTag;
+
+ private static ContentAssistProcessorBuilder fInstance;
+
+ private List<ContentAssistProcessorDefinition> fContentAssistProcessorDefs = null;
+ private ContentAssistProcessorDefinition fCurrentDefinition = null;
+
+ /**
+ * returns singleton instance of ContentAssistProcessorBuilder
+ *
+ * @return ContentAssistProcessorBuilder
+ */
+ public synchronized static ContentAssistProcessorBuilder getInstance() {
+ if (fInstance == null) {
+ fInstance = new ContentAssistProcessorBuilder();
+ }
+ return fInstance;
+ }
+
+ /**
+ * Returns the name of the part ID attribute that is expected
+ * in the target extension.
+ *
+ * @param element
+ * @return String
+ */
+ protected String getId(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_ID);
+ return value;
+ }
+
+ protected String getContentAssistProcessorClass(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_CLASS);
+ return value;
+ }
+
+ /**
+ * Processes element which should be a configuration element specifying an
+ * open on object. Creates a new ContentAssistProcessor definitio object and adds it to the
+ * list of ContentAssistProcessor definition objects
+ *
+ * @param element ContentAssistProcessor configuration element
+ */
+ private void processContentAssistProcessorTag(IConfigurationElement element) {
+ String theId = getId(element);
+ String theClass = getContentAssistProcessorClass(element);
+
+ if (theId != null && theClass != null) {
+ // start building new HyperlinkDefinition
+ fCurrentDefinition = new ContentAssistProcessorDefinition(theId, theClass, element);
+
+ // create a new list of open on definitions if it hasn't been created yet
+ if (fContentAssistProcessorDefs == null) {
+ fContentAssistProcessorDefs = new ArrayList<ContentAssistProcessorDefinition>();
+ }
+ fContentAssistProcessorDefs.add(fCurrentDefinition);
+ }
+ else {
+ fCurrentDefinition = null;
+ }
+ }
+
+ /**
+ * Processes element which should be a configuration element specifying a partition
+ * type for the current contentAssistProcessor tag. Assumes that there is a valid
+ * current contentAssistProcessor tag.
+ *
+ * @param element partitiontype configuration element
+ */
+ private void processPartitionTypeTag(IConfigurationElement element) {
+ // add to current HyperlinkDefinition/contentType
+ String theId = getId(element);
+
+ if (theId != null) {
+ fCurrentDefinition.addPartitionType(theId);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.ibm.sse.editor.internal.extension.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ protected boolean readElement(IConfigurationElement element) {
+ String tag = element.getName();
+
+ if (tag.equals(targetContributionTag)) {
+ processContentAssistProcessorTag(element);
+
+ if (fCurrentDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_PARTITION_TYPE)) {
+ processPartitionTypeTag(element);
+ return true;
+ }
+
+ return false;
+ }
+
+ private void initCache() {
+ if (fContentAssistProcessorDefs == null) {
+ readContributions(TAG_CONTENTASSISTPROCESSOR, PL_CONTENTASSISTPROCESSOR);
+ }
+ }
+
+ /**
+ * Returns all the ContentAssistProcessor definition objects
+ * @return
+ */
+ public ContentAssistProcessorDefinition[] getContentAssistProcessorDefinitions() {
+ initCache();
+ return (fContentAssistProcessorDefs == null ? new ContentAssistProcessorDefinition[0] :
+ (ContentAssistProcessorDefinition[])fContentAssistProcessorDefs.toArray(new ContentAssistProcessorDefinition[fContentAssistProcessorDefs.size()]));
+ }
+
+ /**
+ * Returns all the ContentAssistProcessor definition objects valid for partitionType
+ *
+ * @param partitionType
+ * @return if partitionType is null, null is returned
+ */
+ public ContentAssistProcessorDefinition[] getContentAssistProcessorDefinitions(String partitionType) {
+ if (partitionType == null) {
+ return null;
+ }
+
+ ContentAssistProcessorDefinition[] allDefs = getContentAssistProcessorDefinitions();
+ List defs = new ArrayList();
+ List lastDefs = new ArrayList();
+
+ for (int i = 0; i < allDefs.length; ++i) {
+ List partitions = (List) allDefs[i].getPartitionTypes();
+ if (partitions != null) {
+ if (partitions.isEmpty()) {
+ lastDefs.add(allDefs[i]);
+ }
+ else {
+ int j = 0;
+ boolean added = false;
+ while (j < partitions.size() && !added) {
+ if (partitionType.equals(partitions.get(j))) {
+ defs.add(allDefs[i]);
+ added = true;
+ }
+ else {
+ ++j;
+ }
+ }
+ }
+ }
+ }
+ defs.addAll(lastDefs);
+
+ return (ContentAssistProcessorDefinition[]) defs.toArray(new ContentAssistProcessorDefinition[defs.size()]);
+ }
+
+ /**
+ * @param tag
+ * @param extensionPoint
+ */
+ protected void readContributions(String tag, String extensionPoint) {
+ targetContributionTag = tag;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ readRegistry(registry, ExtensionsPlugin.PLUGIN_ID, extensionPoint);
+ }
+
+}
17 years, 6 months
JBoss Tools SVN: r2276 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-04 03:15:13 -0400 (Wed, 04 Jul 2007)
New Revision: 2276
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 Optimization for incremental build provided.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -30,6 +30,7 @@
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
import org.jboss.tools.seam.internal.core.scanner.lib.LibraryScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
@@ -86,7 +87,7 @@
IFileScanner scanner = FILE_SCANNERS[i];
if(scanner.isRelevant(f)) {
if(!scanner.isLikelyComponentSource(f)) return false;
- SeamComponentDeclaration[] c = null;
+ LoadedDeclarations c = null;
try {
c = scanner.parse(f);
} catch (Exception e) {
@@ -101,8 +102,8 @@
}
}
- void componentsLoaded(SeamComponentDeclaration[] c, IFile resource) {
- if(c == null || c.length == 0) return;
+ void componentsLoaded(LoadedDeclarations c, IFile resource) {
+ if(c == null || c.getComponents().size() + c.getFactories().size() == 0) return;
SeamProject p = getSeamProject();
if(p == null) return;
p.registerComponents(c, resource.getFullPath());
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -5,10 +5,28 @@
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
public abstract class SeamComponentDeclaration implements ISeamComponentDeclaration {
-
+ /**
+ * Path of resource where this component is declared.
+ */
protected IPath source;
+
+ /**
+ * Object that allows to identify this declaration.
+ */
+ protected Object id;
+
+ /**
+ * Seam component name.
+ */
+ protected String name;
- protected String name;
+ public Object getId() {
+ return id;
+ }
+
+ public void setId(Object id) {
+ this.id = id;
+ }
public String getName() {
return name;
@@ -21,6 +39,10 @@
public void setSourcePath(IPath path) {
source = path;
}
+
+ public IPath getSourcePath() {
+ return source;
+ }
public int getLength() {
// TODO Auto-generated method stub
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -1,12 +1,39 @@
package org.jboss.tools.seam.internal.core;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.core.ScopeType;
public class SeamFactory implements ISeamFactory {
- String name = null;
+ /**
+ * Path of resource where this factory is declared.
+ */
+ protected IPath source;
+ /**
+ * Object that allows to identify this declaration.
+ */
+ protected Object id;
+
+ String name = null;
+ String scope = null;
ScopeType scopeType = ScopeType.UNSPECIFIED;
+ public Object getId() {
+ return id;
+ }
+
+ public void setId(Object id) {
+ this.id = id;
+ }
+
+ public void setSourcePath(IPath path) {
+ source = path;
+ }
+
+ public IPath getSourcePath() {
+ return source;
+ }
+
public String getName() {
return name;
}
@@ -21,6 +48,16 @@
public void setScope(ScopeType type) {
this.scopeType = type;
+ scope = scopeType.toString();
}
+ public void setScopeAsString(String scope) {
+ this.scope = scope;
+ try {
+ this.scopeType = scope == null || scope.length() == 0 ? ScopeType.UNSPECIFIED : ScopeType.valueOf(scope.toUpperCase());
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -31,6 +31,18 @@
public void setType(IType type) {
this.type = type;
}
+
+ public ScopeType getScope() {
+ return scopeType;
+ }
+
+ public void setScope(String scope) {
+ if(scope == null || scope.length() == 0) {
+ scopeType = ScopeType.UNSPECIFIED;
+ } else {
+ scopeType = ScopeType.valueOf(scope.toUpperCase());
+ }
+ }
public String getClassName() {
return className;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -27,6 +27,7 @@
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
/**
* @author glory
@@ -85,29 +86,39 @@
* @param component
* @param source
*/
- public void registerComponents(SeamComponentDeclaration[] list, IPath source) {
+ public void registerComponents(LoadedDeclarations ds, IPath source) {
+ //deprecated
pathRemoved(source);
- if(list == null) return;
+
+ SeamComponentDeclaration[] components = ds.getComponents().toArray(new SeamComponentDeclaration[0]);
+ SeamFactory[] factories = ds.getFactories().toArray(new SeamFactory[0]);
+
+ if(components.length == 0 && factories.length == 0) {
+ pathRemoved(source);
+ return;
+ }
+
+ Map<Object,ISeamComponentDeclaration> currentDeclarations = findComponentDeclarations(source);
- for (int i = 0; i < list.length; i++) {
- list[i].setSourcePath(source);
- String name = list[i].getName();
+ for (int i = 0; i < components.length; i++) {
+ components[i].setSourcePath(source);
+ String name = components[i].getName();
SeamComponent c = getComponent(name);
if(c == null) {
c = newComponent(name);
allComponents.put(name, c);
}
- c.addDeclaration(list[i]);
- if(list[i] instanceof ISeamJavaComponentDeclaration) {
- javaDeclarations.put(c.getClassName(), (SeamJavaComponentDeclaration)list[i]);
+ c.addDeclaration(components[i]);
+ if(components[i] instanceof ISeamJavaComponentDeclaration) {
+ javaDeclarations.put(c.getClassName(), (SeamJavaComponentDeclaration)components[i]);
Set<ISeamComponent> cs = getComponentsByClass(c.getClassName());
for (ISeamComponent ci: cs) {
if(ci == c) continue;
SeamComponent cii = (SeamComponent)ci;
- cii.addDeclaration(list[i]);
+ cii.addDeclaration(components[i]);
}
- } else if(list[i] instanceof ISeamXmlComponentDeclaration) {
- ISeamXmlComponentDeclaration xml = (ISeamXmlComponentDeclaration)list[i];
+ } else if(components[i] instanceof ISeamXmlComponentDeclaration) {
+ ISeamXmlComponentDeclaration xml = (ISeamXmlComponentDeclaration)components[i];
String className = xml.getClassName();
SeamJavaComponentDeclaration j = javaDeclarations.get(className);
if(j != null) c.addDeclaration(j);
@@ -142,6 +153,17 @@
}
}
}
+
+ public Map<Object,ISeamComponentDeclaration> findComponentDeclarations(IPath source) {
+ Map<Object,ISeamComponentDeclaration> map = new HashMap<Object, ISeamComponentDeclaration>();
+ for (SeamComponent c: allComponents.values()) {
+ for (ISeamComponentDeclaration d: c.getAllDeclarations()) {
+ SeamComponentDeclaration di = (SeamComponentDeclaration)d;
+ if(source.equals(di.getSourcePath())) map.put(di.getId(), di);
+ }
+ }
+ return map;
+ }
//deprecated
public Set<ISeamComponent> getComponentsByName(String name) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -38,6 +38,6 @@
* @return
* @throws Exception
*/
- public SeamComponentDeclaration[] parse(IFile f) throws Exception;
+ public LoadedDeclarations parse(IFile f) throws Exception;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -3,14 +3,14 @@
import java.util.ArrayList;
import java.util.List;
-import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamFactory;
public class LoadedDeclarations {
- List<SeamComponent> components = new ArrayList<SeamComponent>();
+ List<SeamComponentDeclaration> components = new ArrayList<SeamComponentDeclaration>();
List<SeamFactory> factories = new ArrayList<SeamFactory>();
- public List<SeamComponent> getComponents() {
+ public List<SeamComponentDeclaration> getComponents() {
return components;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -29,6 +29,7 @@
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
public class JavaScanner implements IFileScanner {
@@ -68,14 +69,13 @@
* @return
* @throws Exception
*/
- public SeamComponentDeclaration[] parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws Exception {
ICompilationUnit u = getCompilationUnit(f);
if(u == null) return null;
ASTRequestorImpl requestor = new ASTRequestorImpl();
ICompilationUnit[] us = new ICompilationUnit[]{u};
ASTParser.newParser(AST.JLS3).createASTs(us, new String[0], requestor, null);
- SeamComponentDeclaration component = requestor.getComponent();
- return component == null ? new SeamComponentDeclaration[0] : new SeamComponentDeclaration[]{component};
+ return requestor.getDeclarations();
}
private ICompilationUnit getCompilationUnit(IFile f) throws Exception {
@@ -97,10 +97,10 @@
class ASTRequestorImpl extends ASTRequestor {
private ASTVisitorImpl visitor = new ASTVisitorImpl();
- private SeamJavaComponentDeclaration component = null;
+ LoadedDeclarations ds = new LoadedDeclarations();
- public SeamComponentDeclaration getComponent() {
- return component;
+ public LoadedDeclarations getDeclarations() {
+ return ds;
}
public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
@@ -118,12 +118,14 @@
if(visitor.name != null && visitor.type != null) {
String n = visitor.type.getElementName();
n = getResolvedType(visitor.type, n);
- component = new SeamJavaComponentDeclaration();
+ SeamJavaComponentDeclaration component = new SeamJavaComponentDeclaration();
+ ds.getComponents().add(component);
+ component.setType(visitor.type);
+ component.setId(visitor.type);
component.setClassName(n);
component.setName(visitor.name);
if(visitor.scope != null) {
- //TODO
- //component.setScope(visitor.scope);
+ component.setScope(visitor.scope);
}
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -10,15 +10,16 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.scanner.lib;
-import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.seam.internal.core.SeamComponent;
-import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamPropertiesDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
public class LibraryScanner implements IFileScanner {
@@ -41,7 +42,7 @@
return false;
}
- public SeamComponentDeclaration[] parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws Exception {
XModelObject o = EclipseResourceUtil.getObjectByResource(f);
if(o == null) return null;
if(!o.getModelEntity().getName().equals("FileSystemJar")) {
@@ -53,30 +54,44 @@
XModelObject componentsXML = o.getChildByPath("META-INF/components.xml");
if(componentsXML == null && seamProperties == null) return null;
- ArrayList<SeamComponentDeclaration> list = new ArrayList<SeamComponentDeclaration>();
+ LoadedDeclarations ds = new LoadedDeclarations();
- processJavaClasses(o, list);
+ processJavaClasses(o, ds);
if(componentsXML != null) {
- SeamComponentDeclaration[] components = new XMLScanner().parse(componentsXML);
- if(components != null) {
- for (int i = 0; i < components.length; i++) list.add(components[i]);
+ LoadedDeclarations ds1 = new XMLScanner().parse(componentsXML, f.getFullPath());
+ if(ds1 != null) {
+ ds.getComponents().addAll(ds1.getComponents());
+ ds.getFactories().addAll(ds1.getFactories());
}
}
if(seamProperties != null) {
XModelObject[] properties = seamProperties.getChildren();
+ Map<String, SeamPropertiesDeclaration> ds1 = new HashMap<String, SeamPropertiesDeclaration>();
for (int i = 0; i < properties.length; i++) {
String name = properties[i].getAttributeValue("name");
String value = properties[i].getAttributeValue("value");
- //TODO put that to a component
+ int q = name.lastIndexOf('.');
+ if(q < 0) continue;
+ String componentName = name.substring(0, q);
+ String propertyName = name.substring(q + 1);
+ SeamPropertiesDeclaration d = ds1.get(componentName);
+ if(d == null) {
+ d = new SeamPropertiesDeclaration();
+ d.setId(properties[i]);
+ d.setSourcePath(f.getFullPath());
+ d.setName(componentName);
+ ds1.put(componentName, d);
+ }
+ d.addStringProperty(propertyName, value);
}
- //TODO add components to list
+ ds.getComponents().addAll(ds1.values());
}
- return list.toArray(new SeamComponentDeclaration[0]);
+ return ds;
}
- protected void processJavaClasses(XModelObject o, ArrayList<SeamComponentDeclaration> list) {
+ protected void processJavaClasses(XModelObject o, LoadedDeclarations ds) {
//TODO
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-03 22:09:21 UTC (rev 2275)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-04 07:15:13 UTC (rev 2276)
@@ -18,16 +18,18 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
-import org.jboss.tools.seam.internal.core.SeamComponent;
-import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamXmlFactory;
+import org.jboss.tools.seam.internal.core.SeamFactory;
import org.jboss.tools.seam.internal.core.SeamProperty;
import org.jboss.tools.seam.internal.core.SeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
public class XMLScanner implements IFileScanner {
@@ -67,9 +69,9 @@
* @return
* @throws Exception
*/
- public SeamComponentDeclaration[] parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws Exception {
XModelObject o = EclipseResourceUtil.getObjectByResource(f);
- return parse(o);
+ return parse(o, f.getFullPath());
}
static Set<String> COMMON_ATTRIBUTES = new HashSet<String>();
@@ -85,9 +87,9 @@
// COMMON_ATTRIBUTES.add(ISeamComponent.JNDI_NAME);
}
- public SeamComponentDeclaration[] parse(XModelObject o) {
+ public LoadedDeclarations parse(XModelObject o, IPath source) {
if(o == null) return null;
- ArrayList<SeamComponentDeclaration> list = new ArrayList<SeamComponentDeclaration>();
+ LoadedDeclarations ds = new LoadedDeclarations();
XModelObject[] os = o.getChildren();
for (int i = 0; i < os.length; i++) {
XModelEntity componentEntity = os[i].getModelEntity();
@@ -144,21 +146,21 @@
//TODO assign positioning attributes to created ISeamProperty object
}
- list.add(component);
+ ds.getComponents().add(component);
} else if(os[i].getModelEntity().getName().startsWith("SeamFactory")) {
- //TODO what is the best way for factory?
- SeamComponent component = new SeamComponent();
- //TODO
-// component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
-// component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
+ //TODO replace with xml factory
+ SeamFactory factory = new SeamFactory();
+ factory.setId(os[i]);
+ factory.setSourcePath(source);
+ factory.setName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.NAME));
+ factory.setScopeAsString(os[i].getAttributeValue(ISeamXmlComponentDeclaration.SCOPE));
String value = os[i].getAttributeValue("value");
- //TODO how should we resolve value?
-// if(value != null) component.addStringProperty("value", value);
-
-// list.add(component);
+ if(factory instanceof ISeamXmlFactory) {
+ ((ISeamXmlFactory)factory).setValue(value);
+ }
+ ds.getFactories().add(factory);
}
}
-
- return list.toArray(new SeamComponentDeclaration[0]);
+ return ds;
}
}
\ No newline at end of file
17 years, 6 months
JBoss Tools SVN: r2275 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-07-03 18:09:21 -0400 (Tue, 03 Jul 2007)
New Revision: 2275
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
Log:
Uncommitted resources fixes JBIDE-501
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-07-03 21:48:24 UTC (rev 2274)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-07-03 22:09:21 UTC (rev 2275)
@@ -114,6 +114,7 @@
}
} catch( SecurityException se ) {
pollingException = new PollingSecurityException("Security Exception: " + se.getMessage());
+ done = true;
} catch( Exception e ) {
started = STATE_STOPPED;
if( !expectedState )
17 years, 6 months
JBoss Tools SVN: r2274 - in trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-07-03 17:48:24 -0400 (Tue, 03 Jul 2007)
New Revision: 2274
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java
Log:
Uncommitted resources fixes JBIDE-501
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-07-03 17:58:13 UTC (rev 2273)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/runtime/server/polling/TwiddlePoller.java 2007-07-03 21:48:24 UTC (rev 2274)
@@ -21,24 +21,35 @@
*/
package org.jboss.ide.eclipse.as.core.runtime.server.polling;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.security.Principal;
import java.util.Date;
import java.util.Properties;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.naming.InitialContext;
-import javax.naming.NamingException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.model.DescriptorModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel;
+import org.jboss.ide.eclipse.as.core.model.DescriptorModel.ServerDescriptorModel;
import org.jboss.ide.eclipse.as.core.model.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.runtime.server.IServerStatePoller;
+import org.jboss.ide.eclipse.as.core.server.JBossServerLaunchConfiguration;
import org.jboss.ide.eclipse.as.core.server.TwiddleLauncher;
+import org.jboss.ide.eclipse.as.core.util.ArgsUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.core.util.SimpleTreeItem;
public class TwiddlePoller implements IServerStatePoller {
@@ -75,20 +86,24 @@
ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
ClassLoader twiddleLoader = getClassLoader();
if( twiddleLoader != null ) {
+ String serverConfDir = ServerConverter.getJBossServer(server).getConfigDirectory(false);
+ ServerDescriptorModel descriptorModel = DescriptorModel.getDefault().getServerModel(new Path(serverConfDir));
+ int port = descriptorModel.getJNDIPort();
+
Thread.currentThread().setContextClassLoader(twiddleLoader);
-
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- props.put("java.naming.provider.url","jnp://localhost:1099");
props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
+ props.put("java.naming.provider.url","jnp://" + server.getHost() + ":" + port);
+ setCredentials();
+
while( !done && !canceled ) {
InitialContext ic;
try {
ic = new InitialContext(props);
Object obj = ic.lookup("jmx/invoker/RMIAdaptor");
ic.close();
- System.out.println(obj);
if( obj instanceof MBeanServerConnection ) {
MBeanServerConnection connection = (MBeanServerConnection)obj;
Object attInfo = connection.getAttribute(new ObjectName("jboss.system:type=Server"), "Started");
@@ -97,8 +112,6 @@
if( b && expectedState )
done = true;
}
- } catch (NamingException e) {
- pollingException = new PollingNamingException("Naming Exception: " + e.getMessage());
} catch( SecurityException se ) {
pollingException = new PollingSecurityException("Security Exception: " + se.getMessage());
} catch( Exception e ) {
@@ -106,13 +119,48 @@
if( !expectedState )
done = true;
}
-
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
} // end while
}
Thread.currentThread().setContextClassLoader(currentLoader);
}
+
+ protected void setCredentials() {
+ try {
+ ILaunchConfiguration lc = server.getLaunchConfiguration(true, new NullProgressMonitor());
+ String twiddleArgs = lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS
+ + JBossServerLaunchConfiguration.PRGM_ARGS_TWIDDLE_SUFFIX, (String)null);
+ String user = ArgsUtil.getValue(twiddleArgs, "-u", "--user");
+ String password = ArgsUtil.getValue(twiddleArgs, "-p", "--password");
+
+ // get our methods
+ Class simplePrincipal = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.security.SimplePrincipal");
+ Class securityAssoc = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.security.SecurityAssociation");
+ securityAssoc.getMethods(); // force-init the methods since the class hasn't been initialized yet.
+
+ Constructor newSimplePrincipal = simplePrincipal.getConstructor(new Class[] { String.class });
+ Object newPrincipalInstance = newSimplePrincipal.newInstance(new Object[] {user});
+
+
+ // set the principal
+ Method setPrincipalMethod = securityAssoc.getMethod("setPrincipal", new Class[] {Principal.class});
+ setPrincipalMethod.invoke(null, new Object[] {newPrincipalInstance});
+
+ // set the credential
+ Method setCredentialMethod = securityAssoc.getMethod("setCredential", new Class[] {Object.class});
+ setCredentialMethod.invoke(null, new Object[] {password});
+ } catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
protected ClassLoader getClassLoader() {
try {
IRuntime rt = server.getRuntime();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java 2007-07-03 17:58:13 UTC (rev 2273)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ArgsUtil.java 2007-07-03 21:48:24 UTC (rev 2274)
@@ -29,8 +29,8 @@
public static final Integer NO_VALUE = new Integer(-1);
- public static Map getSystemProperties(String s) {
- String[] args = parse(s);
+ public static Map getSystemProperties(String argString) {
+ String[] args = parse(argString);
HashMap map = new HashMap();
for( int i = 0; i < args.length; i++ ) {
@@ -44,11 +44,19 @@
}
}
}
-
return map;
-
}
+ public static String getValue(String allArgs, String shortOpt, String longOpt) {
+ String[] args = parse(allArgs);
+ for( int i = 0; i < args.length; i++ ) {
+ if( args[i].equals(shortOpt))
+ return args[i+1];
+ if( args[i].startsWith(longOpt + "="))
+ return args[i].substring(args[i].indexOf('=') + 1);
+ }
+ return null;
+ }
public static String[] parse(String s) {
try {
ArrayList l = new ArrayList();
17 years, 6 months
JBoss Tools SVN: r2273 - trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-07-03 13:58:13 -0400 (Tue, 03 Jul 2007)
New Revision: 2273
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
http://jira.jboss.com/jira/browse/EXIN-217 Fix scanner test
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-07-03 17:47:44 UTC (rev 2272)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-07-03 17:58:13 UTC (rev 2273)
@@ -24,6 +24,7 @@
import org.jboss.tools.common.model.XJob;
import org.jboss.tools.common.test.util.TestProjectProvider;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamProperty;
import org.jboss.tools.seam.core.SeamCoreBuilder;
@@ -69,7 +70,7 @@
IFileScanner scanner = SeamCoreBuilder.getXMLScanner();
assertTrue("Scanner cannot recognise components.xml", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise components.xml content", scanner.isLikelyComponentSource(f));
- ISeamComponent[] cs = null;
+ ISeamComponentDeclaration[] cs = null;
try {
cs = scanner.parse(f);
@@ -120,7 +121,7 @@
IFileScanner scanner = SeamCoreBuilder.getJavaScanner();
assertTrue("Scanner cannot recognise User.java", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise User.java content", scanner.isLikelyComponentSource(f));
- ISeamComponent[] cs = null;
+ ISeamComponentDeclaration[] cs = null;
try {
cs = scanner.parse(f);
@@ -161,7 +162,7 @@
IFileScanner scanner = SeamCoreBuilder.getLibraryScanner();
assertTrue("Scanner cannot recognise jboss-seam.jar", scanner.isRelevant(f));
assertTrue("Scanner cannot recognise jboss-seam.jar content", scanner.isLikelyComponentSource(f));
- ISeamComponent[] cs = null;
+ ISeamComponentDeclaration[] cs = null;
try {
cs = scanner.parse(f);
17 years, 6 months