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


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

def initialize(settings)
  textdomain "network"

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

Instance Method Details

#helpObject


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

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

#initObject


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

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

#itemsObject


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

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

#labelObject


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

def label
  _("&Configuration Name")
end

#optObject


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

def opt
  [:editable, :hstretch]
end

#storeObject


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

def store
  return if @settings.name == value
  @settings.rename_interface(value)
end

#validateObject


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

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