Module: Yast::PartitioningEpGraphInclude

Defined in:
../../src/include/partitioning/ep-graph.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CreateDeviceGraphPanel(user_data)



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File '../../src/include/partitioning/ep-graph.rb', line 59

def CreateDeviceGraphPanel(user_data)
  filename = "#{Directory.tmpdir}/device.gv"
  Storage.SaveDeviceGraph(filename)

  UI.ReplaceWidget(
    :tree_panel,
    Greasemonkey.Transform(
      VBox(
        # dialog heading, graph is the mathematic term for
        # a set of notes connected with edges
        term(:IconAndHeading, _("Device Graph"), StorageIcons.graph_icon),
        term(
          :Graph,
          Id(:graph),
          Opt(:notify, :notifyContextMenu),
          filename,
          "dot"
        ),
        HBox(
          # button text
          PushButton(Id(:save), _("Save Device Graph...")),
          HStretch()
        )
      )
    )
  )

  SCR.Execute(path(".target.remove"), filename)

  # helptext
  helptext = _("<p>This view shows a graph of devices.</p>")

  Wizard.RestoreHelp(helptext)

  nil
end

- (Object) CreateMountGraphPanel(user_data)



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File '../../src/include/partitioning/ep-graph.rb', line 154

def CreateMountGraphPanel(user_data)
  filename = "#{Directory.tmpdir}/mount.gv"
  Storage.SaveMountGraph(filename)

  UI.ReplaceWidget(
    :tree_panel,
    Greasemonkey.Transform(
      VBox(
        # dialog heading, graph is the mathematic term for
        # a set of notes connected with edges
        term(:IconAndHeading, _("Mount Graph"), StorageIcons.graph_icon),
        term(
          :Graph,
          Id(:graph),
          Opt(:notify, :notifyContextMenu),
          filename,
          "dot"
        ),
        HBox(
          # button text
          PushButton(Id(:save), _("Save Mount Graph...")),
          HStretch()
        )
      )
    )
  )

  SCR.Execute(path(".target.remove"), filename)

  # helptext
  helptext = _("<p>This view shows a graph of mount points.</p>")

  Wizard.RestoreHelp(helptext)

  nil
end

- (Object) EpContextMenuDeviceGraph



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File '../../src/include/partitioning/ep-graph.rb', line 32

def EpContextMenuDeviceGraph
  widget = ContextMenu.Simple(
    [
      Item(
        Id(:add_raid),
        term(:icon, StorageIcons.raid_icon),
        _("Add RAID")
      ),
      Item(
        Id(:add_lvmvg),
        term(:icon, StorageIcons.lvm_icon),
        _("Add Volume Group")
      )
    ]
  )

  case widget
    when :add_raid
      EpCreateRaid()
    when :add_lvmvg
      EpCreateVolumeGroup()
  end

  nil
end

- (Object) HandleDeviceGraphPanel(user_data, event)



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File '../../src/include/partitioning/ep-graph.rb', line 109

def HandleDeviceGraphPanel(user_data, event)
  event = deep_copy(event)
  _GotoDevice = lambda do |device|
    TreePanel.SwitchToNew(device)
    UI.SetFocus(UI.WidgetExists(Id(:table)) ? Id(:table) : Id(:text))

    nil
  end

  case Event.IsWidgetContextMenuActivated(event)
    when :graph
      node = Convert.to_string(UI.QueryWidget(Id(:graph), :Item))

      if Builtins.isempty(node)
        EpContextMenuDeviceGraph()
      elsif String.StartsWith(node, "device:")
        EpContextMenuDevice(Builtins.substring(node, 7))
      end 

      # TODO: update graph
  end

  case Event.IsWidgetActivated(event)
    when :graph
      node = Convert.to_string(UI.QueryWidget(Id(:graph), :Item))

      if String.StartsWith(node, "device:")
        _GotoDevice.call(Builtins.substring(node, 7))
      elsif String.StartsWith(node, "mountpoint:")
        _GotoDevice.call(Builtins.substring(node, 11))
      end
    when :save
      filename = UI.AskForSaveFileName("/tmp", "*.gv", "Save as...")
      if filename != nil
        if !Storage.SaveDeviceGraph(filename)
          # error popup
          Popup.Error(_("Saving graph file failed."))
        end
      end
  end

  nil
end

- (Object) HandleMountGraphPanel(user_data, event)



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File '../../src/include/partitioning/ep-graph.rb', line 204

def HandleMountGraphPanel(user_data, event)
  event = deep_copy(event)
  _GotoDevice = lambda do |device|
    TreePanel.SwitchToNew(device)
    UI.SetFocus(UI.WidgetExists(Id(:table)) ? Id(:table) : Id(:text))

    nil
  end

  case Event.IsWidgetActivated(event)
    when :graph
      node = Convert.to_string(UI.QueryWidget(Id(:graph), :Item))

      if String.StartsWith(node, "mountpoint:")
        _GotoDevice.call(Builtins.substring(node, 11))
      end
    when :save
      filename = UI.AskForSaveFileName("/tmp", "*.gv", "Save as...")
      if filename != nil
        if !Storage.SaveMountGraph(filename)
          # error popup
          Popup.Error(_("Saving graph file failed."))
        end
      end
  end

  nil
end

- (Object) initialize_partitioning_ep_graph(include_target)



28
29
30
# File '../../src/include/partitioning/ep-graph.rb', line 28

def initialize_partitioning_ep_graph(include_target)
  textdomain "storage"
end

- (Object) RefreshDeviceGraphPanel(user_data)



97
98
99
100
101
102
103
104
105
106
# File '../../src/include/partitioning/ep-graph.rb', line 97

def RefreshDeviceGraphPanel(user_data)
  filename = "#{Directory.tmpdir}/device.gv"
  Storage.SaveDeviceGraph(filename)

  UI.ChangeWidget(Id(:graph), :Filename, filename)

  SCR.Execute(path(".target.remove"), filename)

  nil
end

- (Object) RefreshMountGraphPanel(user_data)



192
193
194
195
196
197
198
199
200
201
# File '../../src/include/partitioning/ep-graph.rb', line 192

def RefreshMountGraphPanel(user_data)
  filename = "#{Directory.tmpdir}/mount.gv"
  Storage.SaveMountGraph(filename)

  UI.ChangeWidget(Id(:graph), :Filename, filename)

  SCR.Execute(path(".target.remove"), filename)

  nil
end