Author: koen.aers(a)jboss.com
Date: 2011-07-28 03:51:54 -0400 (Thu, 28 Jul 2011)
New Revision: 33296
Added:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/MetaCommandTriggeredAction.java
Removed:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/ShellDecorator.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/META-INF/beans.xml
Log:
- initial implementation of MetaCommandTriggeredAction
- remove ShellDecorator
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/META-INF/beans.xml
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/META-INF/beans.xml 2011-07-28
07:49:50 UTC (rev 33295)
+++
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/META-INF/beans.xml 2011-07-28
07:51:54 UTC (rev 33296)
@@ -2,7 +2,4 @@
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
- <decorators>
- <class>org.jboss.tools.forge.runtime.ext.ShellDecorator</class>
- </decorators>
</beans>
Added:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/MetaCommandTriggeredAction.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/MetaCommandTriggeredAction.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/MetaCommandTriggeredAction.java 2011-07-28
07:51:54 UTC (rev 33296)
@@ -0,0 +1,44 @@
+package org.jboss.tools.forge.runtime.ext;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+import org.jboss.forge.shell.Shell;
+import org.jboss.forge.shell.spi.TriggeredAction;
+
+public class MetaCommandTriggeredAction implements TriggeredAction {
+
+ private static final String ESCAPE = new String(new char[] { 27, '[',
'%' });
+
+ @Inject Shell shell;
+
+ @Override
+ public ActionListener getListener() {
+ return new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ shell.print(ESCAPE);
+ String text = shell.readLine();
+ shell.print(ESCAPE);
+ handleHiddenCommand(text);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+ };
+ }
+
+ private void handleHiddenCommand(String text) {
+ shell.print(ESCAPE + "handling hidden command : " + text + ESCAPE);
+ }
+
+ @Override
+ public char getTrigger() {
+ return (char)31;
+ }
+
+}
Deleted:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/ShellDecorator.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/ShellDecorator.java 2011-07-28
07:49:50 UTC (rev 33295)
+++
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/ShellDecorator.java 2011-07-28
07:51:54 UTC (rev 33296)
@@ -1,37 +0,0 @@
-package org.jboss.tools.forge.runtime.ext;
-
-import java.io.IOException;
-
-import javax.decorator.Decorator;
-import javax.decorator.Delegate;
-import javax.inject.Inject;
-
-import org.jboss.forge.shell.Shell;
-
-@Decorator
-public abstract class ShellDecorator implements Shell {
-
- private static final String ESCAPE = new String(new char[] { 27, '[',
'%' });
-
- @Inject @Delegate Shell shell;
-
- @Override
- public String readLine() throws IOException {
- String str = shell.readLine();
- int i1 = str.indexOf(ESCAPE);
- int i2 = str.indexOf(ESCAPE, i1 + 3);
- if (i1 != -1 && str.length() > i1 + 3) {
- i2 = str.indexOf(ESCAPE);
- if (i2 != -1) {
- handleHidden(str.substring(i1 + 3, i2));
- }
- return "";
- }
- return str;
- }
-
- private void handleHidden(String str) {
- shell.println(ESCAPE + "hidden detected: " + str + ESCAPE);
- }
-
-}