[openrtm-commit:03176] r798 - in trunk/rtmtools/jp.go.aist.rtm.nameserviceview: . icons src/jp/go/aist/rtm/nameserviceview/nl src/jp/go/aist/rtm/nameserviceview/ui/action src/jp/go/aist/rtm/nameserviceview/ui/dialog

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 2月 21日 (水) 00:59:15 JST


Author: ga
Date: 2018-02-21 00:59:15 +0900 (Wed, 21 Feb 2018)
New Revision: 798

Added:
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/StartNameServiceAction.java
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/dialog/PasswordDialog.java
Modified:
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.properties
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.xml
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/nl/messages.properties
   trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/KillZombiesAction.java
Log:
Add NameSever start button

Added: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png
===================================================================
(Binary files differ)

Index: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png	2018-02-15 15:23:16 UTC (rev 797)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png	2018-02-20 15:59:15 UTC (rev 798)

Property changes on: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/icons/StartNS.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.properties	2018-02-15 15:23:16 UTC (rev 797)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.properties	2018-02-20 15:59:15 UTC (rev 798)
@@ -37,3 +37,4 @@
 Synchronize =Synchronize 
 Kill_Zombies =&Kill Zombies
 Kill_All_Zombies =Kill All Zombies
+Start_NameService =&Start_NameService

Modified: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.xml
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.xml	2018-02-15 15:23:16 UTC (rev 797)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/plugin.xml	2018-02-20 15:59:15 UTC (rev 798)
@@ -31,6 +31,15 @@
 		<viewContribution 
 			id="jp.go.aist.rtm.nameserviceview.ui.views.nameserviceview.NameServiceView.contribution" 
 			targetID="jp.go.aist.rtm.nameserviceview.ui.views.nameserviceview.NameServiceView">        
+			<action
+				class="jp.go.aist.rtm.nameserviceview.ui.action.StartNameServiceAction"
+				icon="icons/StartNS.png"
+				id="jp.go.aist.rtm.nameserviceview.ui.action.StartNameservice"
+				label="%Start_NameService"
+				menubarPath="additions"
+				toolbarPath="additions"
+				tooltip="%Start_NameService">
+			</action>
 			<action id="jp.go.aist.rtm.nameserviceview.ui.action.AddNameServiceAction" 
 				label="%Add_Name_Server" 
 				menubarPath="additions"

Modified: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/nl/messages.properties
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/nl/messages.properties	2018-02-15 15:23:16 UTC (rev 797)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/nl/messages.properties	2018-02-20 15:59:15 UTC (rev 798)
@@ -74,4 +74,8 @@
 Delete_from_Name_Service =Delete from Name Service
 Delete_from_View =Delete from View
 ShowIORDialog.title=Show IOR
-
+KillZombiesAction.title=Delete zombies
+KillZombiesAction.start=Delete all zombie entries
+KillZombiesAction.process=Deleting zombie entries...
+KillZombiesAction.finish=Finished deleting zombie entries.
+PasswordDialog.1=Please input password

Modified: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/KillZombiesAction.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/KillZombiesAction.java	2018-02-15 15:23:16 UTC (rev 797)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/KillZombiesAction.java	2018-02-20 15:59:15 UTC (rev 798)
@@ -6,6 +6,7 @@
 
 import jp.go.aist.rtm.nameserviceview.model.manager.NameServerManager;
 import jp.go.aist.rtm.nameserviceview.model.nameservice.NamingObjectNode;
+import jp.go.aist.rtm.nameserviceview.nl.Messages;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -21,6 +22,10 @@
  *
  */
 public class KillZombiesAction implements IViewActionDelegate {
+	private static final String KILL_ZOMLIES_TITLE = Messages.getString("KillZombiesAction.title");
+	private static final String KILL_ZOMLIES_START = Messages.getString("KillZombiesAction.start");
+	private static final String KILL_ZOMLIES_PROCESS = Messages.getString("KillZombiesAction.process");
+	private static final String KILL_ZOMLIES_FINISH = Messages.getString("KillZombiesAction.finish");
 
 //	@Override
 	public void init(IViewPart view) {
@@ -27,15 +32,15 @@
 	}
 
 	public void run(IAction action) {
-		Job job = new Job("ゾンビ削除処理") {
+		Job job = new Job(KILL_ZOMLIES_TITLE) {
 			@SuppressWarnings("unchecked")
 			protected IStatus run(IProgressMonitor monitor) {
 
-				monitor.beginTask("すべてのゾンビエントリを削除します", 100);
+				monitor.beginTask(KILL_ZOMLIES_START, 100);
 
 				monitor.internalWorked(30);
 
-				monitor.subTask("ゾンビのエントリを削除しています...");
+				monitor.subTask(KILL_ZOMLIES_PROCESS);
 
 				List<NamingObjectNode> deleteList = new ArrayList<NamingObjectNode>();
 				for (Iterator iter = NameServerManager.eInstance
@@ -57,7 +62,7 @@
 					}
 				}
 
-				monitor.subTask("ゾンビのエントリの削除を終了しました。");
+				monitor.subTask(KILL_ZOMLIES_FINISH);
 				monitor.done();
 
 				return org.eclipse.core.runtime.Status.OK_STATUS;

Added: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/StartNameServiceAction.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/StartNameServiceAction.java	                        (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/StartNameServiceAction.java	2018-02-20 15:59:15 UTC (rev 798)
@@ -0,0 +1,61 @@
+package jp.go.aist.rtm.nameserviceview.ui.action;
+
+import java.io.IOException;
+
+import jp.go.aist.rtm.nameserviceview.model.manager.NameServerManager;
+import jp.go.aist.rtm.nameserviceview.ui.dialog.PasswordDialog;
+import jp.go.aist.rtm.nameserviceview.ui.views.nameserviceview.NameServiceView;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+
+public class StartNameServiceAction implements IViewActionDelegate {
+	private NameServiceView view;
+	private boolean isWindows = false; 
+	
+//	@Override
+	public void init(IViewPart view) {
+		this.view = (NameServiceView) view;
+	}
+
+	public void run(IAction action) {
+		String targetOS = System.getProperty("os.name").toLowerCase();
+		if(targetOS.toLowerCase().startsWith("windows")) {
+			isWindows = true;
+		}
+		
+		if(isWindows) {
+			String target = System.getenv("RTM_ROOT") + "bin" + Path.SEPARATOR + "rtm-naming.bat"; 
+			try {
+				ProcessBuilder pb = new ProcessBuilder(target);
+				Process process = pb.start();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+			
+		} else {
+			String passWord = "";
+			PasswordDialog  passwdDialog = new PasswordDialog(view.getSite().getShell());
+			if(passwdDialog.open()!=Dialog.OK) return;
+			
+			passWord = passwdDialog.getPassWord();
+			String target = "rtm-naming"; 
+			try {
+				ProcessBuilder pb = new ProcessBuilder(target, "-f", "-w " + passWord);
+				Process process = pb.start();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		/////
+		NameServerManager.eInstance.addNameServer("localhost");
+		NameServerManager.eInstance.refreshAll();
+	}
+
+	public void selectionChanged(IAction action, ISelection selection) {
+	}
+}


Property changes on: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/action/StartNameServiceAction.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/dialog/PasswordDialog.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/dialog/PasswordDialog.java	                        (rev 0)
+++ trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/dialog/PasswordDialog.java	2018-02-20 15:59:15 UTC (rev 798)
@@ -0,0 +1,74 @@
+package jp.go.aist.rtm.nameserviceview.ui.dialog;
+
+import jp.go.aist.rtm.nameserviceview.nl.Messages;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class PasswordDialog extends Dialog {
+	private Text txtPasswd;
+	private String passWord = "";
+	
+	public String getPassWord() {
+		return passWord;
+	}
+
+	public PasswordDialog(Shell parentShell) {
+		super(parentShell);
+		setShellStyle(getShellStyle() | SWT.CENTER | SWT.RESIZE);
+	}
+	
+	@Override
+	/**
+	 * {@inheritDoc}
+	 */
+	protected void configureShell(Shell shell) {
+		super.configureShell(shell);
+		shell.setText("Input Password");
+	}
+	
+	@Override
+	protected Point getInitialSize() {
+		return getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+	}
+	
+	@Override
+	/**
+	 * {@inheritDoc}
+	 */
+	protected Control createDialogArea(Composite parent) {
+		GridLayout gridLayout = new GridLayout();
+
+		Composite mainComposite = (Composite) super.createDialogArea(parent);
+		mainComposite.setLayout(gridLayout);
+		mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+		Label label = new Label(mainComposite, SWT.NONE);
+		label.setText(Messages.getString("PasswordDialog.1")); //$NON-NLS-1$
+		GridData labelLayloutData = new GridData(
+				GridData.HORIZONTAL_ALIGN_BEGINNING);
+		label.setLayoutData(labelLayloutData);
+		labelLayloutData.heightHint = 20;
+		
+		txtPasswd = new Text(mainComposite, SWT.PASSWORD|SWT.SINGLE|SWT.BORDER);
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		txtPasswd.setLayoutData(gd);
+
+		return mainComposite;
+	}
+	
+	@Override
+	protected void okPressed() {
+		passWord = txtPasswd.getText();
+		super.okPressed();
+	}
+
+}


Property changes on: trunk/rtmtools/jp.go.aist.rtm.nameserviceview/src/jp/go/aist/rtm/nameserviceview/ui/dialog/PasswordDialog.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the openrtm-commit mailing list