Skip to content

Commit

Permalink
Add About menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene committed Feb 9, 2020
1 parent fbee071 commit 60d90e2
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 44 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/eugene/controller/ParquetDataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.eugene.model.CommonData;
import org.eugene.model.TableMeta;
import org.eugene.persistent.VirtualDB;
import org.eugene.ui.Constants;
import org.eugene.ui.Notifier;

import java.util.ArrayList;
Expand Down Expand Up @@ -47,7 +48,7 @@ public boolean parseData(Path path) {
List<String> commonRecord = new ArrayList<>();
for (int j = 0; j < columnNumber; j++) {
if (record.get(j) == null){
commonRecord.add("NULL");
commonRecord.add(Constants.NULL);
}else{
commonRecord.add(String.valueOf(record.get(j)));
}
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/eugene/controller/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.hadoop.fs.Path;
import org.eugene.core.parquet.ParquetReader;
import org.eugene.model.CommonData;
import org.eugene.model.Parquet;
import org.eugene.model.TableMeta;
import org.eugene.persistent.VirtualDB;
import org.eugene.ui.*;
import org.eugene.ui.Dashboard;
import org.eugene.ui.Main;
import org.eugene.ui.Table;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Renderer {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/eugene/core/orc/ORCReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.eugene.model.CommonData;
import org.eugene.model.TableMeta;
import org.eugene.persistent.VirtualDB;
import org.eugene.ui.Constants;
import org.eugene.ui.Notifier;

import java.util.ArrayList;
Expand All @@ -25,8 +26,6 @@ public boolean read(Path path){
//The JSON schema provided is illegal, so need to make it valid firstly
schema = schema.replaceAll("(\"[\\w]+\"):([\\s]+[{]+)", "$1,$2");
RecordReader records = reader.rows();
//These objects are the metadata for each column. They give you the type of each column and can parse it unless you
//want to parse each column yourself
List fields = inspector.getAllStructFieldRefs();
List<String> propertyList = new ArrayList<>();
int columnNumber = fields.size();
Expand All @@ -47,7 +46,7 @@ public boolean read(Path path){
record.add(field.toString());
}
else{
record.add("NULL");
record.add(Constants.NULL);
}
}
data.add(record);
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/org/eugene/ui/AboutDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.eugene.ui;

import javafx.geometry.Insets;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

import java.awt.*;
import java.net.URI;

public class AboutDialog {
Dialog dialog = new Dialog();

public void init(){
Label intro = new Label();
intro.setText(" Currently supported format: ");
Label parquet = new Label(" - Parquet");
Label orc = new Label(" - ORC");
orc.setPadding(new Insets(0,0,5, 0));
Label author = new Label();
author.setText(" Author: " );
Hyperlink github = new Hyperlink();
github.setText(" github: Eugene");
github.setOnAction(event -> {
try {
Desktop.getDesktop().browse(new URI("https://github.com/Eugene-Mark/"));
} catch (Exception e) {
e.printStackTrace();
}
});
Hyperlink so = new Hyperlink();
so.setText(" stack overflow: Eugene");
so.setOnAction(event -> {
try {
Desktop.getDesktop().browse(new URI("https://stackoverflow.com/users/3378204/eugene"));
} catch (Exception e) {
e.printStackTrace();
}
});
dialog.getDialogPane().setContent(new VBox(intro, parquet, orc, author, github, so));
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);
}

public Dialog getDialog(){
return dialog;
}
}
1 change: 1 addition & 0 deletions src/main/java/org/eugene/ui/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

public class Constants {
public static int MAX_ROW_NUM = 1000;
public static String NULL = "NULL";
}
15 changes: 14 additions & 1 deletion src/main/java/org/eugene/ui/CustomizedMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.avro.generic.GenericData;
import org.apache.hadoop.fs.Path;
import org.eugene.controller.Renderer;
import org.eugene.util.CSVWriter;
Expand Down Expand Up @@ -102,6 +101,20 @@ public CustomizedMenuBar(Stage stage){
this.getMenus().add(file);
this.getMenus().add(view);
disableAll();

//About menu
Menu about = new Menu();
about.setText("About");
MenuItem aboutItem = new MenuItem();
aboutItem.setText("About");
aboutItem.setOnAction(event -> {
AboutDialog aboutDialog = new AboutDialog();
aboutDialog.init();
aboutDialog.getDialog().show();
});
about.getItems().add(aboutItem);
this.getMenus().add(about);

}

private void disableAll(){
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/eugene/ui/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import org.apache.avro.Schema;
import org.eugene.util.TypeFetcher;

import java.io.File;
import java.util.HashMap;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/eugene/ui/SelectPropertyDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.apache.avro.Schema;
import org.eugene.controller.Renderer;
import org.eugene.controller.TableRenderer;
import org.eugene.persistent.VirtualDB;

import java.util.ArrayList;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/eugene/ui/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.apache.avro.generic.GenericData;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -91,7 +90,7 @@ private void generatePage(List<List<String>> data, TableView tableView, int page
for (int j = 0; j < colNumber; j++){
if(showingList.contains(propertyList.get(j))){
if (r.get(j) == null){
row.add(index, new SimpleStringProperty("NULL"));
row.add(index, new SimpleStringProperty(Constants.NULL));
}
else{
row.add(index, new SimpleStringProperty(r.get(j).toString()));
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/eugene/util/CSVWriter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.eugene.util;

import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.hadoop.fs.Path;
import org.eugene.persistent.VirtualDB;
import org.eugene.ui.Constants;

import java.io.PrintWriter;
import java.util.List;
Expand Down Expand Up @@ -31,7 +30,7 @@ public static boolean write(Path path, List<List<String>> data){
for (int i = 0; i < colNumber; i++) {
if (i == (colNumber - 1)) {
if (record.get(i) == null)
out.println("NULL");
out.println(Constants.NULL);
else {
if (record.get(i).toString().contains(",")) {
out.println("\"" + record.get(i) + "\"");
Expand All @@ -41,7 +40,7 @@ public static boolean write(Path path, List<List<String>> data){
}
}else{
if (record.get(i) == null){
out.print("NULL");
out.print(Constants.NULL);
}
else{
if (record.get(i).toString().contains(",")){
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/org/eugene/util/TypeFetcher.java

This file was deleted.

0 comments on commit 60d90e2

Please sign in to comment.