com.alee.laf.filechooser.WebFileChooser Java Examples

The following examples show how to use com.alee.laf.filechooser.WebFileChooser. 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: ComponentUtils.java    From desktopclient-java with GNU General Public License v3.0 6 votes vote down vote up
AttachmentPanel() {
    super(View.GAP_SMALL, false);

    this.add(mStatus = new WebLabel().setItalicFont());
    this.add(mAttLabel = new WebLinkLabel());

    mFileChooser = new WebFileChooser() {
        @Override
        public void approveSelection(){
            File f = getSelectedFile();
            if (f.exists()) {
                int option = JOptionPane.showConfirmDialog(this,
                        String.format(
                                Tr.tr("The file \"%s\" already exists, overwrite?"),
                                f.getName()),
                        Tr.tr("Overwrite File?"),
                        JOptionPane.OK_CANCEL_OPTION);
                if (option != JOptionPane.YES_OPTION)
                    return; // doing nothing means not approve
            }
            super.approveSelection();
        }
    };
}
 
Example #2
Source File: ComponentUtils.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void chooseImage() {
    int state = mImgChooser.showOpenDialog(this);
    if (state != WebFileChooser.APPROVE_OPTION)
        return;

    File imgFile = mImgChooser.getSelectedFile();
    if (!imgFile.isFile())
        return;

    BufferedImage img = MediaUtils.readImage(imgFile).orElse(null);
    if (img == null)
        return;

    this.changeImage(ImageUtils.createPreviewImage(img, mSize));
}
 
Example #3
Source File: ChatView.java    From desktopclient-java with GNU General Public License v3.0 5 votes vote down vote up
private void showFileDialog() {
    int option = mFileChooser.showOpenDialog(ChatView.this);
    if (option != WebFileChooser.APPROVE_OPTION)
        return;

    File file = mFileChooser.getSelectedFile();
    mFileChooser.setCurrentDirectory(file.toPath().getParent().toString());
    this.sendFile(file);
}
 
Example #4
Source File: Menu.java    From Spade with GNU General Public License v3.0 5 votes vote down vote up
public static void showOpenMenu()
{
	final WebFileChooser chooser = new WebFileChooser(Spade.getDir());
	chooser.setFileSelectionMode(WebFileChooser.FILES_ONLY);
	chooser.setAcceptAllFileFilterUsed(false);
	chooser.setFileFilter(new ReadableFileFilter());
	
	// Add ALL the custom image-importers!
	ImageImporter.addAllImporters(chooser);
	
	int returned = chooser.showOpenDialog(new WebDialog(Spade.main.gui.frame, "Load Image"));
	
	if(returned == WebFileChooser.APPROVE_OPTION)
	{
		// If a Image takes too long, the application might crash.
		// By running the actual loading process in another thread, the AWT-Event Thread can continue working while the image is being loaded.
		new Thread(new Runnable()
		{
			@Override
			public void run()
			{
				Document doc = Document.loadFromFile(chooser.getSelectedFile());
				if(doc != null)
				{
					Spade.addDocument(doc);
					Spade.setDocument(doc);
				}
			}
		}).start();
	}
}
 
Example #5
Source File: ImageImporter.java    From Spade with GNU General Public License v3.0 5 votes vote down vote up
public static void addAllImporters(WebFileChooser chooser)
{
	for(ImageImporter importer : importers.values())
	{
		chooser.addChoosableFileFilter(importer);
	}
}
 
Example #6
Source File: ImageExporter.java    From Spade with GNU General Public License v3.0 5 votes vote down vote up
public static void addAllExporters(WebFileChooser chooser)
{
	for(ImageExporter exporter : exporters.values())
	{
		chooser.addChoosableFileFilter(exporter);
	}
}
 
Example #7
Source File: WebFileChooserField.java    From weblaf with GNU General Public License v3.0 4 votes vote down vote up
public WebFileChooser getWebFileChooser ()
{
    return webFileChooser;
}