Over 100 Images To Be Added To NetBeans Platform Showcase

There's a folder in the NetBeans repo where NetBeans Platform application screenshots are stored, one per application (together with a thumbnail image) for publication on the NetBeans Platform Showcase. New images are added there whenever we identify new NetBeans Platform applications. Once in a while, I go to that folder, identify the newest images, and then include them, together with a description, in the showcase, i.e., manually, simply by typing in an HTML file.

However, recently, there have been SO many newly identified NetBeans Platform applications (small tip of the iceberg here), that there's a massive backlog of screenshots that have yet to be published. And, over the years, some screenshots made their way in there without being published in the showcase. Therefore, I needed to create a new plugin that lets me, inside NetBeans IDE, right-click on the folder containing the images, after which a dialog lets me specify the showcase file, which is then searched. If the showcase file does not contain a reference to the name of the image, then that's an image that I need to include in the file.

Via this plugin, I have identified over 100 images that are in the folder but have not yet been included in the showcase. Therefore, if yours hasn't been added yet, please be patient, there's just a massive backlog due to the wide usage of the NetBeans Platform through all kinds of software around the world.

Here's the code for the plugin that lets me do this analysis:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle.Messages;

@ActionID(
        category = "Tools",
        id = "org.netbeans.i2f.LocateImagesInFileAction")
@ActionRegistration(
        displayName = "#CTL_LocateImagesInFileAction")
@ActionReference(path = "Loaders/folder/any/Actions", position = 250)
@Messages("CTL_LocateImagesInFileAction=Locate Images in File")
public final class LocateImagesInFileAction implements ActionListener {

    private final FileObject context;
    private final List<String> notFoundWords = new ArrayList<String>();

    public LocateImagesInFileAction(FileObject context) {
        this.context = context;
    }

    @Override
    public void actionPerformed(ActionEvent ev) {
        NotifyDescriptor.InputLine inputLine = new NotifyDescriptor.InputLine("Path to file: ", "Locate Images in File");
        Object dialog = DialogDisplayer.getDefault().notify(inputLine);
        if (dialog == NotifyDescriptor.OK_OPTION) {
            File fileToAnalyze = new File(inputLine.getInputText());
            if (fileToAnalyze.exists()) {
                FileObject fo = FileUtil.toFileObject(fileToAnalyze);
                try {
                    String textOfFile = fo.asText();
                    for (FileObject onePic : context.getChildren()) {
                        String nameToFind = onePic.getNameExt();
                        if (!nameToFind.contains("thumb")) {
                            if (!textOfFile.contains(nameToFind)) {
                                notFoundWords.add(nameToFind);
                            }
                        }
                    }
                    for (int i = 0; i < notFoundWords.size(); i++) {
                        String onePic = notFoundWords.get(i);
                        System.out.println(i + ": " + onePic);
                    }
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
    
}

The output, when the Action above is invoked, i.e., it is available on any folder (which I have open in the IDE via the Favorites window), starts as follows, then goes on to over 100 images (well, 135 to be exact, but some are duplicates, e.g., "blaCompanyImage.png" and "blaCompanyImage_1.png", which need to be investigated), hence I estimate at least 100 that are genuinely relevant yet missing from the showcase.

0: STORXCom.png
1: lm-wrkbnch.jpg
2: salesSuite.png
3: ircClient.png
4: safetymatch.jpg
5: MercureDashboard.jpg
6: imagegrid-abdomen.jpg
7: NetQuest-Autocompletion-large.gif

Only thing missing is a Browse button, so that one doesn't need to type the path to the file. However, one doesn't need to type the path to the file. Just open it in the IDE and then choose "Copy File Path" in the tab of the file and paste it into the dialog. Then press OK and the selected file is checked to see whether it contains the name of each of the files (not just images, but that doesn't really matter in my case, since the folder that I need to analyze only contains images anyway) in the folder.

Another nice addition is to add an OutputListener, which creates hyperlinks in the Output window for each image not found in the file which, when clicked, opens the image in the IDE:


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today