Search in sources :

Example 1 with EventData

use of org.apache.airavata.xbaya.messaging.EventData in project airavata by apache.

the class MonitorPanel method init.

private void init() {
    this.table = new JTable(this.tableSliderModel) {

        @Override
        public String getToolTipText(MouseEvent event) {
            String tip = null;
            Point point = event.getPoint();
            int colIndex = columnAtPoint(point);
            if (colIndex == EventDataRepository.Column.MESSAGE.ordinal()) {
                tip = "Double click here to see the full message.";
            }
            return tip;
        }
    };
    this.table.getTableHeader().setReorderingAllowed(false);
    this.table.addMouseListener(new MouseInputAdapter() {

        private MonitorWindow window;

        @Override
        public void mouseClicked(MouseEvent event) {
            Point point = event.getPoint();
            int row = MonitorPanel.this.table.rowAtPoint(point);
            if (row >= 0 && row < MonitorPanel.this.table.getRowCount()) {
                EventData message = MonitorPanel.this.tableSliderModel.getEvent(row);
                int clickCount = event.getClickCount();
                if (clickCount == 1) {
                /*                     if (MonitorUtil.getType(message) == MonitorUtil.EventType.PUBLISH_URL) {
                            int column = MonitorPanel.this.table.columnAtPoint(point);
                            if (column == EventDataRepository.Column.MESSAGE.ordinal()) {
                                String url = MonitorUtil.getLocation(message);
                                try {
                                    BrowserLauncher.openURL(url);
                                } catch (Exception e) {
                                    MonitorPanel.this.xbayaGUI.getErrorWindow().error(e.getMessage(), e);
                                }
                            }
                        } else if (MonitorUtil.getType(message) == MonitorUtil.EventType.SENDING_RESULT) {
                            if (null != message && null != message.element("result")
                                    && null != message.element("result").element("body")
                                    && null != message.element("result").element("body").element("Body")) {
                                XmlElement body = message.element("result").element("body").element("Body");
                                Iterator bodyItr = body.children().iterator();
                                // find the first body Element
                                findAndLaunchBrowser(bodyItr);
                                // XmlElement output = message.element("result").element("body").
                                // element("Body").element("Visualize_OutputParams").element("Visualized_Output");
                                // Iterator children = output.children().iterator();
                                // while (children.hasNext()) {
                                // Object object = (Object) children.next();
                                // if(object instanceof String){
                                // try {
                                // new URL(((String)object).trim());
                                // try {
                                // BrowserLauncher.openURL(((String)object).trim());
                                // } catch (Throwable e) {
                                // //do nothing
                                // }
                                // } catch (MalformedURLException e) {
                                // //do nothing
                                // }
                                // }
                                //
                                // }
                            }
                        }*/
                } else if (clickCount >= 2) {
                    // Handle double clicks to pop up a window.
                    if (this.window == null) {
                        this.window = new MonitorWindow(MonitorPanel.this.xbayaGUI);
                    }
                    this.window.show(message);
                }
            }
        }

        /**
         * @param bodyItr
         */
        private void findAndLaunchBrowser(Iterator bodyItr) {
            if (bodyItr.hasNext()) {
                Object firstElement = bodyItr.next();
                if (firstElement instanceof XmlElement) {
                    findAndLuanchBrowser((XmlElement) firstElement);
                }
            }
        }

        /**
         * @param firstElement
         */
        private void findAndLuanchBrowser(XmlElement firstElement) {
            Iterator children = ((XmlElement) firstElement).children().iterator();
            while (children.hasNext()) {
                Object object = (Object) children.next();
                if (object instanceof String) {
                    try {
                        new URL(((String) object).trim());
                        try {
                            BrowserLauncher.openURL(((String) object).trim());
                        } catch (Throwable e) {
                        // do nothing
                        }
                    } catch (MalformedURLException e) {
                    // do nothing
                    }
                } else if (object instanceof XmlElement) {
                    findAndLuanchBrowser((XmlElement) object);
                }
            }
        }
    });
    // Adjust size of columns
    TableColumnModel columnModel = this.table.getColumnModel();
    int columnCount = columnModel.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        TableColumn column = columnModel.getColumn(i);
        if (i == columnCount - 1) {
            column.setPreferredWidth(500);
        } else {
            column.setPreferredWidth(50);
        }
    }
    this.table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    this.scrollPane = new JScrollPane(this.table);
    this.scrollPane.setMinimumSize(SwingUtil.MINIMUM_SIZE);
    this.scrollPane.setDoubleBuffered(true);
    this.slider = new JSlider(this.tableSliderModel);
    this.slider.setSnapToTicks(true);
    this.slider.setEnabled(false);
    this.panel = new JPanel();
    this.panel.setLayout(new BorderLayout());
    this.panel.add(this.scrollPane, BorderLayout.CENTER);
    this.panel.add(this.slider, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MalformedURLException(java.net.MalformedURLException) MouseEvent(java.awt.event.MouseEvent) MonitorWindow(org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow) TableColumnModel(javax.swing.table.TableColumnModel) Point(java.awt.Point) TableColumn(javax.swing.table.TableColumn) EventData(org.apache.airavata.xbaya.messaging.EventData) URL(java.net.URL) Point(java.awt.Point) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) Iterator(java.util.Iterator) XmlElement(org.xmlpull.infoset.XmlElement) JSlider(javax.swing.JSlider) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Example 2 with EventData

use of org.apache.airavata.xbaya.messaging.EventData in project airavata by apache.

the class WorkflowModifier method getOutput.

private String getOutput(String nodeID, String messageName, String parameterName) throws MonitorException {
    List<EventData> events = this.eventData.getEvents();
    for (EventData event : events) {
        // String value = parameter.requiredText();
        return event.getMessage();
    }
    // TODO
    String message = "Couldn't find a notification of the output from the service with nodeID, " + nodeID;
    throw new MonitorException(message);
}
Also used : EventData(org.apache.airavata.xbaya.messaging.EventData) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Example 3 with EventData

use of org.apache.airavata.xbaya.messaging.EventData in project airavata by apache.

the class WorkflowModifier method getWorkflowInput.

private String getWorkflowInput(String nodeID) throws MonitorException {
    logger.debug("Node:" + nodeID);
    List<EventData> events = this.eventData.getEvents();
    for (EventData event : events) {
        // String value = parameter.requiredText();
        return event.getMessage();
    }
    // TODO
    String message = "Couldn't find a notification of about the input with nodeID, " + nodeID;
    throw new MonitorException(message);
}
Also used : EventData(org.apache.airavata.xbaya.messaging.EventData) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException)

Aggregations

EventData (org.apache.airavata.xbaya.messaging.EventData)3 MonitorException (org.apache.airavata.xbaya.messaging.MonitorException)2 BorderLayout (java.awt.BorderLayout)1 Point (java.awt.Point)1 MouseEvent (java.awt.event.MouseEvent)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Iterator (java.util.Iterator)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JSlider (javax.swing.JSlider)1 JTable (javax.swing.JTable)1 MouseInputAdapter (javax.swing.event.MouseInputAdapter)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 MonitorWindow (org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow)1 XmlElement (org.xmlpull.infoset.XmlElement)1