Skip to content
Permalink
Browse files
Moved ObjEntity Class Tab contents to separate FXML/Controller. Fixes #2
.
  • Loading branch information
mrg committed Apr 6, 2016
1 parent 6e4cb87 commit 61610a1b941e817acc3a24e00f9ab0835167fffb
Showing 6 changed files with 223 additions and 104 deletions.
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -282,7 +282,6 @@ private void displayDetailView(Node detailView)
AnchorPane.setBottomAnchor(detailView, 0.0);

detailAnchorPane.getChildren().add(detailView);

}

// private void displayDetailView(BaseView detailView)
@@ -0,0 +1,73 @@
/*****************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
****************************************************************/

package org.apache.cayenne.modeler.controller;

import java.io.IOException;

import org.apache.cayenne.map.ObjEntity;

import de.jensd.fx.glyphs.GlyphsDude;
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;

public class ObjectEntityClassTabViewController extends AnchorPane implements MainWindowSupport
{
@FXML
private Button dbEntitySyncButton;


private MainWindowSupport parent;

public ObjectEntityClassTabViewController(MainWindowSupport parent) throws IOException
{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/view/ObjectEntityClassTabView.fxml"));

this.parent = parent;

fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
fxmlLoader.load();
}


public void initialize()
{
// getScene().getWindow().getScene();
// getStage().getScene().getWindow().get
// System.out.println("mrg: " + getStage().getScene().getRoot());
System.out.println("oectv");

dbEntitySyncButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.REFRESH, "16px"));
}

public void display(ObjEntity objEntity)
{
System.out.println("trying to display: " + objEntity);
}

@Override
public MainWindowViewController getMainWindow()
{
return parent.getMainWindow();
}
}
@@ -32,17 +32,13 @@
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;

public class ObjectEntityViewController extends AnchorPane implements MainWindowSupport
{
@FXML
private Button dbEntitySyncButton;

@FXML
private TableView<ObjAttribute> attributesTableView;

@@ -59,8 +55,13 @@ public class ObjectEntityViewController extends AnchorPane implements MainWindow
@FXML
private TableColumn<ObjAttribute,Boolean> attributeIsInheritedColumn;

@FXML
private AnchorPane classTabAnchorPane;

private MainWindowViewController mainWindow;

private ObjectEntityClassTabViewController objectEntityClassTabViewController;

public ObjectEntityViewController(MainWindowViewController mainWindow) throws IOException
{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/view/ObjectEntityView.fxml"));
@@ -81,10 +82,11 @@ public void initialize()
// System.out.println("mrg: " + getStage().getScene().getRoot());
System.out.println("oev");

loadComponents();

attributeUsedForLockingColumn.setText(null);
attributeIsInheritedColumn.setText(null);

dbEntitySyncButton.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.REFRESH, "16px"));
attributeUsedForLockingColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px"));
attributeIsInheritedColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LEVEL_UP, "16px"));

@@ -121,10 +123,40 @@ public void initialize()

}

private void loadComponents()
{
try
{
objectEntityClassTabViewController = new ObjectEntityClassTabViewController(this);

loadTab(objectEntityClassTabViewController, classTabAnchorPane);
}
catch (Exception exception)
{
// TODO Auto-generated catch block
exception.printStackTrace();
}
}

private void loadTab(AnchorPane source, AnchorPane destination)
{
destination.getChildren().removeAll(destination.getChildren());

// Make the detail view fill the pane.
AnchorPane.setTopAnchor(source, 0.0);
AnchorPane.setLeftAnchor(source, 0.0);
AnchorPane.setRightAnchor(source, 0.0);
AnchorPane.setBottomAnchor(source, 0.0);

destination.getChildren().add(source);

}

public void display(ObjEntity objEntity)
{
System.out.println("trying to display: " + objEntity);
attributesTableView.setItems(FXCollections.observableArrayList(objEntity.getAttributes()));
objectEntityClassTabViewController.display(objEntity);
// objEntity.getAttributes()
}

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>


<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="512.0" prefWidth="759.0" type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<HBox prefWidth="200.0">
<children>
<Label alignment="CENTER_RIGHT" text="Toolbar really goes here..." />
</children>
</HBox>
<Label text="Java Class Configuration">
<font>
<Font name="System Bold" size="18.0" />
</font>
<VBox.margin>
<Insets top="10.0" />
</VBox.margin>
</Label>
<GridPane minHeight="-Infinity" vgap="4.0">
<columnConstraints>
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="225.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="500.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label alignment="CENTER_RIGHT" text="Class Name: " GridPane.rowIndex="3" />
<TextField maxWidth="-Infinity" minWidth="-Infinity" prefWidth="360.0" promptText="ClassName" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Inheritance: " GridPane.rowIndex="5" />
<CheckBox mnemonicParsing="false" text="Abstract Class" GridPane.columnIndex="1" />
<ComboBox prefWidth="360.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label text="Mapped to Database Table/View: " GridPane.rowIndex="4" />
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4">
<children>
<ComboBox prefWidth="200.0" />
<Pane maxWidth="-Infinity" minWidth="-Infinity" prefWidth="20.0" />
<Button fx:id="dbEntitySyncButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefWidth="140.0" text="Sync to DbEntity" textAlignment="CENTER" HBox.hgrow="SOMETIMES">
<font>
<Font size="11.0" />
</font>
</Button>
</children>
</HBox>
<Label text="Package Name: " GridPane.rowIndex="2" />
<Label text="Superclass: " GridPane.rowIndex="1" />
<Label text="Qualifier: " GridPane.rowIndex="6" />
<TextField maxWidth="-Infinity" minWidth="-Infinity" prefWidth="360.0" promptText="some.package.here" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<TextField maxWidth="-Infinity" minWidth="-Infinity" prefWidth="360.0" promptText="some.package.here.SuperClass" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField maxWidth="-Infinity" minWidth="-Infinity" prefWidth="360.0" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<HBox GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="7">
<children>
<CheckBox mnemonicParsing="false" text="Read Only">
<padding>
<Insets right="20.0" />
</padding>
</CheckBox>
<CheckBox mnemonicParsing="false" text="Enable Optimistic Locking for this Class" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<CheckBox mnemonicParsing="false" text="Exclude Superclass Listeners" GridPane.columnIndex="1" GridPane.rowIndex="8" />
<CheckBox mnemonicParsing="false" text="Exclude Default Listeners" GridPane.columnIndex="1" GridPane.rowIndex="9" />
</children>
</GridPane>
<TabPane minWidth="100.0" prefHeight="200.0" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
<tabs>
<Tab text="JavaDoc">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TextArea layoutX="-109.0" layoutY="3.0" prefHeight="100.0" promptText="Omit comment characters. Press return to include newlines in output." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Imports">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TextArea layoutX="75.0" layoutY="8.0" prefHeight="100.0" promptText="Omit the 'import' statement and add a single import per line." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
</children>
</fx:root>

0 comments on commit 61610a1

Please sign in to comment.