setDescription("Define the location of a Hadoop infrastructure " + "for running MapReduce applications.");
final Composite panel = new Composite(parent, SWT.FILL);
GridLayout glayout = new GridLayout(2, false);
panel.setLayout(glayout);
final HadoopConfigurationBuilder uiConfigurationBuilder = location.getUIConfigurationBuilder();
uiConfigurationBuilder.setChangeListener(new ChangeListener() {
@Override
public void notifyChange(ConfProp prop, String propValue) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
getContainer().updateButtons();
}});
}
});
/*
* Location name
*/
{
Label label = new Label(panel, SWT.NONE);
label.setText( "&Location name:");
Text text = new Text(panel, SWT.SINGLE | SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(data);
text.setText(location.getConfPropValue(ConfProp.PI_LOCATION_NAME));
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
final Text text = (Text) e.widget;
final ConfProp prop = (ConfProp) text.getData("hProp");
Display.getDefault().syncExec(new Runnable() {
public void run() {
uiConfigurationBuilder.notifyChange(ConfProp.PI_LOCATION_NAME,text.getText());
}
});
}
});
locationName=text;
}
/*
* Hadoop version
*/
{
Label label = new Label(panel, SWT.NONE);
label.setText("&Hadoop Version:");
Combo options = new Combo(panel, SWT.BORDER | SWT.READ_ONLY);
for(HadoopVersion ver:HadoopVersion.values()){
options.add(ver.getDisplayName());
}
int pos=0;
for(String item:options.getItems()){
if(item.equalsIgnoreCase(location.getVersion().getDisplayName())){
options.select(pos);
break;
}
pos++;
}
options.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
options.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
final String selection = hadoopVersion.getText();
if (location == null || !selection.equals(location.getVersion())) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
try {
location = AbstractHadoopCluster.createCluster(selection);
location.setConfPropValue(ConfProp.PI_HADOOP_VERSION, selection);
location.setConfPropValue(ConfProp.PI_LOCATION_NAME, locationName.getText());
panel.dispose();
createControl(parent);
parent.pack();
parent.getParent().layout(true);
} catch (CoreException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "HDFS Error", "Unable to create HDFS site :"
+ e.getMessage());
}
}
});
}
}
});
hadoopVersion=options;
}
{
uiConfigurationBuilder.buildControl(panel);
this.setControl(panel);
}
{
final Button btn = new Button(panel, SWT.NONE);