Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package com.generalrobotix.ui.util;
00020
00021 import org.eclipse.swt.SWT;
00022 import org.eclipse.swt.events.SelectionEvent;
00023 import org.eclipse.swt.events.SelectionListener;
00024 import org.eclipse.swt.layout.GridData;
00025 import org.eclipse.swt.layout.GridLayout;
00026 import org.eclipse.swt.widgets.Button;
00027 import org.eclipse.swt.widgets.Composite;
00028 import org.eclipse.swt.widgets.Label;
00029 import org.eclipse.swt.widgets.MessageBox;
00030 import org.eclipse.swt.widgets.Text;
00031
00032 @SuppressWarnings("serial")
00033 public class GrxORBMonitor extends Composite {
00034 private MessageBox dialog_ = null;
00035
00036 private Label labelNs = null;
00037 private Text multiText = null;
00038 private Text textNsHost_ = null;
00039 private Text textNsPort_ = null;
00040
00041 public GrxORBMonitor(Composite parent, int style) {
00042 super(parent, style);
00043 this.setLayout(new GridLayout(1, false));
00044
00045 Composite northPane = new Composite(this, SWT.NONE);
00046 northPane.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
00047 GridLayout gridLayout = new GridLayout(5, false);
00048 gridLayout.marginWidth = 5;
00049 gridLayout.horizontalSpacing = 5;
00050 northPane.setLayout(gridLayout);
00051
00052 Button button = new Button(northPane, SWT.PUSH);
00053 button.setText(MessageBundle.get("GrxORBMonitor.button.update"));
00054 GridData btnGridData = new GridData();
00055 btnGridData.widthHint = 80;
00056 btnGridData.heightHint = 26;
00057 button.setLayoutData(btnGridData);
00058 button.addSelectionListener(new SelectionListener() {
00059 public void widgetDefaultSelected(SelectionEvent e) {}
00060 public void widgetSelected(SelectionEvent e) {
00061 update();
00062 }
00063 });
00064
00065 new Label(northPane, SWT.NONE).setText(MessageBundle.get("GrxORBMonitor.label.host"));
00066
00067 textNsHost_ = new Text(northPane, SWT.SINGLE | SWT.BORDER);
00068 textNsHost_.setText(GrxCorbaUtil.nsHost());
00069 GridData textGridData = new GridData();
00070 textGridData.widthHint = 100;
00071 textNsHost_.setLayoutData(textGridData);
00072
00073 new Label(northPane, SWT.NONE).setText(MessageBundle.get("GrxORBMonitor.label.port"));
00074
00075 textNsPort_ = new Text(northPane, SWT.SINGLE | SWT.BORDER);
00076 Integer nsPort = new Integer(GrxCorbaUtil.nsPort());
00077 textNsPort_.setText(nsPort.toString());
00078 textNsPort_.setLayoutData(textGridData);
00079
00080 multiText = new Text(this, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
00081 multiText.setEditable(false);
00082 multiText.setLayoutData(new GridData(GridData.FILL_BOTH));
00083
00084 labelNs = new Label(this, SWT.SHADOW_NONE);
00085 labelNs.setText(MessageBundle.get("GrxORBMonitor.label.NSURL0"));
00086 labelNs.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
00087
00088 setSize(412, 280);
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 public void showDialog() {
00100 if (dialog_ == null) {
00101 dialog_ = new MessageBox(null, SWT.OK);
00102
00103 dialog_.setMessage(MessageBundle.get("GrxORBMonitor.dialog.message.ORB"));
00104
00105
00106
00107
00108
00109
00110
00111 }
00112 multiText.setText("");
00113 dialog_.open();
00114 }
00115
00116 public void update() {
00117 String nsHost = textNsHost_.getText();
00118 String nsPort = textNsPort_.getText();
00119 if (nsHost == null || nsPort == null) {
00120 return;
00121 }
00122 int nsPortInt = Integer.parseInt(nsPort);
00123 labelNs.setText(MessageBundle.get("GrxORBMonitor.label.NSURL1") + nsHost + ":" + nsPort + "/NameService");
00124
00125 String s[] = GrxCorbaUtil.getObjectNameList(nsHost, nsPortInt);
00126 multiText.setText("");
00127 if (s == null) {
00128 return;
00129 }
00130 for (int i = 0; i < s.length; i++) {
00131 String str = null;
00132 if (GrxCorbaUtil.isConnected(s[i], nsHost, nsPortInt)) {
00133 str = MessageBundle.get("GrxORBMonitor.text.active") + s[i] + "\n";
00134 } else {
00135 GrxDebugUtil.println("[GrxORBMonitor] " + s[i] + " is not in " + nsHost + ":" + nsPortInt + " active");
00136 str = MessageBundle.get("GrxORBMonitor.text.notActive") + s[i] + "\n";
00137 }
00138 multiText.append(str);
00139 }
00140
00141 GrxDebugUtil.println("ObjectNum:" + s.length);
00142 }
00143
00144 public String getNSHost() {
00145 return textNsHost_.getText();
00146 }
00147
00148 public String getNSPort() {
00149 return textNsPort_.getText();
00150 }
00151 }