From 9876d09ea5ec9718cf7c3e994bb4588ce42b7e17 Mon Sep 17 00:00:00 2001 From: Bhupendra Bhusman Bhardwaj Date: Mon, 18 Dec 2006 17:31:05 +0000 Subject: QPID-213 management GUI improvements git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@488352 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/management/ui/Constants.java | 5 +- .../management/ui/views/AttributesTabControl.java | 251 ++++++++++----------- .../apache/qpid/management/ui/views/MBeanView.java | 72 +----- .../ui/views/NotificationsTabControl.java | 69 ++++-- .../management/ui/views/OperationTabControl.java | 129 +++++++---- .../qpid/management/ui/views/TabControl.java | 15 +- 6 files changed, 270 insertions(+), 271 deletions(-) diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java index e7cd7f4671..adb20b1cd9 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/Constants.java @@ -36,11 +36,12 @@ public class Constants public final static String MBEAN = "mbean"; public final static String ATTRIBUTES = "Attributes"; public final static String NOTIFICATION = "Notifications"; + public final static String RESULT = "Result"; public final static String ALL = "All"; public final static String NAVIGATION_ROOT = "Qpid Connections"; - public final static String DESCRIPTION = " Description : "; + public final static String DESCRIPTION = " Description"; public final static String BROKER_MANAGER = "Broker_Manager"; public final static String QUEUE = "Queue"; @@ -76,6 +77,8 @@ public class Constants public final static String BUTTON_CLEAR = "Clear"; public final static String BUTTON_CONNECT = "Connect"; public final static String BUTTON_CANCEL = "Cancel"; + public final static String BUTTON_UPDATE = "Update"; + public final static int OPERATION_IMPACT_INFO = 0; public final static int OPERATION_IMPACT_ACTION = 1; diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java index 04890e4e63..7a5217d58a 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/AttributesTabControl.java @@ -39,6 +39,7 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -80,6 +81,10 @@ import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; +/** + * Creates controller composite for the attribute's tab. + * @author Bhupendra Bhardwaj + */ public class AttributesTabControl extends TabControl { private FormToolkit _toolkit; @@ -87,10 +92,11 @@ public class AttributesTabControl extends TabControl private Table _table = null; private TableViewer _tableViewer = null; private static final int[] tableWidths = new int[] {300, 300}; - private static final String DESCRIPTION = "Description"; - private static final String UPDATE_BUTTON = "Update"; private final String[] _tableTitles = {"Attribute Name", "Value"}; + private Composite _tableComposite = null; + private Composite _buttonsComposite = null; + private DisposeListener tableDisposeListener = new DisposeListenerImpl(); final Image image; private Button _detailsButton = null; @@ -107,8 +113,6 @@ public class AttributesTabControl extends TabControl private int startX = 80; private int startY = 60; - static int number = 0; - public AttributesTabControl(TabFolder tabFolder) { super(tabFolder); @@ -118,16 +122,28 @@ public class AttributesTabControl extends TabControl gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; _form.getBody().setLayout(gridLayout); + _tableComposite = _toolkit.createComposite(_form.getBody()); + _tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + _tableComposite.setLayout(new GridLayout()); + _buttonsComposite = _toolkit.createComposite(_form.getBody()); + _tableComposite.setLayoutData(new GridData()); + _buttonsComposite.setLayout(new GridLayout()); image = Display.getCurrent().getSystemImage(SWT.ICON_INFORMATION); createWidgets(); } + /** + * @see TabControl#getControl() + */ public Control getControl() { return _form; } + /** + * Creates required widgets for Attribute's tab + */ protected void createWidgets() { createTable(); @@ -136,10 +152,13 @@ public class AttributesTabControl extends TabControl addTableListeners(); } + /** + * Creates table for listing the MBean attributes + */ private void createTable() - { - _table = _toolkit.createTable(_form.getBody(), SWT.FULL_SELECTION); - GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 6); + { + _table = _toolkit.createTable(_tableComposite, SWT.FULL_SELECTION); + GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); _table.setLayoutData(gridData); for (int i = 0; i < _tableTitles.length; ++i) @@ -154,35 +173,18 @@ public class AttributesTabControl extends TabControl _table.setHeaderVisible (true); } + /** + * Creates tableviewer for the attribute's table + * + */ private void createTableViewer() { _tableViewer = new TableViewer(_table); _tableViewer.setUseHashlookup(true); - //_tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 6)); - - // Set the column properties that will be used in callbacks to recognize - // the column on which we will want to operate _tableViewer.setColumnProperties(_tableTitles); - /* - // Create the cell editors - CellEditor[] cellEditors = new CellEditor[_tableTitles.length]; - - - TextCellEditor textEditor = new TextCellEditor(_table); - cellEditors[0] = textEditor; - textEditor = new TextCellEditor(_table); - cellEditors[1] = textEditor; - - // Assign the cell editors to the viewer - _tableViewer.setCellEditors(cellEditors); - _tableViewer.setCellModifier(new TableCellModifier()); - */ - - - _tableViewer.setContentProvider(new ContentProviderImpl()); _tableViewer.setLabelProvider(new LabelProviderImpl()); - + _tableViewer.setSorter(new ViewerSorterImpl()); } private void createButtons() @@ -192,17 +194,13 @@ public class AttributesTabControl extends TabControl addGraphButton(); addRefreshButton(); } - - + private void addDetailsButton() { // Create and configure the button for attribute details - _detailsButton = _toolkit.createButton(_form.getBody(), - Constants.BUTTON_DETAILS, - SWT.PUSH | SWT.CENTER); - + _detailsButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_DETAILS, SWT.PUSH | SWT.CENTER); _detailsButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - GridData gridData = new GridData(SWT.BEGINNING, SWT.TOP, true, false); + GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 80; _detailsButton.setLayoutData(gridData); _detailsButton.addSelectionListener(new SelectionAdapter() @@ -219,14 +217,15 @@ public class AttributesTabControl extends TabControl }); } + /** + * Creates the button for editing attributes. + */ private void addEditButton() { // Create and configure the button for editing attribute - _editButton = _toolkit.createButton(_form.getBody(), - Constants.BUTTON_EDIT_ATTRIBUTE, - SWT.PUSH | SWT.CENTER); + _editButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_EDIT_ATTRIBUTE, SWT.PUSH | SWT.CENTER); _editButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - GridData gridData = new GridData(SWT.BEGINNING, SWT.TOP, true, false); + GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 80; _editButton.setLayoutData(gridData); _editButton.addSelectionListener(new SelectionAdapter() @@ -241,13 +240,14 @@ public class AttributesTabControl extends TabControl }); } + /** + * Creates the button for viewing Graphs + */ private void addGraphButton() { - _graphButton = _toolkit.createButton(_form.getBody(), - Constants.BUTTON_GRAPH, - SWT.PUSH | SWT.CENTER); + _graphButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_GRAPH, SWT.PUSH | SWT.CENTER); _graphButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - GridData gridData = new GridData(SWT.BEGINNING, SWT.TOP, true, false); + GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 80; _graphButton.setLayoutData(gridData); _graphButton.addSelectionListener(new SelectionAdapter() @@ -262,15 +262,15 @@ public class AttributesTabControl extends TabControl }); } + /** + * Creates the "Refresh" button + */ private void addRefreshButton() { - // Create and configure the "Refresh" button - _refreshButton = _toolkit.createButton(_form.getBody(), - Constants.BUTTON_REFRESH, - SWT.PUSH | SWT.CENTER); + _refreshButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); _refreshButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - GridData gridData = new GridData(SWT.BEGINNING, SWT.TOP, true, false); + GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); gridData.widthHint = 80; _refreshButton.setLayoutData(gridData); _refreshButton.addSelectionListener(new SelectionAdapter() @@ -314,25 +314,14 @@ public class AttributesTabControl extends TabControl { event.height = event.gc.getFontMetrics().getHeight() * 3/2; } - }); - - // Below to be worked on to set an image in front of each row. - /* - _table.addListener(SWT.PaintItem, new Listener() { - public void handleEvent(Event event) - { - int x = event.x + event.width; - Rectangle rect = image.getBounds(); - int offset = Math.max(0, (event.height - rect.height) / 2); - event.gc.drawImage(image, event.x, event.y + offset); - } - }); - */ + }); } - private class MouseListenerImpl implements MouseTrackListener, MouseMoveListener, - KeyListener, MouseListener - + /** + * Listeners implementation class for showing table tooltip + * @author Bhupendra Bhardwaj + */ + private class MouseListenerImpl implements MouseTrackListener, MouseMoveListener, KeyListener, MouseListener { Shell tooltipShell = null; Label tooltipLabel = null; @@ -425,6 +414,10 @@ public class AttributesTabControl extends TabControl } } // end of MouseListenerImpl + /** + * Creates pop-up window for showing attribute details + * @param data - Selectes attribute + */ public void createDetailsPopup(AttributeData data) { int width = 500; @@ -448,6 +441,9 @@ public class AttributesTabControl extends TabControl shell.dispose(); } + /** + * Listener class for table tooltip label + */ final Listener tooltipLabelListener = new Listener () { public void handleEvent (Event event) @@ -471,6 +467,11 @@ public class AttributesTabControl extends TabControl }; + /** + * Create the contents for the attribute details window pop-up + * @param shell - The shell that will be filled with details. + * @param attribute - Selected attribute + */ private void createDetailsPopupContents(Composite shell, AttributeData attribute) { GridLayout layout = new GridLayout(2, false); @@ -495,7 +496,7 @@ public class AttributesTabControl extends TabControl // Description label = new Label(parent, SWT.NONE); - label.setText(DESCRIPTION); + label.setText(Constants.DESCRIPTION); label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); value = new Text(parent, SWT.BEGINNING | SWT.BORDER | SWT.READ_ONLY); value.setText(attribute.getDescription()); @@ -576,13 +577,16 @@ public class AttributesTabControl extends TabControl } } + /** + * Create the button for updating attributes. This should be enabled for writable attribute + */ private Button addUpdateButton(Composite parent) { final Button updateButton = new Button(parent, SWT.PUSH | SWT.CENTER); // set the data to access in the listener - parent.setData(UPDATE_BUTTON, updateButton); + parent.setData(Constants.BUTTON_UPDATE, updateButton); - updateButton.setText(UPDATE_BUTTON); + updateButton.setText(Constants.BUTTON_UPDATE); GridData gridData = new GridData (SWT.CENTER, SWT.BOTTOM, true, true, 2, 1); gridData.widthHint = 100; updateButton.setLayoutData(gridData); @@ -617,7 +621,9 @@ public class AttributesTabControl extends TabControl _tableViewer.setInput(attributesList); } - // Refreshes the attribute tab by querying the mbean server for latest values + /** + * Refreshes the attribute tab by querying the mbean server for latest values + */ @Override public void refresh(ManagedBean mbean) { @@ -637,18 +643,23 @@ public class AttributesTabControl extends TabControl MBeanUtility.handleException(_mbean, ex); } _tableViewer.setInput(attributesList); - _table.setItemCount(attributesList.getCount()); - - // No attribtue selected when refreshing the tab - checkForEnablingButtons(null); + checkForEnablingButtons(getSelectionAttribute()); _form.layout(); } + /** + * @see TabControl#setFocus() + */ public void setFocus() { _table.setFocus(); } + /** + * Checks which buttons are to be enabled or disabled. The graph button will be enabled only + * for readable number attributes. Editing is enabled for writeable attribtues. + * @param attribute + */ private void checkForEnablingButtons(AttributeData attribute) { if (attribute == null) @@ -681,6 +692,10 @@ public class AttributesTabControl extends TabControl } } + /** + * Creates graph in a pop-up window for given attribute. + * @param data + */ private void createGraph(final AttributeData data) { Display display = Display.getCurrent(); @@ -769,8 +784,10 @@ public class AttributesTabControl extends TabControl // Launch the timer display.timerExec(Constants.TIMER_INTERVAL, runnable); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { + while (!shell.isDisposed()) + { + if (!display.readAndDispatch()) + { display.sleep(); } } @@ -780,6 +797,9 @@ public class AttributesTabControl extends TabControl shell.dispose(); } + /** + * @return selected attribute in the table + */ public AttributeData getSelectionAttribute() { int index = _table.getSelectionIndex(); @@ -789,6 +809,12 @@ public class AttributesTabControl extends TabControl return (AttributeData)_table.getItem(index).getData(); } + /** + * checks for newer values of selected attribute to update the graph + * @param canvas + * @param data + * @throws Exception + */ private void animate(Canvas canvas, AttributeData data) throws Exception { String attribute = data.getName(); @@ -813,6 +839,10 @@ public class AttributesTabControl extends TabControl canvas.redraw(); } + /** + * @param maxAttributeValue + * @return dynamically calculated value for y-axis on the graph + */ private long getGraphMaxValue(long maxAttributeValue) { long maxGraphValue = 100; @@ -826,6 +856,10 @@ public class AttributesTabControl extends TabControl return maxGraphValue; } + /** + * Content Provider class for the table viewer + * @author Bhupendra Bhardwaj + */ private class ContentProviderImpl implements IStructuredContentProvider { @@ -845,11 +879,14 @@ public class AttributesTabControl extends TabControl } } + /** + * Label Provider class for the table viewer + * @author Bhupendra Bhardwaj + */ private class LabelProviderImpl extends LabelProvider implements ITableLabelProvider, IFontProvider, IColorProvider { - AttributeData attribute = null; public String getColumnText(Object element, int columnIndex) { @@ -903,58 +940,20 @@ public class AttributesTabControl extends TabControl } } - - /* - class TableCellModifier implements ICellModifier - { - - public boolean canModify(Object element, String property) - { - int columnIndex = Arrays.asList(_tableTitles).indexOf(property); - if (columnIndex == 0) - return false; - - return true; - } - - public Object getValue(Object element, String property) { - // Find the index of the column - int columnIndex = Arrays.asList(_tableTitles).indexOf(property); - Attribute attribute = (Attribute)element; - - - Object result = null; - - switch (columnIndex) - { - case 0 : // attribute name column - result = attribute.getName(); - break; - case 1 : // attribute value column - result = attribute.getValue(); - break; - default : - result = ""; - } - - return result; - } - - - public void modify(Object element, String property, Object value) + /** + * Sorter class for the table viewer. It sorts the table for according to attribute name. + * @author Bhupendra Bhardwaj + * + */ + private class ViewerSorterImpl extends ViewerSorter + { + public int compare(Viewer viewer, Object o1, Object o2) { - // Find the index of the column - int columnIndex = Arrays.asList(_tableTitles).indexOf(property); + AttributeData attribtue1 = (AttributeData)o1; + AttributeData attribtue2 = (AttributeData)o2; - if (columnIndex == 1) - { - //TODO - // update the attribute value and call the MBean setAttribute method - // then refresh the attribute tab with new values - } + return collator.compare(attribtue1.getName(), attribtue2.getName()); } } - */ - } \ No newline at end of file diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java index 063f80fd3f..4b044c2e13 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanView.java @@ -78,74 +78,6 @@ public class MBeanView extends ViewPart IStructuredSelection ss = (IStructuredSelection) sel; TreeObject node = (TreeObject)ss.getFirstElement(); showSelectedMBean(node); - /* - _mbean = null; - setInvisible(); - - if (node == null) - { - _form.setText("Qpid Management Console"); - return; - } - - if (Constants.NOTIFICATION.equals(node.getType())) - { - _mbean = (ManagedBean)node.getParent().getManagedObject(); - } - else if (Constants.MBEAN.equals(node.getType())) - { - _mbean = (ManagedBean)node.getManagedObject(); - } - else - { - _form.setText("Qpid Management Console"); - return; - } - - setFocus(); - try - { - MBeanUtility.getMBeanInfo(_mbean); - } - catch(Exception ex) - { - MBeanUtility.handleException(_mbean, ex); - return; - } - - TabFolder tabFolder = tabFolderMap.get(_mbean.getType()); - if (tabFolder == null) - { - tabFolder = createTabFolder(); - } - - String text = _mbean.getType(); - if (_mbean.getName() != null && _mbean.getName().length() != 0) - { - text = text + ": " + _mbean.getName(); - } - _form.setText(text); - int tabIndex = 0; - if (Constants.NOTIFICATION.equals(node.getType())) - { - tabIndex = tabFolder.getItemCount() -1; - } - - TabItem tab = tabFolder.getItem(tabIndex); - // refreshTab(tab); - // If folder is being set as visible after tab refresh, then the tab - // doesn't have the focus. - - tabFolder.setSelection(tabIndex); - refreshTab(tab); - setVisible(tabFolder); - _form.layout(); - - // Set the focus on the first attribute in attributes table - if (tab.getText().equals(Constants.ATTRIBUTES)) - { - ((TabControl)tabFolder.getData(ATTRIBUTES_CONTROL)).setFocus(); - }*/ } } @@ -156,7 +88,7 @@ public class MBeanView extends ViewPart if (node == null) { - _form.setText("Qpid Management Console"); + _form.setText(Constants.APPLICATION_NAME); return; } @@ -170,7 +102,7 @@ public class MBeanView extends ViewPart } else { - _form.setText("Qpid Management Console"); + _form.setText(Constants.APPLICATION_NAME); return; } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java index c3f42f46aa..c1784d0bf1 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NotificationsTabControl.java @@ -63,9 +63,8 @@ import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; /** - * + * Creates control composite for Notifications tab * @author Bhupendra Bhardwaj - * */ public class NotificationsTabControl extends TabControl { @@ -124,11 +123,18 @@ public class NotificationsTabControl extends TabControl createTableViewer(); } + /** + * @see TabControl#getControl() + */ public Control getControl() { return _form; } + /** + * Creates composite and populates for displaying Notification Information (name, type, description) + * and creates buttons for subscribing or unsubscribing for notifications + */ private void createNotificationInfoComposite() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); @@ -183,7 +189,7 @@ public class NotificationsTabControl extends TabControl formData.top = new FormAttachment(notificationNameCombo, 5); formData.left = new FormAttachment(0, 10); fixedLabel.setLayoutData(formData); - fixedLabel.setText(Constants.DESCRIPTION); + fixedLabel.setText(Constants.DESCRIPTION + " : "); fixedLabel.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); descriptionLabel = _toolkit.createLabel(composite, ""); @@ -196,6 +202,9 @@ public class NotificationsTabControl extends TabControl descriptionLabel.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC)); } + /** + * Creates clear buttin and refresh button + */ private void addButtons() { Composite composite = _toolkit.createComposite(_form.getBody(), SWT.NONE); @@ -239,6 +248,9 @@ public class NotificationsTabControl extends TabControl }); } + /** + * Creates table to display notifications + */ private void createTable() { table = _toolkit.createTable(_form.getBody(), SWT.FULL_SELECTION); @@ -264,6 +276,9 @@ public class NotificationsTabControl extends TabControl table.setLinesVisible(true); } + /** + * Creates JFace viewer for the notifications table + */ protected void createTableViewer() { createTable(); @@ -300,6 +315,9 @@ public class NotificationsTabControl extends TabControl //viewerComposite.layout(); } + /** + * Adds listeners to the viewer for displaying notification details + */ private void addTableListeners() { _tableViewer.addDoubleClickListener(new IDoubleClickListener() @@ -409,15 +427,6 @@ public class NotificationsTabControl extends TabControl } populateNotificationInfo(); - /* - ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); - _notifications = serverRegistry.getNotifications(_mbean); - if (_notifications != null) - { - _tableViewer.setInput(_notifications); - - }*/ - //_tableViewer.setInput(null); workerRunning = true; _form.layout(); } @@ -428,6 +437,9 @@ public class NotificationsTabControl extends TabControl _tableViewer.getTable().clearAll(); } + /** + * Fills the notification information widgets for selected mbean + */ private void populateNotificationInfo() { notificationNameCombo.removeAll(); @@ -448,6 +460,9 @@ public class NotificationsTabControl extends TabControl checkForEnablingButtons(); } + /** + * Checks and the enabing/disabling of buttons + */ private void checkForEnablingButtons() { int nameIndex = notificationNameCombo.getSelectionIndex(); @@ -492,6 +507,9 @@ public class NotificationsTabControl extends TabControl return true; } + /** + * Selection listener for subscribing or unsubscribing the notifications + */ private class SelectionListenerImpl extends SelectionAdapter { public void widgetSelected(SelectionEvent e) @@ -528,7 +546,10 @@ public class NotificationsTabControl extends TabControl } } - + /** + * Selection listener class for the Notification Name. The notification type and description will be + * displayed accordingly + */ private class ComboSelectionListener extends SelectionAdapter { public void widgetSelected(SelectionEvent e) @@ -559,6 +580,9 @@ public class NotificationsTabControl extends TabControl } } + /** + * Content provider class for the table viewer + */ private class ContentProviderImpl implements IStructuredContentProvider, INotificationViewer { public void inputChanged(Viewer v, Object oldInput, Object newInput) @@ -584,6 +608,9 @@ public class NotificationsTabControl extends TabControl } } + /** + * Label provider for the table viewer + */ private class LabelProviderImpl implements ITableLabelProvider { List listeners = new ArrayList(); @@ -643,6 +670,9 @@ public class NotificationsTabControl extends TabControl workerRunning = running; } + /** + * Worker class which keeps looking if there are new notifications coming from server for the selected mbean + */ private class Worker implements Runnable { public void run() @@ -684,6 +714,9 @@ public class NotificationsTabControl extends TabControl } } + /** + * Updates the table with new notifications received from mbean server for the selected mbean + */ private void updateTableViewer() { ServerRegistry serverRegistry = ApplicationRegistry.getServerRegistry(_mbean); @@ -691,16 +724,6 @@ public class NotificationsTabControl extends TabControl if (newList == null) return; - /* - int notificationCount = 0; - if (_notifications != null) - notificationCount = _notifications.size(); - - for (int i = notificationCount; i < newList.size(); i++) - { - ((INotificationViewer)contentProvider).addNotification(newList.get(i)); - }*/ - _notifications = newList; _tableViewer.setInput(_notifications); _tableViewer.refresh(); diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java index c62f90353d..d951642736 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/OperationTabControl.java @@ -66,7 +66,6 @@ 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 { @@ -100,19 +99,28 @@ public class OperationTabControl extends TabControl _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 + } + + /** + * 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 + */ + private void createComposites() + { + // _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)); - + List params = _opData.getParameters(); + if (params != null && !params.isEmpty()) + { + _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); @@ -126,11 +134,15 @@ public class OperationTabControl extends TabControl _resultsComposite.setLayout(new GridLayout()); } + /** + * @see TabControl#getControl() + */ public Control getControl() { return _form; } + @Override public void refresh(ManagedBean mbean) { _mbean = mbean; @@ -138,6 +150,7 @@ public class OperationTabControl extends TabControl _opData = serverRegistry.getOperationModel(mbean).getOperations().get(0); refresh(_mbean, _opData); } + public void refresh(ManagedBean mbean, OperationData opData) { _mbean = mbean; @@ -148,13 +161,14 @@ public class OperationTabControl extends TabControl // instead of having half the widgets displayed. _form.setVisible(false); - ViewUtility.disposeChildren(_headerComposite); - ViewUtility.disposeChildren(_paramsComposite); - ViewUtility.disposeChildren(_resultsComposite); - + ViewUtility.disposeChildren(_form.getBody()); + createComposites(); setHeader(); createParameterWidgets(); + // Set button text and add appropriate listener to button. + // If there are no parameters and it is info operation, then operation gets executed + // and result is displayed List params = opData.getParameters(); if (params != null && !params.isEmpty()) { @@ -174,12 +188,15 @@ public class OperationTabControl extends TabControl _form.layout(); } + /** + * populates the header composite, containing the operation name and description. + */ 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 label = _toolkit.createLabel(_headerComposite, Constants.DESCRIPTION + " : "); label.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false)); @@ -190,6 +207,9 @@ public class OperationTabControl extends TabControl _headerComposite.layout(); } + /** + * Creates the widgets for operation parameters if there are any + */ private void createParameterWidgets() { List params = _opData.getParameters(); @@ -299,11 +319,12 @@ public class OperationTabControl extends TabControl formData.left = new FormAttachment(valueNumerator, 5); label.setLayoutData(formData); } - - //_parametersHolder.setMinSize(_parametersComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)); - //_parametersComposite.layout(); } + /** + * Creates customized dispaly for a method "CreateNewBinding" for Headers exchange + * + */ private void customCreateNewBinding() { headerBindingHashMap = new HashMap(); @@ -381,6 +402,12 @@ public class OperationTabControl extends TabControl composite.layout(); } + /** + * Adds a row for adding a binding for Headers Exchange. Used by the method, which creates the customized + * layout and widgest for Header's exchange method createNewBinding. + * @param parent composite + * @param rowCount - row number + */ private void createARowForCreatingHeadersBinding(Composite parent, int rowCount) { Label key = _toolkit.createLabel(parent, "Name"); @@ -415,6 +442,10 @@ public class OperationTabControl extends TabControl headerBindingHashMap.put(keyText, valueText); } + /** + * Sets text and listener for the operation execution button + * @param text + */ private void setButton(String text) { _executionButton.setText(text); @@ -431,12 +462,16 @@ public class OperationTabControl extends TabControl } } + /** + * displays the operation result in a pop-up window + * @param result + */ private void populateResults(Object result) { Display display = Display.getCurrent(); int width = 600; int height = 400; - Shell shell = ViewUtility.createPopupShell("Result", width, height); + Shell shell = ViewUtility.createPopupShell(Constants.RESULT, width, height); populateResults(result, shell); shell.open(); @@ -448,6 +483,11 @@ public class OperationTabControl extends TabControl shell.dispose(); } + /** + * Displays the operation result + * @param result + * @param parent + */ private void populateResults(Object result, Composite parent) { if (result instanceof TabularDataSupport) @@ -458,34 +498,11 @@ public class OperationTabControl extends TabControl { ViewUtility.populateCompositeDataHolder(parent, (CompositeDataSupport)result); } - } + } /** - * clears the parameter values entered. - * @param opName - - private void clearParameterValues() - { - List 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(""); - } - } - }*/ - + * Clears the parameter values of the operation + */ private void clearParameters() { List params = _opData.getParameters(); @@ -498,6 +515,10 @@ public class OperationTabControl extends TabControl } } + /** + * Clears the values entered by the user from parameter value widgets + * @param control + */ private void clearParameterValues(Composite control) { Control[] controls = control.getChildren(); @@ -556,6 +577,7 @@ public class OperationTabControl extends TabControl } } + // Listener for the "Refresh" execution button private class RefreshListener extends SelectionAdapter { public void widgetSelected(SelectionEvent e) @@ -564,7 +586,9 @@ public class OperationTabControl extends TabControl } } - + /** + * Executres the operation, gets the result from server and displays to the user + */ private void executeAndShowResults() { Object result = null; @@ -578,6 +602,7 @@ public class OperationTabControl extends TabControl return; } + // Some mbeans have only "type" and no "name". String title = _mbean.getType(); if (_mbean.getName() != null && _mbean.getName().length() != 0) { @@ -623,6 +648,9 @@ public class OperationTabControl extends TabControl } } + /** + * Listener class for boolean parameter widgets + */ private class BooleanSelectionListener extends SelectionAdapter { public void widgetSelected(SelectionEvent e) @@ -652,6 +680,10 @@ public class OperationTabControl extends TabControl } } + /** + * Listener class for HeaderExchange's new binding widgets. Used when the new bindings are + * being created for Header's Exchange + */ private class HeaderBindingKeyListener extends KeyAdapter { public void keyReleased(KeyEvent e) @@ -679,6 +711,9 @@ public class OperationTabControl extends TabControl } } + /** + * Listener class for verifying the user input with parameter type + */ private class VerifyListenerImpl implements VerifyListener { public void verifyText(VerifyEvent event) diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java index 4b89b7ca30..c8916044cb 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/TabControl.java @@ -25,6 +25,10 @@ import org.apache.qpid.management.ui.model.OperationData; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.TabFolder; +/** + * Abstract class for all the control classes of tabs. + * @author Bhupendra Bhardwaj + */ public abstract class TabControl { protected ManagedBean _mbean = null; @@ -35,21 +39,24 @@ public abstract class TabControl _tabFolder = tabFolder; } + /** + * @return controller composite for the tab + */ public Control getControl() { return null; } - public void refresh(ManagedBean mbean) - { - - } + public abstract void refresh(ManagedBean mbean); public void refresh(ManagedBean mbean, OperationData opData) { } + /** + * Sets focus on a widget + */ public void setFocus() { -- cgit v1.2.1