@SuppressWarnings("nls")
public void createControl( Composite parent ) {
this.parent = parent;
parent.setLayout(new GridLayout());
ScrolledComposite scrollComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
scrollComposite.setMinHeight(100);
scrollComposite.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
Composite c = new Composite(scrollComposite, SWT.None);
c.setLayout(new GridLayout());
c.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
// choose mapset
Group chooseMapsetGroup = new Group(c, SWT.BORDER);
GridLayout layout1 = new GridLayout(3, false);
chooseMapsetGroup.setLayout(layout1);
chooseMapsetGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
chooseMapsetGroup.setText("Ruling / Affected mapset");
Label mapsetLabel = new Label(chooseMapsetGroup, SWT.NONE);
mapsetLabel.setText("wind file for active region: ");
windPathText = new Text(chooseMapsetGroup, SWT.BORDER);
GridData gd = new GridData();
gd.widthHint = 100;
windPathText.setLayoutData(gd);
windPathText.setEditable(false);
final Button mapsetButton = new Button(chooseMapsetGroup, SWT.BORDER | SWT.PUSH);
GridData gd2 = new GridData();
gd2.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
mapsetButton.setLayoutData(gd2);
mapsetButton.setText("Browse");
mapsetButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected( SelectionEvent e ) {
CatalogJGrassMapsetTreeViewerDialog cDialog = new CatalogJGrassMapsetTreeViewerDialog();
cDialog.open(mapsetButton.getShell());
List<JGrassMapsetGeoResource> selectedLayers = cDialog.getSelectedLayers();
if (selectedLayers == null || selectedLayers.size() == 0) {
return;
}
jGrassMapsetGeoResource = selectedLayers.get(0);
String windPath = jGrassMapsetGeoResource.getActiveRegionWindowPath();
windPathText.setText(windPath);
JGrassRegion jgR = jGrassMapsetGeoResource.getActiveRegionWindow();
CoordinateReferenceSystem crs = jGrassMapsetGeoResource.getLocationCrs();
commitToBlackboards(jgR, crs, windPath);
}
});
// the group for the region
Group regionGroup = new Group(c, SWT.BORDER);
GridLayout layout2 = new GridLayout(2, true);
regionGroup.setLayout(layout2);
regionGroup.setText("Region settings");
regionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
northLabel = new Label(regionGroup, SWT.NONE);
northLabel.setText("north");
northLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
northText = new Text(regionGroup, SWT.BORDER);
northText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
southLabel = new Label(regionGroup, SWT.NONE);
southLabel.setText("south");
southLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
southText = new Text(regionGroup, SWT.BORDER);
southText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
westLabel = new Label(regionGroup, SWT.NONE);
westLabel.setText("west");
westLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
westText = new Text(regionGroup, SWT.BORDER);
westText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
eastLabel = new Label(regionGroup, SWT.NONE);
eastLabel.setText("east");
eastLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
eastText = new Text(regionGroup, SWT.BORDER);
eastText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
rowsLabel = new Label(regionGroup, SWT.NONE);
rowsLabel.setText("rows");
rowsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
rowsText = new Text(regionGroup, SWT.BORDER);
rowsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
colsLabel = new Label(regionGroup, SWT.NONE);
colsLabel.setText("cols");
colsLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
colsText = new Text(regionGroup, SWT.BORDER);
colsText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
xresLabel = new Label(regionGroup, SWT.NONE);
xresLabel.setText("xres");
xresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
xresText = new Text(regionGroup, SWT.BORDER);
xresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
yresLabel = new Label(regionGroup, SWT.NONE);
yresLabel.setText("yres");
yresLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
yresText = new Text(regionGroup, SWT.BORDER);
yresText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
// the group for the style
Group styleGroup = new Group(c, SWT.BORDER);
GridLayout layout3 = new GridLayout(2, true);
styleGroup.setLayout(layout3);
styleGroup.setText("Style properties");
styleGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
gridButton = new Button(styleGroup, SWT.BORDER | SWT.CHECK);
gridButton.setText("visualize active region grid");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gridData.horizontalSpan = 2;
gridButton.setLayoutData(gridData);
Label backgroundColourLabel = new Label(styleGroup, SWT.NONE);
backgroundColourLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
backgroundColourLabel.setText("background color");
backgroundColour = new ColorEditor(styleGroup);
backgroundColour.getButton().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
Label backgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
backgroundAlphaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
backgroundAlphaLabel.setText("background alpha (0-1)");
backgroundAlphaText = new Text(styleGroup, SWT.BORDER);
backgroundAlphaText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
Label foregroundColourLabel = new Label(styleGroup, SWT.NONE);
foregroundColourLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
foregroundColourLabel.setText("foreground color");
foregroundColor = new ColorEditor(styleGroup);
foregroundColor.getButton().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
Label forgroundAlphaLabel = new Label(styleGroup, SWT.NONE);
forgroundAlphaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
forgroundAlphaLabel.setText("foreground alpha (0-1)");
forgroundAlphaText = new Text(styleGroup, SWT.BORDER);
forgroundAlphaText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
// the group for the set region to map
final Group settoGroup = new Group(c, SWT.BORDER);
GridLayout layout4 = new GridLayout(1, true);
settoGroup.setLayout(layout4);
settoGroup.setText("Set region to...");
settoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
rasterMapSetButton = new Button(settoGroup, SWT.NONE);
rasterMapSetButton.setText("set region to raster map");
rasterMapSetButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
rasterMapSetButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
JGRasterChooserDialog tree = new JGRasterChooserDialog(null);
tree.open(settoGroup.getShell(), SWT.SINGLE);
update(tree.getSelectedResources());
}
});
featuresMapSetButton = new Button(settoGroup, SWT.NONE);
featuresMapSetButton.setText("set region to vector map");
featuresMapSetButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
featuresMapSetButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
FeatureChooserDialog tree = new FeatureChooserDialog();
tree.open(settoGroup.getShell(), SWT.SINGLE);
update(tree.getSelectedResources());
}
});
resetToActiveButton = new Button(settoGroup, SWT.NONE);
resetToActiveButton.setText("reset back to actual region");
resetToActiveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
resetToActiveButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
String windPath = windPathText.getText();
try {
JGrassRegion jgR = new JGrassRegion(windPath);
setWidgetsToWindow(jgR);
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
northText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(bound_type);
}
});
southText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(bound_type);
}
});
rowsText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(row_type);
}
});
colsText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(row_type);
}
});
westText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(bound_type);
}
});
xresText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(res_type);
}
});
eastText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(bound_type);
}
});
yresText.addModifyListener(new org.eclipse.swt.events.ModifyListener(){
public void modifyText( org.eclipse.swt.events.ModifyEvent e ) {
if (isWorking)
return;
textModified(res_type);
}
});
foregroundColor.addSelectionListener(this);
backgroundColour.addSelectionListener(this);
/*
* layout
*/
c.layout();
Point size = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
c.setSize(size);
scrollComposite.setContent(c);
}