Added: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java?view=auto&rev=482181
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
 Mon Dec  4 06:19:10 2006
@@ -0,0 +1,718 @@
+/*
+ *
+ * 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.qpid.management.ui.views;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.apache.qpid.management.ui.ApplicationRegistry;
+import org.apache.qpid.management.ui.Constants;
+import org.apache.qpid.management.ui.ManagedBean;
+import org.apache.qpid.management.ui.ServerRegistry;
+import org.apache.qpid.management.ui.jmx.MBeanUtility;
+import org.apache.qpid.management.ui.model.OperationData;
+import org.apache.qpid.management.ui.model.ParameterData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+
+/**
+ * Control class for the MBean operations tab. It creates the required widgets
+ * for the selected MBean.
+ * @author Bhupendra Bhardwaj
+ *
+ */
+public class OperationTabControl extends TabControl
+{
+    private int heightForAParameter = 30;
+    private int labelNumerator = 30;
+    private int valueNumerator = labelNumerator + 20;
+    
+    private FormToolkit _toolkit;
+    private Form        _form;
+    private OperationData _opData;
+    
+    private SelectionListener operationExecutionListener = new 
OperationExecutionListener(); 
+    private SelectionListener refreshListener = new RefreshListener(); 
+    private SelectionListener parameterSelectionListener = new 
ParameterSelectionListener();
+    private SelectionListener bolleanSelectionListener = new 
BooleanSelectionListener();
+    private VerifyListener    verifyListener = new VerifyListenerImpl();
+    private KeyListener       keyListener = new KeyListenerImpl();
+    private KeyListener       headerBindingListener = new 
HeaderBindingKeyListener();
+    
+    private Composite _headerComposite = null;
+    private Composite _paramsComposite = null;
+    private Composite _resultsComposite = null;
+    private Button _executionButton = null;
+    
+    // for customized method in header exchange
+    private HashMap<Text, Text> headerBindingHashMap = null;
+    
+    public OperationTabControl(TabFolder tabFolder)
+    {
+        super(tabFolder);
+        _toolkit = new FormToolkit(_tabFolder.getDisplay());
+        _form = _toolkit.createForm(_tabFolder);
+        _form.getBody().setLayout(new GridLayout());
+        
+        // Form area is devided in four parts:
+        // Header composite - displays operaiton information
+        // Patameters composite - displays parameters if there
+        // Button - operation execution button
+        // Results composite - displays results for operations, which have 
+        //                     no parameters but have some return value
+        _headerComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
+        _headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, 
false));
+        
+        _paramsComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
+        _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, 
false));
+        
+        _executionButton = _toolkit.createButton(_form.getBody(), 
Constants.BUTTON_EXECUTE, SWT.PUSH | SWT.CENTER);
+        
_executionButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON));
+        GridData layoutData = new GridData(SWT.CENTER, SWT.TOP, true, false);
+        layoutData.verticalIndent = 20;
+        _executionButton.setLayoutData(layoutData);
+        
+        _resultsComposite = _toolkit.createComposite(_form.getBody(), 
SWT.NONE);
+        layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+        layoutData.verticalIndent = 20;
+        _resultsComposite.setLayoutData(layoutData);
+        _resultsComposite.setLayout(new GridLayout());
+    }
+    
+    public Control getControl()
+    {
+        return _form;
+    }
+    
+    public void refresh(ManagedBean mbean)
+    {
+        _mbean = mbean;
+        ServerRegistry serverRegistry = 
ApplicationRegistry.getServerRegistry(mbean);     
+        _opData = 
serverRegistry.getOperationModel(mbean).getOperations().get(0);
+        refresh(_mbean, _opData);
+    }
+    public void refresh(ManagedBean mbean, OperationData opData)
+    {
+        _mbean = mbean;
+        _opData = opData;
+        
+        // Setting the form to be invisible. Just in case the mbean server 
connection
+        // is done and it takes time in getting the response, then the ui 
should be blank
+        // instead of having half the widgets displayed.
+        _form.setVisible(false);
+        
+        ViewUtility.disposeChildren(_headerComposite);
+        ViewUtility.disposeChildren(_paramsComposite);
+        ViewUtility.disposeChildren(_resultsComposite);
+        
+        setHeader();
+        createParameterWidgets();
+        
+        List<ParameterData> params = opData.getParameters();
+        if (params != null && !params.isEmpty())
+        {            
+            setButton(Constants.BUTTON_EXECUTE);
+        }
+        else if (opData.getImpact() == Constants.OPERATION_IMPACT_ACTION)
+        {
+            setButton(Constants.BUTTON_EXECUTE);
+        }
+        else if (opData.getImpact() == Constants.OPERATION_IMPACT_INFO)
+        {
+            setButton(Constants.BUTTON_REFRESH);
+            executeAndShowResults();
+        }
+        
+        _form.setVisible(true);
+        _form.layout();
+    }
+    
+    private void setHeader()
+    {
+        _form.setText(ViewUtility.getDisplayText(_opData.getName()));
+        _headerComposite.setLayout(new GridLayout(2, false));
+        //operation description
+        Label label = _toolkit.createLabel(_headerComposite,  
Constants.DESCRIPTION);
+        label.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD));
+        label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false));
+        
+        label = _toolkit.createLabel(_headerComposite,  
_opData.getDescription());
+        label.setFont(ApplicationRegistry.getFont(Constants.FONT_NORMAL));
+        label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, true, false));
+        
+        _headerComposite.layout();
+    }
+    
+    private void createParameterWidgets()
+    {
+        List<ParameterData> params = _opData.getParameters();
+        if (params == null || params.isEmpty())
+        {
+            return;
+        }
+        
+        // Customised parameter widgets        
+        if (_mbean.getType().equals(Constants.EXCHANGE) &&
+            "headers".equals(_mbean.getProperty(Constants.EXCHANGE_TYPE)) &&
+            _opData.getName().equalsIgnoreCase("createNewBinding"))
+        {                                  
+            customCreateNewBinding(); 
+            return;
+        }
+        // end of Customised parameter widgets       
+        
+        _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, 
false));
+        _paramsComposite.setLayout(new FormLayout());
+        for (ParameterData param : params)
+        {            
+            boolean valueInCombo = false;
+            Label label = _toolkit.createLabel(_paramsComposite, 
ViewUtility.getDisplayText(param.getName()));
+            FormData formData = new FormData();
+            formData.top = new FormAttachment(0, params.indexOf(param) * 
heightForAParameter + 2);
+            formData.right = new FormAttachment(labelNumerator);
+            label.setLayoutData(formData);
+            label.setToolTipText(param.getDescription());
+            
+            formData = new FormData();
+            formData.top = new FormAttachment(0, params.indexOf(param) * 
heightForAParameter);
+            formData.left = new FormAttachment(label, 5);
+            formData.right = new FormAttachment(valueNumerator);
+            if (param.getName().equals(Constants.QUEUE))
+            {
+                Combo combo = new Combo(_paramsComposite, SWT.READ_ONLY | 
SWT.DROP_DOWN);
+                String[] items = 
ApplicationRegistry.getServerRegistry(_mbean).getQueueNames();
+                combo.setItems(items);
+                combo.add("Select Queue", 0); 
+                combo.select(0);
+                combo.setLayoutData(formData);
+                combo.setData(param);
+                combo.addSelectionListener(parameterSelectionListener);
+                valueInCombo = true;
+            }
+            else if (param.getName().equals(Constants.EXCHANGE))
+            {
+                Combo combo = new Combo(_paramsComposite, SWT.READ_ONLY | 
SWT.DROP_DOWN);
+                String[] items = 
ApplicationRegistry.getServerRegistry(_mbean).getExchangeNames();
+                combo.setItems(items);
+                combo.add("Select Exchange", 0);
+                combo.select(0);
+                combo.setLayoutData(formData);
+                combo.setData(param);
+                combo.addSelectionListener(parameterSelectionListener);
+                valueInCombo = true;
+            }
+            else if (param.getName().equals(Constants.EXCHANGE_TYPE))
+            {
+                Combo combo = new Combo(_paramsComposite, SWT.READ_ONLY | 
SWT.DROP_DOWN);
+                combo.setItems(Constants.EXCHANGE_TYPE_VALUES);
+                combo.add("Select Exchange Type", 0);
+                combo.select(0);
+                combo.setLayoutData(formData);
+                combo.setData(param);
+                combo.addSelectionListener(parameterSelectionListener);
+                valueInCombo = true;                
+            }
+            else if (param.getType().equals("boolean") || 
param.getType().equals("java.lang.Boolean"))
+            {
+                Combo combo = new Combo(_paramsComposite, SWT.READ_ONLY | 
SWT.DROP_DOWN);
+                combo.setItems(new String[] {"false", "true"});
+                combo.select(0);
+                param.setValueFromString(combo.getItem(0));
+                combo.setLayoutData(formData);
+                combo.setData(param);
+                combo.addSelectionListener(bolleanSelectionListener);
+                valueInCombo = true;                
+            }
+            else
+            {
+                Text text = _toolkit.createText(_paramsComposite, "", 
SWT.NONE);
+                formData = new FormData();
+                formData.top = new FormAttachment(0, params.indexOf(param) * 
heightForAParameter);
+                formData.left = new FormAttachment(label, 5);
+                formData.right = new FormAttachment(valueNumerator);
+                text.setLayoutData(formData);
+                text.addKeyListener(keyListener);
+                text.addVerifyListener(verifyListener);
+                text.setData(param);
+            }
+            
+            // parameter type (int, String etc)
+            if (valueInCombo)
+                label = _toolkit.createLabel(_paramsComposite, "");
+            else
+            {
+                String str = param.getType() ;
+                if (param.getType().lastIndexOf(".") != -1)
+                    str = param.getType().substring(1 + 
param.getType().lastIndexOf("."));
+                
+                label = _toolkit.createLabel(_paramsComposite, "(" + str + 
")");
+            }
+            formData = new FormData();
+            formData.top = new FormAttachment(0, params.indexOf(param) * 
heightForAParameter);
+            formData.left = new FormAttachment(valueNumerator, 5);
+            label.setLayoutData(formData);
+        }
+        
+        
//_parametersHolder.setMinSize(_parametersComposite.computeSize(SWT.DEFAULT, 
SWT.DEFAULT));
+        //_parametersComposite.layout();
+    }
+    
+    private void customCreateNewBinding()
+    {
+        headerBindingHashMap = new HashMap<Text, Text>();
+ 
+        _paramsComposite.setLayout(new GridLayout());
+        _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, 
true));
+        final ScrolledComposite scrolledComposite = new 
ScrolledComposite(_paramsComposite, SWT.BORDER | SWT.V_SCROLL);
+        scrolledComposite.setExpandHorizontal(true);
+        scrolledComposite.setExpandVertical(true);   
+        GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, true);
+        scrolledComposite.setLayoutData(layoutData);
+        scrolledComposite.setLayout(new GridLayout());
+        
+        final Composite composite = 
_toolkit.createComposite(scrolledComposite, SWT.NONE);
+        scrolledComposite.setContent(composite);
+        layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);            
+        layoutData.verticalIndent = 20;
+        composite.setLayoutData(layoutData);
+        composite.setLayout(new FormLayout());
+        
+        List<ParameterData> params = _opData.getParameters();
+        ParameterData param = params.get(0);
+        // Queue selection widget
+        Label label = _toolkit.createLabel(composite, 
ViewUtility.getDisplayText(param.getName()));
+        FormData formData = new FormData();
+        formData.top = new FormAttachment(0, 2);
+        formData.right = new FormAttachment(labelNumerator);
+        label.setLayoutData(formData);
+        label.setToolTipText(param.getDescription());
+        
+        formData = new FormData();
+        formData.top = new FormAttachment(0);
+        formData.left = new FormAttachment(label, 5);
+        formData.right = new FormAttachment(valueNumerator);
+
+        Combo combo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN);
+        String[] items = 
ApplicationRegistry.getServerRegistry(_mbean).getQueueNames();
+        combo.setItems(items);
+        combo.add("Select Queue", 0); 
+        combo.select(0);
+        combo.setLayoutData(formData);
+        combo.setData(param);
+        combo.addSelectionListener(parameterSelectionListener);
+
+        // Binding creation widgets
+        createARowForCreatingHeadersBinding(composite, 1);
+        createARowForCreatingHeadersBinding(composite, 2);
+        createARowForCreatingHeadersBinding(composite, 3);
+        createARowForCreatingHeadersBinding(composite, 4);
+        createARowForCreatingHeadersBinding(composite, 5);
+        createARowForCreatingHeadersBinding(composite, 6);
+        createARowForCreatingHeadersBinding(composite, 7);
+        createARowForCreatingHeadersBinding(composite, 8);
+        
+        final Button addMoreButton = _toolkit.createButton(composite, "Add 
More", SWT.PUSH);
+        formData = new FormData();
+        formData.top = new FormAttachment(0, heightForAParameter);
+        formData.left = new FormAttachment(70, 5);
+        addMoreButton.setLayoutData(formData);
+        addMoreButton.setData("rowCount", 8);
+        addMoreButton.addSelectionListener(new SelectionAdapter()
+            {
+                public void widgetSelected(SelectionEvent e)
+                {
+                    int count = 
Integer.parseInt(addMoreButton.getData("rowCount").toString());
+                    createARowForCreatingHeadersBinding(composite, ++count);
+                    addMoreButton.setData("rowCount", count);
+                    
scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+                    composite.layout();
+                    _form.layout();
+                }
+            });
+          
+        scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, 
SWT.DEFAULT));
+        composite.layout();
+    }
+    
+    private void createARowForCreatingHeadersBinding(Composite parent, int 
rowCount)
+    {  
+        Label key = _toolkit.createLabel(parent, "Name");
+        FormData formData = new FormData();
+        formData.top = new FormAttachment(0, rowCount * heightForAParameter + 
2);
+        formData.right = new FormAttachment(15);
+        key.setLayoutData(formData);
+        
+        Text keyText = _toolkit.createText(parent, "", SWT.NONE);
+        formData = new FormData();
+        formData.top = new FormAttachment(0, rowCount * heightForAParameter);
+        formData.left = new FormAttachment(key, 5);
+        formData.right = new FormAttachment(40);
+        keyText.setLayoutData(formData);
+        keyText.addKeyListener(headerBindingListener);
+        
+        Label value = _toolkit.createLabel(parent, "Value");
+        formData = new FormData();
+        formData.top = new FormAttachment(0, rowCount * heightForAParameter + 
2);
+        formData.right = new FormAttachment(45);
+        value.setLayoutData(formData);
+        
+        Text valueText = _toolkit.createText(parent, "", SWT.NONE);
+        formData = new FormData();
+        formData.top = new FormAttachment(0, rowCount * heightForAParameter);
+        formData.left = new FormAttachment(value, 5);
+        formData.right = new FormAttachment(70);
+        valueText.setLayoutData(formData);
+        valueText.addKeyListener(headerBindingListener);
+        
+        // Add these to the map, to retrieve the values while setting the 
parameter value
+        headerBindingHashMap.put(keyText, valueText);
+    }
+    
+    private void setButton(String text)
+    {
+        _executionButton.setText(text);
+        _executionButton.removeSelectionListener(refreshListener);
+        _executionButton.removeSelectionListener(operationExecutionListener);
+        
+        if (Constants.BUTTON_EXECUTE.equals(text))
+        {
+            _executionButton.addSelectionListener(operationExecutionListener); 
   
+        }
+        else
+        {
+            _executionButton.addSelectionListener(refreshListener);
+        }
+    }   
+
+    private void populateResults(Object result)
+    {
+        Display display = Display.getCurrent();
+        int width = 600;
+        int height = 400;
+        Shell shell = ViewUtility.createPopupShell("Result", width, height);
+        populateResults(result, shell);
+        
+        shell.open();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) {
+                display.sleep();
+            }
+        }
+        shell.dispose();
+    }
+    
+    private void populateResults(Object result, Composite parent)
+    {
+        if (result instanceof TabularDataSupport)
+        {
+            ViewUtility.createTabularDataHolder(parent, 
(TabularDataSupport)result);
+        }
+        else if (result instanceof CompositeDataSupport)
+        {
+            ViewUtility.populateCompositeDataHolder(parent, 
(CompositeDataSupport)result);
+        }
+    }    
+    
+    /**
+     * clears the parameter values entered.
+     * @param opName
+     
+    private void clearParameterValues()
+    {
+        List<ParameterData> params = _opData.getParameters();
+        if (params != null && !params.isEmpty())
+        {
+            for (ParameterData param : params)
+            {
+                param.setValue(null);
+            }
+            
+            Control[] controls = _paramsComposite.getChildren();
+            
+            for (int i = 0; i < controls.length; i++)
+            {
+                if (controls[i] instanceof Combo)
+                    ((Combo)controls[i]).select(0);
+                else if (controls[i] instanceof Text)
+                    ((Text)controls[i]).setText("");
+            }
+        }
+    }*/
+    
+    private void clearParameters()
+    {
+        List<ParameterData> params = _opData.getParameters();
+        if (params != null && !params.isEmpty())
+        {
+            for (ParameterData param : params)
+            {
+                param.setValue(null);
+            }
+        }
+    }
+    
+    private void clearParameterValues(Composite control)
+    {
+        Control[] controls = control.getChildren();
+        if (controls == null || controls.length == 0)
+            return;
+        
+        for (int i = 0; i < controls.length; i++)
+        {
+            if (controls[i] instanceof Combo)
+                ((Combo)controls[i]).select(0);
+            else if (controls[i] instanceof Text)
+                ((Text)controls[i]).setText("");
+            else if (controls[i] instanceof Composite)
+                clearParameterValues((Composite)controls[i]);
+        }
+    }
+    
+    /**
+     * Listener class for operation execution events
+     */
+    private class OperationExecutionListener extends SelectionAdapter
+    {
+        public void widgetSelected(SelectionEvent e)
+        {
+            List<ParameterData> params = _opData.getParameters();
+            if (params != null && !params.isEmpty())
+            {
+                for (ParameterData param : params)
+                { 
+                    if (param.getValue() == null || 
param.getValue().toString().length() == 0)
+                    {
+                        ViewUtility.popupInfoMessage(_form.getText(),
+                                "Please select the " + 
ViewUtility.getDisplayText(param.getName()));
+                        
+                        return;
+                    }
+                }
+            }
+            
+            if (_opData.getImpact() == Constants.OPERATION_IMPACT_ACTION)
+            {
+                String bean = _mbean.getName() == null ? _mbean.getType() : 
_mbean.getName();
+                int response = ViewUtility.popupConfirmationMessage(bean, 
+                        "Do you want to " + _form.getText()+ " ?");
+                if (response == SWT.YES)
+                {
+                    executeAndShowResults();
+                }            
+            }
+            else
+            {
+                executeAndShowResults();
+            }
+            clearParameters();
+            clearParameterValues(_paramsComposite);
+        }
+    }
+    
+    private class RefreshListener extends SelectionAdapter
+    {
+        public void widgetSelected(SelectionEvent e)
+        {
+            executeAndShowResults();
+        }
+    }
+    
+    
+    private void executeAndShowResults()
+    {
+        Object result = null;
+        try
+        {
+            result = MBeanUtility.execute(_mbean, _opData);     
+        }
+        catch(Exception ex)
+        {
+            MBeanUtility.handleException(_mbean, ex);
+            return;
+        }
+        
+        String title = _mbean.getType();
+        if (_mbean.getName() != null && _mbean.getName().length() != 0)
+        {
+            title = _mbean.getName();
+        }
+        
+        if (_opData.getReturnType().equals("void") || 
_opData.getReturnType().equals("java.lang.Void"))
+        {
+            ViewUtility.popupInfoMessage(title, "Operation successful");
+        }
+        else if (_opData.getParameters() != null && 
!_opData.getParameters().isEmpty())
+        {
+            populateResults(result);
+        }
+        else
+        {
+            ViewUtility.disposeChildren(_resultsComposite);
+            /*
+            if (_resultsComposite == null || _resultsComposite.isDisposed())
+            {
+                _resultsComposite = _toolkit.createComposite(_form.getBody(), 
SWT.NONE);
+                GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, 
true);
+                layoutData.verticalIndent = 20;
+                _resultsComposite.setLayoutData(layoutData);
+                _resultsComposite.setLayout(new GridLayout());
+            }*/
+            populateResults(result, _resultsComposite);
+            _resultsComposite.layout();
+            _form.layout();
+        }
+
+    }
+    
+    /**
+     * Listener class for the operation parameters widget
+     */
+    private class ParameterSelectionListener extends SelectionAdapter
+    {
+        public void widgetSelected(SelectionEvent e)
+        {
+            Combo combo = (Combo)e.widget;
+            ParameterData parameter = (ParameterData)combo.getData();
+            if (combo.getSelectionIndex() > 0)
+            {
+                String item = combo.getItem(combo.getSelectionIndex());        
        
+                parameter.setValueFromString(item);
+            }
+            else
+            {
+                parameter.setValue(null);
+            }
+        }
+    }
+    
+    private class BooleanSelectionListener extends SelectionAdapter
+    {
+        public void widgetSelected(SelectionEvent e)
+        {
+            Combo combo = (Combo)e.widget;
+            ParameterData parameter = (ParameterData)combo.getData();
+            String item = combo.getItem(combo.getSelectionIndex());            
    
+            parameter.setValueFromString(item);
+        }
+    }
+    
+    /**
+     * Listener class for the operation parameter value widget (Text field)
+     */
+    private class KeyListenerImpl extends KeyAdapter
+    {
+        public void keyReleased(KeyEvent e) 
+        {
+            if (!(e.widget instanceof Text))
+                return;
+            
+            Text text = (Text)e.widget;
+            // Get the parameters widget and assign the text to the parameter
+            String strValue = text.getText();
+            ParameterData parameter = (ParameterData)text.getData();
+            parameter.setValueFromString(strValue);
+        }
+    }
+    
+    private class HeaderBindingKeyListener extends KeyAdapter
+    {
+        public void keyReleased(KeyEvent e) 
+        {
+            ParameterData param = _opData.getParameters().get(1);
+            StringBuffer paramValue = new StringBuffer();
+            for (Entry<Text, Text> entry : headerBindingHashMap.entrySet())
+            {
+                
+                Text nameText = entry.getKey();
+                String name = nameText.getText();
+                Text valueText = entry.getValue();
+                String value = valueText.getText();
+                if ((name != null) && (name.length() != 0) && (value != null) 
&& (value.length() != 0))
+                {
+                    if (paramValue.length() != 0)
+                    {
+                        paramValue.append(",");
+                    }
+                    paramValue.append(name + "=" + value);
+                }
+            }
+            
+            param.setValue(paramValue.toString());
+        }
+    }
+    
+    private class VerifyListenerImpl implements VerifyListener
+    {
+        public void verifyText(VerifyEvent event)
+        {
+            Text text = (Text)event.widget;
+            String string = event.text;
+            char [] chars = new char [string.length ()];
+            string.getChars (0, chars.length, chars, 0);
+            
+            ParameterData parameter = (ParameterData)text.getData();
+            String type = parameter.getType();
+            if (type.equals("int") || type.equals("java.lang.Integer") ||
+                type.equals("long") || type.equals("java.lang.Long"))
+            {
+                for (int i=0; i<chars.length; i++)
+                {
+                    if (!('0' <= chars [i] && chars [i] <= '9'))
+                    {
+                        event.doit = false;
+                        return;
+                    }
+                }
+                
+            }
+        }
+    }
+    
+}

Propchange: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java?view=auto&rev=482181
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java
 Mon Dec  4 06:19:10 2006
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.qpid.management.ui.views;
+
+import org.apache.qpid.management.ui.ManagedBean;
+import org.apache.qpid.management.ui.model.OperationData;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TabFolder;
+
+public abstract class TabControl
+{
+    protected ManagedBean _mbean = null;
+    protected TabFolder _tabFolder = null;
+    
+    public TabControl(TabFolder tabFolder)
+    {
+        _tabFolder = tabFolder;
+    }
+    
+    public Control getControl()
+    {
+        return null;
+    }
+    
+    public void refresh(ManagedBean mbean)
+    {
+        
+    }
+    
+    public void refresh(ManagedBean mbean, OperationData opData)
+    {
+        
+    }
+    
+    public void setFocus()
+    {
+        
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java?view=auto&rev=482181
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java
 Mon Dec  4 06:19:10 2006
@@ -0,0 +1,125 @@
+/*
+ *
+ * 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.qpid.management.ui.views;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.qpid.management.ui.Constants;
+import org.apache.qpid.management.ui.ManagedBean;
+import org.apache.qpid.management.ui.ManagedObject;
+
+public class TreeObject
+{
+    private String _name;
+    private String _type;
+    private String _url;
+    private TreeObject _parent;
+    private List<TreeObject> _children = new ArrayList<TreeObject>();
+    private ManagedObject _object;
+    
+    public TreeObject(String name, String type)
+    {
+       this._name = name;
+       this._type = type;
+    }
+    
+    public TreeObject(ManagedObject obj)
+    {
+        _name = obj.getName();
+        if (_name == null && (obj instanceof ManagedBean))
+        {
+            _name = ((ManagedBean)obj).getType();
+        }
+        this._type = Constants.MBEAN;
+        this._object = obj;
+    }
+    
+    public void addChild(TreeObject child)
+    {
+        _children.add(child);
+    }
+    
+    public void addChildren(List<TreeObject> subList)
+    {
+        _children.addAll(subList);
+    }
+    
+    public List<TreeObject> getChildren()
+    {
+        return _children;
+    }
+    
+    public void setChildren(List<TreeObject> children)
+    {
+        this._children = children;
+    }
+    
+    public void setName(String value)
+    {
+        _name = value;
+    }
+    
+    public String getName()
+    {
+        return _name;
+    }
+    public String getType()
+    {
+        return _type;
+    }
+
+    public String getUrl()
+    {
+        return _url;
+    }
+
+    public void setUrl(String url)
+    {
+        this._url = url;
+    }
+
+    public ManagedObject getManagedObject()
+    {
+        return _object;
+    }
+
+    public void setManagedObject(ManagedObject obj)
+    {
+        this._object = obj;
+    }
+    
+    public TreeObject getParent()
+    {
+        return _parent;
+    }
+    
+    public void setParent(TreeObject parent)
+    {
+        this._parent = parent;
+        
+        if (parent != null)
+        {
+            this._url = parent.getUrl();
+            parent.addChild(this);
+        }
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TreeObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java?view=auto&rev=482181
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
 Mon Dec  4 06:19:10 2006
@@ -0,0 +1,512 @@
+/*
+ *
+ * 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.qpid.management.ui.views;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.apache.qpid.management.ui.ApplicationWorkbenchAdvisor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class ViewUtility
+{
+    public static final String OP_NAME     = "operation_name";
+    public static final String OP_PARAMS   = "parameters";
+    public static final String PARAMS_TEXT = "text";
+
+    public static final String FIRST = "First";
+    public static final String LAST  = "Last";
+    public static final String NEXT  = "Next";
+    public static final String PREV  = "Previous";
+    public static final String INDEX = "Index";
+    
+    private static List<String> SUPPORTED_ARRAY_DATATYPES = new 
ArrayList<String>();
+    static
+    {
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.String");
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.Boolean");
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.Character");
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.Integer");
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.Long");
+        SUPPORTED_ARRAY_DATATYPES.add("java.lang.Double");
+        SUPPORTED_ARRAY_DATATYPES.add("java.util.Date");
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void createTabularDataHolder(Composite parent, 
TabularDataSupport tabularData)
+    {
+        Composite composite = new Composite(parent, SWT.BORDER);
+        
//composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
+        //composite.setBackground(parent.getBackground());
+        GridLayout layout = new GridLayout(4, true);
+        layout.horizontalSpacing = 0;
+        layout.marginWidth = 0;
+        layout.marginHeight = 10;
+        layout.verticalSpacing = 10;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        Set entrySet = tabularData.entrySet();
+        ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet);
+        if (list.size() == 0)
+        {
+            Text text = new Text(composite, SWT.CENTER | SWT.SINGLE | 
SWT.READ_ONLY);
+            text.setText(" No records ");
+            //text.setBackground(parent.getBackground());
+            GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 
4, 1);
+            text.setLayoutData(layoutData);
+            return;
+        }  
+        // Attach the tabular record to be retrieve and shown
+        composite.setData(list);
+        
+        // Create button and the composite for CompositeData
+        Composite compositeDataHolder = createCompositeDataHolder(composite,
+                                        
tabularData.getTabularType().getRowType());
+
+        // display the first record
+        CompositeData data = (CompositeData)(list.get(0)).getValue();
+        composite.setData(INDEX, 0);
+        populateCompositeDataHolder(compositeDataHolder, data);
+        enableOrDisableTraversalButtons(composite);
+    }
+
+    public static void enableOrDisableTraversalButtons(Composite composite)
+    {
+        int index = (Integer)composite.getData(INDEX);
+        int size = ((List)composite.getData()).size();
+
+        ((Button)composite.getData(FIRST)).setEnabled(true);
+        ((Button)composite.getData(PREV)).setEnabled(true);
+        ((Button)composite.getData(NEXT)).setEnabled(true);
+        ((Button)composite.getData(LAST)).setEnabled(true);
+
+        if (index == 0)
+        {
+            ((Button)composite.getData(FIRST)).setEnabled(false);
+            ((Button)composite.getData(PREV)).setEnabled(false);
+        }
+        if (index == size -1)
+        {
+            ((Button)composite.getData(NEXT)).setEnabled(false);
+            ((Button)composite.getData(LAST)).setEnabled(false);
+        }
+    }
+
+    public static Composite createCompositeDataHolder(final Composite 
dataHolder, CompositeType compositeType)
+    {        
+        Label description = new Label(dataHolder, SWT.CENTER);
+        description.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, 
false, 4, 1));
+        String desc = compositeType.getDescription();
+        // TODO nameLabel.setFont(font);
+        description.setText(desc);
+
+        // Add traversal buttons
+        final Button firstRecordButton = new Button(dataHolder, SWT.PUSH);
+        firstRecordButton.setText(FIRST);
+        GridData layoutData = new GridData (GridData.HORIZONTAL_ALIGN_END);
+        layoutData.widthHint = 80;
+        firstRecordButton.setLayoutData(layoutData);
+
+        final Button nextRecordButton = new Button(dataHolder, SWT.PUSH);
+        nextRecordButton.setText(NEXT);
+        layoutData = new GridData (GridData.HORIZONTAL_ALIGN_END);
+        layoutData.widthHint = 80;
+        nextRecordButton.setLayoutData(layoutData);
+
+        final Button previousRecordButton = new Button(dataHolder, SWT.PUSH);
+        previousRecordButton.setText(PREV);
+        layoutData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
+        layoutData.widthHint = 80;
+        previousRecordButton.setLayoutData(layoutData);
+
+        final Button lastRecordButton = new Button(dataHolder, SWT.PUSH);
+        lastRecordButton.setText(LAST);
+        layoutData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
+        layoutData.widthHint = 80;
+        lastRecordButton.setLayoutData(layoutData);
+        
+        final Composite composite = new Composite(dataHolder, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.horizontalSpacing = layout.verticalSpacing = 0;
+        layout.marginHeight = layout.marginWidth = 0;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 
4, 1));
+
+        // Add button references.  These references will be used when buttons
+        // are to enabled or disabled based of record index. e.g. for first 
record
+        // First and Previous buttons will be disabled.
+        dataHolder.setData(FIRST, firstRecordButton);
+        dataHolder.setData(NEXT, nextRecordButton);
+        dataHolder.setData(PREV, previousRecordButton);
+        dataHolder.setData(LAST, lastRecordButton);
+
+        // Listener for the traversal buttons
+        SelectionListener listener = new SelectionAdapter()
+        {
+            public void widgetSelected(SelectionEvent e)
+            {
+                if (!(e.widget instanceof Button))
+                    return;
+
+                Button traverseButton =(Button)e.widget; 
+                CompositeData data = getCompositeData(dataHolder, 
traverseButton.getText());
+                populateCompositeDataHolder(composite, data);
+                enableOrDisableTraversalButtons(dataHolder);   
+            }
+        };
+
+        firstRecordButton.addSelectionListener(listener);    
+        nextRecordButton.addSelectionListener(listener);
+        previousRecordButton.addSelectionListener(listener);
+        lastRecordButton.addSelectionListener(listener);
+
+        return composite;
+    }
+    
+    private static CompositeData getCompositeData(Composite compositeHolder, 
String dataIndex)
+    {
+        List objectData = (List)compositeHolder.getData();
+        if (objectData == null || objectData.isEmpty())
+        {
+            //          TODO
+        }
+
+        // Get the index of record to be shown.
+        int index = 0;
+        if (compositeHolder.getData(INDEX) != null)
+        {
+            index = (Integer)compositeHolder.getData(INDEX);
+        }
+
+        if (FIRST.equals(dataIndex))
+        {
+            index = 0;
+        }
+        else if (NEXT.equals(dataIndex))
+        {
+            index = index + 1;
+        }
+        else if (PREV.equals(dataIndex))
+        {
+            index = (index != 0) ? (index = index - 1) : index;
+        }
+        else if (LAST.equals(dataIndex))
+        {
+            index = objectData.size() -1;
+        }
+
+        // Set the index being shown.
+        compositeHolder.setData(INDEX, index);
+        System.out.println("index :" + index);
+
+        return (CompositeData)((Map.Entry)objectData.get(index)).getValue();
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void populateCompositeDataHolder(Composite parent, 
CompositeData data/*String dataIndex*/)
+    {
+        Control[] oldControls = parent.getChildren();       
+        for (int i = 0; i < oldControls.length; i++)
+        {
+            oldControls[i].dispose();
+        }
+        
+        Composite compositeHolder = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout(4, false);
+        layout.horizontalSpacing = 10;
+        compositeHolder.setLayout(layout);
+        compositeHolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, 
true));       
+        
+        
+        // ItemNames in composite data
+        List<String> itemNames = new 
ArrayList<String>(data.getCompositeType().keySet());
+
+        for (String itemName : itemNames)
+        {
+            OpenType itemType = data.getCompositeType().getType(itemName);
+            if (compositeHolder.getData(itemName) == null)
+            {
+                Label keyLabel = new Label(compositeHolder, SWT.TRAIL);
+                keyLabel.setText(itemName);
+                GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, 
false, 1, 1);
+                layoutData.minimumWidth = 70;
+                keyLabel.setLayoutData(layoutData);
+                System.out.println(itemType);
+
+                if (itemType.isArray())
+                {
+                    OpenType type = ((ArrayType)itemType).getElementOpenType();
+                    System.out.println("Array Element type = " + 
type.getClassName());
+                    //  If Byte array and mimetype is text, convert to text 
string
+                    if (type.getClassName().equals(Byte.class.getName()))
+                    {
+                        String mimeType = null; 
+                        String encoding = null;
+                        if (data.containsKey("MimeType"))
+                        {
+                            mimeType = (String)data.get("MimeType");
+                            encoding = (String)data.get("Encoding");
+                            if (encoding == null || encoding.length() == 0)
+                            {
+                                encoding = Charset.defaultCharset().name();
+                            }
+                            
+                            if (mimeType.equals("text/plain"))
+                            {
+                                displayByteArray(compositeHolder, data, 
itemName, encoding);
+                            }
+                        }
+                        else
+                        {
+                            displayNotSupportedDataType(compositeHolder);
+                        }                        
+                    }
+                    // If array of any other supported type, show as a list of 
String array
+                    else if 
(SUPPORTED_ARRAY_DATATYPES.contains(type.getClassName()))
+                    {
+                        displayArrayItem(compositeHolder, data, itemName);
+                    }
+                    else
+                    {
+                        displayNotSupportedDataType(compositeHolder);
+                    }
+                }
+                else if (itemType instanceof TabularType)
+                {
+                    Composite composite = new Composite(compositeHolder, 
SWT.NONE);
+                    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, 
true, false, 3, 1));
+                    layout = new GridLayout();
+                    layout.marginHeight = 0;
+                    layout.marginWidth = 0;
+                    composite.setLayout(layout);
+                    createTabularDataHolder(composite, 
(TabularDataSupport)data.get(itemName));
+                }
+                else
+                {
+                    Text valueText = new Text(compositeHolder, SWT.READ_ONLY | 
SWT.BORDER);
+                    valueText.setText(String.valueOf(data.get(itemName)));
+                    valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, 
true, false, 3, 1));
+                }
+            }
+        }   
+        
+        // layout the composite after creating new widgets.
+        parent.layout();
+    } //end of method
+  
+    
+    private static void displayByteArray(Composite compositeHolder, 
CompositeData data, String itemName, String encoding)
+    {
+        Byte[] arrayItems = (Byte[])data.get(itemName);
+        byte[] byteArray = new byte[arrayItems.length];
+
+        for (int i = 0; i < arrayItems.length; i++)
+        {
+            byteArray[i] = arrayItems[i];
+        }
+        try
+        {
+            String textMessage = new String(byteArray, encoding);
+            System.out.println("\nMessage : \n" + textMessage + "\n");
+
+            Text valueText = new Text(compositeHolder, SWT.READ_ONLY | 
SWT.BORDER |
+                    SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
+            valueText.setText(textMessage);
+            GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 
3, 1);
+            gridData.heightHint = 300;
+            valueText.setLayoutData(gridData);
+        }
+        catch(Exception ex)
+        {
+            ex.printStackTrace();
+        }
+    }
+    
+    public static int popupInfoMessage(String title, String message)
+    {
+        MessageBox messageBox = new 
MessageBox(Display.getCurrent().getActiveShell(), 
+                                    SWT.ICON_INFORMATION | SWT.OK);
+        messageBox.setMessage(message);
+        messageBox.setText(title);
+        int response = messageBox.open();
+        
+        return response;
+    }
+    
+    public static int popupErrorMessage(String title, String message)
+    {
+        MessageBox messageBox = new 
MessageBox(Display.getCurrent().getActiveShell(), 
+                                    SWT.ICON_ERROR | SWT.OK);
+        messageBox.setMessage(message);
+        messageBox.setText(title);
+        int response = messageBox.open();
+        
+        return response;
+    }
+    
+    public static int popupConfirmationMessage(String title, String message)
+    {
+        MessageBox messageBox = new 
MessageBox(Display.getCurrent().getActiveShell(), 
+                                SWT.ICON_QUESTION | SWT.YES | SWT.NO | 
SWT.CANCEL);
+        messageBox.setMessage(message);
+        messageBox.setText(title);
+        int response = messageBox.open();
+        
+        return response;
+    }
+    
+    public static void popupError(String title, String message, Exception ex)
+    {
+        IStatus status = new Status(IStatus.ERROR, 
ApplicationWorkbenchAdvisor.PERSPECTIVE_ID,
+                                    IStatus.ERROR, ex.getMessage(), ex); 
+        ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, 
message, status);
+
+    }
+    
+    public static void popupError(String errorMsg)
+    {
+        Display display = Display.getCurrent();
+        Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN | 
SWT.MAX);
+        shell.setText("Attribute");
+        shell.setLayout(new GridLayout());
+        int x = display.getBounds().width;
+        int y = display.getBounds().height;
+        int width = 500;
+        int height = 250;
+        shell.setBounds(x/4, y/4, width, height);
+        
+        Label label = new Label(shell, SWT.NONE);
+        label.setText(errorMsg);
+        label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false));
+        
+        shell.open();
+        while (!shell.isDisposed()) {
+            if (!display.readAndDispatch()) {
+                display.sleep();
+            }
+        }
+        shell.dispose();
+    }
+    
+    public static Shell createPopupShell(String title, int width, int height)
+    {
+        Display display = Display.getCurrent();
+        Shell shell = new Shell(display, SWT.BORDER | SWT.CLOSE | SWT.MIN 
|SWT.MAX);
+        shell.setText(title);
+        shell.setLayout(new GridLayout());       
+        int x = display.getBounds().width;
+        int y = display.getBounds().height;
+        shell.setBounds(x/4, y/4, width, height); 
+        
+        return shell;
+    }
+    
+    private static void displayArrayItem(Composite compositeHolder, 
CompositeData data, String itemName)
+    {
+        Object[] arrayItems = (Object[])data.get(itemName);
+        String[] items = new String[arrayItems.length];
+        for (int i = 0; i < arrayItems.length; i++)
+        {
+            items[i] = String.valueOf(arrayItems[i]);
+        }
+        org.eclipse.swt.widgets.List list = new 
org.eclipse.swt.widgets.List(compositeHolder,
+                SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | 
SWT.READ_ONLY);
+        list.setItems(items);
+        list.setBackground(compositeHolder.getBackground());
+        list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+    }
+    
+    private static void displayNotSupportedDataType(Composite compositeHolder)
+    {
+        Text valueText = new Text(compositeHolder, SWT.READ_ONLY);
+        valueText.setText("Format is not supported to be displayed");
+        valueText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 
3, 1));
+    }
+    
+    /**
+     * Converts the input string to displayable format by converting some 
character case or inserting space
+     * @param input
+     * @return
+     */
+    public static String getDisplayText(String input)
+    {
+        StringBuffer result = new StringBuffer(input);
+        if (Character.isLowerCase(result.charAt(0)))
+        {
+            result.setCharAt(0, Character.toUpperCase(result.charAt(0)));
+        }
+        for (int i = 1; i < input.length(); i++)
+        {
+            if (Character.isUpperCase(result.charAt(i)) && 
!Character.isWhitespace(result.charAt(i - 1))
+                                                        && 
Character.isLowerCase(result.charAt(i - 1)))
+            {
+                result.insert(i, " ");
+                i++;
+            }
+            else if (Character.isLowerCase(result.charAt(i)) && 
Character.isWhitespace(result.charAt(i - 1)))
+            {
+                result.setCharAt(i, Character.toUpperCase(result.charAt(i)));
+            }
+                
+        }
+        
+        return result.toString();
+    }
+    
+    public static void disposeChildren(Composite parent)
+    {
+        if (parent == null || parent.isDisposed())
+            return;
+        
+        Control[] oldControls = parent.getChildren();        
+        for (int i = 0; i < oldControls.length; i++)
+        {
+            oldControls[i].dispose();
+        }
+    }
+}

Propchange: 
incubator/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/ViewUtility.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/java/management/eclipse-plugin/startup.jar
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/management/eclipse-plugin/startup.jar?view=auto&rev=482181
==============================================================================
Binary file - no diff available.

Propchange: incubator/qpid/trunk/qpid/java/management/eclipse-plugin/startup.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to