You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2011/12/19 00:28:48 UTC
svn commit: r1220562 - in
/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya:
appwrapper/ menues/edit/ registrybrowser/ registrybrowser/nodes/
Author: samindaw
Date: Sun Dec 18 23:28:47 2011
New Revision: 1220562
URL: http://svn.apache.org/viewvc?rev=1220562&view=rev
Log:
https://issues.apache.org/jira/browse/AIRAVATA-235
fixed for service descs
Added:
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/DescriptorEditorDialog.java
Modified:
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/JCRBrowserPanel.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/AbstractAiravataTreeNode.java
incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/ServiceDescriptionNode.java
Added: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/DescriptorEditorDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/DescriptorEditorDialog.java?rev=1220562&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/DescriptorEditorDialog.java (added)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/DescriptorEditorDialog.java Sun Dec 18 23:28:47 2011
@@ -0,0 +1,335 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.appwrapper;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.apache.airavata.common.utils.SwingUtil;
+import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.registry.api.Registry;
+import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.gui.GridPanel;
+import org.apache.airavata.xbaya.gui.XBayaDialog;
+import org.apache.airavata.xbaya.registrybrowser.nodes.JCRBrowserIcons;
+
+public class DescriptorEditorDialog extends JDialog {
+
+ private static final long serialVersionUID = 478151437279682576L;
+
+ private XBayaEngine engine;
+
+ private XBayaDialog dialog;
+
+ private Registry registry;
+
+ private JList descriptorList;
+
+ private Map<ApplicationDeploymentDescription,String> dlist;
+
+ private JButton editButton;
+
+ private AbstractButton removeButton;
+
+ public enum DescriptorType{
+ HOST,
+ SERVICE,
+ APPLICATION
+ };
+
+ public DescriptorType descriptorType;
+
+ /**
+ * @param engine XBaya workflow engine
+ */
+ public DescriptorEditorDialog(XBayaEngine engine,DescriptorType descriptorType) {
+ this.engine = engine;
+ setRegistry(engine.getConfiguration().getJcrComponentRegistry().getRegistry());
+ this.descriptorType=descriptorType;
+ initGUI();
+
+ }
+
+ /**
+ * Displays the dialog.
+ */
+ public void show() {
+ this.dialog.show();
+ }
+
+ public void hide() {
+ this.dialog.hide();
+ }
+
+ /**
+ * Initializes the GUI.
+ */
+ private void initGUI() {
+ descriptorList= new JList(new DefaultListModel());
+ descriptorList.setCellRenderer(new DescriptorListCellRenderer(descriptorType));
+ JScrollPane pane = new JScrollPane(descriptorList);
+
+ GridPanel infoPanel=new GridPanel();
+ infoPanel.add(pane);
+ infoPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
+ SwingUtil.layoutToGrid(infoPanel.getSwingComponent(), 1, 1, 0, 0);
+
+ JButton newButton = new JButton("New...");
+ newButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ newDescriptor();
+ }
+ });
+ descriptorList.addListSelectionListener(new ListSelectionListener(){
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ boolean isSelected=descriptorList.getSelectedIndex()!=-1;
+ editButton.setEnabled(isSelected);
+ removeButton.setEnabled(isSelected);
+ }
+
+ });
+ editButton = new JButton("Edit...");
+ editButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ editDescriptor();
+ }
+
+ });
+ removeButton = new JButton("Remove");
+ removeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ deleteDescriptor();
+ }
+ });
+ JButton closeButton = new JButton("Close");
+ closeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+
+
+ GridPanel buttonPanel = new GridPanel();
+ buttonPanel.add(newButton);
+ buttonPanel.add(editButton);
+ buttonPanel.add(removeButton);
+ buttonPanel.add(closeButton);
+ buttonPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
+ String title=null;
+ switch (descriptorType){
+ case HOST:
+ title="Host Descriptions";
+ break;
+ case SERVICE:
+ title="Service Descriptions";
+ break;
+ case APPLICATION:
+ title="Application Descriptions";
+ break;
+ }
+ this.dialog = new XBayaDialog(this.engine, title, infoPanel, buttonPanel);
+ this.dialog.setDefaultButton(editButton);
+ editButton.setEnabled(false);
+ removeButton.setEnabled(false);
+ loadDescriptors();
+ }
+
+ private void editDescriptor() {
+ switch (descriptorType){
+ case HOST:
+ break;
+ case SERVICE:
+ ServiceDescription d = (ServiceDescription) getSelected();
+ ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(getRegistry(),false,d);
+ serviceDescriptionDialog.open();
+ break;
+ case APPLICATION:
+ break;
+ }
+ }
+
+ private void newDescriptor() {
+ switch (descriptorType){
+ case HOST:
+ HostDescriptionDialog hostDescriptionDialog = new HostDescriptionDialog(engine);
+ hostDescriptionDialog.show();
+ if (hostDescriptionDialog.isHostCreated()){
+ loadDescriptors();
+ }
+ break;
+ case SERVICE:
+ ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(getRegistry());
+ serviceDescriptionDialog.open();
+ if (serviceDescriptionDialog.isServiceCreated()){
+ loadDescriptors();
+ }
+ break;
+ case APPLICATION:
+ ApplicationDescriptionDialog applicationDescriptionDialog = new ApplicationDescriptionDialog(engine);
+ applicationDescriptionDialog.open();
+ if (applicationDescriptionDialog.isApplicationDescCreated()){
+ loadDescriptors();
+ }
+ break;
+ }
+
+ }
+
+ private Object getSelected() {
+ return descriptorList.getModel().getElementAt(descriptorList.getSelectedIndex());
+ }
+ protected boolean askQuestion(String title, String question) {
+ return JOptionPane.showConfirmDialog(null, question, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
+ }
+ private boolean deleteDescriptor(){
+ String title=null;
+ String question=null;
+ switch (descriptorType){
+ case HOST:
+ HostDescription h = (HostDescription) getSelected();
+ title = "Host description";
+ question = "Are you sure that you want to remove the service description \""
+ + h.getType().getHostName() + "\"?";
+ break;
+ case SERVICE:
+ ServiceDescription d = (ServiceDescription) getSelected();
+ title = "Service description";
+ question = "Are you sure that you want to remove the service description \""
+ + d.getType().getName() + "\"?";
+ break;
+ case APPLICATION:
+ ApplicationDeploymentDescription a = (ApplicationDeploymentDescription) getSelected();
+ title = "Service description";
+ question = "Are you sure that you want to remove the service description \""
+ + a.getType().getApplicationName().getStringValue() + "\"?";
+ break;
+ }
+
+
+ if (askQuestion(title, question)) {
+ try {
+ switch (descriptorType){
+ case HOST:
+ HostDescription h = (HostDescription) getSelected();
+ getRegistry().deleteHostDescription(h.getType().getHostName());
+ break;
+ case SERVICE:
+ ServiceDescription d = (ServiceDescription) getSelected();
+ getRegistry().deleteServiceDescription(d.getType().getName());
+ break;
+ case APPLICATION:
+ ApplicationDeploymentDescription a = (ApplicationDeploymentDescription) getSelected();
+ String[] s = dlist.get(a).split("$");
+ getRegistry().deleteDeploymentDescription(s[0], s[1], a.getType().getApplicationName().getStringValue());
+ break;
+ }
+ loadDescriptors();
+ } catch (RegistryException e) {
+ this.engine.getErrorWindow().error(e);
+ }
+ }
+ return true;
+ }
+
+ private void loadDescriptors() {
+ descriptorList.removeAll();
+ try {
+ List<?> descriptors=null;
+ switch (descriptorType){
+ case HOST:
+ descriptors = getRegistry().searchHostDescription(".*");
+ break;
+ case SERVICE:
+ descriptors = getRegistry().searchServiceDescription(".*");
+ break;
+ case APPLICATION:
+ dlist=getRegistry().searchDeploymentDescription();
+ descriptors =Arrays.asList(dlist.keySet().toArray(new ApplicationDeploymentDescription[]{}));
+ break;
+ }
+ for (Object d : descriptors) {
+ ((DefaultListModel)descriptorList.getModel()).addElement(d);
+ }
+ } catch (RegistryException e) {
+ engine.getErrorWindow().error(e);
+ }
+ }
+
+ private static class DescriptorListCellRenderer extends DefaultListCellRenderer{
+ private static final long serialVersionUID = -1019715929291926180L;
+ private DescriptorType descriptorType;
+ public DescriptorListCellRenderer(DescriptorType descriptorType) {
+ this.descriptorType=descriptorType;
+ }
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index, boolean isSelected, boolean cellHasFocus) {
+ Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ if (c instanceof JLabel){
+ switch (descriptorType){
+ case HOST:
+ ((JLabel) c).setText(((HostDescription)value).getType().getHostName());
+ ((JLabel) c).setIcon(JCRBrowserIcons.HOST_ICON);
+ break;
+ case SERVICE:
+ ((JLabel) c).setText(((ServiceDescription)value).getType().getName());
+ ((JLabel) c).setIcon(JCRBrowserIcons.SERVICE_ICON);
+ break;
+ case APPLICATION:
+ ((JLabel) c).setText(((ApplicationDeploymentDescription)value).getType().getApplicationName().getStringValue());
+ ((JLabel) c).setIcon(JCRBrowserIcons.APPLICATION_ICON);
+ break;
+ }
+
+ }
+ return c;
+ }
+
+ }
+ public Registry getRegistry() {
+ return registry;
+ }
+
+ public void setRegistry(Registry registry) {
+ this.registry = registry;
+ }
+}
\ No newline at end of file
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java?rev=1220562&r1=1220561&r2=1220562&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java Sun Dec 18 23:28:47 2011
@@ -45,7 +45,6 @@ import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
@@ -79,17 +78,20 @@ public class ServiceDescriptionDialog ex
private boolean serviceCreated = false;
private JLabel lblError;
private ServiceDescription serviceDescription;
+ private ServiceDescription orginalServiceDescription;
private JButton okButton;
private JButton btnDeleteParameter;
private DefaultTableModel defaultTableModel;
private Registry registry;
+ private boolean newDescription;
+ private boolean ignoreTableChanges=false;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
- ServiceDescriptionDialog dialog = new ServiceDescriptionDialog(null);
+ ServiceDescriptionDialog dialog = new ServiceDescriptionDialog(null,true,null);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
@@ -97,24 +99,32 @@ public class ServiceDescriptionDialog ex
}
}
+ public ServiceDescriptionDialog(Registry registry) {
+ this(registry,true,null);
+ }
+
/**
* Create the dialog.
*/
- public ServiceDescriptionDialog(Registry registry) {
+ public ServiceDescriptionDialog(Registry registry, boolean newDescription, ServiceDescription serviceDescription) {
+ setNewDescription(newDescription);
+ this.setOrginalServiceDescription(serviceDescription);
addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent arg0) {
- String baseName = "Service";
- int i = 1;
- String defaultName = baseName + i;
- try {
- while (getRegistry().getServiceDescription(defaultName) != null) {
- defaultName = baseName + (++i);
- }
- } catch (Exception e) {
- }
- txtServiceName.setText(defaultName);
- setServiceName(txtServiceName.getText());
+ if (isNewDescription()) {
+ String baseName = "Service";
+ int i = 1;
+ String defaultName = baseName + i;
+ try {
+ while (getRegistry().getServiceDescription(defaultName) != null) {
+ defaultName = baseName + (++i);
+ }
+ } catch (Exception e) {
+ }
+ txtServiceName.setText(defaultName);
+ setServiceName(txtServiceName.getText());
+ }
}
});
setRegistry(registry);
@@ -132,16 +142,18 @@ public class ServiceDescriptionDialog ex
}
private void initGUI() {
- setTitle("New Service Description");
- setBounds(100, 100, 463, 459);
+ if (isNewDescription()) {
+ setTitle("New Service Description");
+ }else{
+ setTitle("Update Service Description: "+getOrginalServiceDescription().getType().getName());
+ }
+ setBounds(100, 100, 463, 459);
setModal(true);
setLocationRelativeTo(null);
BorderLayout borderLayout = new BorderLayout();
borderLayout.setVgap(5);
borderLayout.setHgap(5);
getContentPane().setLayout(borderLayout);
-// contentPanel.setBorder(null);
-// getContentPane().add(contentPanel, BorderLayout.EAST);
txtServiceName = new XBayaTextField();
txtServiceName.getSwingComponent().addKeyListener(new KeyAdapter() {
@@ -152,7 +164,6 @@ public class ServiceDescriptionDialog ex
});
txtServiceName.setColumns(10);
lblServiceName = new XBayaLabel("Service name",txtServiceName);
- JSeparator separator = new JSeparator();
JLabel lblInputParameters = new JLabel("Service Parameters");
lblInputParameters.setFont(new Font("Tahoma", Font.BOLD, 11));
@@ -178,18 +189,27 @@ public class ServiceDescriptionDialog ex
@Override
public void tableChanged(TableModelEvent arg0) {
- int selectedRow = tblParameters.getSelectedRow();
- if (selectedRow != -1 && defaultTableModel.getRowCount()>0) {
- Object parameterIOType = defaultTableModel.getValueAt(selectedRow, 0);
- Object parameterDataType = defaultTableModel.getValueAt(selectedRow, 2);
- if (parameterIOType == null || parameterIOType.equals("")) {
- defaultTableModel.setValueAt(getIOStringList()[0], selectedRow, 0);
- }
- if (parameterDataType == null || parameterDataType.equals("")) {
- defaultTableModel.setValueAt(getDataTypes()[0], selectedRow, 2);
- }
- }
- addNewRowIfLastIsNotEmpty();
+ if (!ignoreTableChanges) {
+ int selectedRow = tblParameters.getSelectedRow();
+ if (selectedRow != -1
+ && defaultTableModel.getRowCount() > 0) {
+ Object parameterIOType = defaultTableModel.getValueAt(
+ selectedRow, 0);
+ Object parameterDataType = defaultTableModel
+ .getValueAt(selectedRow, 2);
+ if (parameterIOType == null
+ || parameterIOType.equals("")) {
+ defaultTableModel.setValueAt(getIOStringList()[0],
+ selectedRow, 0);
+ }
+ if (parameterDataType == null
+ || parameterDataType.equals("")) {
+ defaultTableModel.setValueAt(getDataTypes()[0],
+ selectedRow, 2);
+ }
+ }
+ addNewRowIfLastIsNotEmpty();
+ }
}
});
@@ -238,7 +258,20 @@ public class ServiceDescriptionDialog ex
gbc_panel.gridy = 0;
buttonPane.add(panel);
{
+ JButton resetButton = new JButton("Reset");
+ resetButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ loadData();
+ }
+ });
+ panel.add(resetButton);
+ }
+ {
okButton = new JButton("Save");
+ if (!isNewDescription()){
+ okButton.setText("Update");
+ }
okButton.setEnabled(false);
okButton.addActionListener(new ActionListener() {
@Override
@@ -285,8 +318,35 @@ public class ServiceDescriptionDialog ex
SwingUtil.layoutToGrid(getContentPane(), 2, 1, 0, 0);
setResizable(false);
getRootPane().setDefaultButton(okButton);
+ if (!isNewDescription()){
+ loadData();
+ }
+
}
+ private void loadData() {
+ txtServiceName.setText(getOrginalServiceDescription().getType().getName());
+ setServiceName(txtServiceName.getText());
+
+ if (!isNewDescription()){
+ txtServiceName.setEditable(false);
+ }
+ ignoreTableChanges=true;
+ while(defaultTableModel.getRowCount()>0){
+ defaultTableModel.removeRow(0);
+ }
+ InputParameterType[] iparameters = getOrginalServiceDescription().getType().getInputParametersArray();
+ for (InputParameterType parameter : iparameters) {
+ defaultTableModel.addRow(new Object[] { getIOStringList()[0], parameter.getParameterName(),parameter.getParameterType().getName(),parameter.getParameterDescription()});
+ }
+ OutputParameterType[] oparameters = getOrginalServiceDescription().getType().getOutputParametersArray();
+ for (OutputParameterType parameter : oparameters) {
+ defaultTableModel.addRow(new Object[] { getIOStringList()[1], parameter.getParameterName(), parameter.getParameterType().getName(),parameter.getParameterDescription()});
+ }
+ addNewRowIfLastIsNotEmpty();
+ ignoreTableChanges=false;
+ }
+
private String[] getIOStringList() {
String[] ioStringList = new String[] { "Input", "Output" };
return ioStringList;
@@ -354,7 +414,7 @@ public class ServiceDescriptionDialog ex
throw e;
}
}
- if (serviceDescription2 != null) {
+ if (isNewDescription() && serviceDescription2 != null) {
throw new Exception("Service descriptor with the given name already exists!!!");
}
}
@@ -443,7 +503,23 @@ public class ServiceDescriptionDialog ex
this.registry = registry;
}
- private class StringArrayComboBoxEditor extends DefaultCellEditor {
+ public boolean isNewDescription() {
+ return newDescription;
+ }
+
+ public void setNewDescription(boolean newDescription) {
+ this.newDescription = newDescription;
+ }
+
+ public ServiceDescription getOrginalServiceDescription() {
+ return orginalServiceDescription;
+ }
+
+ public void setOrginalServiceDescription(ServiceDescription orginalServiceDescription) {
+ this.orginalServiceDescription = orginalServiceDescription;
+ }
+
+ private class StringArrayComboBoxEditor extends DefaultCellEditor {
private static final long serialVersionUID = -304464739219209395L;
public StringArrayComboBoxEditor(Object[] items) {
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java?rev=1220562&r1=1220561&r2=1220562&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/edit/EditMenuItem.java Sun Dec 18 23:28:47 2011
@@ -29,6 +29,9 @@ import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.appwrapper.DescriptorEditorDialog;
+import org.apache.airavata.xbaya.appwrapper.DescriptorEditorDialog.DescriptorType;
+import org.apache.airavata.xbaya.util.XBayaUtil;
import org.apache.airavata.xbaya.wf.gui.ParameterPropertyWindow;
import org.apache.airavata.xbaya.wf.gui.WorkflowPropertyWindow;
import org.slf4j.Logger;
@@ -129,11 +132,12 @@ public class EditMenuItem {
JMenuItem menuItem = new JMenuItem("Host Descriptions...");
menuItem.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
- //TODO
- }
+ if (XBayaUtil.acquireJCRRegistry(engine)) {
+ DescriptorEditorDialog dialog = new DescriptorEditorDialog(engine,DescriptorType.HOST);
+ dialog.show();
+ }
+ }
});
- //FIXME enable the menu once this functionality is implemented
- menuItem.setEnabled(false);
return menuItem;
}
@@ -141,11 +145,12 @@ public class EditMenuItem {
JMenuItem menuItem = new JMenuItem("Service Descriptions...");
menuItem.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
- //TODO
+ if (XBayaUtil.acquireJCRRegistry(engine)) {
+ DescriptorEditorDialog dialog = new DescriptorEditorDialog(engine,DescriptorType.SERVICE);
+ dialog.show();
+ }
}
});
- //FIXME enable the menu once this functionality is implemented
- menuItem.setEnabled(false);
return menuItem;
}
@@ -153,11 +158,12 @@ public class EditMenuItem {
JMenuItem menuItem = new JMenuItem("Application Descriptions...");
menuItem.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
- //TODO
- }
+ if (XBayaUtil.acquireJCRRegistry(engine)) {
+ DescriptorEditorDialog dialog = new DescriptorEditorDialog(engine,DescriptorType.APPLICATION);
+ dialog.show();
+ }
+ }
});
- //FIXME enable the menu once this functionality is implemented
- menuItem.setEnabled(false);
return menuItem;
}
}
\ No newline at end of file
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/JCRBrowserPanel.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/JCRBrowserPanel.java?rev=1220562&r1=1220561&r2=1220562&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/JCRBrowserPanel.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/JCRBrowserPanel.java Sun Dec 18 23:28:47 2011
@@ -29,6 +29,7 @@ import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
@@ -125,7 +126,14 @@ public class JCRBrowserPanel extends JPa
triggerNodeAction(EditAction.ID);
}
});
-
+ tree.addMouseListener(new MouseAdapter(){
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2){
+ triggerNodeAction(null);
+ }
+ }
+ });
browserActions.add(actionRefresh);
browserActions.add(actionAdd);
browserActions.add(actionDelete);
@@ -232,6 +240,9 @@ public class JCRBrowserPanel extends JPa
if (o instanceof AbstractAiravataTreeNode) {
AbstractAiravataTreeNode node = ((AbstractAiravataTreeNode) o);
try {
+ if (action==null){
+ action=node.getDefaultAction();
+ }
node.triggerAction(tree, action);
} catch (Exception e) {
e.printStackTrace();
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/AbstractAiravataTreeNode.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/AbstractAiravataTreeNode.java?rev=1220562&r1=1220561&r2=1220562&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/AbstractAiravataTreeNode.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/AbstractAiravataTreeNode.java Sun Dec 18 23:28:47 2011
@@ -21,21 +21,26 @@
package org.apache.airavata.xbaya.registrybrowser.nodes;
-import org.apache.airavata.registry.api.Registry;
-import org.apache.airavata.xbaya.XBayaEngine;
-import org.apache.airavata.xbaya.registrybrowser.menu.AbstractBrowserActionItem;
-import org.apache.airavata.xbaya.registrybrowser.menu.RefreshAction;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
-import javax.swing.*;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
+
+import org.apache.airavata.registry.api.Registry;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.registrybrowser.menu.AbstractBrowserActionItem;
+import org.apache.airavata.xbaya.registrybrowser.menu.RefreshAction;
public abstract class AbstractAiravataTreeNode implements TreeNode {
@@ -157,6 +162,10 @@ public abstract class AbstractAiravataTr
}
public abstract List<String> getSupportedActions();
+
+ public String getDefaultAction() {
+ return null;
+ }
public boolean isActionSupported(AbstractBrowserActionItem action) {
return getSupportedActions().contains(action.getID());
Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/ServiceDescriptionNode.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/ServiceDescriptionNode.java?rev=1220562&r1=1220561&r2=1220562&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/ServiceDescriptionNode.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/registrybrowser/nodes/ServiceDescriptionNode.java Sun Dec 18 23:28:47 2011
@@ -26,12 +26,12 @@ import java.util.Arrays;
import java.util.List;
import javax.swing.Icon;
-import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.tree.TreeNode;
import org.apache.airavata.commons.gfac.type.ServiceDescription;
import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.xbaya.appwrapper.ServiceDescriptionDialog;
import org.apache.airavata.xbaya.registrybrowser.menu.AbstractBrowserActionItem;
import org.apache.airavata.xbaya.registrybrowser.menu.DeleteAction;
import org.apache.airavata.xbaya.registrybrowser.menu.EditAction;
@@ -84,22 +84,31 @@ public class ServiceDescriptionNode exte
public boolean triggerAction(JTree tree, String action) throws Exception {
if (action.equals(DeleteAction.ID)) {
- deleteHostDescription(tree);
- return true;
+ return deleteServiceDescription(tree);
} else if (action.equals(EditAction.ID)) {
- JOptionPane.showMessageDialog(null, "TODO");
- return true;
+ return editServiceDescription(tree);
}
return super.triggerAction(tree, action);
}
- private void deleteHostDescription(JTree tree) throws RegistryException {
+ private boolean editServiceDescription(JTree tree) {
+ ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(getRegistry(),false,getServiceDescription());
+ serviceDescriptionDialog.open();
+ if (serviceDescriptionDialog.isServiceCreated()) {
+ refresh();
+ reloadTreeNode(tree, this);
+ }
+ return true;
+ }
+
+ private boolean deleteServiceDescription(JTree tree) throws RegistryException {
if (askQuestion("Service description", "Are you sure that you want to remove the service description \""
+ getServiceDescription().getType().getName() + "\"?")) {
getRegistry().deleteServiceDescription(getServiceDescription().getType().getName());
((AbstractAiravataTreeNode) getParent()).refresh();
reloadTreeNode(tree, getParent());
}
+ return true;
}
@Override
@@ -107,7 +116,7 @@ public class ServiceDescriptionNode exte
if (action.getID().equals(DeleteAction.ID)) {
return "Remove";
} else if (action.getID().equals(EditAction.ID)) {
- return "Edit";
+ return "View/Edit";
}
return action.getDefaultCaption();
}
@@ -121,4 +130,9 @@ public class ServiceDescriptionNode exte
public String getActionDescription(AbstractBrowserActionItem action) {
return null;
}
+
+ @Override
+ public String getDefaultAction() {
+ return EditAction.ID;
+ }
}