Advertisement
nickmcski

Untitled

Jan 18th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.78 KB | None | 0 0
  1. this patch series consists of 1 patches.
  2.  
  3.  
  4. Content-Type: text/plain; charset="us-ascii"
  5. MIME-Version: 1.0
  6. Content-Transfer-Encoding: 7bit
  7. Subject: [PATCH] Added a confirmation message when makeing a new document,
  8. warning that all unsaved changes will be lost
  9. X-Mercurial-Node: 0585952b1e7b8c7c8831b3374033bedd5ce11d66
  10. X-Mercurial-Series-Index: 1
  11. X-Mercurial-Series-Total: 1
  12. Message-Id: <0585952b1e7b8c7c8831.1421631286@NICK-PC>
  13. X-Mercurial-Series-Id: <0585952b1e7b8c7c8831.1421631286@NICK-PC>
  14. User-Agent: Mercurial-patchbomb/3.1.2
  15. Date: Sun, 18 Jan 2015 18:34:46 -0700
  16. From: nickmcski
  17. To: nick.mc.ski@gmail.com
  18.  
  19. # HG changeset patch
  20. # User nickmcski
  21. # Date 1421630975 25200
  22. # Sun Jan 18 18:29:35 2015 -0700
  23. # Node ID 0585952b1e7b8c7c8831b3374033bedd5ce11d66
  24. # Parent b2e9c0797f6ecabe91de7d9929d3f763ee60fb48
  25. Added a confirmation message when makeing a new document, warning that all unsaved changes will be lost.
  26.  
  27. diff -r b2e9c0797f6e -r 0585952b1e7b lib/designer.rb
  28. --- a/lib/designer.rb Fri Dec 12 17:12:27 2014 -0500
  29. +++ b/lib/designer.rb Sun Jan 18 18:29:35 2015 -0700
  30. @@ -733,25 +733,28 @@
  31. def new_document
  32. # TODO: check for unsaved changes
  33. # assign the root canvas node from preferences
  34. - @current_save_data = @currently_open_file = nil
  35. - @stage.title = "SmartDashboard : Untitled"
  36. - clear_tabs()
  37. - # TODO: don't copy this in the ctor
  38. + answer = SD::DesignerSupport::NewDocQuestion.ask(@stage)
  39. + if answer == :newDoc
  40. + @current_save_data = @currently_open_file = nil
  41. + @stage.title = "SmartDashboard : Untitled"
  42. + clear_tabs()
  43. + # TODO: don't copy this in the ctor
  44.  
  45. - main_vc = SD::Windowing::DefaultViewController.new
  46. - main_vc.on_focus_request do |focus|
  47. - tab_auto_focus(main_vc, focus)
  48. + main_vc = SD::Windowing::DefaultViewController.new
  49. + main_vc.on_focus_request do |focus|
  50. + tab_auto_focus(main_vc, focus)
  51. + end
  52. + main_tab = add_tab(main_vc)
  53. + SD::Plugins.view_controllers.find_all{|x|x.default > 0}.each do |x|
  54. + vc = x.new
  55. + vc.on_focus_request do |focus|
  56. + tab_auto_focus(vc, focus)
  57. + end
  58. + add_tab(vc)
  59. + end
  60. + tab_select(main_tab)
  61. + @current_save_data = SD::IOSupport::DashObject.parse_scene_graph(@view_controllers.to_a, @data_core)
  62. end
  63. - main_tab = add_tab(main_vc)
  64. - SD::Plugins.view_controllers.find_all{|x|x.default > 0}.each do |x|
  65. - vc = x.new
  66. - vc.on_focus_request do |focus|
  67. - tab_auto_focus(vc, focus)
  68. - end
  69. - add_tab(vc)
  70. - end
  71. - tab_select(main_tab)
  72. - @current_save_data = SD::IOSupport::DashObject.parse_scene_graph(@view_controllers.to_a, @data_core)
  73. end
  74.  
  75. def hide_properties_ctx(ctx)
  76. diff -r b2e9c0797f6e -r 0585952b1e7b lib/designer_support/new_doc_question.rb
  77. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  78. +++ b/lib/designer_support/new_doc_question.rb Sun Jan 18 18:29:35 2015 -0700
  79. @@ -0,0 +1,52 @@
  80. +# Copyright (C) 2015 Nicholas
  81. +#
  82. +# This program is free software: you can redistribute it and/or modify
  83. +# it under the terms of the GNU General Public License as published by
  84. +# the Free Software Foundation, either version 3 of the License, or
  85. +# (at your option) any later version.
  86. +#
  87. +# This program is distributed in the hope that it will be useful,
  88. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  89. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  90. +# GNU General Public License for more details.
  91. +#
  92. +# You should have received a copy of the GNU General Public License
  93. +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  94. +
  95. +module SD
  96. + module DesignerSupport
  97. + class NewDocQuestion
  98. + include JRubyFX::Controller
  99. + fxml "NewDocumentQuestion.fxml"
  100. + attr_reader :res
  101. +
  102. + def initialize(cb)
  103. + @res = cb
  104. + end
  105. +
  106. + def newDoc
  107. + done :newDoc
  108. + end
  109. + def cancel
  110. + done :cancel
  111. + end
  112. +
  113. + def done(res)
  114. + @res.call res
  115. + @stage.hide
  116. + end
  117. +
  118. + def self.ask(stage)
  119. + res = :cancel
  120. + stage(init_style: :utility, init_modality: :app, title: "New document?") do
  121. + init_owner stage
  122. + fxml SD::DesignerSupport::NewDocQuestion, :initialize => [lambda{|x|res=x}]
  123. +
  124. + show_and_wait
  125. + print res
  126. + end
  127. + return res
  128. + end
  129. + end
  130. + end
  131. +end
  132. diff -r b2e9c0797f6e -r 0585952b1e7b lib/res/NewDocumentQuestion.fxml
  133. --- /dev/null Thu Jan 01 00:00:00 1970 +0000
  134. +++ b/lib/res/NewDocumentQuestion.fxml Sun Jan 18 18:29:35 2015 -0700
  135. @@ -0,0 +1,70 @@
  136. +<?xml version="1.0" encoding="UTF-8"?>
  137. +
  138. +<?import java.lang.*?>
  139. +<?import java.util.*?>
  140. +<?import javafx.geometry.*?>
  141. +<?import javafx.scene.control.*?>
  142. +<?import javafx.scene.image.*?>
  143. +<?import javafx.scene.layout.*?>
  144. +<?import javafx.scene.paint.*?>
  145. +<?import javafx.scene.text.*?>
  146. +
  147. +<GridPane hgap="14.0" maxHeight="+Infinity" maxWidth="+Infinity" minHeight="-Infinity" minWidth="-Infinity" vgap="20.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
  148. + <children>
  149. + <ImageView fitHeight="60.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="0" GridPane.valignment="TOP">
  150. + <image>
  151. + <Image url="@img/60-fxicon.png" />
  152. + <!-- place holder -->
  153. + </image>
  154. + </ImageView>
  155. + <VBox maxHeight="+Infinity" maxWidth="+Infinity" minHeight="-Infinity" prefWidth="400.0" spacing="7.0" GridPane.columnIndex="1" GridPane.rowIndex="0">
  156. + <children>
  157. + <Label fx:id="messageLabel" text="Are you sure you want to make a new document?" textAlignment="LEFT" wrapText="true">
  158. + <font>
  159. + <Font name="System Bold" size="13.0" />
  160. + </font>
  161. + </Label>
  162. + <Label fx:id="detailsLabel" prefHeight="34.0" prefWidth="303.0" text="Any of your unsaved changes to this document will be lost" textAlignment="LEFT" wrapText="true">
  163. + <font>
  164. + <Font size="12.0" />
  165. + </font>
  166. + </Label>
  167. + </children>
  168. + </VBox>
  169. + <HBox maxHeight="-Infinity" maxWidth="+Infinity" minHeight="-Infinity" minWidth="-Infinity" GridPane.columnIndex="1" GridPane.rowIndex="1">
  170. + <children>
  171. + <HBox id="HBox" fx:id="actionParent" alignment="CENTER">
  172. + <HBox.margin>
  173. + <Insets />
  174. + </HBox.margin>
  175. + </HBox>
  176. + <Pane maxWidth="+Infinity" HBox.hgrow="ALWAYS" />
  177. + <Button fx:id="cancelButton" cancelButton="true" minWidth="80.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" HBox.hgrow="NEVER">
  178. + <HBox.margin>
  179. + <Insets />
  180. + </HBox.margin>
  181. + </Button>
  182. + <HBox id="HBox" fx:id="okParent" alignment="CENTER">
  183. + <children>
  184. + <Button fx:id="okButton" defaultButton="true" minWidth="80.0" mnemonicParsing="false" onAction="#newDoc" text="New Document" HBox.hgrow="NEVER">
  185. + <HBox.margin>
  186. + <Insets left="14.0" />
  187. + </HBox.margin>
  188. + </Button>
  189. + </children>
  190. + </HBox>
  191. + </children>
  192. + </HBox>
  193. + </children>
  194. + <columnConstraints>
  195. + <ColumnConstraints hgrow="NEVER" maxWidth="-Infinity" minWidth="-Infinity" />
  196. + <ColumnConstraints halignment="CENTER" hgrow="ALWAYS" maxWidth="+Infinity" minWidth="-Infinity" />
  197. + </columnConstraints>
  198. + <padding>
  199. + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" />
  200. + </padding>
  201. + <rowConstraints>
  202. + <RowConstraints maxHeight="+Infinity" minHeight="-Infinity" valignment="CENTER" vgrow="ALWAYS" />
  203. + <RowConstraints maxHeight="-Infinity" minHeight="-Infinity" vgrow="NEVER" />
  204. + </rowConstraints>
  205. +</GridPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement