com.kotcrab.vis.ui.widget.file.FileChooser Java Examples

The following examples show how to use com.kotcrab.vis.ui.widget.file.FileChooser. 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: PackInputFilesController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("addInputFiles") void addInputFiles() {
    final FileChooser fileChooser = new FileChooser(FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(true);
    fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
            .rule("Image files", "png", "jpg", "jpeg").get()); //TODO localize
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> files) {
            PackModel pack = getSelectedPack();
            for (FileHandle file : files) {
                pack.addInputFile(file, InputFile.Type.Input);
            }
        }
    });
    stage.addActor(fileChooser.fadeIn());
}
 
Example #2
Source File: FileChooserField.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(mode);
                fileChooser.setListener(new SingleFileChooserListener() {
                    @Override
                    protected void selected(FileHandle file) {
                        fileHandle = file;
                        path = file.path();

                        textField.setText(file.path());
                        if (fileSelected != null) {
                            fileSelected.selected(file);
                        }
                    }
                });
                UI.INSTANCE.addActor(fileChooser.fadeIn());
            }
        });

    }
 
Example #3
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 #4
Source File: App.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void create() {
    if (params.debug) {
        Gdx.app.log(TAG, "Application is running in DEBUG mode.");
    }

    Gdx.app.getGraphics().setContinuousRendering(false);

    Gdx.input.setInputProcessor(inputMultiplexer);

    initiateContext();

    FileChooser.setSaveLastDirectory(true);
    FileChooser.setDefaultPrefsName("file_chooser.xml");

    // Uncomment to update project's LML DTD schema
    // LmlUtils.saveDtdSchema(interfaceService.getParser(), Gdx.files.local("../lml.dtd"));
}
 
Example #5
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("pickOutputDir") public void pickOutputDir() {
    final PackModel pack = getSelectedPack();
    if (pack == null) return;

    FileHandle dir = FileUtils.obtainIfExists(pack.getOutputDir());
    if (dir == null) {
        dir = fileChooserHistory.getLastDir(FileChooserHistory.Type.OUTPUT_DIR);
    }

    FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> file) {
            FileHandle chosenFile = file.first();
            fileChooserHistory.putLastDir(FileChooserHistory.Type.OUTPUT_DIR, chosenFile);
            pack.setOutputDir(chosenFile.file().getAbsolutePath());
        }
    });
    getStage().addActor(fileChooser.fadeIn());
}
 
Example #6
Source File: DirsSuggestionPopup.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private int createRecentDirSuggestions (Array<FileHandle> files, float width) {
	clearChildren();
	int suggestions = 0;
	for (final FileHandle file : files) {
		if (file.exists() == false) continue;

		MenuItem item = createMenuItem(file.path());
		item.getLabel().setEllipsis(true);
		item.getLabelCell().width(width - 20);
		addItem(item);

		item.addListener(new ChangeListener() {
			@Override
			public void changed (ChangeEvent event, Actor actor) {
				chooser.setDirectory(file, FileChooser.HistoryPolicy.ADD);
			}
		});

		suggestions++;
		if (suggestions == MAX_SUGGESTIONS) {
			break;
		}
	}

	return suggestions;
}
 
Example #7
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("openProject") public void openProject() {
      final ProjectModel project = getProject();
      FileHandle dir = fileChooserHistory.getLastDir(FileChooserHistory.Type.PROJECT);
      if (FileUtils.fileExists(project.getProjectFile())) {
          dir = project.getProjectFile().parent();
      }

      final FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN);
      fileChooser.setIconProvider(new AppIconProvider(fileChooser));
      fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
	.rule(getString("projectFileDescription", AppConstants.PROJECT_FILE_EXT), AppConstants.PROJECT_FILE_EXT).get());
      fileChooser.setListener(new FileChooserAdapter() {
          @Override
          public void selected (Array<FileHandle> file) {
              final FileHandle chosenFile = file.first();
              commonDialogs.checkUnsavedChanges(new Runnable() {
                  @Override
                  public void run() {
                      loadProject(chosenFile);
                  }
              });
          }
      });
      getStage().addActor(fileChooser.fadeIn());
  }
 
Example #8
Source File: TextureUnpackerDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("pickOutputDir") void pickOutputDir() {
    FileHandle dir = FileUtils.obtainIfExists(edtOutputDir.getText());
    if (dir == null && FileUtils.fileExists(edtAtlasPath.getText())) {
        dir = FileUtils.obtainIfExists(edtAtlasPath.getText()).parent();
    }

    FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> file) {
            FileHandle chosenFile = file.first();
            edtOutputDir.setText(chosenFile.path());
        }
    });
    stage.addActor(fileChooser.fadeIn());
}
 
Example #9
Source File: TextureUnpackerDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("pickAtlasPath") void pickAtlasPath() {
    FileHandle dir = FileUtils.obtainIfExists(edtAtlasPath.getText());

    final FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
    fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
            .rule("Texture atlas (*.json;*.pack;*.atlas)", "json", "pack", "atlas").get());
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> file) {
            FileHandle chosenFile = file.first();
            edtAtlasPath.setText(chosenFile.path());
        }
    });
    stage.addActor(fileChooser.fadeIn());

}
 
Example #10
Source File: NinePatchToolController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
public void initiateFromFilePicker() {
    FileHandle rootDir = null;
    if (sourceFile != null) {
        rootDir = sourceFile.parent();
    }

    final FileChooser fileChooser = new FileChooser(rootDir, FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
    fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
            .rule("PNG or 9-Patch", "png", "9.png").get());
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> files) {
            FileHandle file = files.first();
            initiateWithSourceFile(file);
        }
    });
    Stage stage = interfaceService.getCurrentController().getStage();
    stage.addActor(fileChooser.fadeIn());

    if (sourceFile != null && FileUtils.fileExists(sourceFile)) {
        fileChooser.setSelectedFiles(sourceFile);
    }
}
 
Example #11
Source File: PackInputFilesController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@LmlAction("addIgnoreFiles") void addIgnoreFiles() {
    final FileChooser fileChooser = new FileChooser(FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
    fileChooser.setMultiSelectionEnabled(true);
    fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
            .rule("Image files", "png", "jpg", "jpeg").get()); //TODO localize
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> files) {
            PackModel pack = getSelectedPack();
            for (FileHandle file : files) {
                pack.addInputFile(file, InputFile.Type.Ignore);
            }
        }
    });
    stage.addActor(fileChooser.fadeIn());
}
 
Example #12
Source File: BatchConvertDialog.java    From talos with Apache License 2.0 6 votes vote down vote up
public BatchConvertDialog() {
    super("Batch Convert Legacy Effects");

    setCenterOnAdd(true);
    setModal(true);
    setResizable(true);
    setMovable(true);
    addCloseButton();
    closeOnEscape();


    setSize(700, 400);
    centerWindow();

    initContent();

    fileChooser = new FileChooser(FileChooser.Mode.OPEN);
    fileChooser.setBackground(getSkin().getDrawable("window-noborder"));

}
 
Example #13
Source File: UIStage.java    From talos with Apache License 2.0 6 votes vote down vote up
public void legacyImportAction() {
	fileChooser.setMode(FileChooser.Mode.OPEN);
	fileChooser.setMultiSelectionEnabled(false);
	fileChooser.setFileFilter(new FileChooser.DefaultFileFilter(fileChooser));
	fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);

	fileChooser.setListener(new FileChooserAdapter() {
		@Override
		public void selected (Array<FileHandle> file) {
			TalosMain.Instance().TalosProject().importFromLegacyFormat(file.get(0));
			TalosMain.Instance().ProjectController().unbindFromFile();
		}
	});

	stage.addActor(fileChooser.fadeIn());
}
 
Example #14
Source File: UIStage.java    From talos with Apache License 2.0 5 votes vote down vote up
public void openProjectAction(final IProject projectType) {
	String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Open", projectType);
	if(defaultLocation.equals("")) {
		TalosMain.Instance().ProjectController().getLastDir("Save", projectType);
	}
	fileChooser.setDirectory(defaultLocation);

	fileChooser.setMode(FileChooser.Mode.OPEN);
	fileChooser.setMultiSelectionEnabled(false);

	fileChooser.setFileFilter(new FileFilter() {
		@Override
		public boolean accept(File pathname) {
			return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(projectType.getExtension());
		}
	});
	fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);

	fileChooser.setListener(new FileChooserAdapter() {
		@Override
		public void selected (Array<FileHandle> file) {
			String path = file.first().file().getAbsolutePath();
			TalosMain.Instance().ProjectController().setProject(projectType);
			TalosMain.Instance().ProjectController().loadProject(Gdx.files.absolute(path));
		}
	});

	stage.addActor(fileChooser.fadeIn());
}
 
Example #15
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getDirIcon (FileChooser.FileItem item) {
	Drawable icon = getIcon(iconFolderBig, chooser.getViewMode());
	if (icon == null)
		return super.getDirIcon(item);
	return icon;
}
 
Example #16
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public HighResFileChooserIconProvider (FileChooser chooser) {
	super(chooser);
	highResTextures = new TextureAtlas(Gdx.files.classpath("file-chooser-high-res.atlas"));
	loadIcons(iconFolderBig, "icon-folder");
	loadIcons(iconFileText, "icon-file-text");
	loadIcons(iconFileImage, "icon-file-image");
	loadIcons(iconFilePdf, "icon-file-pdf");
	loadIcons(iconFileAudio, "icon-file-audio");
}
 
Example #17
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getImageIcon (FileChooser.FileItem item) {
	Drawable icon = getIcon(iconFileImage, chooser.getViewMode());
	if (icon == null)
		return super.getImageIcon(item);
	return icon;
}
 
Example #18
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getAudioIcon (FileChooser.FileItem item) {
	Drawable icon = getIcon(iconFileAudio, chooser.getViewMode());
	if (icon == null)
		return super.getAudioIcon(item);
	return icon;
}
 
Example #19
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getPdfIcon (FileChooser.FileItem item) {
	Drawable icon = getIcon(iconFilePdf, chooser.getViewMode());
	if (icon == null)
		return super.getPdfIcon(item);
	return icon;
}
 
Example #20
Source File: HighResFileChooserIconProvider.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getTextIcon (FileChooser.FileItem item) {
	Drawable icon = getIcon(iconFileText, chooser.getViewMode());
	if (icon == null)
		return super.getTextIcon(item);
	return icon;
}
 
Example #21
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
protected void exportUIImages() {
	FileChooser fileChooser = new FileChooser(Mode.OPEN);
	fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
	fileChooser.setViewMode(ViewMode.LIST);

	fileChooser.setSelectionMode(SelectionMode.DIRECTORIES);
	getStage().addActor(fileChooser);

	fileChooser.setListener(new FileChooserListener() {

		@Override
		public void selected(Array<FileHandle> files) {
			try {
				// fileChooser.setTitle("Select the file to export the
				// project texts");

				ImageUtils.unpackAtlas(new File(Ctx.project.getAssetPath() + Project.UI_PATH + "/1/ui.atlas"),
						files.get(0).file());

				Message.showMsg(getStage(), "UI Atlas images exported sucessfully.", 4);
			} catch (Exception e) {
				Message.showMsg(getStage(), "There was a problem exporting images from UI Atlas.", 4);
				EditorLogger.printStackTrace(e);
			}
		}

		@Override
		public void canceled() {

		}
	});

}
 
Example #22
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void exportTSV() {

		FileChooser fileChooser = new FileChooser(Mode.SAVE);
		fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
		fileChooser.setViewMode(ViewMode.LIST);

		fileChooser.setSelectionMode(SelectionMode.FILES);
		getStage().addActor(fileChooser);

		fileChooser.setListener(new FileChooserListener() {

			@Override
			public void selected(Array<FileHandle> files) {
				try {
					// fileChooser.setTitle("Select the file to export the
					// project texts");

					I18NUtils.exportTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH,
							files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");

					Message.showMsg(getStage(), files.get(0).file().getName() + " exported sucessfully.", 4);
				} catch (IOException e) {
					Message.showMsg(getStage(), "There was a problem generating the .tsv file.", 4);
					EditorLogger.printStackTrace(e);
				}
			}

			@Override
			public void canceled() {

			}
		});
	}
 
Example #23
Source File: ToolsWindow.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
private void importTSV() {

		FileChooser fileChooser = new FileChooser(Mode.OPEN);
		fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
		fileChooser.setViewMode(ViewMode.LIST);

		fileChooser.setSelectionMode(SelectionMode.FILES);
		getStage().addActor(fileChooser);

		fileChooser.setListener(new FileChooserListener() {

			@Override
			public void selected(Array<FileHandle> files) {
				try {
					// chooser.setTitle("Select the .tsv file to import");

					I18NUtils.importTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH,
							files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");

					// Reload texts
					Ctx.project.getI18N().load(Ctx.project.getChapter().getId());

					Message.showMsg(getStage(), files.get(0).file().getName() + " imported sucessfully.", 4);

				} catch (IOException e) {
					Message.showMsg(getStage(), "There was a problem importing the .tsv file.", 4);
					EditorLogger.printStackTrace(e);
				}
			}

			@Override
			public void canceled() {

			}
		});
	}
 
Example #24
Source File: UIStage.java    From talos with Apache License 2.0 5 votes vote down vote up
public void exportAsAction() {
	IProject projectType = TalosMain.Instance().ProjectController().getProject();
	String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Export", projectType);
	fileChooser.setDirectory(defaultLocation);

	final String ext = projectType.getExportExtension();

	fileChooser.setMode(FileChooser.Mode.SAVE);
	fileChooser.setMultiSelectionEnabled(false);
	fileChooser.setFileFilter(new FileFilter() {
		@Override
		public boolean accept(File pathname) {
			return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(ext);
		}
	});
	fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);

	fileChooser.setListener(new FileChooserAdapter() {
		@Override
		public void selected(Array<FileHandle> file) {
			String path = file.first().file().getAbsolutePath();
			if(!path.endsWith(ext)) {
				if(path.indexOf(".") > 0) {
					path = path.substring(0, path.indexOf("."));
				}
				path += ext;
			}
			FileHandle handle = Gdx.files.absolute(path);
			TalosMain.Instance().ProjectController().exportProject(handle);
		}
	});

	fileChooser.setDefaultFileName(TalosMain.Instance().ProjectController().getCurrentExportNameSuggestion());

	stage.addActor(fileChooser.fadeIn());
}
 
Example #25
Source File: UIStage.java    From talos with Apache License 2.0 5 votes vote down vote up
public void saveAsProjectAction() {
	IProject projectType = TalosMain.Instance().ProjectController().getProject();
	String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Save", projectType);
	fileChooser.setDirectory(defaultLocation);

	final String ext = projectType.getExtension();
	fileChooser.setMode(FileChooser.Mode.SAVE);
	fileChooser.setMultiSelectionEnabled(false);
	fileChooser.setFileFilter(new FileFilter() {
		@Override
		public boolean accept(File pathname) {
			return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(ext);
		}
	});
	fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);

	fileChooser.setListener(new FileChooserAdapter() {
		@Override
		public void selected(Array<FileHandle> file) {
			String path = file.first().file().getAbsolutePath();
			if(!path.endsWith(ext)) {
				if(path.indexOf(".") > 0) {
					path = path.substring(0, path.indexOf("."));
				}
				path += ext;
			}
			FileHandle handle = Gdx.files.absolute(path);
			TalosMain.Instance().ProjectController().saveProject(handle);
		}
	});

	fileChooser.setDefaultFileName(TalosMain.Instance().ProjectController().currentTab.fileName);

	stage.addActor(fileChooser.fadeIn());
}
 
Example #26
Source File: GlobalActions.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@LmlAction("saveProjectAs") public void saveProjectAs() {
      resetViewFocus();

      final ProjectModel project = getProject();
      FileHandle projectFile = project.getProjectFile();
      FileHandle dir = fileChooserHistory.getLastDir(FileChooserHistory.Type.PROJECT);
      if (FileUtils.fileExists(projectFile)) {
          dir = projectFile.parent();
      }

      FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.SAVE);
      fileChooser.setIconProvider(new AppIconProvider(fileChooser));
      fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
	.rule(getString("projectFileDescription", AppConstants.PROJECT_FILE_EXT), AppConstants.PROJECT_FILE_EXT).get());
      fileChooser.setListener(new FileChooserAdapter() {
          @Override
          public void selected (Array<FileHandle> file) {
              FileHandle chosenFile = file.first();
              fileChooserHistory.putLastDir(FileChooserHistory.Type.PROJECT, chosenFile.parent());

              if (chosenFile.extension().length() == 0) {
                  chosenFile = Gdx.files.getFileHandle(chosenFile.path()+"."+AppConstants.PROJECT_FILE_EXT, chosenFile.type());
              }

              getProject().setProjectFile(chosenFile);
              projectSerializer.saveProject(project, chosenFile);
          }
      });
      getStage().addActor(fileChooser.fadeIn());

      if (FileUtils.fileExists(projectFile)) { fileChooser.setSelectedFiles(projectFile); }
  }
 
Example #27
Source File: SettingsDialog.java    From talos with Apache License 2.0 5 votes vote down vote up
public SettingsDialog() {
    super("Talos Preferences");

    textFieldMap = new ObjectMap<>();

    setCenterOnAdd(true);
    setModal(true);
    setResizable(true);
    setMovable(true);
    addCloseButton();
    closeOnEscape();

    initContent();

    pack();
    invalidate();

    centerWindow();

    fileChooser = new FileChooser(FileChooser.Mode.OPEN);
    fileChooser.setBackground(getSkin().getDrawable("window-noborder"));

    for(String key: textFieldMap.keys()) {
        textFieldMap.get(key).setText(TalosMain.Instance().Prefs().getString(key));
    }

}
 
Example #28
Source File: InputFilePropertiesDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@LmlAction("showFilePicker") void showFilePicker() {
    final FileChooser fileChooser = new FileChooser(inputFile.getFileHandle().parent(), FileChooser.Mode.OPEN);
    fileChooser.setIconProvider(new AppIconProvider(fileChooser));
    if (inputFile.isDirectory()) {
        fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);
    }  else {
        fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
        fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true)
                .rule("Image files", "png", "jpg", "jpeg").get()); //TODO localize
    }
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> files) {
            FileHandle file = files.first();
            if (file.equals(inputFile.getFileHandle())) return;

            InputFile newInputFile = modelUtils.changeInputFileHandle(modelService.getProject().getSelectedPack(), InputFilePropertiesDialogController.this.inputFile, file);

            if (newInputFile != null) {
                InputFilePropertiesDialogController.this.inputFile = newInputFile;
                mapDataFromModel();
            }
        }
    });
    stage.addActor(fileChooser.fadeIn());

    if (FileUtils.fileExists(inputFile.getFileHandle())) { fileChooser.setSelectedFiles(inputFile.getFileHandle()); }
}
 
Example #29
Source File: SettingsDialog.java    From talos with Apache License 2.0 5 votes vote down vote up
private void showFolderSelect(final String id) {
    fileChooser.setMode(FileChooser.Mode.OPEN);
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);

    fileChooser.setListener(new FileChooserAdapter() {
        @Override
        public void selected (Array<FileHandle> file) {
            textFieldMap.get(id).setText(file.get(0).path());
        }
    });

    getStage().addActor(fileChooser.fadeIn());
}
 
Example #30
Source File: AppIconProvider.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
protected Drawable getDefaultIcon(FileChooser.FileItem item) {
    String ext = item.getFile().extension().toLowerCase();
    if (ext.equals(AppConstants.PROJECT_FILE_EXT)) {
        return chooser.getSkin().getDrawable("custom/ic-gdx-texture-packer");
    }

    return null;
}