crsButton.setText("..."); //$NON-NLS-1$
crsButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
Shell shell = new Shell(text.getShell(), SWT.SHELL_TRIM);
Dialog dialog = new Dialog(shell){
private CRSChooser chooser;
private CoordinateReferenceSystem crs;
@Override
protected void configureShell( Shell shell ) {
super.configureShell(shell);
shell.setText("Choose CRS");
}
@Override
protected Control createDialogArea( Composite parent ) {
Composite comp = (Composite) super.createDialogArea(parent);
GridLayout gLayout = (GridLayout) comp.getLayout();
gLayout.numColumns = 1;
chooser = new CRSChooser(new Controller(){
public void handleClose() {
buttonPressed(OK);
}
public void handleOk() {
buttonPressed(OK);
}
});
return chooser.createControl(parent);
}
@Override
protected void buttonPressed( int buttonId ) {
if (buttonId == OK) {
crs = chooser.getCRS();
try {
String codeFromCrs = OmsBoxUtils.getCodeFromCrs(crs);
text.setText(codeFromCrs);
} catch (Exception e) {
e.printStackTrace();
}
}
close();
}
};
dialog.setBlockOnOpen(true);
dialog.open();
}
});
// initially set to map's crs
IMap activeMap = ApplicationGIS.getActiveMap();