com.kotcrab.vis.ui.util.dialog.Dialogs Java Examples

The following examples show how to use com.kotcrab.vis.ui.util.dialog.Dialogs. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageChooserField.java    From Mundus with Apache License 2.0 6 votes vote down vote up
private void setupListeners() {
    fcBtn.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            FileChooser fileChooser = UI.INSTANCE.getFileChooser();
            fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
            fileChooser.setListener(new SingleFileChooserListener() {
                public void selected(FileHandle file) {
                    if (FileFormatUtils.isImage(file)) {
                        setImage(file);
                    } else {
                        Dialogs.showErrorDialog(UI.INSTANCE, "This is no image");
                    }
                }
            });
            UI.INSTANCE.addActor(fileChooser.fadeIn());
        }
    });
}
 
Example #2
Source File: FileChooser.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void showNewDirectoryDialog () {
	Dialogs.showInputDialog(getChooserStage(), NEW_DIRECTORY_DIALOG_TITLE.get(), NEW_DIRECTORY_DIALOG_TEXT.get(), true, new InputDialogAdapter() {
		@Override
		public void finished (String input) {
			if (FileUtils.isValidFileName(input) == false) {
				Dialogs.showErrorDialog(getChooserStage(), NEW_DIRECTORY_DIALOG_ILLEGAL_CHARACTERS.get());
				return;
			}

			for (FileHandle file : currentDirectory.list()) {
				if (file.name().equals(input)) {
					Dialogs.showErrorDialog(getChooserStage(), NEW_DIRECTORY_DIALOG_ALREADY_EXISTS.get());
					return;
				}
			}

			FileHandle newDir = currentDirectory.child(input);
			newDir.mkdirs();
			refresh();
			highlightFiles(newDir);
		}
	});
}
 
Example #3
Source File: FileChooser.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void showFileDeleteDialog (final FileHandle fileToDelete) {
	Dialogs.showOptionDialog(getChooserStage(), POPUP_TITLE.get(),
			fileDeleter.hasTrash() ? CONTEXT_MENU_MOVE_TO_TRASH_WARNING.get() : CONTEXT_MENU_DELETE_WARNING.get(),
			OptionDialogType.YES_NO, new OptionDialogAdapter() {
				@Override
				public void yes () {
					try {
						boolean success = fileDeleter.delete(fileToDelete);
						if (success == false) {
							Dialogs.showErrorDialog(getChooserStage(), POPUP_DELETE_FILE_FAILED.get());
						}
					} catch (IOException e) {
						Dialogs.showErrorDialog(getChooserStage(), POPUP_DELETE_FILE_FAILED.get(), e);
						e.printStackTrace();
					}
					refresh();
				}
			});
}
 
Example #4
Source File: CommonDialogs.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
/**
 * @param onConfirm Fires on "no" or "yes" choice.
 * @param onCancel Fires on "cancel" choice. May be null.
 */
public void checkUnsavedChanges(final Runnable onConfirm, final Runnable onCancel) {
    if (!globalActions.modelService.hasProjectChanges()) {
        onConfirm.run();
    } else {
        OptionDialog optionDialog = OptionDialog.show(getStage(),
                getString("dUnsavedChangesTitle"),
                getString("dUnsavedChangesMessage"),
                Dialogs.OptionDialogType.YES_NO_CANCEL, new OptionDialogAdapter() {
                    @Override
                    public void no() {
                        onConfirm.run();
                    }

                    @Override
                    public void yes() {
                        globalActions.saveProject();
                        onConfirm.run();
                    }

                    @Override
                    public void cancel() {
                        if (onCancel != null) {
                            onCancel.run();
                        }
                    }
                });
        optionDialog.closeOnEscape();
    }
}
 
Example #5
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@LmlAction("renamePack") public void renamePack() {
    final PackModel pack = getSelectedPack();
    if (pack == null) return;

    Dialogs.InputDialog dialog = new Dialogs.InputDialog(getString("renamePack"), null, true, null, new InputDialogAdapter() {
        @Override
        public void finished(String input) {
            pack.setName(input);
        }
    });
    getStage().addActor(dialog.fadeIn());
    dialog.setText(pack.getName(), true);
}
 
Example #6
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@LmlAction("deletePack") public void deletePack() {
    final PackModel pack = getSelectedPack();
    if (pack == null) return;

    OptionDialog optionDialog = OptionDialog.show(getStage(), getString("deletePack"), getString("dialogTextDeletePack", pack.getName()),
            Dialogs.OptionDialogType.YES_CANCEL, new OptionDialogAdapter() {
                @Override
                public void yes() {
                    modelUtils.selectClosestPack(pack);
                    getProject().removePack(pack);
                }
            });
    optionDialog.closeOnEscape();
}
 
Example #7
Source File: ModelPlacementTool.java    From Mundus with Apache License 2.0 5 votes vote down vote up
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {

    if (modelInstance != null && button == Input.Buttons.LEFT) {
        int id = getProjectManager().current().obtainID();
        GameObject modelGo = new GameObject(getProjectManager().current().currScene.sceneGraph, model.getName(),
                id);
        getProjectManager().current().currScene.sceneGraph.addGameObject(modelGo);

        modelInstance.transform.getTranslation(tempV3);
        modelGo.translate(tempV3);

        PickableModelComponent modelComponent = new PickableModelComponent(modelGo, Shaders.INSTANCE.getModelShader());
        modelComponent.setShader(getShader());
        modelComponent.setModel(model, true);
        modelComponent.encodeRaypickColorId();

        try {
            modelGo.addComponent(modelComponent);
        } catch (InvalidComponentException e) {
            Dialogs.showErrorDialog(UI.INSTANCE, e.getMessage());
            return false;
        }

        Mundus.INSTANCE.postEvent(new SceneGraphChangedEvent());
        mouseMoved(screenX, screenY);
    }
    return false;
}
 
Example #8
Source File: TabbedPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
/**
 * Removes tab from pane, if tab is dirty and 'ignoreTabDirty == false' this will cause to display "Unsaved changes" dialog!
 * @return true if tab was removed, false if that tab wasn't added to this pane or "Unsaved changes" dialog was started
 */
public boolean remove (final Tab tab, boolean ignoreTabDirty) {
	checkIfTabsBelongsToThisPane(tab);

	if (ignoreTabDirty) {
		return removeTab(tab);
	}

	if (tab.isDirty() && mainTable.getStage() != null) {
		Dialogs.showOptionDialog(mainTable.getStage(), Text.UNSAVED_DIALOG_TITLE.get(), Text.UNSAVED_DIALOG_TEXT.get(),
				OptionDialogType.YES_NO_CANCEL, new OptionDialogAdapter() {
					@Override
					public void yes () {
						tab.save();
						removeTab(tab);
					}

					@Override
					public void no () {
						removeTab(tab);
					}
				});
	} else {
		return removeTab(tab);
	}

	return false;
}
 
Example #9
Source File: FileChooser.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void showOverwriteQuestion (final Array<FileHandle> filesList) {
	String text = filesList.size == 1 ? POPUP_FILE_EXIST_OVERWRITE.get() : POPUP_MULTIPLE_FILE_EXIST_OVERWRITE.get();
	Dialogs.showOptionDialog(getChooserStage(), POPUP_TITLE.get(), text, OptionDialogType.YES_NO, new OptionDialogAdapter() {
		@Override
		public void yes () {
			notifyListenerAndCloseDialog(filesList);
		}
	});
}
 
Example #10
Source File: FileHistoryManager.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private boolean setDirectoryFromHistory (FileHandle dir) {
	if (dir.exists()) {
		callback.setDirectory(dir, HistoryPolicy.IGNORE);
		return true;
	} else {
		Dialogs.showErrorDialog(callback.getStage(), DIRECTORY_NO_LONGER_EXISTS.get());
		return false;
	}
}
 
Example #11
Source File: ErrorReporting.java    From talos with Apache License 2.0 4 votes vote down vote up
public void reportException(Throwable e) {
    Dialogs.showErrorDialog(TalosMain.Instance().UIStage().getStage(), "Talos just encountered an error, click details, then copy and send error developers if you dare", e);
}
 
Example #12
Source File: OptionDialog.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
public static OptionDialog show(Stage stage, String title, String text, Dialogs.OptionDialogType type, OptionDialogListener listener) {
    OptionDialog dialog = new OptionDialog(title, text, type, listener);
    stage.addActor(dialog.fadeIn());
    return dialog;
}
 
Example #13
Source File: FileChooser.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private void showDialog (String text) {
	Dialogs.showOKDialog(getChooserStage(), POPUP_TITLE.get(), text);
}
 
Example #14
Source File: TestLauncher.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private void createMenus () {
	Menu fileMenu = new Menu("File");
	Menu editMenu = new Menu("Edit");
	Menu windowMenu = new Menu("Window");
	Menu helpMenu = new Menu("Help");

	fileMenu.addItem(createTestsMenu());
	fileMenu.addItem(new MenuItem("menuitem #1"));
	fileMenu.addItem(new MenuItem("menuitem #2").setShortcut("f1"));
	fileMenu.addItem(new MenuItem("menuitem #3").setShortcut("f2"));
	fileMenu.addItem(new MenuItem("menuitem #4").setShortcut("alt + f4"));

	MenuItem subMenuItem = new MenuItem("submenu #1");
	subMenuItem.setShortcut("alt + insert");
	subMenuItem.setSubMenu(createSubMenu());
	fileMenu.addItem(subMenuItem);

	MenuItem subMenuItem2 = new MenuItem("submenu #2");
	subMenuItem2.setSubMenu(createSubMenu());
	fileMenu.addItem(subMenuItem2);

	MenuItem subMenuItem3 = new MenuItem("submenu disabled");
	subMenuItem3.setDisabled(true);
	subMenuItem3.setSubMenu(createSubMenu());
	fileMenu.addItem(subMenuItem3);

	// ---

	editMenu.addItem(new MenuItem("menuitem #5"));
	editMenu.addItem(new MenuItem("menuitem #6"));
	editMenu.addSeparator();
	editMenu.addItem(new MenuItem("menuitem #7"));
	editMenu.addItem(new MenuItem("menuitem #8"));
	editMenu.addItem(createDoubleNestedMenu());

	MenuItem disabledItem = new MenuItem("disabled menuitem");
	disabledItem.setDisabled(true);
	MenuItem disabledItem2 = new MenuItem("disabled menuitem shortcut").setShortcut("alt + f4");
	disabledItem2.setDisabled(true);

	editMenu.addItem(disabledItem);
	editMenu.addItem(disabledItem2);

	windowMenu.addItem(new MenuItem("menuitem #9"));
	windowMenu.addItem(new MenuItem("menuitem #10"));
	windowMenu.addItem(new MenuItem("menuitem #11"));
	windowMenu.addSeparator();
	windowMenu.addItem(new MenuItem("menuitem #12"));

	helpMenu.addItem(new MenuItem("about", new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Dialogs.showOKDialog(stage, "about", "visui version: " + VisUI.VERSION);
		}
	}));

	menuBar.addMenu(fileMenu);
	menuBar.addMenu(editMenu);
	menuBar.addMenu(windowMenu);
	menuBar.addMenu(helpMenu);
}