Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-04-19 13:49:21 +0000
committerTom Schindl2013-04-19 13:49:21 +0000
commit1fd07b2ca7e7a4c7c790a36ba52237822f1b1683 (patch)
tree58ef5e6a7740359dbcaac7412f28e8c495a62102
parent0e4dc192b67e434b05f789d4a15d1b1ac0af5bb6 (diff)
downloadorg.eclipse.efxclipse-1fd07b2ca7e7a4c7c790a36ba52237822f1b1683.tar.gz
org.eclipse.efxclipse-1fd07b2ca7e7a4c7c790a36ba52237822f1b1683.tar.xz
org.eclipse.efxclipse-1fd07b2ca7e7a4c7c790a36ba52237822f1b1683.zip
initial check in (without icons)
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.classpath7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.gitignore2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.project34
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.resources.prefs2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.runtime.prefs2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.jdt.core.prefs7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/IP-TODO.txt8
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/META-INF/MANIFEST.MF36
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/build.properties4
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/pom.xml34
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/Dialog.java210
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/MessageDialog.java208
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/PromptInputDialog.java49
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/TitleAreaDialog.java87
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/icons/todo.txt1
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/message_dialog.css23
-rwxr-xr-xreleng/org.eclipse.fx.releng/pom.xml1
17 files changed, 715 insertions, 0 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.classpath b/bundles/runtime/org.eclipse.fx.ui.dialogs/.classpath
new file mode 100755
index 000000000..b1dabee38
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.gitignore b/bundles/runtime/org.eclipse.fx.ui.dialogs/.gitignore
new file mode 100755
index 000000000..4dc009173
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.project b/bundles/runtime/org.eclipse.fx.ui.dialogs/.project
new file mode 100755
index 000000000..8ce461155
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.fx.ui.dialogs</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.resources.prefs b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.resources.prefs
new file mode 100755
index 000000000..99f26c020
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.runtime.prefs b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.runtime.prefs
new file mode 100755
index 000000000..deae05a97
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\r\n
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 000000000..f42de363a
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/IP-TODO.txt b/bundles/runtime/org.eclipse.fx.ui.dialogs/IP-TODO.txt
new file mode 100755
index 000000000..1584165bc
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/IP-TODO.txt
@@ -0,0 +1,8 @@
+Oxygene Icons (Creative Commons 3.0 & LGPL):
+---------------------
+From: svn -r 760421 co svn://anonsvn.kde.org/home/kde/trunk/kdesupport/oxygen-icons
+.../icons/dialog-error.png
+.../icons/dialog-information.png
+.../icons/dialog-warning.png
+.../icons/preferences-desktop-notification.png
+.../icons/system-help.png \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.ui.dialogs/META-INF/MANIFEST.MF
new file mode 100755
index 000000000..6c717bb4c
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Dialogs
+Bundle-SymbolicName: org.eclipse.fx.ui.dialogs
+Bundle-Version: 0.8.1.qualifier
+Require-Bundle: org.eclipse.fx.ui.panes;bundle-version="0.8.1"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Import-Package: javafx.animation;version="2.0.0",
+ javafx.application;version="2.0.0",
+ javafx.beans;version="2.0.0",
+ javafx.beans.binding;version="2.0.0",
+ javafx.beans.property;version="2.0.0",
+ javafx.beans.value;version="2.0.0",
+ javafx.collections;version="2.0.0",
+ javafx.concurrent;version="2.0.0",
+ javafx.embed.swing;version="2.0.0",
+ javafx.event;version="2.0.0",
+ javafx.fxml;version="2.0.0",
+ javafx.geometry;version="2.0.0",
+ javafx.scene;version="2.0.0",
+ javafx.scene.chart;version="2.0.0",
+ javafx.scene.control;version="2.0.0",
+ javafx.scene.control.cell;version="2.0.0",
+ javafx.scene.effect;version="2.0.0",
+ javafx.scene.image;version="2.0.0",
+ javafx.scene.input;version="2.0.0",
+ javafx.scene.layout;version="2.0.0",
+ javafx.scene.media;version="2.0.0",
+ javafx.scene.paint;version="2.0.0",
+ javafx.scene.shape;version="2.0.0",
+ javafx.scene.text;version="2.0.0",
+ javafx.scene.transform;version="2.0.0",
+ javafx.scene.web;version="2.0.0",
+ javafx.stage;version="2.0.0",
+ javafx.util;version="2.0.0"
+Export-Package: org.eclipse.fx.ui.dialogs
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/build.properties b/bundles/runtime/org.eclipse.fx.ui.dialogs/build.properties
new file mode 100755
index 000000000..34d2e4d2d
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/pom.xml b/bundles/runtime/org.eclipse.fx.ui.dialogs/pom.xml
new file mode 100755
index 000000000..2d25d34a0
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/pom.xml
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <name>e(fx)clipse - Runtime - UI - Dialogs</name>
+ <groupId>org.eclipse.fx</groupId>
+ <artifactId>org.eclipse.fx.ui.dialogs</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+ <parent>
+ <groupId>org.eclipse.fx</groupId>
+ <artifactId>releng</artifactId>
+ <relativePath>../../../releng/org.eclipse.fx.releng/pom.xml</relativePath>
+ <version>0.8.1-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <resources>
+ <!-- to ensure that the feature lookup of the ui test works -->
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>META-INF/</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/Dialog.java b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/Dialog.java
new file mode 100755
index 000000000..01625737b
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/Dialog.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Point2D;
+import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Priority;
+import javafx.scene.layout.Region;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+import javafx.stage.StageStyle;
+import javafx.stage.Window;
+
+public abstract class Dialog {
+ public static final int OK_BUTTON = 1;
+ public static final int CANCEL_BUTTON = 2;
+
+ private Stage stage;
+ private boolean blockOnOpen = true;
+ private int returnCode;
+ private List<Button> buttons;
+ private String title;
+ private Window parent;
+
+ public Dialog(Window parent, String title) {
+ this.parent = parent;
+ this.title = title;
+ }
+
+ protected Parent createContents() {
+ BorderPane p = new BorderPane();
+ p.getStyleClass().add(getClass().getSimpleName());
+ HBox box = new HBox();
+ box.setPadding(getContentInset());
+
+ Node content = createDialogArea();
+ HBox.setHgrow(content, Priority.ALWAYS);
+ box.getChildren().add(content);
+
+ p.setCenter(box);
+ p.setBottom(createButtonBar());
+ return p;
+ }
+
+ protected Insets getContentInset() {
+ return new Insets(10,10,0,10);
+ }
+
+ protected abstract Node createDialogArea();
+
+ protected Node createButtonBar() {
+ HBox b = new HBox(10);
+ b.setPadding(new Insets(10));
+ Region spacer = new Region();
+
+ b.getChildren().add(spacer);
+ HBox.setHgrow(spacer, Priority.ALWAYS);
+
+ buttons = createButtonsForBar();
+ b.getChildren().addAll(buttons);
+
+ return b;
+ }
+
+ protected List<Button> createButtonsForBar() {
+ List<Button> rv = new ArrayList<Button>();
+ rv.add(createButtonForBar(CANCEL_BUTTON, "Cancel",isOkDefault(CANCEL_BUTTON),isCancelDefault(CANCEL_BUTTON)));
+ rv.add(createButtonForBar(OK_BUTTON, "Ok", isOkDefault(OK_BUTTON), isCancelDefault(OK_BUTTON)));
+ return rv;
+ }
+
+ protected boolean isOkDefault(int buttonId) {
+ return buttonId == OK_BUTTON;
+ }
+
+ protected boolean isCancelDefault(int buttonId) {
+ return buttonId == CANCEL_BUTTON;
+ }
+
+ protected Button createButtonForBar(final int type, String label, boolean defaultOkButton, boolean defaultCancel) {
+ Button b = new Button(label);
+ b.setDefaultButton(defaultOkButton);
+ b.setCancelButton(defaultCancel);
+ b.setOnAction(new EventHandler<ActionEvent>() {
+
+ @Override
+ public void handle(ActionEvent event) {
+ buttonPressed(type);
+ }
+ });
+ return b;
+ }
+
+ protected void buttonPressed(int type) {
+ if( type == CANCEL_BUTTON ) {
+ cancelPressed();
+ } else if( type == OK_BUTTON ) {
+ okPressed();
+ }
+ }
+
+ protected void okPressed() {
+ returnCode = OK_BUTTON;
+ close();
+ }
+
+ protected void cancelPressed() {
+ returnCode = CANCEL_BUTTON;
+ close();
+ }
+
+ protected void setReturnCode(int returnCode) {
+ this.returnCode = returnCode;
+ }
+
+ protected void close() {
+ stage.close();
+ }
+
+ protected List<String> getStylesheets() {
+ if( parent != null ) {
+ return Collections.unmodifiableList(parent.getScene().getStylesheets());
+ }
+ return Collections.emptyList();
+ }
+
+ protected Stage create() {
+ Stage stage = new Stage(StageStyle.UTILITY);
+ stage.setTitle(title);
+// Causes problems when embedded in SWT
+ stage.initOwner(parent);
+ Parent content = createContents();
+ Scene s = new Scene(content);
+ s.getStylesheets().addAll(getStylesheets());
+ stage.setScene(s);
+ return stage;
+ }
+
+ protected Point2D getInitialSize() {
+ return new Point2D(stage.getScene().getRoot().prefWidth(-1), stage.getScene().getRoot().prefHeight(-1));
+ }
+
+ void layout() {
+ double maxWidth = 0;
+ for( Button b : buttons ) {
+ maxWidth = Math.max(maxWidth, b.prefWidth(-1));
+ }
+
+ for( Button b : buttons ) {
+ b.setPrefWidth(maxWidth);
+ }
+
+// Point2D size = getInitialSize();
+// stage.setWidth(size.getX());
+// stage.setHeight(size.getY());
+// stage.sizeToScene();
+ }
+
+ protected Modality getModality() {
+ return Modality.WINDOW_MODAL;
+ }
+
+ public int open() {
+ if( stage == null ) {
+ stage = create();
+ stage.showingProperty().addListener(new ChangeListener<Boolean>() {
+
+ @Override
+ public void changed(
+ ObservableValue<? extends Boolean> observable,
+ Boolean oldValue, Boolean newValue) {
+ if( newValue ) {
+ layout();
+ }
+ }
+ });
+ }
+
+ stage.initModality(getModality());
+ if( blockOnOpen ) {
+ stage.showAndWait();
+ } else {
+ stage.show();
+ }
+
+ return returnCode;
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/MessageDialog.java b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/MessageDialog.java
new file mode 100755
index 000000000..9ede22bc2
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/MessageDialog.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.fx.ui.panes.GridLayoutPane;
+
+import javafx.scene.Node;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.image.ImageView;
+import javafx.stage.Window;
+
+public class MessageDialog extends Dialog {
+ public enum Type {
+ CUSTOM,
+ QUESTION,
+ INFORMATION,
+ WARNING,
+ ERROR,
+ CONFIRM,
+ QUESTION_CANCEL
+ }
+
+ public enum QuestionResult {
+ YES(0),
+ NO(1);
+
+ private final int index;
+
+ private QuestionResult(int index) {
+ this.index = index;
+ }
+
+ static QuestionResult fromIndex(int index) {
+ if( index == YES.index ) {
+ return YES;
+ } else {
+ return NO;
+ }
+ }
+ }
+
+ public enum QuestionCancelResult {
+ YES(0),
+ NO(1),
+ CANCEL(2);
+
+ private final int index;
+
+ private QuestionCancelResult(int index) {
+ this.index = index;
+ }
+
+ static QuestionCancelResult fromIndex(int index) {
+ if( index == YES.index ) {
+ return YES;
+ } else if( index == NO.index ) {
+ return NO;
+ } else {
+ return CANCEL;
+ }
+ }
+ }
+
+ public enum ConfirmResult {
+ OK(0),
+ CANCEL(1);
+
+ private final int index;
+
+ private ConfirmResult(int index) {
+ this.index = index;
+ }
+
+ static ConfirmResult fromIndex(int index) {
+ if( index == OK.index ) {
+ return OK;
+ } else {
+ return CANCEL;
+ }
+ }
+ }
+
+ private final Type type;
+ private final String message;
+ private final String[] dialogButtonLabels;
+ private final int okButton;
+ private final int cancelButton;
+
+ public MessageDialog(Window parent, String windowTitle, String message, Type type, int okButton, int cancelButton, String... dialogButtonLabels) {
+ super(parent, windowTitle);
+ this.type = type;
+ this.message = message;
+ this.dialogButtonLabels = dialogButtonLabels;
+ this.okButton = okButton;
+ this.cancelButton = cancelButton;
+ }
+
+ @Override
+ protected Node createDialogArea() {
+ GridLayoutPane b = new GridLayoutPane();
+ b.setHorizontalSpacing(20);
+ b.setNumColumns(2);
+ b.getStyleClass().add("messagedialog-" + type.name().toLowerCase());
+
+ ImageView view = new ImageView();
+ view.getStyleClass().add("messagedialog-icon");
+ b.getChildren().add(view);
+
+ Label l = new Label(message);
+ l.getStyleClass().add("messagedialog-message");
+
+ b.getChildren().add(l);
+ return b;
+ }
+
+ @Override
+ protected List<String> getStylesheets() {
+ List<String> list = new ArrayList<>(super.getStylesheets());
+ list.add(0, MessageDialog.class.getResource("message_dialog.css").toExternalForm());
+ return list;
+ }
+
+ @Override
+ protected boolean isOkDefault(int buttonId) {
+ return okButton == buttonId;
+ }
+
+ protected boolean isCancelDefault(int buttonId) {
+ return cancelButton == buttonId;
+ }
+
+ @Override
+ protected List<Button> createButtonsForBar() {
+ List<Button> rv = new ArrayList<Button>();
+ for( int i = 0; i < dialogButtonLabels.length; i++ ) {
+ rv.add(createButtonForBar(i,dialogButtonLabels[i], isOkDefault(i), isCancelDefault(i)));
+ }
+ return rv;
+ }
+
+ @Override
+ protected void buttonPressed(int type) {
+ setReturnCode(type);
+ close();
+ }
+
+ public static void openErrorDialog(Window parent, String title, String message) {
+ new MessageDialog(parent, title, message, Type.ERROR, 0, 0, "Ok").open();
+ }
+
+ public static void openWarningDialog(Window parent, String title, String message) {
+ new MessageDialog(parent, title, message, Type.WARNING, 0, 0, "Ok").open();
+ }
+
+ public static void openInformationDialog(Window parent, String title, String message) {
+ new MessageDialog(parent, title, message, Type.INFORMATION, 0, 0, "Ok").open();
+ }
+
+ public static QuestionResult openQuestionDialog(Window parent, String title, String message) {
+ return openQuestionDialog(parent, title, message, QuestionResult.YES);
+ }
+
+ public static QuestionResult openQuestionDialog(Window parent, String title, String message, QuestionResult defaultValue) {
+ return QuestionResult.fromIndex(new MessageDialog(parent, title, message, Type.QUESTION, defaultValue == QuestionResult.YES ? 0 : 1, defaultValue == QuestionResult.YES ? 1 : 0, "Yes", "No").open());
+ }
+
+ public static QuestionCancelResult openQuestionCancelDialog(Window parent, String title, String message) {
+ return openQuestionCancelDialog(parent, title, message, QuestionCancelResult.YES);
+ }
+
+ public static QuestionCancelResult openQuestionCancelDialog(Window parent, String title, String message, QuestionCancelResult defaultValue) {
+ int idx;
+
+ switch (defaultValue) {
+ case CANCEL:
+ idx = 2;
+ break;
+ case NO:
+ idx = 1;
+ break;
+ default:
+ idx = 0;
+ break;
+ }
+
+ return QuestionCancelResult.fromIndex(new MessageDialog(parent, title, message, Type.QUESTION, idx, 2, "Yes", "No", "Cancel").open());
+ }
+
+ public static ConfirmResult openConfirmDialog(Window parent, String title, String message) {
+ return openConfirmDialog(parent, title, message, ConfirmResult.OK);
+ }
+
+ public static ConfirmResult openConfirmDialog(Window parent, String title, String message, ConfirmResult defaultValue) {
+ return ConfirmResult.fromIndex(new MessageDialog(parent, title, message, Type.CONFIRM, defaultValue == ConfirmResult.OK ? 0 : 1, 1, "Ok", "Cancel").open());
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/PromptInputDialog.java b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/PromptInputDialog.java
new file mode 100755
index 000000000..f37c3a5ba
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/PromptInputDialog.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.dialogs;
+
+import javafx.scene.Node;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.HBox;
+import javafx.stage.Window;
+
+public class PromptInputDialog extends Dialog {
+ private String text;
+ private TextField f;
+ private String input;
+
+ public PromptInputDialog(Window parent, String title, String text) {
+ super(parent, title);
+ this.text = text;
+ }
+
+ @Override
+ protected Node createDialogArea() {
+ HBox box = new HBox(5);
+ box.getChildren().add(new Label(text));
+
+ f = new TextField();
+ box.getChildren().add(f);
+
+ return box;
+ }
+
+ @Override
+ protected void okPressed() {
+ super.okPressed();
+ input = f.getText();
+ }
+
+ public String getInput() {
+ return input;
+ }
+} \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/TitleAreaDialog.java b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/TitleAreaDialog.java
new file mode 100755
index 000000000..54336f135
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/TitleAreaDialog.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2012 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl<tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.dialogs;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javafx.geometry.Insets;
+import javafx.scene.Node;
+import javafx.scene.control.Label;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.VBox;
+import javafx.stage.Window;
+
+public abstract class TitleAreaDialog extends Dialog {
+ private String title;
+ private String message;
+ private URL imageURI;
+
+ public TitleAreaDialog(Window parent, String windowTitle, String title, String message, URL imageURI) {
+ super(parent, windowTitle);
+ this.title = title;
+ this.message = message;
+ this.imageURI = imageURI;
+ }
+
+ @Override
+ protected final Node createDialogArea() {
+ VBox pane = new VBox();
+ BorderPane titleArea = new BorderPane();
+ titleArea.setPadding(new Insets(0,0,0,10));
+
+ VBox messageArea = new VBox();
+ messageArea.setPadding(new Insets(10, 0, 0, 0));
+ messageArea.getStyleClass().add("titleDialog_MessageArea");
+
+ {
+ Label l = new Label(title);
+ l.getStyleClass().add("titleDialog_Title");
+ messageArea.getChildren().add(l);
+ }
+
+ {
+ Label l = new Label(message);
+ l.getStyleClass().add("titleDialog_Message");
+ messageArea.getChildren().add(l);
+ }
+
+ titleArea.setCenter(messageArea);
+ try {
+ InputStream in = imageURI.openStream();
+ titleArea.setRight(new ImageView(new Image(in)));
+ in.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ titleArea.setStyle("-fx-border-style: none none solid none; -fx-border-color: lightgray; -fx-border-width: 2px;");
+
+ pane.getChildren().add(titleArea);
+ BorderPane dialogContent = new BorderPane();
+ dialogContent.setCenter(createDialogContent());
+ dialogContent.setPadding(new Insets(10, 10, 10, 10));
+ pane.getChildren().add(dialogContent);
+
+ return pane;
+ }
+
+ @Override
+ protected Insets getContentInset() {
+ return new Insets(0,0,0,0);
+ }
+
+ protected abstract Node createDialogContent();
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/icons/todo.txt b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/icons/todo.txt
new file mode 100644
index 000000000..9d3a11905
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/icons/todo.txt
@@ -0,0 +1 @@
+Get in the icons from oxygen \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/message_dialog.css b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/message_dialog.css
new file mode 100755
index 000000000..8f7b1808f
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.dialogs/src/org/eclipse/fx/ui/dialogs/message_dialog.css
@@ -0,0 +1,23 @@
+.messagedialog-error ImageView.messagedialog-icon {
+ -fx-image: url("icons/dialog-error.png");
+}
+
+.messagedialog-information ImageView.messagedialog-icon {
+ -fx-image: url("icons/dialog-information.png");
+}
+
+.messagedialog-warning ImageView.messagedialog-icon {
+ -fx-image: url("icons/dialog-warning.png");
+}
+
+.messagedialog-confirm ImageView.messagedialog-icon {
+ -fx-image: url("icons/preferences-desktop-notification.png");
+}
+
+.messagedialog-question ImageView.messagedialog-icon {
+ -fx-image: url("icons/system-help.png");
+}
+
+.messagedialog-question_cancel ImageView.messagedialog-icon {
+ -fx-image: url("icons/system-help.png");
+} \ No newline at end of file
diff --git a/releng/org.eclipse.fx.releng/pom.xml b/releng/org.eclipse.fx.releng/pom.xml
index 00387db17..3fd4cbe84 100755
--- a/releng/org.eclipse.fx.releng/pom.xml
+++ b/releng/org.eclipse.fx.releng/pom.xml
@@ -39,6 +39,7 @@
<module>../../bundles/runtime/org.eclipse.fx.ui.animation</module>
<module>../../bundles/runtime/org.eclipse.fx.ui.panes</module>
<module>../../bundles/runtime/org.eclipse.fx.ui.services</module>
+ <module>../../bundles/runtime/org.eclipse.fx.ui.dialogs</module>
<!-- EMF -->
<module>../../bundles/runtime/org.eclipse.fx.emf.edit.ui</module>
<module>../../bundles/runtime/org.eclipse.fx.emf.databinding</module>

Back to the top