64 lines
1.3 KiB
Smalltalk
64 lines
1.3 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioUrlNode,
|
|
#superclass : #GrafoscopioAbstractNode,
|
|
#instVars : [
|
|
'link'
|
|
],
|
|
#category : #'Grafoscopio-Model'
|
|
}
|
|
|
|
{ #category : #'instance creation' }
|
|
GrafoscopioUrlNode class >> new [
|
|
^ super new
|
|
content;
|
|
yourself
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> content [
|
|
^ (self url
|
|
ifNil: [ ' Invalid url ' ]
|
|
ifNotNil: [ :url | self fetchContent: url ])
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> fetchContent: anUrl [
|
|
^ (ZnEasy get: anUrl) entity contents
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> getUrl [
|
|
| url |
|
|
url := UIManager default
|
|
request: 'Please insert a url '
|
|
initialAnswer: 'http://'
|
|
title: 'URL Node'.
|
|
url ifNil: [ ^ nil ].
|
|
url := url asZnUrl.
|
|
(url host isEmptyOrNil
|
|
or: [ url scheme isEmptyOrNil or: [ url authority isEmptyOrNil ] ])
|
|
ifTrue: [ ^ nil ].
|
|
^ url
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioUrlNode >> link: aZnUrl [
|
|
link := aZnUrl
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> openIn: aNotebook [
|
|
super openIn: aNotebook.
|
|
aNotebook links text: (link ifNil: 'Invalid url') asString
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> shouldAskBeforeRemove [
|
|
^ false
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioUrlNode >> url [
|
|
^ link ifNil: [ link := self getUrl ]
|
|
]
|