Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this patch series consists of 1 patches.
- Content-Type: text/plain; charset="us-ascii"
- MIME-Version: 1.0
- Content-Transfer-Encoding: 7bit
- Subject: [PATCH] Added a confirmation message when makeing a new document,
- warning that all unsaved changes will be lost
- X-Mercurial-Node: 0585952b1e7b8c7c8831b3374033bedd5ce11d66
- X-Mercurial-Series-Index: 1
- X-Mercurial-Series-Total: 1
- Message-Id: <0585952b1e7b8c7c8831.1421631286@NICK-PC>
- X-Mercurial-Series-Id: <0585952b1e7b8c7c8831.1421631286@NICK-PC>
- User-Agent: Mercurial-patchbomb/3.1.2
- Date: Sun, 18 Jan 2015 18:34:46 -0700
- From: nickmcski
- To: nick.mc.ski@gmail.com
- # HG changeset patch
- # User nickmcski
- # Date 1421630975 25200
- # Sun Jan 18 18:29:35 2015 -0700
- # Node ID 0585952b1e7b8c7c8831b3374033bedd5ce11d66
- # Parent b2e9c0797f6ecabe91de7d9929d3f763ee60fb48
- Added a confirmation message when makeing a new document, warning that all unsaved changes will be lost.
- diff -r b2e9c0797f6e -r 0585952b1e7b lib/designer.rb
- --- a/lib/designer.rb Fri Dec 12 17:12:27 2014 -0500
- +++ b/lib/designer.rb Sun Jan 18 18:29:35 2015 -0700
- @@ -733,25 +733,28 @@
- def new_document
- # TODO: check for unsaved changes
- # assign the root canvas node from preferences
- - @current_save_data = @currently_open_file = nil
- - @stage.title = "SmartDashboard : Untitled"
- - clear_tabs()
- - # TODO: don't copy this in the ctor
- + answer = SD::DesignerSupport::NewDocQuestion.ask(@stage)
- + if answer == :newDoc
- + @current_save_data = @currently_open_file = nil
- + @stage.title = "SmartDashboard : Untitled"
- + clear_tabs()
- + # TODO: don't copy this in the ctor
- - main_vc = SD::Windowing::DefaultViewController.new
- - main_vc.on_focus_request do |focus|
- - tab_auto_focus(main_vc, focus)
- + main_vc = SD::Windowing::DefaultViewController.new
- + main_vc.on_focus_request do |focus|
- + tab_auto_focus(main_vc, focus)
- + end
- + main_tab = add_tab(main_vc)
- + SD::Plugins.view_controllers.find_all{|x|x.default > 0}.each do |x|
- + vc = x.new
- + vc.on_focus_request do |focus|
- + tab_auto_focus(vc, focus)
- + end
- + add_tab(vc)
- + end
- + tab_select(main_tab)
- + @current_save_data = SD::IOSupport::DashObject.parse_scene_graph(@view_controllers.to_a, @data_core)
- end
- - main_tab = add_tab(main_vc)
- - SD::Plugins.view_controllers.find_all{|x|x.default > 0}.each do |x|
- - vc = x.new
- - vc.on_focus_request do |focus|
- - tab_auto_focus(vc, focus)
- - end
- - add_tab(vc)
- - end
- - tab_select(main_tab)
- - @current_save_data = SD::IOSupport::DashObject.parse_scene_graph(@view_controllers.to_a, @data_core)
- end
- def hide_properties_ctx(ctx)
- diff -r b2e9c0797f6e -r 0585952b1e7b lib/designer_support/new_doc_question.rb
- --- /dev/null Thu Jan 01 00:00:00 1970 +0000
- +++ b/lib/designer_support/new_doc_question.rb Sun Jan 18 18:29:35 2015 -0700
- @@ -0,0 +1,52 @@
- +# Copyright (C) 2015 Nicholas
- +#
- +# This program is free software: you can redistribute it and/or modify
- +# it under the terms of the GNU General Public License as published by
- +# the Free Software Foundation, either version 3 of the License, or
- +# (at your option) any later version.
- +#
- +# This program is distributed in the hope that it will be useful,
- +# but WITHOUT ANY WARRANTY; without even the implied warranty of
- +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- +# GNU General Public License for more details.
- +#
- +# You should have received a copy of the GNU General Public License
- +# along with this program. If not, see <http://www.gnu.org/licenses/>.
- +
- +module SD
- + module DesignerSupport
- + class NewDocQuestion
- + include JRubyFX::Controller
- + fxml "NewDocumentQuestion.fxml"
- + attr_reader :res
- +
- + def initialize(cb)
- + @res = cb
- + end
- +
- + def newDoc
- + done :newDoc
- + end
- + def cancel
- + done :cancel
- + end
- +
- + def done(res)
- + @res.call res
- + @stage.hide
- + end
- +
- + def self.ask(stage)
- + res = :cancel
- + stage(init_style: :utility, init_modality: :app, title: "New document?") do
- + init_owner stage
- + fxml SD::DesignerSupport::NewDocQuestion, :initialize => [lambda{|x|res=x}]
- +
- + show_and_wait
- + print res
- + end
- + return res
- + end
- + end
- + end
- +end
- diff -r b2e9c0797f6e -r 0585952b1e7b lib/res/NewDocumentQuestion.fxml
- --- /dev/null Thu Jan 01 00:00:00 1970 +0000
- +++ b/lib/res/NewDocumentQuestion.fxml Sun Jan 18 18:29:35 2015 -0700
- @@ -0,0 +1,70 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +
- +<?import java.lang.*?>
- +<?import java.util.*?>
- +<?import javafx.geometry.*?>
- +<?import javafx.scene.control.*?>
- +<?import javafx.scene.image.*?>
- +<?import javafx.scene.layout.*?>
- +<?import javafx.scene.paint.*?>
- +<?import javafx.scene.text.*?>
- +
- +<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">
- + <children>
- + <ImageView fitHeight="60.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="0" GridPane.valignment="TOP">
- + <image>
- + <Image url="@img/60-fxicon.png" />
- + <!-- place holder -->
- + </image>
- + </ImageView>
- + <VBox maxHeight="+Infinity" maxWidth="+Infinity" minHeight="-Infinity" prefWidth="400.0" spacing="7.0" GridPane.columnIndex="1" GridPane.rowIndex="0">
- + <children>
- + <Label fx:id="messageLabel" text="Are you sure you want to make a new document?" textAlignment="LEFT" wrapText="true">
- + <font>
- + <Font name="System Bold" size="13.0" />
- + </font>
- + </Label>
- + <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">
- + <font>
- + <Font size="12.0" />
- + </font>
- + </Label>
- + </children>
- + </VBox>
- + <HBox maxHeight="-Infinity" maxWidth="+Infinity" minHeight="-Infinity" minWidth="-Infinity" GridPane.columnIndex="1" GridPane.rowIndex="1">
- + <children>
- + <HBox id="HBox" fx:id="actionParent" alignment="CENTER">
- + <HBox.margin>
- + <Insets />
- + </HBox.margin>
- + </HBox>
- + <Pane maxWidth="+Infinity" HBox.hgrow="ALWAYS" />
- + <Button fx:id="cancelButton" cancelButton="true" minWidth="80.0" mnemonicParsing="false" onAction="#cancel" text="Cancel" HBox.hgrow="NEVER">
- + <HBox.margin>
- + <Insets />
- + </HBox.margin>
- + </Button>
- + <HBox id="HBox" fx:id="okParent" alignment="CENTER">
- + <children>
- + <Button fx:id="okButton" defaultButton="true" minWidth="80.0" mnemonicParsing="false" onAction="#newDoc" text="New Document" HBox.hgrow="NEVER">
- + <HBox.margin>
- + <Insets left="14.0" />
- + </HBox.margin>
- + </Button>
- + </children>
- + </HBox>
- + </children>
- + </HBox>
- + </children>
- + <columnConstraints>
- + <ColumnConstraints hgrow="NEVER" maxWidth="-Infinity" minWidth="-Infinity" />
- + <ColumnConstraints halignment="CENTER" hgrow="ALWAYS" maxWidth="+Infinity" minWidth="-Infinity" />
- + </columnConstraints>
- + <padding>
- + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" />
- + </padding>
- + <rowConstraints>
- + <RowConstraints maxHeight="+Infinity" minHeight="-Infinity" valignment="CENTER" vgrow="ALWAYS" />
- + <RowConstraints maxHeight="-Infinity" minHeight="-Infinity" vgrow="NEVER" />
- + </rowConstraints>
- +</GridPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement