use of org.apache.airavata.xbaya.ui.widgets.XBayaComboBox in project airavata by apache.
the class InstanceConfigurationDialog method initGui.
/**
* Initializes the GUI.
*/
private void initGui() {
/*
* Name
*/
this.nameTextField = new XBayaTextField();
XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
this.nameTextField.setEditable(false);
/*
* Radio button
*/
this.amiButton = new JRadioButton("Start new instance");
this.amiButton.setSelected(true);
this.amiButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent paramActionEvent) {
InstanceConfigurationDialog.this.instanceTypeComboBox.getJComboBox().setEnabled(true);
}
});
this.instanceTypeComboBox = new XBayaComboBox(new DefaultComboBoxModel(AmazonUtil.INSTANCE_TYPE));
this.instanceTypeComboBox.setSelectedItem(AmazonUtil.INSTANCE_TYPE[1]);
GridPanel amiPanel = new GridPanel();
amiPanel.add(this.amiButton);
amiPanel.add(this.instanceTypeComboBox);
amiPanel.layout(1, 2, GridPanel.WEIGHT_NONE, 1);
this.idButton = new JRadioButton("Use existing instance");
this.idButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent paramActionEvent) {
InstanceConfigurationDialog.this.instanceTypeComboBox.getJComboBox().setEnabled(false);
}
});
ButtonGroup serviceTypeButtonGroup = new ButtonGroup();
serviceTypeButtonGroup.add(this.amiButton);
serviceTypeButtonGroup.add(this.idButton);
XBayaLabel radioLabel = new XBayaLabel("Options", this.amiButton);
/*
* AMI/Instance ID
*/
this.idTextField = new XBayaTextField();
XBayaLabel idLabel = new XBayaLabel("AMI/Instance ID", this.amiButton);
/*
* Username
*/
this.usernameTextField = new XBayaTextField();
XBayaLabel usernameLabel = new XBayaLabel("Username", this.amiButton);
GridPanel gridPanel = new GridPanel();
gridPanel.add(nameLabel);
gridPanel.add(this.nameTextField);
gridPanel.add(radioLabel);
gridPanel.add(amiPanel);
gridPanel.add(new JPanel());
gridPanel.add(this.idButton);
gridPanel.add(idLabel);
gridPanel.add(this.idTextField);
gridPanel.add(usernameLabel);
gridPanel.add(this.usernameTextField);
gridPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1);
JButton okButton = new JButton("OK");
okButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (InstanceConfigurationDialog.this.idTextField.getText() == null || InstanceConfigurationDialog.this.idTextField.getText().isEmpty()) {
InstanceConfigurationDialog.this.xbayaGUI.getErrorWindow().error("Please input AMI ID or Instance ID");
return;
}
if (InstanceConfigurationDialog.this.usernameTextField.getText() == null || InstanceConfigurationDialog.this.usernameTextField.getText().isEmpty()) {
InstanceConfigurationDialog.this.xbayaGUI.getErrorWindow().error("Please input username to access instance");
return;
}
InstanceConfigurationDialog.this.node.setStartNewInstance(InstanceConfigurationDialog.this.amiButton.isSelected());
if (InstanceConfigurationDialog.this.amiButton.isSelected()) {
InstanceConfigurationDialog.this.node.setAmiId(InstanceConfigurationDialog.this.idTextField.getText());
InstanceConfigurationDialog.this.node.setInstanceType(InstanceConfigurationDialog.this.instanceTypeComboBox.getText());
} else {
InstanceConfigurationDialog.this.node.setInstanceId(InstanceConfigurationDialog.this.idTextField.getText());
InstanceConfigurationDialog.this.node.setInstanceType(null);
}
InstanceConfigurationDialog.this.node.setUsername(InstanceConfigurationDialog.this.usernameTextField.getText());
hide();
}
});
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
hide();
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
this.dialog = new XBayaDialog(this.xbayaGUI, "Instance Configuration", gridPanel, buttonPanel);
this.dialog.setDefaultButton(okButton);
}
use of org.apache.airavata.xbaya.ui.widgets.XBayaComboBox in project airavata by apache.
the class EC2LaunchWindow method initGUI.
private void initGUI() {
/* Main Panel */
this.amiTextField = new XBayaTextField();
XBayaLabel amiLabel = new XBayaLabel("AMI ID", this.amiTextField);
this.numberOfInstanceSpinner = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
XBayaLabel nInstanceLabel = new XBayaLabel("Number Of Instances", this.numberOfInstanceSpinner);
this.instanceTypeComboBox = new XBayaComboBox(new DefaultComboBoxModel(AmazonUtil.INSTANCE_TYPE));
this.instanceTypeComboBox.setSelectedItem(AmazonUtil.INSTANCE_TYPE[1]);
XBayaLabel instanceTypeLabel = new XBayaLabel("Instance Type", this.instanceTypeComboBox);
JRadioButton noKeyButton = new JRadioButton("No Key Pair");
noKeyButton.setSelected(true);
noKeyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent paramActionEvent) {
EC2LaunchWindow.this.keyComboBox.getJComboBox().setEnabled(false);
}
});
this.existKeyButton = new JRadioButton("Exist Key Pairs");
this.existKeyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent paramActionEvent) {
if (EC2LaunchWindow.this.keyComboBoxModel == null) {
EC2LaunchWindow.this.keyComboBoxModel = new DefaultComboBoxModel(AmazonUtil.loadKeypairs().toArray());
EC2LaunchWindow.this.keyComboBox.setModel(EC2LaunchWindow.this.keyComboBoxModel);
}
EC2LaunchWindow.this.keyComboBox.getJComboBox().setEnabled(true);
}
});
ButtonGroup serviceTypeButtonGroup = new ButtonGroup();
serviceTypeButtonGroup.add(noKeyButton);
serviceTypeButtonGroup.add(this.existKeyButton);
this.keyComboBox = new XBayaComboBox(new DefaultComboBoxModel());
this.keyComboBox.getJComboBox().setEnabled(false);
GridPanel radioPanel = new GridPanel();
radioPanel.add(noKeyButton);
radioPanel.add(new JPanel());
radioPanel.add(this.existKeyButton);
radioPanel.add(this.keyComboBox);
radioPanel.layout(2, 2, 0, 1);
XBayaLabel keyLabel = new XBayaLabel("Key Pair", radioPanel);
GridPanel mainPanel = new GridPanel(true);
mainPanel.add(amiLabel);
mainPanel.add(this.amiTextField);
mainPanel.add(nInstanceLabel);
mainPanel.add(this.numberOfInstanceSpinner);
mainPanel.add(instanceTypeLabel);
mainPanel.add(this.instanceTypeComboBox);
mainPanel.add(keyLabel);
mainPanel.add(radioPanel);
mainPanel.layout(4, 2, 0, GridPanel.WEIGHT_EQUALLY);
/* Button Panel */
JButton lunchButton = new JButton("Launch");
lunchButton.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
// validation
if (EC2LaunchWindow.this.amiTextField.getText() == null || EC2LaunchWindow.this.amiTextField.getText().isEmpty() || (Integer) EC2LaunchWindow.this.numberOfInstanceSpinner.getValue() <= 0) {
EC2LaunchWindow.this.engine.getGUI().getErrorWindow().info(EC2LaunchWindow.this.dialog.getDialog(), "Warning", "Please input all fields");
return;
}
try {
// get all data
String ami = EC2LaunchWindow.this.amiTextField.getText();
String instanceType = EC2LaunchWindow.this.instanceTypeComboBox.getText();
Integer n = (Integer) EC2LaunchWindow.this.numberOfInstanceSpinner.getValue();
// use exist key pair
if (EC2LaunchWindow.this.existKeyButton.isSelected()) {
String keyname = EC2LaunchWindow.this.keyComboBox.getText();
AmazonUtil.launchInstance(ami, instanceType, n, keyname);
} else {
AmazonUtil.launchInstance(ami, instanceType, n);
}
EC2LaunchWindow.this.hide();
} catch (NumberFormatException nfe) {
EC2LaunchWindow.this.engine.getGUI().getErrorWindow().info(EC2LaunchWindow.this.dialog.getDialog(), "Warning", "Number of Instances is not numeric");
} catch (Exception ex) {
EC2LaunchWindow.this.engine.getGUI().getErrorWindow().error(EC2LaunchWindow.this.dialog.getDialog(), "Cannot start EC2 instances: " + ex.getMessage(), ex);
}
}
});
JButton closeButton = new JButton("Close");
closeButton.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
EC2LaunchWindow.this.hide();
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(lunchButton);
buttonPanel.add(closeButton);
this.dialog = new XBayaDialog(this.engine.getGUI(), "Amazon EC2 Launcher", mainPanel, buttonPanel);
}
use of org.apache.airavata.xbaya.ui.widgets.XBayaComboBox in project airavata by apache.
the class RegistryWindow method initGUI.
/**
* Initializes the GUI.
*/
private void initGUI() {
this.serverTextField = new XBayaTextField();
this.portTextField = new XBayaTextField();
this.gatewayIdTextField = new XBayaTextField();
this.usernameTextField = new XBayaTextField();
this.serverTextField.setText("localhost");
this.portTextField.setText("8930");
this.gatewayIdTextField.setText("sample");
this.usernameTextField.setText("airavata");
ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
if (thriftClientData != null) {
this.serverTextField.setText(thriftClientData.getServerAddress());
this.gatewayIdTextField.setText(thriftClientData.getGatewayId());
this.portTextField.setText(String.valueOf(thriftClientData.getServerPort()));
this.usernameTextField.setText(thriftClientData.getUsername());
}
try {
ClientSettings.initializeTrustStore();
} catch (ApplicationSettingsException e) {
throw new RuntimeException("An error occurred while initializing client configurations");
}
XBayaLabel serverAddressLabel = new XBayaLabel("Server Address", this.serverTextField);
XBayaLabel serverPortLabel = new XBayaLabel("Server Port", this.portTextField);
XBayaLabel gatewayNameLabel = new XBayaLabel("Gateway ID", this.gatewayIdTextField);
XBayaLabel gatewayUserLabel = new XBayaLabel("Gateway User", this.usernameTextField);
serviceTypeModel = new DefaultComboBoxModel(ThriftServiceType.values());
serviceTypeModel.setSelectedItem(getServiceType());
this.serviceTypeCombo = new XBayaComboBox(serviceTypeModel);
JLabel serviceTypeLabel = new JLabel("Airavata Service");
// serviceTypeCombo.addActionListener(new AbstractAction() {
// public void actionPerformed(ActionEvent e) {
// // createNewUser();
// }
// });
GridPanel infoPanel = new GridPanel();
infoPanel.add(serviceTypeLabel);
infoPanel.add(this.serviceTypeCombo);
infoPanel.add(serverAddressLabel);
infoPanel.add(this.serverTextField);
infoPanel.add(serverPortLabel);
infoPanel.add(this.portTextField);
infoPanel.add(gatewayNameLabel);
infoPanel.add(this.gatewayIdTextField);
infoPanel.add(gatewayUserLabel);
infoPanel.add(this.usernameTextField);
infoPanel.layout(5, 2, GridPanel.WEIGHT_NONE, 1);
// infoPanel.layout(2, 2, GridPanel.WEIGHT_NONE, 1);
infoPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
JButton okButton = new JButton("OK");
okButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
ok();
}
});
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
hide();
}
});
GridPanel buttonPanel = new GridPanel();
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
buttonPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
this.dialog = new XBayaDialog(this.engine.getGUI(), "Configure Airavata Thrift Service", infoPanel, buttonPanel);
this.dialog.setDefaultButton(okButton);
}
Aggregations