Class: Y2Network::Widgets::InterfaceName

Inherits:
CWM::ComboBox
  • Object
show all
Defined in:
src/lib/y2network/widgets/interface_name.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ InterfaceName

Returns a new instance of InterfaceName.



29
30
31
32
33
34
35
# File 'src/lib/y2network/widgets/interface_name.rb', line 29

def initialize(settings)
  super()
  textdomain "network"

  @settings = settings
  @old_name = @settings.name
end

Instance Method Details

#helpObject



45
46
47
48
# File 'src/lib/y2network/widgets/interface_name.rb', line 45

def help
  # FIXME: missing. Try to explain what it affect. Especially for fake devices
  ""
end

#initObject



50
51
52
53
# File 'src/lib/y2network/widgets/interface_name.rb', line 50

def init
  self.value = @settings.name
  Yast::UI.ChangeWidget(Id(widget_id), :ValidChars, @settings.name_valid_characters)
end

#itemsObject



55
56
57
58
59
# File 'src/lib/y2network/widgets/interface_name.rb', line 55

def items
  @settings.proposed_names.map do |name|
    [name, name]
  end
end

#labelObject



37
38
39
# File 'src/lib/y2network/widgets/interface_name.rb', line 37

def label
  _("&Configuration Name")
end

#optObject



41
42
43
# File 'src/lib/y2network/widgets/interface_name.rb', line 41

def opt
  [:editable, :hstretch]
end

#storeObject



83
84
85
86
87
# File 'src/lib/y2network/widgets/interface_name.rb', line 83

def store
  return if @settings.name == value

  @settings.rename_interface(value)
end

#validateObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'src/lib/y2network/widgets/interface_name.rb', line 61

def validate
  if @old_name != value && @settings.name_exists?(value)
    Yast::Popup.Error(
      format(_("Configuration name %s already exists.\nChoose a different one."), value)
    )
    focus
    return false
  end

  if !@settings.valid_name?(value)
    # TODO: write in popup what is limitations
    Yast::Popup.Error(
      format(_("Configuration name %s is invalid.\nChoose a different one."), value)
    )

    focus
    return false
  end

  true
end