Module: Yast::PartitioningEpGraphInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) CreateDeviceGraphPanel(user_data)



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
# File '../../src/include/partitioning/ep-graph.rb', line 60

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)



149
150
151
152
153
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
# File '../../src/include/partitioning/ep-graph.rb', line 149

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



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

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)



104
105
106
107
108
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
# File '../../src/include/partitioning/ep-graph.rb', line 104

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)



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File '../../src/include/partitioning/ep-graph.rb', line 193

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)



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

def initialize_partitioning_ep_graph(include_target)
  textdomain "storage"
end

- (Object) RefreshDeviceGraphPanel(user_data)



92
93
94
95
96
97
98
99
100
101
# File '../../src/include/partitioning/ep-graph.rb', line 92

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)



181
182
183
184
185
186
187
188
189
190
# File '../../src/include/partitioning/ep-graph.rb', line 181

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