本文整理汇总了Java中com.kotcrab.vis.ui.widget.file.FileChooser类的典型用法代码示例。如果您正苦于以下问题:Java FileChooser类的具体用法?Java FileChooser怎么用?Java FileChooser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileChooser类属于com.kotcrab.vis.ui.widget.file包,在下文中一共展示了FileChooser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EditorManager
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
public EditorManager(){
FileChooser.setDefaultPrefsName("white-ui-editor");
FileChooser.setSaveLastDirectory(true);
events = new Array<>();
assetManager = new AssetManager();
assetManager.load("badlogic.jpg", Texture.class);
assetManager.load("icon/select.9.png",Texture.class);
assetManager.load("icon/align_left.png",Texture.class);
assetManager.load("icon/align_right.png",Texture.class);
assetManager.load("icon/align_center.png",Texture.class);
assetManager.load("icon/align_h_center.png",Texture.class);
assetManager.load("icon/align_bottom.png",Texture.class);
assetManager.load("icon/align_top.png",Texture.class);
assetManager.load("icon/label.png",Texture.class);
assetManager.load("icon/image.png",Texture.class);
assetManager.load("icon/group.png",Texture.class);
assetManager.load("icon/button.png",Texture.class);
assetManager.load("icon/checkbox.png",Texture.class);
assetManager.load("icon/textfield.png",Texture.class);
assetManager.finishLoading();
}
示例2: load
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
public void load(Runnable callback) {
chooser.setMode(FileChooser.Mode.OPEN);
chooser.setDirectory(new File(""));
chooser.setListener(new FileChooserAdapter(){
@Override
public void selected(Array<FileHandle> files) {
FileHandle first = files.first();
if(first != null) try {
load(first.file(), callback);
} catch (IOException e) {
e.printStackTrace();
}
}
});
this.chooser.centerWindow();
this.stage.addActor(this.chooser.fadeIn());
}
示例3: getFontIcon
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
private Drawable getFontIcon(FileChooser.FileItem item) {
FileHandle fileHandle = item.getFile();
BitmapFont bitmapFont;
try {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = CB.getScaledInt(50);
parameter.characters = SkinFont.DEFAULT_CHARACTER;
parameter.genMipMaps = true;
parameter.minFilter = Texture.TextureFilter.MipMapNearestNearest;
bitmapFont = generator.generateFont(parameter);
} catch (Exception e) {
return getImageIcon(item);
}
Drawable drawable = new BitmapFontDrawable(bitmapFont, item.getFile().nameWithoutExtension());
return drawable;
}
示例4: NewFileListener
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
public NewFileListener(FileChooser fileChooser, DataManager dataManager) {
this.fileChooser = fileChooser;
this.dataManager = dataManager;
if(ChiptuneTracker.getInstance().isChangeData()) {
String text;
if(dataManager.getCurrentFile() == null) {
text = "New file has been modified. Save changes?";
}
else {
text = dataManager.getCurrentFile()+" has been modified. Save changes?";
}
Dialogs.showOptionDialog(ChiptuneTracker.getInstance().getAsciiTerminal().getStage(), "Save Resource", text, Dialogs.OptionDialogType.YES_NO_CANCEL, this);
((View) ChiptuneTracker.getInstance().getScreen()).setListActorTouchables(Touchable.disabled);
}
else {
clearAction();
additionalYesActions();
}
}
示例5: addInputFiles
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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());
}
示例6: addIgnoreFiles
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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());
}
示例7: initiateFromFilePicker
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
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);
}
}
示例8: pickAtlasPath
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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());
}
示例9: pickOutputDir
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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());
}
示例10: openProject
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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) {
FileHandle chosenFile = file.first();
loadProject(chosenFile);
}
});
getStage().addActor(fileChooser.fadeIn());
}
示例11: pickOutputDir
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@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());
}
示例12: setupListeners
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
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());
}
});
}
示例13: setupListeners
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
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());
}
});
}
示例14: process
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final FileChooser actor,
final String rawAttributeData) {
final ActorConsumer<?, FileChooser> action = parser.parseAction(rawAttributeData, actor);
if (action == null) {
parser.throwErrorIfStrict(
"File deleter attribute expects an action that returns a FileDeleter instance. Action not found for: "
+ rawAttributeData);
}
final Object result = action.consume(actor);
if (result instanceof FileChooser.FileDeleter) {
actor.setFileDeleter((FileChooser.FileDeleter) result);
} else {
parser.throwErrorIfStrict(
"Unable to set file deleter. A method returning FileDeleter instance is required; got result: "
+ result);
}
}
示例15: process
import com.kotcrab.vis.ui.widget.file.FileChooser; //导入依赖的package包/类
@Override
public void process(final LmlParser parser, final LmlTag tag, final FileChooser actor,
final String rawAttributeData) {
final ActorConsumer<?, FileChooser> action = parser.parseAction(rawAttributeData, actor);
if (action == null) {
parser.throwErrorIfStrict(
"File type filter attribute expects an action that returns a FileTypeFilter instance. Action not found for: "
+ rawAttributeData);
}
final Object result = action.consume(actor);
if (result instanceof FileTypeFilter) {
actor.setFileTypeFilter((FileTypeFilter) result);
} else {
parser.throwErrorIfStrict(
"Unable to set file type filter. A method returning FileTypeFilter instance is required; got result: "
+ result);
}
}