Skip to content

Commit

Permalink
teiides-2019: Added "Set as root" option for complex types and XSD Pa…
Browse files Browse the repository at this point in the history
…rticles.
  • Loading branch information
tejones committed Jan 21, 2014
1 parent d271703 commit 1e929b6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,28 @@ public void setRootPath(String thePath) {
if( thePath != null && thePath.length() > 0 ) {
// Need to remove the OLD root path from FULL path
SchemaPath oldRelativePath = new SchemaPath(getRelativePath());

SchemaPath newRelativePath = this.rootXmlPath;
StringBuffer buf = new StringBuffer();
for (String seg : newRelativePath.segments){
if (!thePath.contains(seg)){
buf.append("/").append(seg); //$NON-NLS-1$
}
}
StringBuffer newRelativeBuf = new StringBuffer();
for (String seg : oldRelativePath.segments){
if (!thePath.contains(seg)){
newRelativeBuf.append("/").append(seg); //$NON-NLS-1$
}
}


String tmpRoot = thePath;
if( thePath.endsWith("/")) { //$NON-NLS-1$
tmpRoot = tmpRoot.substring(0, thePath.length()-1);
}

String newFullPath = tmpRoot + oldRelativePath;
String newFullPath = tmpRoot + buf + newRelativeBuf;

setFullXmlPath(newFullPath); //tmpRoot + oldRelativePath.toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.impl.XSDElementDeclarationImpl;
import org.eclipse.xsd.impl.XSDParticleImpl;
import org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl;
import org.teiid.designer.modelgenerator.wsdl.ui.Messages;
import org.teiid.designer.modelgenerator.wsdl.ui.wizards.soap.ImportWsdlSchemaHandler;
import org.teiid.designer.modelgenerator.wsdl.ui.wizards.soap.OperationsDetailsPage;
import org.teiid.designer.modelgenerator.wsdl.ui.wizards.soap.ProcedureInfo;
import org.teiid.designer.modelgenerator.wsdl.ui.wizards.soap.SchemaTreeModel.SchemaNode;
import org.teiid.designer.transformation.ui.wizards.xmlfile.XmlElement;
import org.teiid.designer.ui.common.util.WidgetFactory;


Expand All @@ -32,7 +37,7 @@
*/
public class ResponseSchemaContentsGroup {
TreeViewer schemaTreeViewer;
Action createColumnAction;
Action createColumnAction, setRootPathAction;
ColumnsInfoPanel columnsInfoPanel;

// TYPE either BODY or SOAP
Expand Down Expand Up @@ -71,7 +76,7 @@ private void createPanel(Composite parent) {
/**
* {@inheritDoc}
*
* @see oblafond@redhat.comrg.eclipse.jface.viewers.
* @see org.eclipse.jface.viewers.
* ISelectionChangedListener #selectionChanged(org.eclipse
* .jface.viewers.SelectionChangedEvent)
*/
Expand All @@ -83,9 +88,15 @@ public void selectionChanged(final SelectionChangedEvent event) {
Object element = ((SchemaNode)selection.getFirstElement()).getElement();
if( ImportWsdlSchemaHandler.shouldCreateResponseColumn(element) ) {
columnMenuManager.add(createColumnAction);
} else if (element instanceof XSDElementDeclarationImpl ) {
Object type = ((XSDElementDeclarationImpl) element).getTypeDefinition();
if( type instanceof XSDComplexTypeDefinition) {
columnMenuManager.add(setRootPathAction);
}
} else if (element instanceof XSDParticleImpl ) {
columnMenuManager.add(setRootPathAction);
}
}

}
});

Expand All @@ -109,7 +120,22 @@ public void run() {
createResponseColumn();
}
};
}
this.setRootPathAction = new Action(Messages.SetAsRootPath) {
@Override
public void run() {
setRootPath();
}
};
}

private void setRootPath() {
IStructuredSelection selection = (IStructuredSelection) schemaTreeViewer.getSelection();
Object obj = selection.getFirstElement();
String pathValue = ((SchemaNode)obj).getChildren().iterator().next().getFullPath();
this.columnsInfoPanel.getRootPathText().setText(pathValue);
getResponseInfo().setRootPath(pathValue);
this.columnsInfoPanel.refresh();
}

public void setColumnsInfoPanel(ColumnsInfoPanel panel) {
this.columnsInfoPanel = panel;
Expand Down

0 comments on commit 1e929b6

Please sign in to comment.