Grafoscopio/src/Grafoscopio/GrafoscopioUrlNode.class.st

57 lines
1.2 KiB
Smalltalk

Class {
#name : #GrafoscopioUrlNode,
#superclass : #GrafoscopioAbstractNode,
#instVars : [
'link'
],
#category : #'Grafoscopio-Model'
}
{ #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')
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> shouldAskBeforeRemove [
^ false
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> url [
^ link ifNil: [ link := self getUrl ]
]