Skip to contentSkip to conversation

[411343]Provide access to readers in host shell

RFC PATCH In review Ioana Grigoropol 2 participants 4 messages Jun 21, 2013 – Jun 25, 2013

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 [411343]Provide access to readers in host shell

- add a plain getter in the AbstractHostShell class:
- the compilation is not broken for subclasses of this class since it always returns null
- the targeted classes (local and remote) can implement the getter (local implementation is already there)
- the reader can be accessed and the output can be read in a synchronous way
- add implementation of getReader in TerminaServiceHostShell
- store the underlying reader as a field of this class & return it

---
 .../services/shells/TerminalServiceHostShell.java  |   20 ++++++++++++--------
 .../rse/services/shells/AbstractHostShell.java     |    9 +++++++--
 2 files changed, 19 insertions(+), 10 deletions(-)
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java +12 -8
index 2a461ad..0775894 100644
@@ -22,6 +22,7 @@
  * Anna Dushistova  (MontaVista) - [258720] SshHostShell fails to run command if initialWorkingDirectory supplied
  * Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
  * Martin Oberhuber (Wind River) - [356132] wait for initial output
+ * Ioana Grigoropol (Intel)      - [411343] Provide access to readers in host shell
  *******************************************************************************/
 
 package org.eclipse.rse.internal.services.shells;
@@ -47,7 +48,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
 	public static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$
 
 	ITerminalShell fTerminalShell;
-	
+	BufferedReader fBufReader;
 	private TerminalServiceShellOutputReader fStdoutHandler;
 	
 	private TerminalServiceShellOutputReader fStderrHandler;
@@ -60,21 +61,21 @@ public class TerminalServiceHostShell extends AbstractHostShell {
 		try {
 			fTerminalShell = terminalShell;
 			String encoding = fTerminalShell.getDefaultEncoding();
-			BufferedReader bufReader;
+
 			if (encoding != null) {
-				bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+				fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell
 						.getInputStream(), encoding)); 
 			} else {
-				bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+				fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell
 								.getInputStream()));
 			}
 			//bug 356132: wait for initial output before sending any command
 			//FIXME this should likely move into the TerminalServiceShellWriterThread, so wait can be canceled
-			bufReader.mark(1);
-			bufReader.read();
-			bufReader.reset();
+			fBufReader.mark(1);
+			fBufReader.read();
+			fBufReader.reset();
 			
-			fStdoutHandler = new TerminalServiceShellOutputReader(this, bufReader, false);
+			fStdoutHandler = new TerminalServiceShellOutputReader(this, fBufReader, false);
 			fStderrHandler = new TerminalServiceShellOutputReader(this, null, true);
 			OutputStream outputStream = fTerminalShell.getOutputStream();
 			if (encoding != null) {
@@ -170,4 +171,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
 		return "echo $PWD'>'"; //$NON-NLS-1$
 	}
 
+	public BufferedReader getReader(boolean isErrorReader) {
+		return fBufReader;
+	}
 }
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java +7 -2
index 0ac8e3f..4d189b6 100644
@@ -11,11 +11,13 @@
  * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
  * 
  * Contributors:
- * {Name} (company) - description of contribution.
+ *   Ioana Grigoropol (Intel)      - [411343] Provide access to readers in host shell
  ********************************************************************************/
 
 package org.eclipse.rse.services.shells;
 
+import java.io.BufferedReader;
+
 
 public abstract class AbstractHostShell implements IHostShell
 {
@@ -34,4 +36,7 @@ public abstract class AbstractHostShell implements IHostShell
 		}
 	}
 
-}
\ No newline at end of file
+	public BufferedReader getReader(boolean isErrorReader){
+		return null;
+	}
+}
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH v2 1/1 [411387] SystemRemoteFolderDialog should return a path when selecting 'My Home' or 'Root'

- when browsing to pick the project location, if "My Home" or "Root" get picked the project location remains empty
- this is caused by the RSEUIFileManager browseDirectory method
- the selection made in the SystemRemoteFolderDialog is an SystemFilterReference, and thus not a instance of IRemoteFile.
- if the selection is of type ISystemFilterReference:
- make sure that the children of the system filter are populated
- retrieve the adapter for the filter and populate the children list
- retrieve first child from the list & return parent path
- if the parent path is null for the first child:
- this is actually the root of the file system -> return path of this child

---
 .../internal/remote/rse/ui/RSEUIFileManager.java   |   27 +++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
core/org.eclipse.ptp.remote.rse.ui/src/org/eclipse/ptp/internal/remote/rse/ui/RSEUIFileManager.java +26 -1
index 8182f01..c9a6357 100644
@@ -7,21 +7,27 @@
  *
  * Contributors:
  * IBM Corporation - Initial API and implementation
+ * Ioana Grigoropol (Intel) - browseDirectory should return a path when selecting 'My Home' or 'Root'
  *******************************************************************************/
 package org.eclipse.ptp.internal.remote.rse.ui;
 
 import java.util.Vector;
 
+import org.eclipse.core.runtime.IAdapterFactory;
 import org.eclipse.jface.window.Window;
 import org.eclipse.ptp.internal.remote.rse.core.RSEConnection;
 import org.eclipse.ptp.remote.core.IRemoteConnection;
 import org.eclipse.ptp.remote.core.IRemoteConnectionManager;
 import org.eclipse.ptp.remote.core.IRemoteServices;
 import org.eclipse.ptp.remote.ui.IRemoteUIFileManager;
+import org.eclipse.rse.core.filters.ISystemFilterReference;
 import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.SystemChildrenContentsType;
 import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog;
 import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog;
+import org.eclipse.rse.internal.ui.view.SystemViewFilterReferenceAdapter;
 import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.rse.ui.RSEUIPlugin;
 import org.eclipse.swt.widgets.Shell;
 
 public class RSEUIFileManager implements IRemoteUIFileManager {
@@ -51,6 +57,25 @@ public class RSEUIFileManager implements IRemoteUIFileManager {
 			if (retObj instanceof IRemoteFile) {
 				IRemoteFile selectedFile = (IRemoteFile) retObj;
 				return selectedFile.getAbsolutePath();
+			} else if (retObj instanceof ISystemFilterReference){
+				ISystemFilterReference selectedFile = (ISystemFilterReference)retObj;
+
+				RSEUIPlugin plugin = RSEUIPlugin.getDefault();
+				if (selectedFile.getContents(SystemChildrenContentsType.getInstance()) == null) {
+					// in order to make sure that the children of this SystemFilterReference are populated
+					// the method getChildren() of the underlying adapter must be invoked
+					IAdapterFactory factory = plugin.getSystemViewAdapterFactory();
+					SystemViewFilterReferenceAdapter adapter = (SystemViewFilterReferenceAdapter)factory.getAdapter(selectedFile, ISystemFilterReference.class);
+					adapter.getChildren(selectedFile);
+				}
+				// now that the children are cached for the filter references we can try and access them
+				Object[] con = selectedFile.getContents(SystemChildrenContentsType.getInstance());
+				if (con != null && con[0] instanceof IRemoteFile) {
+					IRemoteFile file = (IRemoteFile)con[0];
+					if (file.getParentPath() == null)
+						return file.getAbsolutePath();// this is actually the root of the file system
+					return file.getParentPath();
+				}
 			}
 		}
 		return null;
@@ -134,4 +159,4 @@ public class RSEUIFileManager implements IRemoteUIFileManager {
 	public void showConnections(boolean enable) {
 		onlyConnection = !enable;
 	}
-}
\ No newline at end of file
+}
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to Ioana Grigoropol

Hi Ioana,

Unfortunately we have to introduce the API getReader in IHostShell interface, otherwise, when I applied the patch to my clean upstream RSE master and open a project I'm getting:

An internal error occurred during "Open Project"
Unresolved compilation problems:
The method getReader(Boolean) is undefined for the type IHostShell....

Please do some local verification when sending patches upstream.

Thanks,
Jessica

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Friday, June 21, 2013 8:19 AM
To: [email protected]
Subject: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

- add a plain getter in the AbstractHostShell class:
- the compilation is not broken for subclasses of this class since it always returns null
- the targeted classes (local and remote) can implement the getter (local implementation is already there)
- the reader can be accessed and the output can be read in a synchronous way
- add implementation of getReader in TerminaServiceHostShell
- store the underlying reader as a field of this class & return it

---
 .../services/shells/TerminalServiceHostShell.java  |   20 ++++++++++++--------
 .../rse/services/shells/AbstractHostShell.java     |    9 +++++++--
 2 files changed, 19 insertions(+), 10 deletions(-)
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/ renamed from rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java +0 -0
index 2a461ad..0775894 100644

+++ services/shells/TerminalServiceHostShell.java
@@ -22,6 +22,7 @@
* Anna Dushistova (MontaVista) - [258720] SshHostShell fails to run command if initialWorkingDirectory supplied
* Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
* Martin Oberhuber (Wind River) - [356132] wait for initial output
+ * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell
*******************************************************************************/

package org.eclipse.rse.internal.services.shells;
@@ -47,7 +48,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
public static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$

ITerminalShell fTerminalShell;
-
+ BufferedReader fBufReader;
private TerminalServiceShellOutputReader fStdoutHandler;

private TerminalServiceShellOutputReader fStderrHandler; @@ -60,21 +61,21 @@ public class TerminalServiceHostShell extends AbstractHostShell {
try {
fTerminalShell = terminalShell;
String encoding = fTerminalShell.getDefaultEncoding();
- BufferedReader bufReader;
+
if (encoding != null) {
- bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+ fBufReader = new BufferedReader(new
+InputStreamReader(fTerminalShell
.getInputStream(), encoding));
} else {
- bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+ fBufReader = new BufferedReader(new
+InputStreamReader(fTerminalShell
.getInputStream()));
}
//bug 356132: wait for initial output before sending any command
//FIXME this should likely move into the TerminalServiceShellWriterThread, so wait can be canceled
- bufReader.mark(1);
- bufReader.read();
- bufReader.reset();
+ fBufReader.mark(1);
+ fBufReader.read();
+ fBufReader.reset();

- fStdoutHandler = new TerminalServiceShellOutputReader(this, bufReader, false);
+ fStdoutHandler = new TerminalServiceShellOutputReader(this,
+fBufReader, false);
fStderrHandler = new TerminalServiceShellOutputReader(this, null, true); OutputStream outputStream = fTerminalShell.getOutputStream(); if (encoding != null) {
@@ -170,4 +171,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
return "echo $PWD'>'"; //$NON-NLS-1$
}

+ public BufferedReader getReader(boolean isErrorReader) {
+ return fBufReader;
+ }
}

rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/ renamed from rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java +0 -0
index 0ac8e3f..4d189b6 100644

+++ shells/AbstractHostShell.java
@@ -11,11 +11,13 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. *
* Contributors:
- * {Name} (company) - description of contribution.
+ * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell
********************************************************************************/

package org.eclipse.rse.services.shells;

+import java.io.BufferedReader;
+

public abstract class AbstractHostShell implements IHostShell { @@ -34,4 +36,7 @@ public abstract class AbstractHostShell implements IHostShell
}
}

-}
\ No newline at end of file
+ public BufferedReader getReader(boolean isErrorReader){
+ return null;
+ }
+}
--
1.7.10.4

_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#3 lore raw

Hi Jessica,

I have just tested with a clean master & my upstream patch. Everything compiles fine.
There are no changes made to IHostShell what so ever. In this patch, I only change AbstractHostShell and TerminalServiceHostShell.

Please make sure that your TM &Yocto plugin sources are up to date and refreshed in you workspace.

Thanks,
Ioana
________________________________________
From: Zhang, Jessica
Sent: Friday, June 21, 2013 8:42 PM
To: Grigoropol, IoanaX; [email protected]
Subject: RE: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

Hi Ioana,

Unfortunately we have to introduce the API getReader in IHostShell interface, otherwise, when I applied the patch to my clean upstream RSE master and open a project I'm getting:

An internal error occurred during "Open Project"
Unresolved compilation problems:
The method getReader(Boolean) is undefined for the type IHostShell....

Please do some local verification when sending patches upstream.

Thanks,
Jessica

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ioana Grigoropol
Sent: Friday, June 21, 2013 8:19 AM
To: [email protected]
Subject: [yocto] [RFC PATCH v2 upstream org.eclipse.tm] [411343]Provide access to readers in host shell

- add a plain getter in the AbstractHostShell class:
- the compilation is not broken for subclasses of this class since it always returns null
- the targeted classes (local and remote) can implement the getter (local implementation is already there)
- the reader can be accessed and the output can be read in a synchronous way
- add implementation of getReader in TerminaServiceHostShell
- store the underlying reader as a field of this class & return it

---
 .../services/shells/TerminalServiceHostShell.java  |   20 ++++++++++++--------
 .../rse/services/shells/AbstractHostShell.java     |    9 +++++++--
 2 files changed, 19 insertions(+), 10 deletions(-)
rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/ renamed from rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java +0 -0
index 2a461ad..0775894 100644

+++ services/shells/TerminalServiceHostShell.java
@@ -22,6 +22,7 @@
* Anna Dushistova (MontaVista) - [258720] SshHostShell fails to run command if initialWorkingDirectory supplied
* Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
* Martin Oberhuber (Wind River) - [356132] wait for initial output
+ * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell
*******************************************************************************/

package org.eclipse.rse.internal.services.shells;
@@ -47,7 +48,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
public static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$

ITerminalShell fTerminalShell;
-

+       BufferedReader fBufReader;
        private TerminalServiceShellOutputReader fStdoutHandler;

        private TerminalServiceShellOutputReader fStderrHandler; @@ -60,21 +61,21 @@ public class TerminalServiceHostShell extends AbstractHostShell {
                try {
                        fTerminalShell = terminalShell;
                        String encoding = fTerminalShell.getDefaultEncoding();
-                       BufferedReader bufReader;
+
                        if (encoding != null) {
-                               bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+                               fBufReader = new BufferedReader(new
+InputStreamReader(fTerminalShell
                                                .getInputStream(), encoding));
                        } else {
-                               bufReader = new BufferedReader(new InputStreamReader(fTerminalShell
+                               fBufReader = new BufferedReader(new
+InputStreamReader(fTerminalShell
                                                                .getInputStream()));
                        }
                        //bug 356132: wait for initial output before sending any command
                        //FIXME this should likely move into the TerminalServiceShellWriterThread, so wait can be canceled
-                       bufReader.mark(1);
-                       bufReader.read();
-                       bufReader.reset();
+                       fBufReader.mark(1);
+                       fBufReader.read();
+                       fBufReader.reset();

- fStdoutHandler = new TerminalServiceShellOutputReader(this, bufReader, false);
+ fStdoutHandler = new TerminalServiceShellOutputReader(this,

+fBufReader, false);
                        fStderrHandler = new TerminalServiceShellOutputReader(this, null, true);
                        OutputStream outputStream = fTerminalShell.getOutputStream();
                        if (encoding != null) {
@@ -170,4 +171,7 @@ public class TerminalServiceHostShell extends AbstractHostShell {
                return "echo $PWD'>'"; //$NON-NLS-1$
        }

+ public BufferedReader getReader(boolean isErrorReader) {
+ return fBufReader;
+ }
}

rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/ renamed from rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShell.java +0 -0
index 0ac8e3f..4d189b6 100644

+++ shells/AbstractHostShell.java
@@ -11,11 +11,13 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. *
* Contributors:
- * {Name} (company) - description of contribution.
+ * Ioana Grigoropol (Intel) - [411343] Provide access to readers in host shell
********************************************************************************/

package org.eclipse.rse.services.shells;

+import java.io.BufferedReader;
+

public abstract class AbstractHostShell implements IHostShell { @@ -34,4 +36,7 @@ public abstract class AbstractHostShell implements IHostShell

                }
        }

-}
\ No newline at end of file
+ public BufferedReader getReader(boolean isErrorReader){
+ return null;
+ }
+}
--
1.7.10.4

_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto