Index: src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java =================================================================== --- src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java (revision 27346) +++ src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java (working copy) @@ -114,8 +114,9 @@ * @author Dart * */ -public class SmooksGraphicalEditorPart extends GraphicalEditor implements ISelectionChangedListener, - ISourceSynchronizeListener, IGraphicalEditorPart, ITaskNodeProvider, ISmooksModelValidateListener { +public class SmooksGraphicalEditorPart extends GraphicalEditor implements + ISelectionChangedListener, ISourceSynchronizeListener, + IGraphicalEditorPart, ITaskNodeProvider, ISmooksModelValidateListener { private CommandStackListener emfCommandStackListener = null; @@ -171,12 +172,13 @@ } }); - this.editDomain.getCommandStack().addCommandStackEventListener(new CommandStackEventListener() { + this.editDomain.getCommandStack().addCommandStackEventListener( + new CommandStackEventListener() { - public void stackChanged(CommandStackEvent event) { - firePropertyChange(PROP_DIRTY); - } - }); + public void stackChanged(CommandStackEvent event) { + firePropertyChange(PROP_DIRTY); + } + }); this.smooksModelProvider = provider; this.setEditDomain(editDomain); @@ -186,52 +188,80 @@ private void createEMFCommandStackListener() { emfCommandStackListener = new org.eclipse.emf.common.command.CommandStackListener() { public void commandStackChanged(EventObject event) { - final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack) event.getSource()) - .getMostRecentCommand(); + final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack) event + .getSource()).getMostRecentCommand(); final EventObject fe = event; - getEditorSite().getShell().getDisplay().asyncExec(new Runnable() { - public void run() { - if (mostRecentCommand != null) { - Command rawCommand = mostRecentCommand; - while (rawCommand instanceof CommandWrapper) { - rawCommand = ((CommandWrapper) rawCommand).getCommand(); - } - int commandType = EXECUTE_COMMAND; - Command undoCommand = ((org.eclipse.emf.common.command.CommandStack) fe.getSource()) - .getUndoCommand(); - Command redoCommand = ((org.eclipse.emf.common.command.CommandStack) fe.getSource()) - .getRedoCommand(); - if (undoCommand != null || rawCommand.equals(undoCommand)) { - commandType = EXECUTE_COMMAND; - } - if (redoCommand != null || rawCommand.equals(redoCommand)) { - commandType = UNDO_COMMAND; - } - if (rawCommand instanceof CompoundCommand) { - List commandList = ((CompoundCommand) rawCommand).getCommandList(); - for (Iterator iterator = commandList.iterator(); iterator.hasNext();) { - Command command = (Command) iterator.next(); - while (command instanceof CommandWrapper) { - command = ((CommandWrapper) command).getCommand(); + getEditorSite().getShell().getDisplay() + .asyncExec(new Runnable() { + public void run() { + if (mostRecentCommand != null) { + Command rawCommand = mostRecentCommand; + while (rawCommand instanceof CommandWrapper) { + rawCommand = ((CommandWrapper) rawCommand) + .getCommand(); } - handleInputParamChange(command); - if (command instanceof SetCommand || command instanceof AddCommand - || command instanceof DeleteCommand || command instanceof RemoveCommand) { - refershRecentAffectedModel(command, command.getAffectedObjects(), commandType); + int commandType = EXECUTE_COMMAND; + Command undoCommand = ((org.eclipse.emf.common.command.CommandStack) fe + .getSource()).getUndoCommand(); + while (undoCommand != null + && undoCommand instanceof CommandWrapper) { + undoCommand = ((CommandWrapper) undoCommand) + .getCommand(); } - } - } else { - if (rawCommand instanceof SetCommand || rawCommand instanceof AddCommand - || rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand) { - handleInputParamChange(rawCommand); - refershRecentAffectedModel(rawCommand, mostRecentCommand.getAffectedObjects(), - commandType); + Command redoCommand = ((org.eclipse.emf.common.command.CommandStack) fe + .getSource()).getRedoCommand(); + while (redoCommand != null + && redoCommand instanceof CommandWrapper) { + redoCommand = ((CommandWrapper) redoCommand) + .getCommand(); + } + if (undoCommand != null + && rawCommand.equals(undoCommand)) { + commandType = EXECUTE_COMMAND; + } + if (redoCommand != null + && rawCommand.equals(redoCommand)) { + commandType = UNDO_COMMAND; + } + if (rawCommand instanceof CompoundCommand) { + List commandList = ((CompoundCommand) rawCommand) + .getCommandList(); + for (Iterator iterator = commandList + .iterator(); iterator.hasNext();) { + Command command = (Command) iterator + .next(); + while (command instanceof CommandWrapper) { + command = ((CommandWrapper) command) + .getCommand(); + } + handleInputParamChange(command); + if (command instanceof SetCommand + || command instanceof AddCommand + || command instanceof DeleteCommand + || command instanceof RemoveCommand) { + refershRecentAffectedModel( + command, + command.getAffectedObjects(), + commandType); + } + } + } else { + if (rawCommand instanceof SetCommand + || rawCommand instanceof AddCommand + || rawCommand instanceof DeleteCommand + || rawCommand instanceof RemoveCommand) { + handleInputParamChange(rawCommand); + refershRecentAffectedModel( + rawCommand, + mostRecentCommand + .getAffectedObjects(), + commandType); + } + } } } - } - } - }); + }); } }; } @@ -256,7 +286,8 @@ IEditorSite site = getEditorSite(); if (site instanceof SmooksTaskDetailsEditorSite) { - FormPage page = ((SmooksTaskDetailsEditorSite) site).getParentEditor(); + FormPage page = ((SmooksTaskDetailsEditorSite) site) + .getParentEditor(); FormToolkit tool = page.getManagedForm().getToolkit(); Composite mainComposite = tool.createComposite(parent); mainComposite.setBackground(tool.getColors().getBorderColor()); @@ -274,7 +305,8 @@ return super.getGraphicalViewer(); } - private void handleCommandStack(org.eclipse.emf.common.command.CommandStack commandStack) { + private void handleCommandStack( + org.eclipse.emf.common.command.CommandStack commandStack) { if (emfCommandStackListener != null) { commandStack.addCommandStackListener(emfCommandStackListener); } @@ -297,7 +329,8 @@ protected void autoLayoutWhenCommandChange(Command command) { Collection affectedObjects = command.getAffectedObjects(); boolean refreshInputModel = false; - for (Iterator iterator2 = affectedObjects.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = affectedObjects.iterator(); iterator2 + .hasNext();) { Object object = (Object) iterator2.next(); if (command instanceof AddCommand) { if (needToLayoutWhenAddModel(object)) { @@ -313,7 +346,8 @@ deletedObjs = ((RemoveCommand) command).getCollection(); } if (deletedObjs != null) { - for (Iterator iterator = deletedObjs.iterator(); iterator.hasNext();) { + for (Iterator iterator = deletedObjs.iterator(); iterator + .hasNext();) { Object object2 = (Object) iterator.next(); if (needToLayoutWhenRemoveModel(object2)) { refreshInputModel = true; @@ -341,7 +375,8 @@ protected void handleInputParamChange(Command command) { Collection affectedObjects = command.getAffectedObjects(); boolean refreshInputModel = false; - for (Iterator iterator2 = affectedObjects.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = affectedObjects.iterator(); iterator2 + .hasNext();) { Object object = (Object) iterator2.next(); if (object instanceof ParamType) { if (SmooksUIUtils.isInputParamType((ParamType) object)) { @@ -361,7 +396,8 @@ deletedObjs = ((RemoveCommand) command).getCollection(); } if (deletedObjs != null) { - for (Iterator iterator = deletedObjs.iterator(); iterator.hasNext();) { + for (Iterator iterator = deletedObjs.iterator(); iterator + .hasNext();) { Object object2 = (Object) iterator.next(); if (object2 instanceof ParamType) { if (SmooksUIUtils.isInputParamType((ParamType) object2)) { @@ -396,7 +432,8 @@ return new ConnectionModelFactoryImpl(); } - public void setConnectionModelFactory(ConnectionModelFactory connectionModelFactory) { + public void setConnectionModelFactory( + ConnectionModelFactory connectionModelFactory) { this.connectionModelFactory = connectionModelFactory; } @@ -411,7 +448,8 @@ return new GraphicalModelFactoryImpl(); } - public void setGraphicalModelFactory(GraphicalModelFactoryImpl graphicalModelFactory) { + public void setGraphicalModelFactory( + GraphicalModelFactoryImpl graphicalModelFactory) { this.graphicalModelFactory = graphicalModelFactory; } @@ -424,29 +462,40 @@ getSelectionActions().add(autoLayout.getId()); } - private void deleteRelatedConnection(AbstractSmooksGraphicalModel effecedNode, EStructuralFeature feature, - SetCommand command) { - EObject data = (EObject) AdapterFactoryEditingDomain.unwrap(effecedNode.getData()); + private void deleteRelatedConnection( + AbstractSmooksGraphicalModel effecedNode, + EStructuralFeature feature, SetCommand command) { + EObject data = (EObject) AdapterFactoryEditingDomain.unwrap(effecedNode + .getData()); if (feature.equals(SmooksUIUtils.getBeanIDRefFeature(data))) { - List sourceConnections = effecedNode.getSourceConnections(); - List temp = new ArrayList(sourceConnections); + List sourceConnections = effecedNode + .getSourceConnections(); + List temp = new ArrayList( + sourceConnections); for (Iterator iterator = temp.iterator(); iterator.hasNext();) { - TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next(); - AbstractSmooksGraphicalModel target = treeNodeConnection.getTargetNode(); + TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator + .next(); + AbstractSmooksGraphicalModel target = treeNodeConnection + .getTargetNode(); Object refValue = command.getValue(); - if(refValue == null) continue; + if (refValue == null) + continue; String refID = refValue.toString(); - Object targetModel = AdapterFactoryEditingDomain.unwrap(target.getData()); + Object targetModel = AdapterFactoryEditingDomain.unwrap(target + .getData()); if (targetModel instanceof EObject) { - EStructuralFeature idfeature = SmooksUIUtils.getBeanIDFeature((EObject) targetModel); + EStructuralFeature idfeature = SmooksUIUtils + .getBeanIDFeature((EObject) targetModel); if (idfeature == null) continue; Object iddata = ((EObject) targetModel).eGet(idfeature); if (iddata != null) { if (refID == null || !refID.equals(iddata)) { - target.getTargetConnections().remove(treeNodeConnection); - effecedNode.getSourceConnections().remove(treeNodeConnection); + target.getTargetConnections().remove( + treeNodeConnection); + effecedNode.getSourceConnections().remove( + treeNodeConnection); target.fireConnectionChanged(); } } @@ -455,22 +504,31 @@ } if (feature.equals(SmooksUIUtils.getBeanIDFeature(data))) { - List targetConnections = effecedNode.getTargetConnections(); - List temp = new ArrayList(targetConnections); + List targetConnections = effecedNode + .getTargetConnections(); + List temp = new ArrayList( + targetConnections); for (Iterator iterator = temp.iterator(); iterator.hasNext();) { - TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next(); - AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode(); + TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator + .next(); + AbstractSmooksGraphicalModel source = treeNodeConnection + .getSourceNode(); String beanID = command.getValue().toString(); - Object sourceModel = AdapterFactoryEditingDomain.unwrap(source.getData()); + Object sourceModel = AdapterFactoryEditingDomain.unwrap(source + .getData()); if (sourceModel instanceof EObject) { - EStructuralFeature idRefFeature = SmooksUIUtils.getBeanIDRefFeature((EObject) sourceModel); + EStructuralFeature idRefFeature = SmooksUIUtils + .getBeanIDRefFeature((EObject) sourceModel); if (idRefFeature == null) continue; - Object idRefData = ((EObject) sourceModel).eGet(idRefFeature); + Object idRefData = ((EObject) sourceModel) + .eGet(idRefFeature); if (idRefData != null) { if (beanID == null || !beanID.equals(idRefData)) { - source.getSourceConnections().remove(treeNodeConnection); - effecedNode.getTargetConnections().remove(treeNodeConnection); + source.getSourceConnections().remove( + treeNodeConnection); + effecedNode.getTargetConnections().remove( + treeNodeConnection); source.fireConnectionChanged(); } } @@ -479,27 +537,37 @@ } if (feature.equals(SmooksUIUtils.getSelectorFeature(data))) { - List targetConnections = effecedNode.getTargetConnections(); - List temp = new ArrayList(targetConnections); + List targetConnections = effecedNode + .getTargetConnections(); + List temp = new ArrayList( + targetConnections); for (Iterator iterator = temp.iterator(); iterator.hasNext();) { - TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next(); - AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode(); - if (source instanceof InputDataContianerModel || source instanceof InputDataTreeNodeModel) { + TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator + .next(); + AbstractSmooksGraphicalModel source = treeNodeConnection + .getSourceNode(); + if (source instanceof InputDataContianerModel + || source instanceof InputDataTreeNodeModel) { String selector = command.getValue().toString(); - Object sourceModel = AdapterFactoryEditingDomain.unwrap(source.getData()); + Object sourceModel = AdapterFactoryEditingDomain + .unwrap(source.getData()); if (sourceModel instanceof IXMLStructuredObject) { - IXMLStructuredObject root = SmooksUIUtils.getRootParent((IXMLStructuredObject) sourceModel); + IXMLStructuredObject root = SmooksUIUtils + .getRootParent((IXMLStructuredObject) sourceModel); Object oldNode = null; try { - oldNode = SmooksUIUtils.localXMLNodeWithPath(selector, root); + oldNode = SmooksUIUtils.localXMLNodeWithPath( + selector, root); } catch (Throwable t) { } if (oldNode == sourceModel) { break; } else { - source.getSourceConnections().remove(treeNodeConnection); - effecedNode.getTargetConnections().remove(treeNodeConnection); + source.getSourceConnections().remove( + treeNodeConnection); + effecedNode.getTargetConnections().remove( + treeNodeConnection); source.fireConnectionChanged(); } } @@ -516,18 +584,23 @@ * @param affectedObjects * @param commandType */ - protected void refershRecentAffectedModel(Command command, Collection affectedObjects, int commandType) { - for (Iterator iterator = affectedObjects.iterator(); iterator.hasNext();) { + protected void refershRecentAffectedModel(Command command, + Collection affectedObjects, int commandType) { + for (Iterator iterator = affectedObjects.iterator(); iterator + .hasNext();) { Object object = (Object) iterator.next(); object = AdapterFactoryEditingDomain.unwrap(object); if (commandType == EXECUTE_COMMAND || commandType == REDO_COMMAND) { if (object instanceof SmooksResourceListType) { if (command instanceof AddCommand) { - Collection colletion = ((AddCommand) command).getCollection(); - for (Iterator iterator2 = colletion.iterator(); iterator2.hasNext();) { + Collection colletion = ((AddCommand) command) + .getCollection(); + for (Iterator iterator2 = colletion.iterator(); iterator2 + .hasNext();) { Object childModel = (Object) iterator2.next(); - childModel = AdapterFactoryEditingDomain.unwrap(childModel); + childModel = AdapterFactoryEditingDomain + .unwrap(childModel); AbstractSmooksGraphicalModel graphModel = createGraphModel(childModel); if (graphModel == null) continue; @@ -537,21 +610,27 @@ expandConnectedModels(connections); } } - if (command instanceof DeleteCommand || command instanceof RemoveCommand) { + if (command instanceof DeleteCommand + || command instanceof RemoveCommand) { Collection colletion = null; if (command instanceof DeleteCommand) { - colletion = ((DeleteCommand) command).getCollection(); + colletion = ((DeleteCommand) command) + .getCollection(); } if (command instanceof RemoveCommand) { - colletion = ((RemoveCommand) command).getCollection(); + colletion = ((RemoveCommand) command) + .getCollection(); } - for (Iterator iterator2 = colletion.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = colletion.iterator(); iterator2 + .hasNext();) { Object childModel = (Object) iterator2.next(); - childModel = AdapterFactoryEditingDomain.unwrap(childModel); + childModel = AdapterFactoryEditingDomain + .unwrap(childModel); AbstractSmooksGraphicalModel graphModel = findGraphicalModel(childModel); if (graphModel == null) continue; - AbstractSmooksGraphicalModel.disconnectAllConnections(graphModel); + AbstractSmooksGraphicalModel + .disconnectAllConnections(graphModel); root.removeTreeNode(graphModel); } } @@ -563,9 +642,11 @@ continue; } node.fireVisualChanged(); - EStructuralFeature feature = ((SetCommand) command).getFeature(); + EStructuralFeature feature = ((SetCommand) command) + .getFeature(); if (SmooksUIUtils.isRelatedConnectionFeature(feature)) { - deleteRelatedConnection(node, feature, (SetCommand) command); + deleteRelatedConnection(node, feature, + (SetCommand) command); Collection connections = createConnection(node); node.fireConnectionChanged(); expandConnectedModels(connections); @@ -598,7 +679,8 @@ node.fireChildrenChanged(); node.fireConnectionChanged(); } - if (command instanceof DeleteCommand || command instanceof RemoveCommand) { + if (command instanceof DeleteCommand + || command instanceof RemoveCommand) { if (node != null) { node.fireChildrenChanged(); } @@ -612,14 +694,16 @@ AbstractSmooksGraphicalModel node = findGraphicalModel(object); if (command instanceof AddCommand) { if (object instanceof SmooksResourceListType) { - Collection cccc = ((AddCommand) command).getCollection(); - for (Iterator iterator2 = cccc.iterator(); iterator2.hasNext();) { + Collection cccc = ((AddCommand) command) + .getCollection(); + for (Iterator iterator2 = cccc.iterator(); iterator2 + .hasNext();) { Object object2 = (Object) iterator2.next(); - object2 = AdapterFactoryEditingDomain.unwrap(object2); + object2 = AdapterFactoryEditingDomain + .unwrap(object2); AbstractSmooksGraphicalModel gmodel = findGraphicalModel(object2); if (gmodel != null) { root.removeTreeNode(gmodel); - break; } } } else { @@ -633,15 +717,18 @@ continue; } node.fireVisualChanged(); - EStructuralFeature feature = ((SetCommand) command).getFeature(); + EStructuralFeature feature = ((SetCommand) command) + .getFeature(); if (SmooksUIUtils.isRelatedConnectionFeature(feature)) { - deleteRelatedConnection(node, feature, (SetCommand) command); + deleteRelatedConnection(node, feature, + (SetCommand) command); Collection connections = createConnection(node); node.fireConnectionChanged(); expandConnectedModels(connections); } } - if (command instanceof DeleteCommand || command instanceof RemoveCommand) { + if (command instanceof DeleteCommand + || command instanceof RemoveCommand) { Collection cccc = null; if (command instanceof DeleteCommand) { cccc = ((DeleteCommand) command).getCollection(); @@ -649,14 +736,16 @@ if (command instanceof RemoveCommand) { cccc = ((RemoveCommand) command).getCollection(); } - for (Iterator iterator2 = cccc.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = cccc.iterator(); iterator2 + .hasNext();) { Object object2 = (Object) iterator2.next(); object2 = AdapterFactoryEditingDomain.unwrap(object2); // it means that it's deletecommand undo if (object == object2) { EObject owner = ((EObject) object).eContainer(); if (owner instanceof SmooksResourceListType) { - object = AdapterFactoryEditingDomain.unwrap(object); + object = AdapterFactoryEditingDomain + .unwrap(object); AbstractSmooksGraphicalModel graphModel = createGraphModel(object); if (graphModel == null) continue; @@ -709,18 +798,22 @@ getGraphicalViewer().setEditDomain(editDomain); getGraphicalViewer().setEditPartFactory(createEdtiPartFactory()); - getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart() { - public DragTracker getDragTracker(Request req) { - return new RightClickSelectMarqueeDragTraker(); - } - }); + getGraphicalViewer().setRootEditPart( + new FreeformGraphicalRootEditPart() { + public DragTracker getDragTracker(Request req) { + return new RightClickSelectMarqueeDragTraker(); + } + }); - getGraphicalViewer().addDropTargetListener( - (TransferDropTargetListener) new TemplateTransferDropTargetListener(getGraphicalViewer())); + getGraphicalViewer() + .addDropTargetListener( + (TransferDropTargetListener) new TemplateTransferDropTargetListener( + getGraphicalViewer())); - GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(getGraphicalViewer()); - keyHandler.put(org.eclipse.gef.KeyStroke.getPressed(SWT.DEL, 0), this.getActionRegistry().getAction( - ActionFactory.DELETE.getId())); + GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler( + getGraphicalViewer()); + keyHandler.put(org.eclipse.gef.KeyStroke.getPressed(SWT.DEL, 0), this + .getActionRegistry().getAction(ActionFactory.DELETE.getId())); ContextMenuProvider provider = getContextMenuProvider(); getGraphicalViewer().setContextMenu(provider); @@ -729,7 +822,8 @@ } protected ContextMenuProvider getContextMenuProvider() { - return new SmooksGraphicalEditorMenuContextProvider(getGraphicalViewer(), this.getActionRegistry()); + return new SmooksGraphicalEditorMenuContextProvider( + getGraphicalViewer(), this.getActionRegistry()); } private void hookSelectionActions() { @@ -737,7 +831,8 @@ while (actions.hasNext()) { Object action = actions.next(); if (action instanceof SelectionAction) { - ((SelectionAction) action).setSelectionProvider(getGraphicalViewer()); + ((SelectionAction) action) + .setSelectionProvider(getGraphicalViewer()); } } } @@ -745,7 +840,8 @@ protected List createInputDataGraphModel() { List inputGraphModel = new ArrayList(); if (inputDataList != null && root != null) { - for (Iterator iterator = inputDataList.iterator(); iterator.hasNext();) { + for (Iterator iterator = inputDataList.iterator(); iterator + .hasNext();) { Object object = (Object) iterator.next(); ITreeContentProvider contentProvider = new XMLStructuredDataContentProvider(); ILabelProvider labelProvider = new XMLStructuredDataLabelProvider(); @@ -758,8 +854,9 @@ } containerModel.getChildren().add((IXMLStructuredObject) object); if (containerModel != null) { - TreeContainerModel container = new InputDataContianerModel(containerModel, contentProvider, - labelProvider, getSmooksModelProvider()); + TreeContainerModel container = new InputDataContianerModel( + containerModel, contentProvider, labelProvider, + getSmooksModelProvider()); root.addTreeNode(container); inputGraphModel.add(container); } @@ -771,7 +868,8 @@ @Override protected void hookGraphicalViewer() { getSelectionSynchronizer().addViewer(getGraphicalViewer()); - getGraphicalViewer().addSelectionChangedListener(getSelectionSynchronizer()); + getGraphicalViewer().addSelectionChangedListener( + getSelectionSynchronizer()); getGraphicalViewer().addSelectionChangedListener(this); } @@ -787,9 +885,11 @@ return; AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain) smooksModelProvider .getEditingDomain(); - if (inputDataList != null && obj != null && obj instanceof DocumentRoot && editingDomain != null) { + if (inputDataList != null && obj != null && obj instanceof DocumentRoot + && editingDomain != null) { createInputDataGraphModel(); - SmooksResourceListType listType = ((DocumentRoot) obj).getSmooksResourceList(); + SmooksResourceListType listType = ((DocumentRoot) obj) + .getSmooksResourceList(); List arcList = listType.getAbstractResourceConfig(); for (Object object : arcList) { AbstractSmooksGraphicalModel gmodel = createGraphModel(object); @@ -812,15 +912,18 @@ this.autoLayout(false); - List diagnosticList = this.getSmooksModelProvider().getDiagnosticList(); + List diagnosticList = this.getSmooksModelProvider() + .getDiagnosticList(); this.validateEnd(diagnosticList); } protected AbstractSmooksGraphicalModel createGraphModel(Object model) { GraphicalModelFactory factory = getGraphicalModelFactory(); if (factory != null) { - Object gmodel = factory.createGraphicalModel(model, smooksModelProvider); - if (gmodel != null && gmodel instanceof AbstractSmooksGraphicalModel) { + Object gmodel = factory.createGraphicalModel(model, + smooksModelProvider); + if (gmodel != null + && gmodel instanceof AbstractSmooksGraphicalModel) { AbstractSmooksGraphicalModel graphicalModel = (AbstractSmooksGraphicalModel) gmodel; return graphicalModel; } @@ -836,7 +939,8 @@ return connections; } - protected Collection createAllConnection(AbstractSmooksGraphicalModel model) { + protected Collection createAllConnection( + AbstractSmooksGraphicalModel model) { try { if (model == null) return null; @@ -864,25 +968,28 @@ } } - public Collection createConnection(AbstractSmooksGraphicalModel model) { + public Collection createConnection( + AbstractSmooksGraphicalModel model) { ConnectionModelFactory connectionModelFactory = getConnectionModelFactory(); List cs = new ArrayList(); ISmooksModelProvider p = getSmooksModelProvider(); if (connectionModelFactory != null) { if (connectionModelFactory.hasConnection(model)) { - Collection cList = connectionModelFactory.createConnection(inputDataList, getSmooksResourceList(), root, model); - + Collection cList = connectionModelFactory + .createConnection(inputDataList, + getSmooksResourceList(), root, model); + if (cList != null) { cs.addAll(cList); } } } - + if (cs.isEmpty()) { return null; } - + return cs; } @@ -945,11 +1052,15 @@ return null; } - public void createConnection(List children, List connections) { + public void createConnection(List children, + List connections) { Object parentTask = taskType.getParent(); - - if(parentTask instanceof TaskType) { - if(((TaskType) parentTask).getId().equals(TaskTypeManager.TASK_ID_INPUT) && !taskType.getId().equals(TaskTypeManager.TASK_ID_JAVA_MAPPING)) { + + if (parentTask instanceof TaskType) { + if (((TaskType) parentTask).getId().equals( + TaskTypeManager.TASK_ID_INPUT) + && !taskType.getId().equals( + TaskTypeManager.TASK_ID_JAVA_MAPPING)) { for (AbstractSmooksGraphicalModel abstractSmooksGraphicalModel : children) { if (abstractSmooksGraphicalModel instanceof InputDataContianerModel) { Collection c = createConnection(abstractSmooksGraphicalModel); @@ -958,7 +1069,7 @@ } break; } - } + } } else { for (AbstractSmooksGraphicalModel abstractSmooksGraphicalModel : children) { if (!(abstractSmooksGraphicalModel instanceof InputDataContianerModel)) { @@ -968,12 +1079,13 @@ connections.addAll(c); } } - List cchildren = abstractSmooksGraphicalModel.getChildren(); + List cchildren = abstractSmooksGraphicalModel + .getChildren(); createConnection(cchildren, connections); } } } - } + } } private boolean canCreateConnection(AbstractSmooksGraphicalModel model) { @@ -1000,47 +1112,60 @@ Object obj = smooksModelProvider.getSmooksModel(); smooksResourceList = null; if (obj instanceof DocumentRoot) { - smooksResourceList = ((DocumentRoot) obj).getSmooksResourceList(); - inputDataList = SelectorCreationDialog.generateInputData(smooksResourceList); + smooksResourceList = ((DocumentRoot) obj) + .getSmooksResourceList(); + inputDataList = SelectorCreationDialog + .generateInputData(smooksResourceList); } } } @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { + public void init(IEditorSite site, IEditorInput input) + throws PartInitException { super.init(site, input); initSmooksData(); if (smooksModelProvider != null) { - this.handleCommandStack(smooksModelProvider.getEditingDomain().getCommandStack()); + this.handleCommandStack(smooksModelProvider.getEditingDomain() + .getCommandStack()); } } - protected void expandConnectedModels(Collection connections) { + protected void expandConnectedModels( + Collection connections) { if (connections == null || connections.isEmpty()) return; List expanedTreeNodeList = new ArrayList(); for (Iterator iterator = connections.iterator(); iterator.hasNext();) { - TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next(); - AbstractSmooksGraphicalModel source = treeNodeConnection.getSourceNode(); - AbstractSmooksGraphicalModel target = treeNodeConnection.getTargetNode(); + TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator + .next(); + AbstractSmooksGraphicalModel source = treeNodeConnection + .getSourceNode(); + AbstractSmooksGraphicalModel target = treeNodeConnection + .getTargetNode(); Object data = source.getData(); Object data2 = target.getData(); - if (source instanceof TreeNodeModel && data instanceof IXMLStructuredObject) { + if (source instanceof TreeNodeModel + && data instanceof IXMLStructuredObject) { expanedTreeNodeList.add((TreeNodeModel) source); } - if (target instanceof TreeNodeModel && data2 instanceof IXMLStructuredObject) { + if (target instanceof TreeNodeModel + && data2 instanceof IXMLStructuredObject) { expanedTreeNodeList.add((TreeNodeModel) target); } } EditPart rootEditPart = getGraphicalViewer().getContents(); if (rootEditPart != null) { List childrenEditPart = rootEditPart.getChildren(); - for (Iterator iterator = childrenEditPart.iterator(); iterator.hasNext();) { + for (Iterator iterator = childrenEditPart.iterator(); iterator + .hasNext();) { Object object = (Object) iterator.next(); -// Object model = ((EditPart) object).getModel(); -// if (object instanceof InputDataContainerEditPart || model instanceof XSLTemplateGraphicalModel) { - SmooksUIUtils.expandGraphTree(expanedTreeNodeList, (TreeNodeEditPart) object); -// } + // Object model = ((EditPart) object).getModel(); + // if (object instanceof InputDataContainerEditPart || model + // instanceof XSLTemplateGraphicalModel) { + SmooksUIUtils.expandGraphTree(expanedTreeNodeList, + (TreeNodeEditPart) object); + // } // if(model instanceof XSLTemplateGraphicalModel){ // ((TreeNodeEditPart) object).expandNode(); // if(!((TreeNodeEditPart) object).getChildren().isEmpty()){ @@ -1064,7 +1189,8 @@ initGraphicalModel(); } - protected void applyGraphicalInformation(AbstractSmooksGraphicalModel graphicalModel) { + protected void applyGraphicalInformation( + AbstractSmooksGraphicalModel graphicalModel) { // GraphType graph1 = getSmooksGraphicsExtType().getGraph(); // applyGraphicalInformation(graph1, graphicalModel); } @@ -1127,9 +1253,11 @@ Node node = (Node) nodeMap.get(part); figureList.add(part); graphAnimation.recordInit(part); - IMoveableModel graphicalModel = (IMoveableModel) part.getModel(); + IMoveableModel graphicalModel = (IMoveableModel) part + .getModel(); map.put(graphicalModel, new Point(node.x, node.y)); - graphAnimation.recordFinal(part, new Rectangle(node.x, node.y, 0, 0)); + graphAnimation.recordFinal(part, new Rectangle(node.x, node.y, + 0, 0)); } IEditorSite editorSite = getEditorSite(); @@ -1183,7 +1311,8 @@ return null; } - protected DirectedGraph collectionGraphInformation(HashMap nodeMap) { + protected DirectedGraph collectionGraphInformation( + HashMap nodeMap) { DirectedGraph graph = new DirectedGraph(); if (getGraphicalViewer() == null) { return graph; @@ -1206,17 +1335,21 @@ for (Iterator iterator = children.iterator(); iterator.hasNext();) { GraphicalEditPart object = (GraphicalEditPart) iterator.next(); - for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { - GraphicalEditPart testEditPart = (GraphicalEditPart) iterator2.next(); + for (Iterator iterator2 = children.iterator(); iterator2 + .hasNext();) { + GraphicalEditPart testEditPart = (GraphicalEditPart) iterator2 + .next(); Node node = nodeMap.get(object); Node testNode = nodeMap.get(testEditPart); if (node != null && testNode != null) { - if (hasConnectionAssociation(object, testEditPart, SOURCE_CONNECT_TYPE)) { + if (hasConnectionAssociation(object, testEditPart, + SOURCE_CONNECT_TYPE)) { Edge edge = new Edge(node, testNode); edge.data = testEditPart; graph.edges.add(edge); } - if (hasConnectionAssociation(object, testEditPart, TARGET_CONNECT_TYPE)) { + if (hasConnectionAssociation(object, testEditPart, + TARGET_CONNECT_TYPE)) { Edge edge = new Edge(testNode, node); graph.edges.add(edge); } @@ -1230,10 +1363,12 @@ if (model == editPart.getModel()) { return true; } - AbstractSmooksGraphicalModel grphicalModel = (AbstractSmooksGraphicalModel) editPart.getModel(); + AbstractSmooksGraphicalModel grphicalModel = (AbstractSmooksGraphicalModel) editPart + .getModel(); if (!grphicalModel.getChildrenWithoutDynamic().isEmpty()) { List children = editPart.getChildren(); - for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = children.iterator(); iterator2 + .hasNext();) { GraphicalEditPart gpart = (GraphicalEditPart) iterator2.next(); if (hasAssociation(model, gpart)) { return true; @@ -1243,7 +1378,8 @@ return false; } - private boolean hasConnectionAssociation(GraphicalEditPart editPart, GraphicalEditPart testEditPart, int connectType) { + private boolean hasConnectionAssociation(GraphicalEditPart editPart, + GraphicalEditPart testEditPart, int connectType) { List sourceConnections = null; if (connectType == SOURCE_CONNECT_TYPE) { sourceConnections = editPart.getSourceConnections(); @@ -1251,9 +1387,11 @@ if (connectType == TARGET_CONNECT_TYPE) { sourceConnections = editPart.getTargetConnections(); } - for (Iterator iterator = sourceConnections.iterator(); iterator.hasNext();) { + for (Iterator iterator = sourceConnections.iterator(); iterator + .hasNext();) { GraphicalEditPart object = (GraphicalEditPart) iterator.next(); - TreeNodeConnection connection = (TreeNodeConnection) object.getModel(); + TreeNodeConnection connection = (TreeNodeConnection) object + .getModel(); Object testModel = null; if (connectType == SOURCE_CONNECT_TYPE) { testModel = connection.getTargetNode(); @@ -1265,12 +1403,15 @@ return true; } } - AbstractSmooksGraphicalModel sourceGraphModel = (AbstractSmooksGraphicalModel) editPart.getModel(); + AbstractSmooksGraphicalModel sourceGraphModel = (AbstractSmooksGraphicalModel) editPart + .getModel(); if (!sourceGraphModel.getChildrenWithoutDynamic().isEmpty()) { List children = editPart.getChildren(); for (Iterator iterator = children.iterator(); iterator.hasNext();) { - GraphicalEditPart childEditPart = (GraphicalEditPart) iterator.next(); - if (hasConnectionAssociation(childEditPart, testEditPart, connectType)) { + GraphicalEditPart childEditPart = (GraphicalEditPart) iterator + .next(); + if (hasConnectionAssociation(childEditPart, testEditPart, + connectType)) { return true; } } @@ -1297,7 +1438,8 @@ */ @Override public void doSave(IProgressMonitor monitor) { - if (getEditDomain() != null && getEditDomain().getCommandStack() != null) { + if (getEditDomain() != null + && getEditDomain().getCommandStack() != null) { getEditDomain().getCommandStack().flush(); } } @@ -1309,8 +1451,9 @@ public void selectionChanged(SelectionChangedEvent event) { updateActions(getSelectionActions()); - ISelectionProvider provider = ((SmooksTaskDetailsEditorSite)getSite()).getMultiPageEditor().getSite().getSelectionProvider(); - if(provider != null){ + ISelectionProvider provider = ((SmooksTaskDetailsEditorSite) getSite()) + .getMultiPageEditor().getSite().getSelectionProvider(); + if (provider != null) { provider.setSelection(event.getSelection()); } } @@ -1334,7 +1477,8 @@ Object obj = smooksModelProvider.getSmooksModel(); smooksResourceList = null; if (obj instanceof DocumentRoot) { - smooksResourceList = ((DocumentRoot) obj).getSmooksResourceList(); + smooksResourceList = ((DocumentRoot) obj) + .getSmooksResourceList(); } return smooksResourceList; } @@ -1351,7 +1495,8 @@ public void inputTypeChanged() { if (root != null && inputDataList != null) { - List newInputDataList = SelectorCreationDialog.generateInputData(getSmooksResourceListType()); + List newInputDataList = SelectorCreationDialog + .generateInputData(getSmooksResourceListType()); List inputs = new ArrayList(); List children = root.getChildren(); @@ -1365,8 +1510,10 @@ } for (Iterator iterator = inputs.iterator(); iterator.hasNext();) { - InputDataContianerModel inputModel = (InputDataContianerModel) iterator.next(); - AbstractSmooksGraphicalModel.disconnectAllConnections(inputModel); + InputDataContianerModel inputModel = (InputDataContianerModel) iterator + .next(); + AbstractSmooksGraphicalModel + .disconnectAllConnections(inputModel); root.removeTreeNode(inputModel); } @@ -1393,7 +1540,8 @@ return; List children = root.getChildren(); for (Iterator iterator = children.iterator(); iterator.hasNext();) { - AbstractSmooksGraphicalModel abstractSmooksGraphicalModel = (AbstractSmooksGraphicalModel) iterator.next(); + AbstractSmooksGraphicalModel abstractSmooksGraphicalModel = (AbstractSmooksGraphicalModel) iterator + .next(); cleanValidationMarker(abstractSmooksGraphicalModel); } } @@ -1401,9 +1549,11 @@ protected void cleanValidationMarker(AbstractSmooksGraphicalModel model) { model.setSeverity(IValidatableModel.NONE); model.getMessage().clear(); - List children = model.getChildrenWithoutDynamic(); + List children = model + .getChildrenWithoutDynamic(); for (Iterator iterator = children.iterator(); iterator.hasNext();) { - AbstractSmooksGraphicalModel abstractSmooksGraphicalModel = (AbstractSmooksGraphicalModel) iterator.next(); + AbstractSmooksGraphicalModel abstractSmooksGraphicalModel = (AbstractSmooksGraphicalModel) iterator + .next(); cleanValidationMarker(abstractSmooksGraphicalModel); } } @@ -1421,7 +1571,8 @@ public void run() { cleanValidationMarker(); - for (Iterator iterator = flist.iterator(); iterator.hasNext();) { + for (Iterator iterator = flist.iterator(); iterator + .hasNext();) { Diagnostic diagnostic = (Diagnostic) iterator.next(); refreshValidateResult(diagnostic); } @@ -1440,7 +1591,8 @@ Object obj = datas.get(1); if (obj == Javabean12Package.Literals.BEAN_TYPE__BEAN_ID) { String message = diagnostic.getMessage(); - if (message != null && message.startsWith("The required feature")) { //$NON-NLS-1$ + if (message != null + && message.startsWith("The required feature")) { //$NON-NLS-1$ return Messages.SmooksJavaMappingGraphicalEditor_BeanIdEmptyErrormessage; } } @@ -1450,7 +1602,8 @@ Object obj = datas.get(1); if (obj == Javabean12Package.Literals.VALUE_TYPE__DATA) { String message = diagnostic.getMessage(); - if (message != null && message.startsWith("The required feature")) { //$NON-NLS-1$ + if (message != null + && message.startsWith("The required feature")) { //$NON-NLS-1$ return Messages.SmooksJavaMappingGraphicalEditor_NodeMustLinkWithSource; } } @@ -1460,7 +1613,8 @@ Object obj = datas.get(1); if (obj == Javabean12Package.Literals.WIRING_TYPE__BEAN_ID_REF) { String message = diagnostic.getMessage(); - if (message != null && message.startsWith("The required feature")) { //$NON-NLS-1$ + if (message != null + && message.startsWith("The required feature")) { //$NON-NLS-1$ return Messages.SmooksJavaMappingGraphicalEditor_NodeMustLinkWithJavaBean; } } @@ -1479,7 +1633,8 @@ Object object = (Object) iterator2.next(); object = AdapterFactoryEditingDomain.unwrap(object); if (object instanceof EObject) { - AbstractSmooksGraphicalModel graphModel = SmooksGraphUtil.findSmooksGraphModel(root, object); + AbstractSmooksGraphicalModel graphModel = SmooksGraphUtil + .findSmooksGraphModel(root, object); if (graphModel == null) continue; obj = graphModel; @@ -1490,7 +1645,8 @@ } } if (obj != null) { - for (Iterator iterator2 = datas.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = datas.iterator(); iterator2 + .hasNext();) { Object object = (Object) iterator2.next(); object = AdapterFactoryEditingDomain.unwrap(object); if (object instanceof EAttribute && obj != null) {