Class: Y2Network::Dialogs::IPAddressLabel

Inherits:
CWM::InputField
  • Object
show all
Defined in:
src/lib/y2network/dialogs/additional_address.rb

Overview

Widget to modify the label of an additional IP address configuration

Instance Method Summary collapse

Constructor Details

#initialize(name, settings, focus: false) ⇒ IPAddressLabel

Returns a new instance of IPAddressLabel.



109
110
111
112
113
114
115
# File 'src/lib/y2network/dialogs/additional_address.rb', line 109

def initialize(name, settings, focus: false)
  textdomain "network"

  @name = name
  @settings = settings
  @focus = focus
end

Instance Method Details

#initObject



117
118
119
120
121
# File 'src/lib/y2network/dialogs/additional_address.rb', line 117

def init
  self.value = @settings.label
  focus if @focus
  Yast::UI.ChangeWidget(Id(widget_id), :ValidChars, Yast::String.CAlnum)
end

#labelObject



123
124
125
# File 'src/lib/y2network/dialogs/additional_address.rb', line 123

def label
  _("&Address Label")
end

#storeObject



127
128
129
# File 'src/lib/y2network/dialogs/additional_address.rb', line 127

def store
  @settings.label = value
end

#validateObject



131
132
133
134
135
136
137
# File 'src/lib/y2network/dialogs/additional_address.rb', line 131

def validate
  return true if "#{@name}.#{value}" =~ /^[[:alnum:]._:-]{1,15}\z/

  Yast::Popup.Error(_("Label is too long."))
  focus
  false
end