Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[Redmine #186] - add the welcome tab on application startup

  • Loading branch information...
commit c653b5ab77da82f3531274c6ebe87df85f7ca6ac 1 parent 1f6198f
Kamil Örs kamilors authored
61 mongoui-fx/src/main/java/com/droidpark/mongoui/component/MongoUITab.java
... ... @@ -0,0 +1,61 @@
  1 +package com.droidpark.mongoui.component;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.InputStream;
  5 +import java.io.InputStreamReader;
  6 +
  7 +import com.droidpark.mongoui.util.Language;
  8 +import com.droidpark.mongoui.util.LanguageConstants;
  9 +
  10 +import javafx.scene.control.Tab;
  11 +import javafx.scene.layout.AnchorPane;
  12 +import javafx.scene.web.WebView;
  13 +
  14 +public class MongoUITab extends Tab implements UITab {
  15 +
  16 + AnchorPane pane;
  17 + WebView webView;
  18 +
  19 + public MongoUITab() {
  20 + init();
  21 + }
  22 +
  23 + private void init() {
  24 + pane = new AnchorPane();
  25 + webView = new WebView();
  26 + webView.prefHeightProperty().bind(pane.heightProperty());
  27 + webView.prefWidthProperty().bind(pane.widthProperty());
  28 + pane.getChildren().add(webView);
  29 + setContent(pane);
  30 + setText(Language.get(LanguageConstants.TAB_LABEL_WELCOME));
  31 + loadContent();
  32 + }
  33 +
  34 + private void loadContent() {
  35 + String page = getStream("mongoui/welcome.html");
  36 + webView.getEngine().loadContent(page);
  37 + }
  38 +
  39 + private String getStream(String file) {
  40 + try {
  41 + InputStream stream = getClass().getClassLoader().getResourceAsStream(file);
  42 + BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
  43 + StringBuilder builder = new StringBuilder();
  44 + String line = null;
  45 + while((line = reader.readLine()) != null) {
  46 + builder.append(line);
  47 + }
  48 + return builder.toString();
  49 + }
  50 + catch (Exception e) {
  51 + e.printStackTrace();
  52 + return null;
  53 + }
  54 + }
  55 +
  56 + public void destroy() {
  57 + webView.prefHeightProperty().unbind();
  58 + webView.prefWidthProperty().unbind();
  59 + }
  60 +
  61 +}
7 mongoui-fx/src/main/java/com/droidpark/mongoui/component/ResultTab.java
... ... @@ -1,12 +1,9 @@
1 1 package com.droidpark.mongoui.component;
2 2
3 3 import java.util.ArrayList;
4   -import java.util.Collections;
5 4 import java.util.HashMap;
6   -import java.util.HashSet;
7 5 import java.util.List;
8 6 import java.util.Map;
9   -import java.util.Set;
10 7
11 8 import org.apache.log4j.Logger;
12 9 import org.bson.types.ObjectId;
@@ -25,7 +22,6 @@
25 22 import com.mongodb.DBCursor;
26 23 import com.mongodb.DBObject;
27 24 import com.mongodb.Mongo;
28   -import com.mongodb.util.JSON;
29 25
30 26 import static com.droidpark.mongoui.util.LanguageConstants.*;
31 27
@@ -44,8 +40,6 @@
44 40 import javafx.scene.control.Tab;
45 41 import javafx.scene.control.TableColumn;
46 42 import javafx.scene.control.TableView;
47   -import javafx.scene.control.TextArea;
48   -import javafx.scene.control.TextField;
49 43 import javafx.scene.control.TitledPane;
50 44 import javafx.scene.control.TreeItem;
51 45 import javafx.scene.control.TreeView;
@@ -53,7 +47,6 @@
53 47 import javafx.scene.image.ImageView;
54 48 import javafx.scene.layout.AnchorPane;
55 49 import javafx.scene.layout.BorderPane;
56   -import javafx.scene.layout.GridPane;
57 50 import javafx.scene.layout.HBox;
58 51 import javafx.scene.layout.Region;
59 52 import javafx.util.Callback;
13 mongoui-fx/src/main/java/com/droidpark/mongoui/form/MainForm.java
... ... @@ -1,6 +1,5 @@
1 1 package com.droidpark.mongoui.form;
2 2
3   -import java.net.UnknownHostException;
4 3 import java.util.ArrayList;
5 4 import java.util.HashSet;
6 5 import java.util.List;
@@ -17,14 +16,10 @@
17 16 import javafx.scene.control.Accordion;
18 17 import javafx.scene.control.Button;
19 18 import javafx.scene.control.ContentDisplay;
20   -import javafx.scene.control.ContextMenu;
21   -import javafx.scene.control.Label;
22   -import javafx.scene.control.MenuItem;
23 19 import javafx.scene.control.ProgressBar;
24 20 import javafx.scene.control.SplitPane;
25 21 import javafx.scene.control.TabPane;
26 22 import javafx.scene.control.TextArea;
27   -import javafx.scene.control.TextField;
28 23 import javafx.scene.control.TitledPane;
29 24 import javafx.scene.control.ToolBar;
30 25 import javafx.scene.control.TreeItem;
@@ -34,15 +29,13 @@
34 29 import javafx.scene.input.MouseEvent;
35 30 import javafx.scene.layout.AnchorPane;
36 31 import javafx.scene.layout.BorderPane;
37   -import javafx.scene.layout.GridPane;
38 32 import javafx.scene.layout.HBox;
39 33 import javafx.scene.layout.Region;
40   -import javafx.scene.web.WebView;
41 34 import javafx.stage.Stage;
42 35
43 36 import static com.droidpark.mongoui.util.LanguageConstants.*;
44 37
45   -import com.droidpark.mongoui.component.ModalDialog;
  38 +import com.droidpark.mongoui.component.MongoUITab;
46 39 import com.droidpark.mongoui.dialog.ConnectionDialog;
47 40 import com.droidpark.mongoui.dialog.ManageCollectionDialog;
48 41 import com.droidpark.mongoui.task.AddTabTask;
@@ -52,7 +45,6 @@
52 45 import com.droidpark.mongoui.util.DBTreeEnum;
53 46 import com.droidpark.mongoui.util.ImageUtil;
54 47 import com.droidpark.mongoui.util.Language;
55   -import com.droidpark.mongoui.util.LanguageConstants;
56 48 import com.droidpark.mongoui.util.Log4jTextAreaAppender;
57 49 import com.droidpark.mongoui.util.MongoUtil;
58 50 import com.droidpark.mongoui.util.Util;
@@ -60,7 +52,6 @@
60 52 import com.mongodb.DBCollection;
61 53 import com.mongodb.DBCursor;
62 54 import com.mongodb.DBObject;
63   -import com.mongodb.Mongo;
64 55
65 56 public class MainForm extends Application {
66 57
@@ -234,6 +225,8 @@ private void initTabPane() {
234 225 tabPane.prefWidthProperty().bind(centerPane.widthProperty());
235 226 tabPane.prefHeightProperty().bind(centerPane.heightProperty());
236 227 centerPane.getChildren().add(tabPane);
  228 + MongoUITab welcomeTab = new MongoUITab();
  229 + tabPane.getTabs().add(welcomeTab);
237 230 }
238 231
239 232 private void initToolBarButtons() {
2  mongoui-fx/src/main/java/com/droidpark/mongoui/util/LanguageConstants.java
@@ -42,4 +42,6 @@
42 42 public static final String LABEL_PORT = "label.port";
43 43 public static final String LABEL_USERNAME = "label.username";
44 44 public static final String LABEL_PASSWORD = "label.password";
  45 +
  46 + public static final String TAB_LABEL_WELCOME = "tab.label.welcome";
45 47 }
3  mongoui-fx/src/main/java/com/droidpark/mongoui/util/MongoUtil.java
... ... @@ -1,11 +1,8 @@
1 1 package com.droidpark.mongoui.util;
2 2
3   -import java.net.UnknownHostException;
4   -
5 3 import org.apache.log4j.Logger;
6 4
7 5 import com.mongodb.Mongo;
8   -import com.mongodb.MongoException;
9 6
10 7 public class MongoUtil {
11 8
4 mongoui-fx/src/main/resources/english.lang.properties
@@ -37,4 +37,6 @@ label.port=Port
37 37 label.username=Username
38 38 label.password=Password
39 39
40   -message.are_you_sure=Are you sure?
  40 +message.are_you_sure=Are you sure?
  41 +
  42 +tab.label.welcome=MongoUI
34 mongoui-fx/src/main/resources/mongoui/welcome.html
... ... @@ -0,0 +1,34 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5 + <title>MongoUI</title>
  6 + <style type="text/css">
  7 + body {font-size: 10pt; font-family: Tahoma; color: #333;}
  8 + .title {padding: 5px; border-bottom: 1px solid #ccc; font-weight: bold; color: #1b1b1b;}
  9 + .text {padding: 5px;}
  10 + </style>
  11 +</head>
  12 +<body>
  13 + <div class="content">
  14 + <div class="title">
  15 + Welcome to MongoUI
  16 + </div>
  17 + <div class="text">
  18 + The MongoUI an Administrator Tool for MongoDB. <br />
  19 + Can be management all mongodb functions. <br />
  20 + <ul>
  21 + <li>Database Management</li>
  22 + <li>User Management</li>
  23 + <li>Collection Management</li>
  24 + <li>Index Management</li>
  25 + <li>Document Management</li>
  26 + <li>Stored JavaScript Management</li>
  27 + <li>Sharding Tools</li>
  28 + <li>Server Status</li>
  29 + <li>Runnable Javascripts</li>
  30 + </ul>
  31 + </div>
  32 + </div>
  33 +</body>
  34 +</html>

0 comments on commit c653b5a

Please sign in to comment.
Something went wrong with that request. Please try again.