Package org.openide.windows

Examples of org.openide.windows.InputOutput


        }
    }

    public void minify() {
        MinifyProperty minifyProperty = MinifyProperty.getInstance();
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Minify(), false);
        MinifyUtil util = new MinifyUtil();
        try {
            long startTime = new Date().getTime();
            FileObject source = context.getPrimaryFile();
            FileObject target = null;
            if (minifyProperty.isSeparatBuild()) {
                File sourceFile = FileUtil.toFile(source);
                File targetFile = getTargetFolder(new File(sourceFile.getParentFile().getPath() + File.separator + sourceFile.getName() + "_BUILD"));
                FileUtils.copyDirectory(sourceFile, targetFile);
                target = FileUtil.toFileObject(targetFile);
            } else {
                target = source;
            }

            MinifyResult minifyResult = util.minify(target, minifyProperty);
            long endTime = new Date().getTime();
            long totalTime = endTime - startTime;

            minifyResult.setDirectories(minifyResult.getDirectories() + 1);
            float jsSpaceSaved = (1 - ((float) minifyResult.getOutputJsFilesSize() / (float) minifyResult.getInputJsFilesSize())) * 100;
            float cssSpaceSaved = (1 - ((float) minifyResult.getOutputCssFilesSize() / (float) minifyResult.getInputCssFilesSize())) * 100;
            float htmlSpaceSaved = (1 - ((float) minifyResult.getOutputHtmlFilesSize() / (float) minifyResult.getInputHtmlFilesSize())) * 100;
            float xmlSpaceSaved = (1 - ((float) minifyResult.getOutputXmlFilesSize() / (float) minifyResult.getInputXmlFilesSize())) * 100;
            float jsonSpaceSaved = (1 - ((float) minifyResult.getOutputJsonFilesSize() / (float) minifyResult.getInputJsonFilesSize())) * 100;

            String cssEval = "", jsEval = "", htmlEval = "", xmlEval = "", jsonEval = "";

            if (!Float.isNaN(jsSpaceSaved)) {
                jsEval = "Input JS Files Size :  " + minifyResult.getInputJsFilesSize() + " Bytes \n"
                        + "After Minifying JS Files Size :  " + minifyResult.getOutputJsFilesSize() + " Bytes \n"
                        + "JS Space Saved " + jsSpaceSaved + "% \n";
            }
            if (!Float.isNaN(cssSpaceSaved)) {
                cssEval = "Input CSS Files Size :  " + minifyResult.getInputCssFilesSize() + " Bytes \n"
                        + "After Minifying CSS Files Size :  " + minifyResult.getOutputCssFilesSize() + " Bytes \n"
                        + "CSS Space Saved " + cssSpaceSaved + "% \n";
            }
            if (!Float.isNaN(htmlSpaceSaved)) {
                htmlEval = "Input HTML Files Size :  " + minifyResult.getInputHtmlFilesSize() + " Bytes \n"
                        + "After Minifying HTML Files Size :  " + minifyResult.getOutputHtmlFilesSize() + " Bytes \n"
                        + "HTML Space Saved " + htmlSpaceSaved + "% \n";
            }
            if (!Float.isNaN(xmlSpaceSaved)) {
                xmlEval = "Input XML Files Size :  " + minifyResult.getInputXmlFilesSize() + " Bytes \n"
                        + "After Minifying XML Files Size :  " + minifyResult.getOutputXmlFilesSize() + " Bytes \n"
                        + "XML Space Saved " + xmlSpaceSaved + "% \n";
            }
            if (!Float.isNaN(jsonSpaceSaved)) {
                jsonEval = "Input JSON Files Size :  " + minifyResult.getInputJsonFilesSize() + " Bytes \n"
                        + "After Minifying JSON Files Size :  " + minifyResult.getOutputJsonFilesSize() + " Bytes \n"
                        + "JSON Space Saved " + jsonSpaceSaved + "% \n";
            }
            if (minifyProperty.isEnableOutputLogAlert()) {
                JOptionPane.showMessageDialog(null, "Js Css Minified Completed Successfully \n Logs - \n"
                        + minifyResult.getDirectories() + " Directories Found \n"
                        + minifyResult.getJsFiles() + " JS Files Minified \n"
                        + minifyResult.getCssFiles() + " CSS Files Minified \n"
                        + minifyResult.getHtmlFiles() + " HTML Files Minified \n"
                        + minifyResult.getXmlFiles() + " XML Files Minified \n"
                        + minifyResult.getJsonFiles() + " JSON Files Minified \n"
                        + jsEval + cssEval + htmlEval + xmlEval + jsonEval
                        + "Total Time - " + totalTime + "ms");
            }
        } catch (Exception ex) {
            io.getOut().println("Exception: " + ex.toString());
        }
    }
View Full Code Here


        ph.start();
        theTask.schedule(0);
    }

    void decode() {
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
        ImageUtil imageUtil = new ImageUtil();
        try {
            FileObject file = context.getPrimaryFile();
            if (file.getExt().equalsIgnoreCase("ENCODE")) {
                File newFile = new File(file.getPath());
                String fileType = file.getName().substring(file.getName().lastIndexOf('.') + 1);
                imageUtil.decodeToImage(FileUtils.readFileToString(newFile), file.getParent().getPath() + File.separator + file.getName(), fileType);
            } else {
                JOptionPane.showMessageDialog(null, "Invalid file to decode", "Warning", JOptionPane.WARNING_MESSAGE);
            }
        } catch (IOException ex) {
            io.getOut().println("Exception: " + ex.toString());
        }
    }
View Full Code Here

        ph.start();
        theTask.schedule(0);
    }

    void encode() {
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
        ImageUtil imageUtil = new ImageUtil();
        try {
            FileObject file = context.getPrimaryFile();
            String imgstr;
            imgstr = imageUtil.encodeToString(file.getPath(), file.getExt());
            File newFile = new File(file.getParent().getPath() + File.separator + file.getName() + "." + file.getExt() + ".encode");
            FileUtils.writeStringToFile(newFile, imgstr);
            io.getOut().println("Image Base64 Encoding : " + imgstr);
        } catch (IOException ex) {
            io.getOut().println("Exception: " + ex.toString());
        }
    }
View Full Code Here

        e.printStackTrace();
      }       
     }
   
    public void compressJPG(String inputFilePath, String outputFilePath, String fileType) {
        InputOutput io = IOProvider.getDefault().getIO(Bundle.CTL_Base64Encode(), false);
        try {
            File imageFile = new File(inputFilePath);
            File compressedImageFile = new File(outputFilePath);

            InputStream is = new FileInputStream(imageFile);
            OutputStream os = new FileOutputStream(compressedImageFile);
            float quality = 0.5f;
// create a BufferedImage as the result of decoding the supplied InputStream
            BufferedImage image = ImageIO.read(is);
// get all image writers for JPG format
            Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(fileType);

            if (!writers.hasNext()) {
                throw new IllegalStateException("No writers found");
            }
            ImageWriter writer = writers.next();
            ImageOutputStream ios = ImageIO.createImageOutputStream(os);
            writer.setOutput(ios);
            ImageWriteParam param = writer.getDefaultWriteParam();
            param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
            param.setCompressionQuality(quality);
// appends a complete image stream containing a single image and
            //associated stream and image metadata and thumbnails to the output
            writer.write(null, new IIOImage(image, null, null), param);
            is.close();
            os.close();
            ios.close();
            writer.dispose();
        } catch (IOException ex) {
            io.getOut().println("Exception: " + ex.toString());
        }
    }
View Full Code Here

        }
        return true;
    }

    public static OutputWriter getOutputWindowWriter(String title) {
        InputOutput io = TopManager.getDefault().getIO(title, false);
        io.setFocusTaken(true);
        io.setOutputVisible(true);
       
        OutputWriter out = io.getOut();
        try {
            out.reset();
        }
        catch( IOException e) {
            e.printStackTrace(System.err);
View Full Code Here

        }
        return true;
    }

    public static OutputWriter getOutputWindowWriter(String title) {
        InputOutput io = TopManager.getDefault().getIO(title, false);
        io.setFocusTaken(true);
        io.setOutputVisible(true);
       
        OutputWriter out = io.getOut();
        try {
            out.reset();
        }
        catch( IOException e) {
            e.printStackTrace(System.err);
View Full Code Here

        }
        return true;
    }

    public static OutputWriter getOutputWindowWriter(String title) {
        InputOutput io = TopManager.getDefault().getIO(title, false);
        io.setFocusTaken(true);
        io.setOutputVisible(true);
       
        OutputWriter out = io.getOut();
        try {
            out.reset();
        }
        catch( IOException e) {
            e.printStackTrace(System.err);
View Full Code Here

     * @param c Color to display the method
     * @param listener
     */
    public static void output(String name, String mess, Color c, OutputListener listener) {
        boolean select = getIO(name) || !outputMap.contains(name);
        InputOutput io = IOProvider.getDefault().getIO(name, select);
        if (select) {
            io.select();
        }
        io.setFocusTaken(false);
        if (mess == null || mess.trim().isEmpty()) {
            if (listener == null) {
                io.getOut().println(mess);
            } else {
                try {
                    io.getOut().println(mess, listener);
                } catch (IOException ex1) {
                    Logger.getLogger(OutputHandler.class.getSimpleName(), ex1.getMessage());
                    io.getOut().println(mess);
                }
            }
        } else {
            if (c != null && c != Color.BLACK) {
                try {
                    if (listener == null) {
                        IOColorLines.println(io, mess, c);
                    } else {
                        IOColorLines.println(io, mess, listener, true, c);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(OutputHandler.class.getSimpleName(), ex.getMessage());
                    if (listener == null) {
                        io.getOut().println(mess);
                    } else {
                        try {
                            io.getOut().println(mess, listener);
                        } catch (IOException ex1) {
                            Logger.getLogger(OutputHandler.class.getSimpleName(), ex1.getMessage());
                            io.getOut().println(mess);
                        }
                    }
                }
            } else {
                //Just print in black as default
                if (listener == null) {
                    io.getOut().println(mess);
                } else {
                    try {
                        io.getOut().println(mess, listener);
                    } catch (IOException ex1) {
                        Logger.getLogger(OutputHandler.class.getSimpleName(), ex1.getMessage());
                        io.getOut().println(mess);
                    }
                }
            }
        }
    }
View Full Code Here

    public ExtraLock reformatLock() {
        return null;
    }

    private void showError(Exception e) {
        InputOutput io;
        OutputWriter outputWriter;
        io = IOProvider.getDefault().getIO("Cucumber", false);
        io.select();
        outputWriter = io.getOut();
        e.printStackTrace(outputWriter);
        // This seems to block the IDE
        // JOptionPane.showMessageDialog(null, e, e.getMessage(), JOptionPane.ERROR_MESSAGE);
    }
View Full Code Here

public class CucumberOutputWindow {

    public static OutputWriter getOutputWriter(String title, Action[] actions) {
        // get an output window tab
        //io = IOProvider.getDefault().getIO("Cucumber", false);
        InputOutput io = IOProvider.getDefault().getIO("Cucumber: " + title, actions);
        io.select();
        return io.getOut();
    }
View Full Code Here

TOP

Related Classes of org.openide.windows.InputOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.