nus-cs2103-AY1718S1 / forum

Discussion Forum
5 stars 0 forks source link

Authentication Window before MainWindow #155

Closed charlesgohck closed 6 years ago

charlesgohck commented 6 years ago

Was wondering if someone could point me in the right direction? I am trying to make an authentication window appear before the Main Window. I have 2 questions:

  1. How do I run a dummy loader? I am getting this when I try to run just this Java class and I can't seem to find a workaround. I just want to display another window without affecting anything else:

    screen shot 2017-10-29 at 5 06 36 pm
  2. Where can I disable MainWindow from executing before my authentication window? I'm playing around with the UiManager but I'm getting NullPointerExceptions a lot of the time...

This is the YouTube tutorial I am trying to follow. Unfortunately the structure is slightly different in that the controller and view are together. https://www.youtube.com/watch?v=5NM27PP5rME&list=PLhs1urmduZ29jTcE1ca8Z6bZNvH_39ayL&index=19

Zhiyuan-Amos commented 6 years ago

--content deleted--

Oops I recall I'm not supposed to give an answer that quickly :P I'll wait 24hrs and see if anyone else has an answer first.

charlesgohck commented 6 years ago

Thanks Zhi Yuan. I managed to get the window to load but it seems like all the fxml files do not have a controller tagged to them.

Most of the tutorials I have seen only have the View tagged to a Controller. Why did we (i.e. addresbook) choose to design it in another way.

Zhiyuan-Amos commented 6 years ago

I suppose you've seen my post through the email notification haha. Can you post the link which solved the problem, so that future students can use it too?

If I'm getting your question rightly, I think this may be the answer to your question (https://github.com/se-edu/addressbook-level4/pull/578#issuecomment-316976110). Context of the PR: I was trying to make each view to be tagged to a controller as well. By tagging the fxml files to a controller, you are not able to pass arguments to them. Currently, AddressBook requires us to pass arguments to these controllers.

Whether or not we can do better, you are free to continue on my PR HAHA and let us know :P

(I don't know which guides you have seen so I'm not 100% sure whether I'm answering your qn though).

charlesgohck commented 6 years ago

@Zhiyuan-Amos :) Actually I got lucky and managed to trigger the opening of the settings window (ignore the set controller code; that is the breaking code)

screen shot 2017-10-29 at 8 32 31 pm

However, the issue here is that I can set everything but the FXML elements are not showing up. Usually with the controller tagged to the view we should be able to make everything appear easily. But now its not so easy :(

screen shot 2017-10-29 at 8 34 18 pm
Zhiyuan-Amos commented 6 years ago

Actually I got lucky and managed to trigger the opening of the settings window

That's great! ^^

However, the issue here is that I can set everything but the FXML elements are not showing up. Usually with the controller tagged to the view we should be able to make everything appear easily. But now its not so easy :(

Well I'll let you figure it out on your own :P That's part of Software Engineering XD

damithc commented 6 years ago

@Zhiyuan-Amos would tracing through how the help Window works is useful to @charlesgoh here?

Zhiyuan-Amos commented 6 years ago

It's slightly different because HelpWindow loads an existing file, whereas the Settings thing that Charles is doing requires further configuration of the internal components.

Perhaps Charles can post the .fxml file here so that other students can take a look and help ^^

charlesgohck commented 6 years ago

Sure thing :)

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<AnchorPane prefHeight="150.0" prefWidth="400.0" styleClass="background" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <VBox layoutX="33.0" layoutY="116.0" prefHeight="186.0" prefWidth="400.0" stylesheets="@DarkTheme.css" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <children>
            <Label alignment="CENTER" prefHeight="32.0" prefWidth="400.0" styleClass="label-bright" stylesheets="@DarkTheme.css" text="Password Settings" textAlignment="CENTER">
               <VBox.margin>
                  <Insets top="10.0" />
               </VBox.margin>
            </Label>
            <PasswordField fx:id="oldPassword" promptText="New Password" styleClass="text-field" stylesheets="@DarkTheme.css">
               <VBox.margin>
                  <Insets left="20.0" right="20.0" top="20.0" />
               </VBox.margin>
            </PasswordField>
            <PasswordField fx:id="newPassword" promptText="New Password" styleClass="text-field" stylesheets="@DarkTheme.css">
               <VBox.margin>
                  <Insets left="20.0" right="20.0" top="30.0" />
               </VBox.margin>
            </PasswordField>
            <PasswordField fx:id="confirmPassword" promptText="Confirm Password" styleClass="text-field" stylesheets="@DarkTheme.css">
               <VBox.margin>
                  <Insets left="20.0" right="20.0" top="30.0" />
               </VBox.margin>
            </PasswordField>
         </children>
      </VBox>
      <HBox layoutX="-5.0" layoutY="228.0" prefHeight="50.0" prefWidth="400.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
         <children>
            <Button mnemonicParsing="false" onAction="#handleSavePasswordChange" prefHeight="55.0" prefWidth="200.0" stylesheets="@DarkTheme.css" text="SAVE" />
            <Button mnemonicParsing="false" onAction="#handleCancelPasswordAction" prefHeight="51.0" prefWidth="201.0" stylesheets="@DarkTheme.css" text="CANCEL" />
         </children>
      </HBox>
   </children>
</AnchorPane>

It looks like this:

screen shot 2017-10-30 at 8 59 37 am
damithc commented 6 years ago

Perhaps Charles can post the .fxml file here so that other students can take a look and help ^^

Even better if you can create a PR and post the link here so that the reader gets the full context.

charlesgohck commented 6 years ago

https://github.com/CS2103AUG2017-W09-B2/main/pull/87 This is the PR I am working on

damithc commented 6 years ago

@charlesgoh is this issue still relevant? Close if not.