diff options
| author | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-03-07 17:10:13 +0000 |
|---|---|---|
| committer | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-03-07 17:10:13 +0000 |
| commit | c4d2e2a327175ad1703639e42363e8b4479ce0c0 (patch) | |
| tree | b906d9950b10ae79366e37af50a9a7b6ef53e2c0 /java/management | |
| parent | df552a1a4862615bad7335409fc6df1a80368911 (diff) | |
| download | qpid-python-c4d2e2a327175ad1703639e42363e8b4479ce0c0.tar.gz | |
Fixed -> Clicking the top level Refresh button was throwing NullPointerException for virtual host if a server node is selected.
Added static import for Constants and added form.body layout instead of each Composite layout separately.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@515649 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management')
7 files changed, 155 insertions, 169 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 7beb9c9b49..54d7b063ec 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 @@ -30,11 +30,11 @@ public class Constants public final static String APPLICATION_NAME = "Qpid Management Console"; public final static String VALUE = "value"; public final static String TYPE = "type"; - public final static String SERVER = "server"; - public final static String DOMAIN = "domain"; + public final static String NODE_TYPE_SERVER = "server"; + public final static String NODE_TYPE_DOMAIN = "domain"; public final static String NODE_TYPE_MBEANTYPE = "mbeantype"; // currently used only for virtual host instances, but will work as general also - public final static String TYPE_INSTANCE = "mbeantype_instance"; + public final static String NODE_TYPE_TYPEINSTANCE = "mbeantype_instance"; public final static String MBEAN = "mbean"; public final static String ATTRIBUTE = "Attribute"; public final static String ATTRIBUTES = "Attributes"; 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 feb853ab00..e3a7402c52 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 @@ -20,8 +20,8 @@ */ package org.apache.qpid.management.ui.views; +import static org.apache.qpid.management.ui.Constants.*; 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.jmx.JMXServerRegistry; import org.apache.qpid.management.ui.jmx.MBeanUtility; @@ -158,10 +158,10 @@ public class AttributesTabControl extends TabControl GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); _table.setLayoutData(gridData); - for (int i = 0; i < Constants.ATTRIBUTE_TABLE_TITLES.length; ++i) + for (int i = 0; i < ATTRIBUTE_TABLE_TITLES.length; ++i) { final TableColumn column = new TableColumn(_table, SWT.NONE); - column.setText(Constants.ATTRIBUTE_TABLE_TITLES[i]); + column.setText(ATTRIBUTE_TABLE_TITLES[i]); column.setWidth(tableWidths[i]); column.setResizable(false); } @@ -177,7 +177,7 @@ public class AttributesTabControl extends TabControl { _tableViewer = new TableViewer(_table); _tableViewer.setUseHashlookup(true); - _tableViewer.setColumnProperties(Constants.ATTRIBUTE_TABLE_TITLES); + _tableViewer.setColumnProperties(ATTRIBUTE_TABLE_TITLES); _tableViewer.setContentProvider(new ContentProviderImpl()); _tableViewer.setLabelProvider(new LabelProviderImpl()); _tableViewer.setSorter(new ViewerSorterImpl()); @@ -194,8 +194,8 @@ public class AttributesTabControl extends TabControl private void addDetailsButton() { // Create and configure the button for attribute details - _detailsButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_DETAILS, SWT.PUSH | SWT.CENTER); - _detailsButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _detailsButton = _toolkit.createButton(_buttonsComposite, BUTTON_DETAILS, SWT.PUSH | SWT.CENTER); + _detailsButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); gridData.widthHint = 80; _detailsButton.setLayoutData(gridData); @@ -219,8 +219,8 @@ public class AttributesTabControl extends TabControl private void addEditButton() { // Create and configure the button for editing attribute - _editButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_EDIT_ATTRIBUTE, SWT.PUSH | SWT.CENTER); - _editButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _editButton = _toolkit.createButton(_buttonsComposite, BUTTON_EDIT_ATTRIBUTE, SWT.PUSH | SWT.CENTER); + _editButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); gridData.widthHint = 80; _editButton.setLayoutData(gridData); @@ -241,8 +241,8 @@ public class AttributesTabControl extends TabControl */ private void addGraphButton() { - _graphButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_GRAPH, SWT.PUSH | SWT.CENTER); - _graphButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _graphButton = _toolkit.createButton(_buttonsComposite, BUTTON_GRAPH, SWT.PUSH | SWT.CENTER); + _graphButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); gridData.widthHint = 80; _graphButton.setLayoutData(gridData); @@ -263,9 +263,9 @@ public class AttributesTabControl extends TabControl */ private void addRefreshButton() { - _refreshButton = _toolkit.createButton(_buttonsComposite, Constants.BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); + _refreshButton = _toolkit.createButton(_buttonsComposite, BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); - _refreshButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _refreshButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData gridData = new GridData(SWT.CENTER, SWT.TOP, false, false); gridData.widthHint = 80; _refreshButton.setLayoutData(gridData); @@ -425,7 +425,7 @@ public class AttributesTabControl extends TabControl } Display display = Display.getCurrent(); - Shell shell = ViewUtility.createPopupShell(Constants.ATTRIBUTE, width, height); + Shell shell = ViewUtility.createPopupShell(ATTRIBUTE, width, height); createDetailsPopupContents(shell, data); shell.open(); @@ -484,7 +484,7 @@ public class AttributesTabControl extends TabControl // Name Label label = new Label(parent, SWT.NONE); - label.setText(Constants.ATTRIBUTE_TABLE_TITLES[0]); + label.setText(ATTRIBUTE_TABLE_TITLES[0]); GridData layoutData = new GridData(SWT.TRAIL, SWT.TOP, false, false); label.setLayoutData(layoutData); Text value = new Text(parent, SWT.BEGINNING | SWT.BORDER |SWT.READ_ONLY); @@ -494,7 +494,7 @@ public class AttributesTabControl extends TabControl // Description label = new Label(parent, SWT.NONE); - label.setText(Constants.DESCRIPTION); + label.setText(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()); @@ -502,7 +502,7 @@ public class AttributesTabControl extends TabControl // value label = new Label(parent, SWT.NONE); - label.setText(Constants.ATTRIBUTE_TABLE_TITLES[1]); + label.setText(ATTRIBUTE_TABLE_TITLES[1]); label.setLayoutData(new GridData(SWT.TRAIL, SWT.TOP, false, false)); if (!attribute.isReadable()) @@ -582,9 +582,9 @@ public class AttributesTabControl extends TabControl { final Button updateButton = new Button(parent, SWT.PUSH | SWT.CENTER); // set the data to access in the listener - parent.setData(Constants.BUTTON_UPDATE, updateButton); + parent.setData(BUTTON_UPDATE, updateButton); - updateButton.setText(Constants.BUTTON_UPDATE); + updateButton.setText(BUTTON_UPDATE); GridData gridData = new GridData (SWT.CENTER, SWT.BOTTOM, true, true, 2, 1); gridData.widthHint = 100; updateButton.setLayoutData(gridData); @@ -642,7 +642,9 @@ public class AttributesTabControl extends TabControl } _tableViewer.setInput(attributesList); checkForEnablingButtons(getSelectionAttribute()); - _form.layout(); + + _form.layout(true); + _form.getBody().layout(true, true); } /** @@ -679,7 +681,8 @@ public class AttributesTabControl extends TabControl else { _editButton.setEnabled(false); - if (attribute.isNumber()) + // Currently only Queues are having attributes, which are suitable for a graph + if (attribute.isNumber() && _mbean.isQueue()) { _graphButton.setEnabled(true); } @@ -770,7 +773,7 @@ public class AttributesTabControl extends TabControl try { animate(canvas, data); - Display.getCurrent().timerExec(Constants.TIMER_INTERVAL, this); + Display.getCurrent().timerExec(TIMER_INTERVAL, this); } catch(Exception ex) { @@ -780,7 +783,7 @@ public class AttributesTabControl extends TabControl }; // Launch the timer - display.timerExec(Constants.TIMER_INTERVAL, runnable); + display.timerExec(TIMER_INTERVAL, runnable); while (!shell.isDisposed()) { @@ -915,7 +918,7 @@ public class AttributesTabControl extends TabControl public Font getFont(Object element) { - return ApplicationRegistry.getFont(Constants.FONT_TABLE_CELL); + return ApplicationRegistry.getFont(FONT_TABLE_CELL); } public Color getForeground(Object element) diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java index 4c57ebb6af..a8a96e0b5a 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/MBeanTypeTabControl.java @@ -3,8 +3,8 @@ package org.apache.qpid.management.ui.views; import java.util.Collections; import java.util.HashMap; +import static org.apache.qpid.management.ui.Constants.*; 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.jmx.MBeanUtility; import org.apache.qpid.management.ui.model.AttributeData; @@ -135,11 +135,11 @@ public abstract class MBeanTypeTabControl _labelName = _toolkit.createLabel(_headerComposite, "Type:", SWT.NONE); GridData gridData = new GridData(SWT.CENTER, SWT.TOP, true, false); _labelName.setLayoutData(gridData); - _labelName.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); + _labelName.setFont(ApplicationRegistry.getFont(FONT_BOLD)); _labelDesc = _toolkit.createLabel(_headerComposite, " ", SWT.NONE); _labelDesc.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false)); - _labelDesc.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC)); + _labelDesc.setFont(ApplicationRegistry.getFont(FONT_ITALIC)); _headerComposite.layout(); } @@ -203,7 +203,7 @@ public abstract class MBeanTypeTabControl */ protected void createRefreshButton(Composite parentComposite) { - Button _refreshButton = _toolkit.createButton(parentComposite, Constants.BUTTON_REFRESH, SWT.PUSH); + Button _refreshButton = _toolkit.createButton(parentComposite, BUTTON_REFRESH, SWT.PUSH); GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false); gridData.widthHint = 120; _refreshButton.setLayoutData(gridData); @@ -241,7 +241,7 @@ public abstract class MBeanTypeTabControl _labelList = _toolkit.createLabel(_listComposite, " ", SWT.CENTER); gridData = new GridData(SWT.CENTER, SWT.TOP, true, false, 1, 1); _labelList.setLayoutData(gridData); - _labelList.setFont(ApplicationRegistry.getFont(Constants.FONT_NORMAL)); + _labelList.setFont(ApplicationRegistry.getFont(FONT_NORMAL)); _list = new List(_listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); gridData = new GridData(SWT.FILL, SWT.FILL, true, true,1, 1); @@ -271,10 +271,8 @@ public abstract class MBeanTypeTabControl public void layout() { - _headerComposite.layout(); - _listComposite.layout(); - _composite.layout(); - _form.layout(); + _form.layout(true); + _form.getBody().layout(true, true); } // sets the map with appropriate mbean and name 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 52de47bfda..59b9fe3aaa 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 @@ -22,8 +22,8 @@ package org.apache.qpid.management.ui.views; import java.util.HashMap; +import static org.apache.qpid.management.ui.Constants.*; 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.ManagedServer; import org.apache.qpid.management.ui.ServerRegistry; @@ -91,7 +91,7 @@ public class MBeanView extends ViewPart // an mbeantype. For mbeantype selection(eg Connection, Queue, Exchange) _mbean will remain null. _mbean = null; setInvisible(); - _form.setText(Constants.APPLICATION_NAME); + _form.setText(APPLICATION_NAME); // If a selected node(mbean) gets unregistered from mbena server, mbenaview should should // make the tabfolber for that mbean invisible @@ -99,22 +99,38 @@ public class MBeanView extends ViewPart return; setServer(); - try + refreshMBeanView(); + } + } + + public void refreshMBeanView() + { + try + { + if (NODE_TYPE_SERVER.equals(_selectedNode.getType()) || + NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) ) { - if (Constants.NODE_TYPE_MBEANTYPE.equals(_selectedNode.getType())) - { - refreshTypeTabFolder(_selectedNode.getName()); - } - else - { - showSelectedMBean(); - } - _form.layout(); + return; + } + else if (NODE_TYPE_TYPEINSTANCE.equals(_selectedNode.getType())) + { + // An virtual host instance is selected + refreshTypeTabFolder(typeTabFolder.getItem(0)); } - catch(Exception ex) + else if (NODE_TYPE_MBEANTYPE.equals(_selectedNode.getType())) { - MBeanUtility.handleException(_mbean, ex); + refreshTypeTabFolder(_selectedNode.getName()); + } + else + { + showSelectedMBean(); } + _form.layout(true); + _form.getBody().layout(true, true); + } + catch(Exception ex) + { + MBeanUtility.handleException(_mbean, ex); } } @@ -126,7 +142,8 @@ public class MBeanView extends ViewPart */ private void setServer() { - if (Constants.SERVER.equals(_selectedNode.getType())) + if (NODE_TYPE_SERVER.equals(_selectedNode.getType()) || + NODE_TYPE_DOMAIN.equals(_selectedNode.getType()) ) { _server = (ManagedServer)_selectedNode.getManagedObject(); _virtualHostName = null; @@ -134,12 +151,12 @@ public class MBeanView extends ViewPart else { TreeObject parent = _selectedNode.getParent(); - while (parent != null && !parent.getType().equals(Constants.SERVER)) + while (parent != null && !parent.getType().equals(NODE_TYPE_SERVER)) { parent = parent.getParent(); } - if (parent != null && parent.getType().equals(Constants.SERVER)) + if (parent != null && parent.getType().equals(NODE_TYPE_SERVER)) _server = (ManagedServer)parent.getManagedObject(); _virtualHostName = _selectedNode.getVirtualHost(); @@ -158,11 +175,11 @@ public class MBeanView extends ViewPart private void showSelectedMBean() throws Exception { - if (Constants.NOTIFICATION.equals(_selectedNode.getType())) + if (NOTIFICATION.equals(_selectedNode.getType())) { _mbean = (ManagedBean)_selectedNode.getParent().getManagedObject(); } - else if (Constants.MBEAN.equals(_selectedNode.getType())) + else if (MBEAN.equals(_selectedNode.getType())) { _mbean = (ManagedBean)_selectedNode.getManagedObject(); } @@ -203,7 +220,7 @@ public class MBeanView extends ViewPart } _form.setText(text); int tabIndex = 0; - if (Constants.NOTIFICATION.equals(_selectedNode.getType())) + if (NOTIFICATION.equals(_selectedNode.getType())) { tabIndex = tabFolder.getItemCount() -1; } @@ -222,7 +239,7 @@ public class MBeanView extends ViewPart _toolkit = new FormToolkit(parent.getDisplay()); _form = _toolkit.createForm(parent); _form.getBody().setLayout(new FormLayout()); - _form.setText(Constants.APPLICATION_NAME); + _form.setText(APPLICATION_NAME); // Add selection listener for selection events in the Navigation view getSite().getPage().addSelectionListener(NavigationView.ID, selectionListener); @@ -232,35 +249,6 @@ public class MBeanView extends ViewPart createMBeanTypeTabFolder(); } - public void refreshMBeanView() throws Exception - { - int tabIndex = 0; - TabItem tab = null; - if (_mbean == null) - { - tabIndex = typeTabFolder.getSelectionIndex(); - if (tabIndex == -1) - return; - - tab = typeTabFolder.getItem(tabIndex); - refreshTypeTabFolder(tab); - } - else - { - TabFolder tabFolder = tabFolderMap.get(_mbean.getType()); - if (tabFolder == null) - return; - - tabIndex = tabFolder.getSelectionIndex(); - tab = tabFolder.getItem(tabIndex); - if (tab == null) - return; - - refreshTab(tab); - } - _form.layout(); - } - private TabFolder createMBeanTabFolder() { TabFolder tabFolder = new TabFolder(_form.getBody(), SWT.NONE); @@ -325,7 +313,7 @@ public class MBeanView extends ViewPart } TabItem tab = new TabItem(tabFolder, SWT.NONE); - tab.setText(Constants.ATTRIBUTES); + tab.setText(ATTRIBUTES); AttributesTabControl controller = new AttributesTabControl(tabFolder); tab.setControl(controller.getControl()); tab.setData(CONTROLLER, controller); @@ -357,7 +345,7 @@ public class MBeanView extends ViewPart NotificationsTabControl controller = new NotificationsTabControl(tabFolder); TabItem tab = new TabItem(tabFolder, SWT.NONE); - tab.setText(Constants.NOTIFICATION); + tab.setText(NOTIFICATION); tab.setData(CONTROLLER, controller); tab.setControl(controller.getControl()); } @@ -410,19 +398,19 @@ public class MBeanView extends ViewPart typeTabFolder.setVisible(false); TabItem tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(Constants.CONNECTION); + tab.setText(CONNECTION); MBeanTypeTabControl controller = new ConnectionTypeTabControl(typeTabFolder); tab.setData(CONTROLLER, controller); tab.setControl(controller.getControl()); tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(Constants.EXCHANGE); + tab.setText(EXCHANGE); controller = new ExchangeTypeTabControl(typeTabFolder); tab.setData(CONTROLLER, controller); tab.setControl(controller.getControl()); tab = new TabItem(typeTabFolder, SWT.NONE); - tab.setText(Constants.QUEUE); + tab.setText(QUEUE); controller = new QueueTypeTabControl(typeTabFolder); tab.setData(CONTROLLER, controller); tab.setControl(controller.getControl()); @@ -464,15 +452,15 @@ public class MBeanView extends ViewPart private void refreshTypeTabFolder(String type) throws Exception { - if (Constants.CONNECTION.equals(type)) + if (CONNECTION.equals(type)) { refreshTypeTabFolder(typeTabFolder.getItem(0)); } - else if (Constants.EXCHANGE.equals(type)) + else if (EXCHANGE.equals(type)) { refreshTypeTabFolder(typeTabFolder.getItem(1)); } - else if (Constants.QUEUE.equals(type)) + else if (QUEUE.equals(type)) { refreshTypeTabFolder(typeTabFolder.getItem(2)); } diff --git a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java index 1f9e2e67fb..a02c170c38 100644 --- a/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java +++ b/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/NavigationView.java @@ -30,8 +30,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import static org.apache.qpid.management.ui.Constants.*; 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.ManagedServer; import org.apache.qpid.management.ui.ServerRegistry; @@ -190,7 +190,7 @@ public class NavigationView extends ViewPart } // Server connection is successful. Now add the server in the tree - TreeObject serverNode = new TreeObject(serverAddress, Constants.SERVER); + TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER); serverNode.setUrl(url); serverNode.setManagedObject(managedServer); _serversRootNode.addChild(serverNode); @@ -241,9 +241,9 @@ public class NavigationView extends ViewPart String domain = server.getDomain(); try { - if (!domain.equals(Constants.ALL)) + if (!domain.equals(ALL)) { - TreeObject domainNode = new TreeObject(domain, Constants.DOMAIN); + TreeObject domainNode = new TreeObject(domain, NODE_TYPE_DOMAIN); domainNode.setParent(serverNode); populateDomain(domainNode); @@ -254,7 +254,7 @@ public class NavigationView extends ViewPart List<String> domains = MBeanUtility.getAllDomains(server);; for (String domainName : domains) { - TreeObject domainNode = new TreeObject(domainName, Constants.DOMAIN); + TreeObject domainNode = new TreeObject(domainName, NODE_TYPE_DOMAIN); domainNode.setParent(serverNode); domainList.add(domainNode); @@ -299,7 +299,7 @@ public class NavigationView extends ViewPart // This will add the default nodes to the domain node for (TreeObject child : domain.getChildren()) { - if (!child.getName().startsWith(Constants.VIRTUAL_HOST)) + if (!child.getName().startsWith(VIRTUAL_HOST)) { addDefaultNodes(domain); } @@ -315,13 +315,13 @@ public class NavigationView extends ViewPart */ private void addDefaultNodes(TreeObject parent) { - TreeObject typeChild = new TreeObject(Constants.CONNECTION, Constants.NODE_TYPE_MBEANTYPE); + TreeObject typeChild = new TreeObject(CONNECTION, NODE_TYPE_MBEANTYPE); typeChild.setParent(parent); typeChild.setVirtualHost(parent.getVirtualHost()); - typeChild = new TreeObject(Constants.EXCHANGE, Constants.NODE_TYPE_MBEANTYPE); + typeChild = new TreeObject(EXCHANGE, NODE_TYPE_MBEANTYPE); typeChild.setParent(parent); typeChild.setVirtualHost(parent.getVirtualHost()); - typeChild = new TreeObject(Constants.QUEUE, Constants.NODE_TYPE_MBEANTYPE); + typeChild = new TreeObject(QUEUE, NODE_TYPE_MBEANTYPE); typeChild.setParent(parent); typeChild.setVirtualHost(parent.getVirtualHost()); } @@ -338,7 +338,7 @@ public class NavigationView extends ViewPart List<TreeObject> childNodes = parent.getChildren(); for (TreeObject child : childNodes) { - if ((Constants.NODE_TYPE_MBEANTYPE.equals(child.getType()) || Constants.TYPE_INSTANCE.equals(child.getType())) && + if ((NODE_TYPE_MBEANTYPE.equals(child.getType()) || NODE_TYPE_TYPEINSTANCE.equals(child.getType())) && typeName.equals(child.getName())) return child; } @@ -350,7 +350,7 @@ public class NavigationView extends ViewPart List<TreeObject> childNodes = typeNode.getChildren(); for (TreeObject child : childNodes) { - if (Constants.MBEAN.equals(child.getType()) && mbeanName.equals(child.getName())) + if (MBEAN.equals(child.getType()) && mbeanName.equals(child.getName())) return true; } return false; @@ -401,7 +401,7 @@ public class NavigationView extends ViewPart typeNode.setVirtualHost(mbean.getVirtualHostName()); // Create default nodes for VHost instances - if (type.equals(Constants.VIRTUAL_HOST)) + if (type.equals(VIRTUAL_HOST)) { addDefaultNodes(typeNode); } @@ -422,20 +422,20 @@ public class NavigationView extends ViewPart // Add notification node // TODO: show this only if the mbean sends any notification - TreeObject notificationNode = new TreeObject(Constants.NOTIFICATION, Constants.NOTIFICATION); + TreeObject notificationNode = new TreeObject(NOTIFICATION, NOTIFICATION); notificationNode.setParent(mbeanNode); } private TreeObject createTypeNode(TreeObject parent, String name) { - TreeObject typeNode = new TreeObject(name, Constants.NODE_TYPE_MBEANTYPE); + TreeObject typeNode = new TreeObject(name, NODE_TYPE_MBEANTYPE); typeNode.setParent(parent); return typeNode; } private TreeObject createTypeInstanceNode(TreeObject parent, String name) { - TreeObject typeNode = new TreeObject(name, Constants.TYPE_INSTANCE); + TreeObject typeNode = new TreeObject(name, NODE_TYPE_TYPEINSTANCE); typeNode.setParent(parent); return typeNode; } @@ -466,7 +466,7 @@ public class NavigationView extends ViewPart TreeObject objectToRemove = null; for (TreeObject child : list) { - if (Constants.MBEAN.equals(child.getType())) + if (MBEAN.equals(child.getType())) { String name = mbean.getName() != null ? mbean.getName() : mbean.getType(); if (child.getName().equals(name)) @@ -589,7 +589,7 @@ public class NavigationView extends ViewPart { IStructuredSelection ss = (IStructuredSelection)_treeViewer.getSelection(); TreeObject selectedNode = (TreeObject)ss.getFirstElement(); - if (ss.isEmpty() || selectedNode == null || (!selectedNode.getType().equals(Constants.SERVER))) + if (ss.isEmpty() || selectedNode == null || (!selectedNode.getType().equals(NODE_TYPE_SERVER))) { throw new InfoRequiredException("Please select the server"); } @@ -612,7 +612,7 @@ public class NavigationView extends ViewPart createTreeViewer(composite); _rootNode = new TreeObject("ROOT", "ROOT"); - _serversRootNode = new TreeObject(Constants.NAVIGATION_ROOT, "ROOT"); + _serversRootNode = new TreeObject(NAVIGATION_ROOT, "ROOT"); _serversRootNode.setParent(_rootNode); _treeViewer.setInput(_rootNode); @@ -633,7 +633,7 @@ public class NavigationView extends ViewPart String url = getRMIURL(serverAddress); ManagedServer managedServer = new ManagedServer(url, "org.apache.qpid"); managedServer.setName(serverAddress); - TreeObject serverNode = new TreeObject(serverAddress, Constants.SERVER); + TreeObject serverNode = new TreeObject(serverAddress, NODE_TYPE_SERVER); serverNode.setUrl(url); serverNode.setManagedObject(managedServer); _serversRootNode.addChild(serverNode); @@ -711,28 +711,28 @@ public class NavigationView extends ViewPart public Image getImage(Object element) { TreeObject node = (TreeObject)element; - if (node.getType().equals(Constants.NOTIFICATION)) + if (node.getType().equals(NOTIFICATION)) { - return ApplicationRegistry.getImage(Constants.NOTIFICATION_IMAGE); + return ApplicationRegistry.getImage(NOTIFICATION_IMAGE); } - else if (!node.getType().equals(Constants.MBEAN)) + else if (!node.getType().equals(MBEAN)) { if (_treeViewer.getExpandedState(node)) - return ApplicationRegistry.getImage(Constants.OPEN_FOLDER_IMAGE); + return ApplicationRegistry.getImage(OPEN_FOLDER_IMAGE); else - return ApplicationRegistry.getImage(Constants.CLOSED_FOLDER_IMAGE); + return ApplicationRegistry.getImage(CLOSED_FOLDER_IMAGE); } else { - return ApplicationRegistry.getImage(Constants.MBEAN_IMAGE); + return ApplicationRegistry.getImage(MBEAN_IMAGE); } } public String getText(Object element) { TreeObject node = (TreeObject)element; - if (node.getType().equals(Constants.NODE_TYPE_MBEANTYPE)) + if (node.getType().equals(NODE_TYPE_MBEANTYPE)) { return node.getName() + "s"; } @@ -745,14 +745,14 @@ public class NavigationView extends ViewPart public Font getFont(Object element) { TreeObject node = (TreeObject)element; - if (node.getType().equals(Constants.SERVER)) + if (node.getType().equals(NODE_TYPE_SERVER)) { if (node.getChildren().isEmpty()) - return ApplicationRegistry.getFont(Constants.FONT_NORMAL); + return ApplicationRegistry.getFont(FONT_NORMAL); else - return ApplicationRegistry.getFont(Constants.FONT_BOLD); + return ApplicationRegistry.getFont(FONT_BOLD); } - return ApplicationRegistry.getFont(Constants.FONT_NORMAL); + return ApplicationRegistry.getFont(FONT_NORMAL); } } // End of LabelProviderImpl @@ -762,7 +762,7 @@ public class NavigationView extends ViewPart public int category(Object element) { TreeObject node = (TreeObject)element; - if (node.getType().equals(Constants.MBEAN)) + if (node.getType().equals(MBEAN)) return 1; return 2; } 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 c45ad7b362..4f0acde1b4 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 @@ -23,8 +23,8 @@ package org.apache.qpid.management.ui.views; import java.util.ArrayList; import java.util.List; +import static org.apache.qpid.management.ui.Constants.*; 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; @@ -142,7 +142,7 @@ public class NotificationsTabControl extends TabControl composite.setLayout(new FormLayout()); Label label = _toolkit.createLabel(composite, "Select the notification to subscribe or unsubscribe"); - label.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); + label.setFont(ApplicationRegistry.getFont(FONT_BOLD)); FormData formData = new FormData(); formData.top = new FormAttachment(0, 10); formData.left = new FormAttachment(0, 10); @@ -165,8 +165,8 @@ public class NotificationsTabControl extends TabControl typesCombo.addSelectionListener(comboListener); _subscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER); - _subscribeButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - _subscribeButton.setText(Constants.SUBSCRIBE_BUTTON); + _subscribeButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); + _subscribeButton.setText(SUBSCRIBE_BUTTON); formData = new FormData(); formData.top = new FormAttachment(label, 10); formData.left = new FormAttachment(65, 10); @@ -175,8 +175,8 @@ public class NotificationsTabControl extends TabControl _subscribeButton.addSelectionListener(selectionListener); _unsubscribeButton = new Button(composite, SWT.PUSH | SWT.CENTER); - _unsubscribeButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); - _unsubscribeButton.setText(Constants.UNSUBSCRIBE_BUTTON); + _unsubscribeButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); + _unsubscribeButton.setText(UNSUBSCRIBE_BUTTON); formData = new FormData(); formData.top = new FormAttachment(label, 10); formData.left = new FormAttachment(_subscribeButton, 10); @@ -189,8 +189,8 @@ 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.setFont(ApplicationRegistry.getFont(Constants.FONT_BOLD)); + fixedLabel.setText(DESCRIPTION + " : "); + fixedLabel.setFont(ApplicationRegistry.getFont(FONT_BOLD)); descriptionLabel = _toolkit.createLabel(composite, ""); formData = new FormData(); @@ -199,7 +199,7 @@ public class NotificationsTabControl extends TabControl formData.right = new FormAttachment(100); descriptionLabel.setLayoutData(formData); descriptionLabel.setText(" "); - descriptionLabel.setFont(ApplicationRegistry.getFont(Constants.FONT_ITALIC)); + descriptionLabel.setFont(ApplicationRegistry.getFont(FONT_ITALIC)); } /** @@ -212,8 +212,8 @@ public class NotificationsTabControl extends TabControl composite.setLayout(new GridLayout(2, true)); // Add Clear Button - _clearButton = _toolkit.createButton(composite, Constants.BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); - _clearButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _clearButton = _toolkit.createButton(composite, BUTTON_CLEAR, SWT.PUSH | SWT.CENTER); + _clearButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData gridData = new GridData(SWT.LEAD, SWT.TOP, true, false); gridData.widthHint = 80; _clearButton.setLayoutData(gridData); @@ -231,8 +231,8 @@ public class NotificationsTabControl extends TabControl }); // Add Refresh Button - _refreshButton = _toolkit.createButton(composite, Constants.BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); - _refreshButton.setFont(ApplicationRegistry.getFont(Constants.FONT_BUTTON)); + _refreshButton = _toolkit.createButton(composite, BUTTON_REFRESH, SWT.PUSH | SWT.CENTER); + _refreshButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); gridData = new GridData(SWT.TRAIL, SWT.TOP, true, false); gridData.widthHint = 80; _refreshButton.setLayoutData(gridData); @@ -427,7 +427,8 @@ public class NotificationsTabControl extends TabControl populateNotificationInfo(); workerRunning = true; - _form.layout(); + _form.layout(true); + _form.getBody().layout(true, true); } private void 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 0103efbcd1..49b61c0fc6 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 @@ -24,8 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import static org.apache.qpid.management.ui.Constants.*; 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.jmx.MBeanUtility; import org.apache.qpid.management.ui.model.OperationData; @@ -121,8 +121,8 @@ public class OperationTabControl extends TabControl _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)); + _executionButton = _toolkit.createButton(_form.getBody(), BUTTON_EXECUTE, SWT.PUSH | SWT.CENTER); + _executionButton.setFont(ApplicationRegistry.getFont(FONT_BUTTON)); GridData layoutData = new GridData(SWT.CENTER, SWT.TOP, true, false); layoutData.verticalIndent = 20; _executionButton.setLayoutData(layoutData); @@ -162,15 +162,15 @@ public class OperationTabControl extends TabControl List<ParameterData> params = _opData.getParameters(); if (params != null && !params.isEmpty()) { - setButton(Constants.BUTTON_EXECUTE); + setButton(BUTTON_EXECUTE); } - else if (_opData.getImpact() == Constants.OPERATION_IMPACT_ACTION) + else if (_opData.getImpact() == OPERATION_IMPACT_ACTION) { - setButton(Constants.BUTTON_EXECUTE); + setButton(BUTTON_EXECUTE); } - else if (_opData.getImpact() == Constants.OPERATION_IMPACT_INFO) + else if (_opData.getImpact() == OPERATION_IMPACT_INFO) { - setButton(Constants.BUTTON_REFRESH); + setButton(BUTTON_REFRESH); executeAndShowResults(); } @@ -180,12 +180,8 @@ public class OperationTabControl extends TabControl public void layout() { - _headerComposite.layout(); - if (_paramsComposite != null && !_paramsComposite.isDisposed()) - { - _paramsComposite.layout(); - } - _form.layout(); + _form.layout(true); + _form.getBody().layout(true, true); } /** @@ -196,12 +192,12 @@ public class OperationTabControl extends TabControl _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 label = _toolkit.createLabel(_headerComposite, DESCRIPTION + " : "); + label.setFont(ApplicationRegistry.getFont(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.setFont(ApplicationRegistry.getFont(FONT_NORMAL)); label.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, true, false)); _headerComposite.layout(); @@ -220,8 +216,8 @@ public class OperationTabControl extends TabControl // Customised parameter widgets if (_mbean.isExchange() && - Constants.EXCHANGE_TYPE_VALUES[2].equals(_mbean.getProperty(Constants.EXCHANGE_TYPE)) && - _opData.getName().equalsIgnoreCase(Constants.OPERATION_CREATE_BINDING)) + EXCHANGE_TYPE_VALUES[2].equals(_mbean.getProperty(EXCHANGE_TYPE)) && + _opData.getName().equalsIgnoreCase(OPERATION_CREATE_BINDING)) { customCreateNewBinding(); return; @@ -254,24 +250,24 @@ public class OperationTabControl extends TabControl formData.left = new FormAttachment(label, 5); formData.right = new FormAttachment(valueWidth); String[] items = null; - if (param.getName().equals(Constants.QUEUE)) + if (param.getName().equals(QUEUE)) { List<String> qList = ApplicationRegistry.getServerRegistry(_mbean).getQueueNames(_virtualHostName); - // Customization for AMQQueueMBean method Constants.OPERATION_MOVE_MESSAGES - if (_opData.getName().equals(Constants.OPERATION_MOVE_MESSAGES)) + // Customization for AMQQueueMBean method OPERATION_MOVE_MESSAGES + if (_opData.getName().equals(OPERATION_MOVE_MESSAGES)) { qList.remove(_mbean.getName()); } // End of Customization items = qList.toArray(new String[0]); } - else if (param.getName().equals(Constants.EXCHANGE)) + else if (param.getName().equals(EXCHANGE)) { items = ApplicationRegistry.getServerRegistry(_mbean).getExchangeNames(_virtualHostName); } - else if (param.getName().equals(Constants.EXCHANGE_TYPE)) + else if (param.getName().equals(EXCHANGE_TYPE)) { - items = Constants.EXCHANGE_TYPE_VALUES; + items = EXCHANGE_TYPE_VALUES; } if (items != null) @@ -466,7 +462,7 @@ public class OperationTabControl extends TabControl _executionButton.removeSelectionListener(refreshListener); _executionButton.removeSelectionListener(operationExecutionListener); - if (Constants.BUTTON_EXECUTE.equals(text)) + if (BUTTON_EXECUTE.equals(text)) { _executionButton.addSelectionListener(operationExecutionListener); } @@ -485,8 +481,8 @@ public class OperationTabControl extends TabControl Display display = Display.getCurrent(); int width = 600; int height = 400; - Shell shell = ViewUtility.createPopupShell(Constants.RESULT, width, height); - shell.setImage(ApplicationRegistry.getImage(Constants.CONSOLE_IMAGE)); + Shell shell = ViewUtility.createPopupShell(RESULT, width, height); + shell.setImage(ApplicationRegistry.getImage(CONSOLE_IMAGE)); ViewUtility.populateCompositeWithData(_toolkit, shell, result); shell.open(); @@ -554,8 +550,8 @@ public class OperationTabControl extends TabControl if (param.getValue() == null || param.getValue().toString().length() == 0) { // Customized check, because for this parameter null is allowed - if (param.getName().equals(Constants.ATTRIBUTE_QUEUE_OWNER) && - _opData.getName().equals(Constants.OPERATION_CREATE_QUEUE)) + if (param.getName().equals(ATTRIBUTE_QUEUE_OWNER) && + _opData.getName().equals(OPERATION_CREATE_QUEUE)) { continue; } @@ -569,7 +565,7 @@ public class OperationTabControl extends TabControl } } - if (_opData.getImpact() == Constants.OPERATION_IMPACT_ACTION) + if (_opData.getImpact() == OPERATION_IMPACT_ACTION) { String bean = _mbean.getName() == null ? _mbean.getType() : _mbean.getName(); int response = ViewUtility.popupConfirmationMessage(bean, |
