GrxORBMonitor.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 /*
11  * GrxORBMonitor.java
12  *
13  * Copyright (C) 2007 GeneralRobotix, Inc.
14  * All Rights Reserved
15  *
16  * @author Yuichiro Kawasumi (General Robotix, Inc.)
17  * 2004/03/16
18  */
19 package com.generalrobotix.ui.util;
20 
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.events.SelectionEvent;
23 import org.eclipse.swt.events.SelectionListener;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Button;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.swt.widgets.Label;
29 import org.eclipse.swt.widgets.MessageBox;
30 import org.eclipse.swt.widgets.Text;
31 
32 @SuppressWarnings("serial") //$NON-NLS-1$
33 public class GrxORBMonitor extends Composite {
34  private MessageBox dialog_ = null;
35 
36  private Label labelNs = null;
37  private Text multiText = null;
38  private Text textNsHost_ = null;
39  private Text textNsPort_ = null;
40 
41  public GrxORBMonitor(Composite parent, int style) {
42  super(parent, style);
43  this.setLayout(new GridLayout(1, false));
44 
45  Composite northPane = new Composite(this, SWT.NONE);
46  northPane.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
47  GridLayout gridLayout = new GridLayout(5, false);
48  gridLayout.marginWidth = 5;
49  gridLayout.horizontalSpacing = 5;
50  northPane.setLayout(gridLayout);
51 
52  Button button = new Button(northPane, SWT.PUSH);
53  button.setText(MessageBundle.get("GrxORBMonitor.button.update")); //$NON-NLS-1$
54  GridData btnGridData = new GridData();
55  btnGridData.widthHint = 80;
56  btnGridData.heightHint = 26;
57  button.setLayoutData(btnGridData);
58  button.addSelectionListener(new SelectionListener() {
59  public void widgetDefaultSelected(SelectionEvent e) {}
60  public void widgetSelected(SelectionEvent e) {
61  update();
62  }
63  });
64 
65  new Label(northPane, SWT.NONE).setText(MessageBundle.get("GrxORBMonitor.label.host")); //$NON-NLS-1$
66 
67  textNsHost_ = new Text(northPane, SWT.SINGLE | SWT.BORDER);
68  textNsHost_.setText(GrxCorbaUtil.nsHost());
69  GridData textGridData = new GridData();
70  textGridData.widthHint = 100;
71  textNsHost_.setLayoutData(textGridData);
72 
73  new Label(northPane, SWT.NONE).setText(MessageBundle.get("GrxORBMonitor.label.port")); //$NON-NLS-1$
74 
75  textNsPort_ = new Text(northPane, SWT.SINGLE | SWT.BORDER);
76  Integer nsPort = new Integer(GrxCorbaUtil.nsPort());
77  textNsPort_.setText(nsPort.toString());
78  textNsPort_.setLayoutData(textGridData);
79 
80  multiText = new Text(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
81  multiText.setEditable(false);
82  multiText.setLayoutData(new GridData(GridData.FILL_BOTH));
83 
84  labelNs = new Label(this, SWT.SHADOW_NONE);
85  labelNs.setText(MessageBundle.get("GrxORBMonitor.label.NSURL0")); //$NON-NLS-1$
86  labelNs.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
87 
88  setSize(412, 280);
89  }
90 
91  // public methods --------------------------------------------------------
92  // public static GrxORBMonitor getInstance() {
93  // if (this_ == null){
94  // this_ = new GrxORBMonitor();
95  // }
96  // return this_;
97  // }
98 
99  public void showDialog() {//JFrame frame){
100  if (dialog_ == null) {
101  dialog_ = new MessageBox(null, SWT.OK);
102  //dialog_ = new JDialog(frame,"ORB Monitor",false);
103  dialog_.setMessage(MessageBundle.get("GrxORBMonitor.dialog.message.ORB")); //$NON-NLS-1$
104  //dialog_.pack();
105  //dialog_.setContentPane(this);
106  // dialog_.addWindowListener(new java.awt.event.WindowAdapter() {
107  // public void windowClosing(java.awt.event.WindowEvent e) {
108  // dialog_.setVisible(false);
109  // }
110  // });
111  }
112  multiText.setText(""); //$NON-NLS-1$
113  dialog_.open();
114  }
115 
116  public void update() {
117  String nsHost = textNsHost_.getText();
118  String nsPort = textNsPort_.getText();
119  if (nsHost == null || nsPort == null) {
120  return;
121  }
122  int nsPortInt = Integer.parseInt(nsPort);
123  labelNs.setText(MessageBundle.get("GrxORBMonitor.label.NSURL1") + nsHost + ":" + nsPort + "/NameService"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
124 
125  String s[] = GrxCorbaUtil.getObjectNameList(nsHost, nsPortInt);
126  multiText.setText(""); //$NON-NLS-1$
127  if (s == null) {
128  return;
129  }
130  for (int i = 0; i < s.length; i++) {
131  String str = null;
132  if (GrxCorbaUtil.isConnected(s[i], nsHost, nsPortInt)) {
133  str = MessageBundle.get("GrxORBMonitor.text.active") + s[i] + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
134  } else {
135  GrxDebugUtil.println("[GrxORBMonitor] " + s[i] + " is not in " + nsHost + ":" + nsPortInt + " active"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
136  str = MessageBundle.get("GrxORBMonitor.text.notActive") + s[i] + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
137  }
138  multiText.append(str);
139  }
140 
141  GrxDebugUtil.println("ObjectNum:" + s.length); //$NON-NLS-1$
142  }
143 
144  public String getNSHost() {
145  return textNsHost_.getText();
146  }
147 
148  public String getNSPort() {
149  return textNsPort_.getText();
150  }
151 }
static final String get(String key)
#define null
our own NULL pointer
Definition: IceTypes.h:57
png_uint_32 i
Definition: png.h:2735
static String nsHost()
get hostname where naming server is running
GrxORBMonitor(Composite parent, int style)
static int nsPort()
get port number where naming server is listening
static boolean isConnected(org.omg.CORBA.Object obj)
org


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:38