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.



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

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

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

Instance Method Details

#initObject



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

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

#labelObject



125
126
127
# File 'src/lib/y2network/dialogs/additional_address.rb', line 125

def label
  _("&Address Label")
end

#storeObject



129
130
131
# File 'src/lib/y2network/dialogs/additional_address.rb', line 129

def store
  @settings.label = value
end

#validateObject



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

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

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