JGrassMapGeoResource mr = (JGrassMapGeoResource) object;
maps.add(mr);
}
}
Dialog dialog = new Dialog(shell){
private Text locNameText;
private Text mapsetNameText;
private Text crsText;
private Text xresText;
private Text yresText;
protected Control createDialogArea( Composite maxparent ) {
Composite parent = new Composite(maxparent, SWT.None);
parent.setLayout(new GridLayout());
parent.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL));
// the location name group
Group locNameGroup = new Group(parent, SWT.None);
locNameGroup.setLayout(new GridLayout(2, false));
locNameGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL));
locNameGroup.setText("new location name");
locNameText = new Text(locNameGroup, SWT.BORDER);
locNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER));
locNameText.setText("newLocation");
// the mapset name group
Group mapsetNameGroup = new Group(parent, SWT.None);
mapsetNameGroup.setLayout(new GridLayout(2, false));
mapsetNameGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL));
mapsetNameGroup.setText("new mapset name");
mapsetNameText = new Text(mapsetNameGroup, SWT.BORDER);
mapsetNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER));
mapsetNameText.setText("newMapset");
// the crs choice group
Group crsGroup = new Group(parent, SWT.None);
crsGroup.setLayout(new GridLayout(2, false));
crsGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL));
crsGroup.setText("choose the coordinate reference system for the new location");
crsText = new Text(crsGroup, SWT.BORDER);
crsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER));
crsText.setEditable(false);
final Button crsButton = new Button(crsGroup, SWT.BORDER);
crsButton.setText(" Choose CRS ");
crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
final ChooseCoordinateReferenceSystemDialog crsChooser = new ChooseCoordinateReferenceSystemDialog();
crsChooser.open(new Shell(Display.getDefault()));
CoordinateReferenceSystem readCrs = crsChooser.getCrs();
if (readCrs == null)
return;
crsText.setText(readCrs.getName().toString());
crsText.setData(readCrs);
}
});
// the location name group
Group resolutionGroup = new Group(parent, SWT.None);
resolutionGroup.setLayout(new GridLayout(2, false));
resolutionGroup.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL));
resolutionGroup.setText("output map resolution");
String res = "";
if (maps.size() > 0) {
try {
JGrassRegion activeWindow = maps.get(0).getActiveWindow();
res = String.valueOf(activeWindow.getNSResolution());
} catch (IOException e1) {
e1.printStackTrace();
}
}
Label xresLabel = new Label(resolutionGroup, SWT.NONE);
xresLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
xresLabel.setText("X resolution");
xresText = new Text(resolutionGroup, SWT.BORDER);
xresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER));
xresText.setText(res);
Label yresLabel = new Label(resolutionGroup, SWT.NONE);
yresLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
yresLabel.setText("Y resolution");
yresText = new Text(resolutionGroup, SWT.BORDER);
yresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_CENTER));
yresText.setText(res);
return parent;
}
protected void okPressed() {
locationName = locNameText.getText();
if (locationName == null || locationName.length() < 1) {
locationName = "newLocation";
}
mapsetName = mapsetNameText.getText();
if (mapsetName == null || mapsetName.length() < 1) {
mapsetName = "newMapset";
}
xRes = xresText.getText();
yRes = yresText.getText();
Object crsData = crsText.getData();
if (crsData instanceof CoordinateReferenceSystem) {
crs = (CoordinateReferenceSystem) crsData;
}
super.okPressed();
}
};
dialog.setBlockOnOpen(true);
open = dialog.open();
} catch (Exception e) {
String message = "An error occurred while exporting the maps.";
ExceptionDetailsDialog.openError("ERROR", message, IStatus.ERROR, JGrassPlugin.PLUGIN_ID, e);
}