private boolean testing;
private boolean error = false;
public void op( final Display display, final Object target, final IProgressMonitor monitor )
throws Exception {
final IService service = (IService) target;
final DataStore ds = service.resolve(DataStore.class, monitor);
if (!(ds instanceof ShapefileDataStore)) {
try {
ds.createSchema(null);
} catch (UnsupportedOperationException e) {
if (testing) {
error = true;
return;
} else {
display.asyncExec(new Runnable(){
public void run() {
MessageDialog
.openInformation(display.getActiveShell(),
Messages.NewFeatureTypeOp_title,
Messages.NewFeatureTypeOp_message);
}
});
return;
}
} catch (Exception e) {
// try it
}
}
final SimpleFeatureType[] featureType = new SimpleFeatureType[1];
if (!testing) {
final FeatureTypeEditorDialog[] dialog=new FeatureTypeEditorDialog[1];
PlatformGIS.syncInDisplayThread(new Runnable(){
public void run() {
dialog[0] = new FeatureTypeEditorDialog(display
.getActiveShell(), new ValidateFeatureType(){
public String validate( SimpleFeatureType featureBuilder ) {
return null;
}
});
}
});
int code=-1;
do {
code=openDialog(display, dialog[0], ds);
if( code==Window.CANCEL){
featureType[0]=null;
}else
featureType[0]=dialog[0].getFeatureType(true);
} while( featureType[0] == null && code==Window.OK);
} else {
featureType[0] = DataUtilities.createType("TestName", "Geom:MultiLineString"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (featureType[0] == null)
return;
try {
if (ds instanceof ShapefileDataStore) {
createShapefile(display, monitor, featureType[0], service.getIdentifier());
} else {
ds.createSchema(featureType[0]);
long start=System.currentTimeMillis();
while( !Arrays.asList(ds.getTypeNames()).contains(featureType[0].getName().getLocalPart() ) && start+5000>System.currentTimeMillis()){
Thread.sleep(300);