2
0
Просмотр исходного кода

Use a prompt to connect helios

Nicolas Petton 10 лет назад
Родитель
Сommit
83e02c6d43
2 измененных файлов с 166 добавлено и 171 удалено
  1. 119 123
      src/Helios-Core.js
  2. 47 48
      src/Helios-Core.st

+ 119 - 123
src/Helios-Core.js

@@ -1376,6 +1376,125 @@ globals.HLProgressHandler);
 
 
 
+smalltalk.addClass('HLRemoteConnector', globals.InterfacingObject, [], 'Helios-Core');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "connect",
+protocol: 'connecting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._connectTo_(self._prompt_default_("Connect Helios to","http://localhost:4000"));
+return self}, function($ctx1) {$ctx1.fill(self,"connect",{},globals.HLRemoteConnector)})},
+args: [],
+source: "connect\x0a\x09self connectTo: (self \x0a\x09\x09prompt: 'Connect Helios to'\x0a\x09\x09default: 'http://localhost:4000')",
+messageSends: ["connectTo:", "prompt:default:"],
+referencedClasses: []
+}),
+globals.HLRemoteConnector);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "connectTo:",
+protocol: 'connecting',
+fn: function (aLocation){
+var self=this;
+var target;
+function $HLManager(){return globals.HLManager||(typeof HLManager=="undefined"?nil:HLManager)}
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2,$3,$4,$receiver;
+target=self._openLocation_(aLocation);
+_st(target)._on_do_("loaded",(function(){
+var win;
+return smalltalk.withContext(function($ctx2) {
+win=_st(target)._at_("window");
+$ctx2.sendIdx["at:"]=1;
+win;
+return _st((function(){
+var globals,environment;
+return smalltalk.withContext(function($ctx3) {
+$1=_st(win)._at_("requirejs");
+$ctx3.sendIdx["at:"]=2;
+globals=_st($1)._value_("amber_vm/globals");
+globals;
+$2=globals;
+if(($receiver = $2) == nil || $receiver == null){
+self._error_("Unable to connect to ".__comma(aLocation));
+} else {
+$2;
+};
+environment=_st(_st(globals)._at_("Environment"))._new();
+environment;
+$3=_st($HLManager())._current();
+_st($3)._environment_(environment);
+$4=_st($3)._registerServices();
+return $4;
+}, function($ctx3) {$ctx3.fillBlock({globals:globals,environment:environment},$ctx2,2)})}))._valueWithTimeout_((3000));
+}, function($ctx2) {$ctx2.fillBlock({win:win},$ctx1,1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"connectTo:",{aLocation:aLocation,target:target},globals.HLRemoteConnector)})},
+args: ["aLocation"],
+source: "connectTo: aLocation\x0a\x09| target |\x0a\x09\x0a\x09target := self openLocation: aLocation.\x0a\x09target on: 'loaded' do: [\x0a\x09\x09| win |\x0a\x09\x09win := target at: 'window'.\x0a\x09\x09\x0a\x09\x09[\x0a\x09\x09\x09| globals environment |\x0a\x09\x09\x09globals := (win at: 'requirejs') value: 'amber_vm/globals'.\x0a\x09\x09\x09globals ifNil: [ self error: 'Unable to connect to ', aLocation ].\x0a\x09\x0a\x09\x09\x09environment := (globals at: 'Environment') new.\x0a\x09\x09\x09HLManager current \x0a\x09\x09\x09\x09environment: environment;\x0a\x09\x09\x09\x09registerServices ] valueWithTimeout: 3000 ]",
+messageSends: ["openLocation:", "on:do:", "at:", "valueWithTimeout:", "value:", "ifNil:", "error:", ",", "new", "environment:", "current", "registerServices"],
+referencedClasses: ["HLManager"]
+}),
+globals.HLRemoteConnector);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "openLocation:",
+protocol: 'connecting',
+fn: function (aLocation){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+
+		return require('nw.gui').Window.open(aLocation);
+	;
+return self}, function($ctx1) {$ctx1.fill(self,"openLocation:",{aLocation:aLocation},globals.HLRemoteConnector)})},
+args: ["aLocation"],
+source: "openLocation: aLocation\x0a\x09<\x0a\x09\x09return require('nw.gui').Window.open(aLocation);\x0a\x09>",
+messageSends: [],
+referencedClasses: []
+}),
+globals.HLRemoteConnector);
+
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "connect",
+protocol: 'connecting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._new())._connect();
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"connect",{},globals.HLRemoteConnector.klass)})},
+args: [],
+source: "connect\x0a\x09^ self new connect",
+messageSends: ["connect", "new"],
+referencedClasses: []
+}),
+globals.HLRemoteConnector.klass);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "connectTo:",
+protocol: 'connecting',
+fn: function (anUrl){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=_st(self._new())._connectTo_(anUrl);
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"connectTo:",{anUrl:anUrl},globals.HLRemoteConnector.klass)})},
+args: ["anUrl"],
+source: "connectTo: anUrl\x0a\x09^ self new connectTo: anUrl",
+messageSends: ["connectTo:", "new"],
+referencedClasses: []
+}),
+globals.HLRemoteConnector.klass);
+
+
 smalltalk.addClass('HLWidget', globals.Widget, ['wrapper'], 'Helios-Core');
 globals.HLWidget.comment="I am the abstract superclass of all Helios widgets.\x0a\x0aI provide common methods, additional behavior to widgets useful for Helios, like dialog creation, command execution and tab creation.\x0a\x0a## API\x0a\x0a1. Rendering\x0a\x0a    Instead of overriding `#renderOn:` as with other Widget subclasses, my subclasses should override `#renderContentOn:`.\x0a\x0a2. Refreshing\x0a\x0a    To re-render a widget, use `#refresh`.\x0a\x0a3. Key bindings registration and tabs\x0a\x0a    When displayed as a tab, the widget has a chance to register keybindings with the `#registerBindingsOn:` hook method.\x0a    \x0a4. Unregistration\x0a\x0a    When a widget has subscribed to announcements or other actions that need to be cleared when closing the tab, the hook method `#unregister` will be called by helios.\x0a\x0a5. Tabs\x0a\x0a   To enable a widget class to be open as a tab, override the class-side `#canBeOpenAsTab` method to answer `true`. `#tabClass` and `#tabPriority` can be overridden too to respectively change the css class of the tab and the order of tabs in the main menu.\x0a\x0a6. Command execution\x0a\x0a    An helios command (instance of `HLCommand` or one of its subclass) can be executed with `#execute:`.";
 smalltalk.addMethod(
@@ -5721,129 +5840,6 @@ referencedClasses: []
 globals.HLProgressBarWidget.klass);
 
 
-smalltalk.addClass('HLRemoteConnector', globals.HLWidget, [], 'Helios-Core');
-smalltalk.addMethod(
-smalltalk.method({
-selector: "connect",
-protocol: 'connecting',
-fn: function (){
-var self=this;
-function $HLManager(){return globals.HLManager||(typeof HLManager=="undefined"?nil:HLManager)}
-return smalltalk.withContext(function($ctx1) { 
-_st(_st($HLManager())._current())._request_value_do_("Connect Helios to","http://localhost:4000",(function(url){
-return smalltalk.withContext(function($ctx2) {
-return self._connectTo_(url);
-}, function($ctx2) {$ctx2.fillBlock({url:url},$ctx1,1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"connect",{},globals.HLRemoteConnector)})},
-args: [],
-source: "connect\x0a\x09HLManager current\x0a\x09\x09request: 'Connect Helios to'\x0a\x09\x09value: 'http://localhost:4000'\x0a\x09\x09do: [ :url | self connectTo: url ]",
-messageSends: ["request:value:do:", "current", "connectTo:"],
-referencedClasses: ["HLManager"]
-}),
-globals.HLRemoteConnector);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "connectTo:",
-protocol: 'connecting',
-fn: function (aLocation){
-var self=this;
-var target;
-function $HLManager(){return globals.HLManager||(typeof HLManager=="undefined"?nil:HLManager)}
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2,$3,$4,$receiver;
-target=self._openLocation_(aLocation);
-_st(target)._on_do_("loaded",(function(){
-var win;
-return smalltalk.withContext(function($ctx2) {
-win=_st(target)._at_("window");
-$ctx2.sendIdx["at:"]=1;
-win;
-return _st((function(){
-var globals,environment;
-return smalltalk.withContext(function($ctx3) {
-$1=_st(win)._at_("requirejs");
-$ctx3.sendIdx["at:"]=2;
-globals=_st($1)._value_("amber_vm/globals");
-globals;
-$2=globals;
-if(($receiver = $2) == nil || $receiver == null){
-self._error_("Unable to connect to ".__comma(aLocation));
-} else {
-$2;
-};
-environment=_st(_st(globals)._at_("Environment"))._new();
-environment;
-$3=_st($HLManager())._current();
-_st($3)._environment_(environment);
-$4=_st($3)._registerServices();
-return $4;
-}, function($ctx3) {$ctx3.fillBlock({globals:globals,environment:environment},$ctx2,2)})}))._valueWithTimeout_((3000));
-}, function($ctx2) {$ctx2.fillBlock({win:win},$ctx1,1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"connectTo:",{aLocation:aLocation,target:target},globals.HLRemoteConnector)})},
-args: ["aLocation"],
-source: "connectTo: aLocation\x0a\x09| target |\x0a\x09\x0a\x09target := self openLocation: aLocation.\x0a\x09target on: 'loaded' do: [\x0a\x09\x09| win |\x0a\x09\x09win := target at: 'window'.\x0a\x09\x09\x0a\x09\x09[\x0a\x09\x09\x09| globals environment |\x0a\x09\x09\x09globals := (win at: 'requirejs') value: 'amber_vm/globals'.\x0a\x09\x09\x09globals ifNil: [ self error: 'Unable to connect to ', aLocation ].\x0a\x09\x0a\x09\x09\x09environment := (globals at: 'Environment') new.\x0a\x09\x09\x09HLManager current \x0a\x09\x09\x09\x09environment: environment;\x0a\x09\x09\x09\x09registerServices ] valueWithTimeout: 3000 ]",
-messageSends: ["openLocation:", "on:do:", "at:", "valueWithTimeout:", "value:", "ifNil:", "error:", ",", "new", "environment:", "current", "registerServices"],
-referencedClasses: ["HLManager"]
-}),
-globals.HLRemoteConnector);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "openLocation:",
-protocol: 'connecting',
-fn: function (aLocation){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-
-		return require('nw.gui').Window.open(aLocation);
-	;
-return self}, function($ctx1) {$ctx1.fill(self,"openLocation:",{aLocation:aLocation},globals.HLRemoteConnector)})},
-args: ["aLocation"],
-source: "openLocation: aLocation\x0a\x09<\x0a\x09\x09return require('nw.gui').Window.open(aLocation);\x0a\x09>",
-messageSends: [],
-referencedClasses: []
-}),
-globals.HLRemoteConnector);
-
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "connect",
-protocol: 'connecting',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._new())._connect();
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"connect",{},globals.HLRemoteConnector.klass)})},
-args: [],
-source: "connect\x0a\x09^ self new connect",
-messageSends: ["connect", "new"],
-referencedClasses: []
-}),
-globals.HLRemoteConnector.klass);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "connectTo:",
-protocol: 'connecting',
-fn: function (anUrl){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(self._new())._connectTo_(anUrl);
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"connectTo:",{anUrl:anUrl},globals.HLRemoteConnector.klass)})},
-args: ["anUrl"],
-source: "connectTo: anUrl\x0a\x09^ self new connectTo: anUrl",
-messageSends: ["connectTo:", "new"],
-referencedClasses: []
-}),
-globals.HLRemoteConnector.klass);
-
-
 smalltalk.addClass('HLTabWidget', globals.HLWidget, ['widget', 'label', 'root'], 'Helios-Core');
 globals.HLTabWidget.comment="I am a widget specialized into building another widget as an Helios tab.\x0a\x0aI should not be used directly, `HLWidget class >> #openAsTab` should be used instead.\x0a\x0a## Example\x0a\x0a    HLWorkspace openAsTab";
 smalltalk.addMethod(

+ 47 - 48
src/Helios-Core.st

@@ -491,6 +491,53 @@ do: aBlock on: aCollection displaying: aString
 		displaying: aString
 ! !
 
+InterfacingObject subclass: #HLRemoteConnector
+	instanceVariableNames: ''
+	package: 'Helios-Core'!
+
+!HLRemoteConnector methodsFor: 'connecting'!
+
+connect
+	self connectTo: (self 
+		prompt: 'Connect Helios to'
+		default: 'http://localhost:4000')
+!
+
+connectTo: aLocation
+	| target |
+	
+	target := self openLocation: aLocation.
+	target on: 'loaded' do: [
+		| win |
+		win := target at: 'window'.
+		
+		[
+			| globals environment |
+			globals := (win at: 'requirejs') value: 'amber_vm/globals'.
+			globals ifNil: [ self error: 'Unable to connect to ', aLocation ].
+	
+			environment := (globals at: 'Environment') new.
+			HLManager current 
+				environment: environment;
+				registerServices ] valueWithTimeout: 3000 ]
+!
+
+openLocation: aLocation
+	<
+		return require('nw.gui').Window.open(aLocation);
+	>
+! !
+
+!HLRemoteConnector class methodsFor: 'connecting'!
+
+connect
+	^ self new connect
+!
+
+connectTo: anUrl
+	^ self new connectTo: anUrl
+! !
+
 Widget subclass: #HLWidget
 	instanceVariableNames: 'wrapper'
 	package: 'Helios-Core'!
@@ -1939,54 +1986,6 @@ default
 	^ default ifNil: [ default := self new ]
 ! !
 
-HLWidget subclass: #HLRemoteConnector
-	instanceVariableNames: ''
-	package: 'Helios-Core'!
-
-!HLRemoteConnector methodsFor: 'connecting'!
-
-connect
-	HLManager current
-		request: 'Connect Helios to'
-		value: 'http://localhost:4000'
-		do: [ :url | self connectTo: url ]
-!
-
-connectTo: aLocation
-	| target |
-	
-	target := self openLocation: aLocation.
-	target on: 'loaded' do: [
-		| win |
-		win := target at: 'window'.
-		
-		[
-			| globals environment |
-			globals := (win at: 'requirejs') value: 'amber_vm/globals'.
-			globals ifNil: [ self error: 'Unable to connect to ', aLocation ].
-	
-			environment := (globals at: 'Environment') new.
-			HLManager current 
-				environment: environment;
-				registerServices ] valueWithTimeout: 3000 ]
-!
-
-openLocation: aLocation
-	<
-		return require('nw.gui').Window.open(aLocation);
-	>
-! !
-
-!HLRemoteConnector class methodsFor: 'connecting'!
-
-connect
-	^ self new connect
-!
-
-connectTo: anUrl
-	^ self new connectTo: anUrl
-! !
-
 HLWidget subclass: #HLTabWidget
 	instanceVariableNames: 'widget label root'
 	package: 'Helios-Core'!