Implementation of correlation mapper model was updated.
1.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/Bundle.properties Mon Jan 14 09:53:42 2008 +0000
1.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/Bundle.properties Mon Jan 14 10:44:06 2008 +0000
1.3 @@ -428,3 +428,6 @@
1.4 LBL_Wizard_Step_Correlation_Configuration=Correlation Configuration
1.5 LBL_Initiated_Messaging_Activities=Initiated Messaging Activities:
1.6 LBL_ErrMsg_No_Activity_For_Correlation=There is no available activities for correlation
1.7 +LBL_ErrMsg_No_Links_For_Correlation=At least 1 link has to be defined for correlation
1.8 +LBL_Left_Mapper_Top_Tree_Node_Name_Pattern =Source activity for correlation: {0}
1.9 +LBL_Right_Mapper_Top_Tree_Node_Name_Pattern=Target activity for correlation: {0}
2.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/DefineCorrelationWizard.java Mon Jan 14 09:53:42 2008 +0000
2.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/properties/editors/DefineCorrelationWizard.java Mon Jan 14 10:44:06 2008 +0000
2.3 @@ -401,7 +401,6 @@
2.4 }
2.5 //========================================================================//
2.6 public class WizardDefineCorrelationPanel extends WizardAbstractPanel {
2.7 - private CorrelationMapperTreeModel leftTreeModel, rightTreeModel;
2.8 private Mapper correlationMapper;
2.9
2.10 public WizardDefineCorrelationPanel() {
2.11 @@ -409,11 +408,14 @@
2.12 }
2.13
2.14 public void buildCorrelationMapper(BpelEntity leftBpelEntity, BpelEntity rightBpelEntity) {
2.15 + CorrelationMapperTreeModel leftTreeModel = null, rightTreeModel = null;
2.16 if (leftBpelEntity != null) {
2.17 - leftTreeModel = new CorrelationMapperTreeModel(leftBpelEntity);
2.18 + leftTreeModel = new CorrelationMapperTreeModel(leftBpelEntity,
2.19 + PrintUtil.i18n(WizardDefineCorrelationPanel.class, "LBL_Left_Mapper_Top_Tree_Node_Name_Pattern"));
2.20 }
2.21 if (rightBpelEntity != null) {
2.22 - rightTreeModel = new CorrelationMapperTreeModel(rightBpelEntity);
2.23 + rightTreeModel = new CorrelationMapperTreeModel(rightBpelEntity,
2.24 + PrintUtil.i18n(WizardDefineCorrelationPanel.class, "LBL_Right_Mapper_Top_Tree_Node_Name_Pattern"));
2.25 }
2.26
2.27 MapperModel mapperModel = new CorrelationMapperModel(leftTreeModel, rightTreeModel);
2.28 @@ -429,8 +431,17 @@
2.29
2.30 @Override
2.31 public boolean isValid() {
2.32 - boolean isOK = true;
2.33 -//*******??????? check that left and right trees in mapper contains at least 1 leaf-child.
2.34 + boolean isOK = false;
2.35 + // allows moving to the next panel if the right tree
2.36 + // in mapper contains at least 1 link
2.37 + Map<TreePath, Graph> mapTreePathGraphs = ((CorrelationMapperModel) correlationMapper.getModel()).getMapTreePathGraphs();
2.38 + for (Graph graph : mapTreePathGraphs.values()) {
2.39 + isOK = graph.hasIngoingLinks();
2.40 + if (isOK) break;
2.41 + }
2.42 + wizardDescriptor.putProperty(PROPERTY_ERROR_MESSAGE, isOK ? null :
2.43 + PrintUtil.i18n(WizardDefineCorrelationPanel.class, "LBL_ErrMsg_No_Links_For_Correlation"));
2.44 +
2.45 return isOK;
2.46 }
2.47
2.48 @@ -440,10 +451,18 @@
2.49 //====================================================================//
2.50 private class CorrelationMapperTreeModel extends DefaultTreeModel {
2.51 public CorrelationMapperTreeModel(BpelEntity topBpelEntity) {
2.52 + this(topBpelEntity, null);
2.53 + }
2.54 + public CorrelationMapperTreeModel(BpelEntity topBpelEntity, String nodeNamePattern) {
2.55 super(new CorrelationMapperTreeNode(new BpelBuilderImpl(
2.56 (BpelModelImpl) topBpelEntity.getBpelModel()).createEmpty()));
2.57 ((CorrelationMapperTreeNode) getRoot()).add(
2.58 - new CorrelationMapperTreeNode(topBpelEntity));
2.59 + new CorrelationMapperTreeNode(topBpelEntity, nodeNamePattern));
2.60 + }
2.61 +
2.62 + public BpelEntity getTopBpelEntity() {
2.63 + CorrelationMapperTreeNode topTreeNode = (CorrelationMapperTreeNode) ((CorrelationMapperTreeNode) getRoot()).getChildAt(0);
2.64 + return (BpelEntity) topTreeNode.getUserObject();
2.65 }
2.66
2.67 public void fireTreeChanged(Object source, TreePath treePath) {
2.68 @@ -505,24 +524,33 @@
2.69 }
2.70 //====================================================================//
2.71 private class CorrelationMapperModel implements MapperModel {
2.72 - private TreeModel letfTreeModel, rightTreeModel;
2.73 + private TreeModel leftTreeModel, rightTreeModel;
2.74 private Map<TreePath, Graph> mapTreePathGraphs = new HashMap<TreePath, Graph>();
2.75
2.76 - public CorrelationMapperModel(TreeModel letfTreeModel, TreeModel rightTreeModel) {
2.77 - this.letfTreeModel = letfTreeModel;
2.78 + public CorrelationMapperModel(TreeModel leftTreeModel, TreeModel rightTreeModel) {
2.79 + this.leftTreeModel = leftTreeModel;
2.80 this.rightTreeModel = rightTreeModel;
2.81 TMP_FAKE_GRAPH = new Graph(this);
2.82 }
2.83
2.84 + public Map<TreePath, Graph> getMapTreePathGraphs() {
2.85 + return mapTreePathGraphs;
2.86 + }
2.87 +
2.88 public boolean canConnect(TreePath treePath, SourcePin source, TargetPin target) {
2.89 boolean result = false;
2.90 + CorrelationMapperTreeNode treeNode = null;
2.91 if ((source != null) && (source instanceof TreeSourcePin)) {
2.92 TreePath sourceTreePath = ((TreeSourcePin) source).getTreePath();
2.93 - if (((TreeNode) sourceTreePath.getLastPathComponent()).isLeaf()) {
2.94 - result = true;
2.95 - }
2.96 + treeNode = (CorrelationMapperTreeNode) sourceTreePath.getLastPathComponent();
2.97 + result = treeNode.isLeaf();
2.98 + result &= ! treeNode.getUserObject().equals(
2.99 + ((CorrelationMapperTreeModel) leftTreeModel).getTopBpelEntity());
2.100 }
2.101 - result &= ((TreeNode) treePath.getLastPathComponent()).isLeaf();
2.102 + treeNode = (CorrelationMapperTreeNode) treePath.getLastPathComponent();
2.103 + result &= treeNode.isLeaf();
2.104 + result &= ! treeNode.getUserObject().equals(
2.105 + ((CorrelationMapperTreeModel) rightTreeModel).getTopBpelEntity());
2.106
2.107 if (target instanceof Graph) {
2.108 Graph targetGraph = (Graph) target;