Example usage for java.awt AWTException getMessage

List of usage examples for java.awt AWTException getMessage

Introduction

In this page you can find the example usage for java.awt AWTException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sikulix.core.SX.java

/**
 * ***** Property SXROBOT *****/*  w w  w .jav a2  s.co  m*/
 *
 * @return
 */
public static Robot getSXROBOT() {
    if (isNotSet(SXROBOT)) {
        try {
            SXROBOT = new Robot();
        } catch (AWTException e) {
            terminate(1, "getSXROBOT: not possible: %s", e.getMessage());
        }
    }
    return SXROBOT;
}

From source file:com.sikulix.core.SX.java

public static IRobot getLocalRobot() {
    if (isNotSet(SXLOCALROBOT)) {
        try {//from  ww  w.j a va 2  s  .c o m
            SXLOCALROBOT = new LocalRobot();
        } catch (AWTException e) {
            terminate(1, "getLocalRobot: not possible: %s", e.getMessage());
        }
    }
    return SXLOCALROBOT;
}

From source file:lucee.runtime.img.Image.java

public static void writeOutGif(BufferedImage src, OutputStream os) throws IOException {
    BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB);
    QuantizeFilter filter = new QuantizeFilter();
    filter.setSerpentine(true);//from   w  w  w.  jav  a2s .  c o  m
    filter.setDither(true);
    //filter.setNumColors(8);
    filter.filter(src, dst);

    //image(Quantizer.quantize(image(), 8));
    try {
        GifEncoder enc = new GifEncoder(dst);
        enc.Write(os);
        os.flush();
    } catch (AWTException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.puzzle.gui.MainFrame.java

public void tray() {//-----ljs
    tray = SystemTray.getSystemTray(); // ?     
    PopupMenu pop = new PopupMenu(); // ????  
    final MenuItem show = new MenuItem("?");
    final MenuItem exit = new MenuItem("?");
    pop.add(show);/*from w w  w. j av  a  2 s  . c o m*/
    pop.add(exit);
    show.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showMouseClick(e);
        }
    });
    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            exitMouseClick(e);
        }
    });

    trayIcon = new TrayIcon(
            Toolkit.getDefaultToolkit().getImage(MainFrame.class.getResource("/images/flag.png")),
            "??V1.0", pop);//  
    trayIcon.setImageAutoSize(true);
    //?  
    trayIcon.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            trayIconMouseClick(e);
        }
    });

    try {
        tray.add(trayIcon); //   
    } catch (AWTException ex) {
        log.error(ex.getMessage(), ex);
        ex.printStackTrace();
    }

}

From source file:com.pentaho.ctools.issues.cde.CDE417.java

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name: /*from  w  ww .ja va2 s.c  om*/
 *   Popup Export issues
 *
 * Description: 
 *   CDE-417 issue, so when user clicks to export chart, popup shown has chart preview. 
 *   CDE-424 issue we'll delete the .js file prior to opening the dashboard and saving the dashboard should create 
 *   the .js file again and enable exporting.
 *   CDF-448 exporting chart with skip ticks (chart is too small to show all labels) is successful
 *   CDF-502 export chart with array parameters is successful
 *   CDE-514 all charts are available on charts to export property and all elements are available on the data to export property
 *   
 * Steps:
 * 424
 *    1. Open PUC and click Browse Files
 *    2. Go to dashboard folder, click countryChart.js file and click Move To Trash
 *    3. Open created sample and save Dashboard
 * 514
 *    4. Go to Export Component and assert all charts appear on the Chart to Export property
 *    5. Assert all charts and the table appear on data to export property
 *    
 * 417/448/502
 *    6. Click to export chart, click export, assert chart is shown and assert export works as expected (448 and 502)
 *    7. Click to export chart2, click export, assert chart is shown and assert export works as expected
 * 
 * @throws InterruptedException
 *
 */
@Test
public void tc01_PopupExportComponent_PreviewerRendersChart() throws InterruptedException {
    this.log.info("tc01_PopupExportComponent_PreviewerRendersChart");

    /*
     * ## Step 1
     */
    //Show Hidden Files
    BrowseFiles browser = new BrowseFiles(driver);
    if (!PUCSettings.SHOWHIDDENFILES) {
        browser.CheckShowHiddenFiles();
    }

    /*
     * ## Step 2
     */
    //String pathChart = "/public/Issues/CDF/CDF-548/chart.js";
    //String pathCdfChart = "/public/Issues/CDF/CDF-548/CDF-548_chart.js";
    String pathCountryChart = "/public/Issues/CDF/CDF-548/countryChart.js";
    String pathCdfCountryChart = "/public/Issues/CDF/CDF-548/CDF-548_countryChart.js";
    //boolean fileDeleteChart = browser.DeleteFile( pathChart );
    //boolean fileDeleteCdfChart = browser.DeleteFile( pathCdfChart );
    boolean fileDeleteCountryChart = browser.DeleteFile(pathCountryChart);
    boolean fileDeleteCdfCountryChart = browser.DeleteFile(pathCdfCountryChart);
    //assertTrue( fileDeleteChart );
    //assertTrue( fileDeleteCdfChart );
    assertTrue(fileDeleteCountryChart);
    assertTrue(fileDeleteCdfCountryChart);

    driver.switchTo().defaultContent();
    WebDriver frame = driver.switchTo().frame("browser.perspective");
    this.elemHelper.WaitForAttributeValue(frame, By.xpath("//div[@id='fileBrowserFiles']/div[2]/div[1]"),
            "title", "CDF-548.cda");
    String nameOfCdf548Wcdf = this.elemHelper.GetAttribute(frame,
            By.xpath("//div[@id='fileBrowserFiles']/div[2]/div[1]"), "title");
    assertEquals("CDF-548.cda", nameOfCdf548Wcdf);

    /*
     * ## Step 3
     */
    // Go to Export Popup Component sample in Edit mode
    driver.get(baseUrl + "api/repos/%3Apublic%3AIssues%3ACDF%3ACDF-548%3ACDF-548.wcdf/edit");

    //Save Dashboard
    WebElement saveButton = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("Save"));
    assertNotNull(saveButton);
    this.elemHelper.Click(driver, By.id("Save"));
    WebElement saveNotify = this.elemHelper.WaitForElementPresenceAndVisible(driver,
            By.cssSelector("div.notify-bar-message"));
    assertNotNull(saveNotify);
    String saveMessage = this.elemHelper.WaitForElementPresentGetText(driver,
            By.cssSelector("div.notify-bar-message"));
    assertEquals("Dashboard saved successfully", saveMessage);

    /* 
     * ## Step 4 
      */
    //Go to components panel and expand "Others"
    WebElement componentsPanelButton = this.elemHelper.FindElement(driver,
            By.cssSelector("div.componentsPanelButton"));
    assertNotNull(componentsPanelButton);
    componentsPanelButton.click();
    WebElement componentsTable = this.elemHelper.FindElement(driver, By.id("cdfdd-components-components"));
    assertNotNull(componentsTable);
    WebElement othersExpander = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='table-cdfdd-components-components']//tr[@id='OTHERCOMPONENTS']/td/span"));
    assertNotNull(othersExpander);
    othersExpander.click();

    //Select Export Popup Component
    WebElement exportPopupElement = this.elemHelper.FindElement(driver,
            By.xpath("//table[@id='table-cdfdd-components-components']//td[contains(text(),'exportPopup')]"));
    assertNotNull(exportPopupElement);
    exportPopupElement.click();

    //Open options for Chart Component to Export and assert "chart" and "countryChart"
    WebElement chartExportProperty = this.elemHelper.FindElement(driver, By.xpath(
            "//table[@id='table-cdfdd-components-properties']//td[@title='Id for Chart Component to Export']/../td[2]"));
    assertNotNull(chartExportProperty);
    chartExportProperty.click();
    WebElement chartExportInput = this.elemHelper.FindElement(driver, By.xpath(
            "//table[@id='table-cdfdd-components-properties']//td[@title='Id for Chart Component to Export']/../td[2]/form/input"));
    assertNotNull(chartExportInput);
    chartExportInput.clear();
    Robot robot;
    try {
        robot = new Robot();
        robot.keyPress(KeyEvent.VK_DOWN);
        robot.keyRelease(KeyEvent.VK_DOWN);
    } catch (AWTException e) {
        e.printStackTrace();
    }
    WebElement chartExportOptions = this.elemHelper.FindElement(driver, By.xpath("//body/ul"));
    assertNotNull(chartExportOptions);
    String chartOption1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//body/ul/li/a"));
    String chartOption2 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//body/ul/li[2]/a"));
    assertEquals("chart", chartOption1);
    assertEquals("countryChart", chartOption2);
    this.elemHelper.Click(driver, By.xpath("//body/ul/li/a"));

    /* 
     * ## Step 5 
      */
    //Open options for Data Component to Export and assert "table", "chart" and "countryChart"
    WebElement dataExportProperty = this.elemHelper.FindElement(driver, By.xpath(
            "//table[@id='table-cdfdd-components-properties']//td[@title='Id for Data Component to Export']/../td[2]"));
    assertNotNull(dataExportProperty);
    dataExportProperty.click();
    WebElement dataExportInput = this.elemHelper.FindElement(driver, By.xpath(
            "//table[@id='table-cdfdd-components-properties']//td[@title='Id for Data Component to Export']/../td[2]/form/input"));
    assertNotNull(dataExportInput);
    dataExportInput.clear();
    Robot robot1;
    try {
        robot1 = new Robot();
        robot1.keyPress(KeyEvent.VK_DOWN);
        robot1.keyRelease(KeyEvent.VK_DOWN);
    } catch (AWTException e) {
        e.printStackTrace();
    }
    WebElement dataExportOptions = this.elemHelper.FindElement(driver, By.xpath("//body/ul"));
    assertNotNull(dataExportOptions);
    String dataOption1 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//body/ul/li/a"));
    String dataOption2 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//body/ul/li[2]/a"));
    String dataOption3 = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//body/ul/li[3]/a"));
    assertEquals("table", dataOption1);
    assertEquals("chart", dataOption2);
    assertEquals("countryChart", dataOption3);

    /* 
     * ## Step 6 
     */
    driver.get(baseUrl + "api/repos/%3Apublic%3AIssues%3ACDF%3ACDF-548%3ACDF-548.wcdf/generatedContent");
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));

    //Click export Button
    WebElement exportChartButton = this.elemHelper.FindElement(driver, By.xpath("//div[@id='export']/div"));
    assertNotNull(exportChartButton);
    exportChartButton.click();

    //Assert popup and click Export Chart link
    WebElement exportChartLink = this.elemHelper.FindElement(driver, By.cssSelector("div.exportElement"));
    assertNotNull(exportChartLink);
    exportChartLink.click();

    //Assert chart popup
    WebElement exportChartPopup = this.elemHelper.FindElement(driver, By.id("fancybox-content"));
    assertNotNull(exportChartPopup);

    // Check URL of displayed image
    String chartSRCUrl = this.elemHelper.GetAttribute(driver,
            By.xpath("//div[@id='fancybox-content']/div/div/div/div[2]/img"), "src");
    assertEquals(baseUrl
            + "plugin/cgg/api/services/draw?outputType=png&script=%2Fpublic%2FIssues%2FCDF%2FCDF-548%2Fchart.js&paramcountries=France&paramcountries=USA&paramwidth=400&paramheight=400",
            chartSRCUrl);
    assertEquals(200, HttpUtils.GetResponseCode(chartSRCUrl, "admin", "password"));

    // Export chart and assert export was successful
    WebElement chartExportButton = this.elemHelper.FindElement(driver,
            By.cssSelector("div.exportChartPopupButton.exportChartOkButton"));
    assertNotNull(chartExportButton);

    //Click export and assert file is correctly downloaded
    try {
        //Delete the existence if exist
        new File(this.exportFilePath).delete();

        //Click to export
        chartExportButton.click();

        //Wait for file to be created in the destination dir
        DirectoryWatcher dw = new DirectoryWatcher();
        dw.WatchForCreate(downloadDir);

        //Check if the file really exist
        File exportFile = new File(this.exportFilePath);
        // assertTrue(exportFile.exists());

        //Wait for the file to be downloaded totally
        for (int i = 0; i < 50; i++) { //we only try 50 times == 5000 ms
            long nSize = FileUtils.sizeOf(exportFile);
            //Since the file always contents the same data, we wait for the expected bytes
            if (nSize >= 10000) {
                break;
            }
            this.log.info("BeforeSleep " + nSize);
            Thread.sleep(100);
        }

        this.log.info("File size :" + FileUtils.sizeOf(exportFile));

        //Check if the file downloaded is the expected
        String md5 = DigestUtils.md5Hex(Files.readAllBytes(exportFile.toPath()));
        assertEquals(md5, "c8c3ad02461f7b5c8a36ee2aec0eca95");

        //The delete file
        DeleteFile();

    } catch (Exception e) {
        this.log.error(e.getMessage());
    }

    // Close dialog box
    this.elemHelper.Click(driver, By.id("fancybox-close"));
    assertTrue(this.elemHelper.WaitForElementNotPresent(driver,
            By.xpath("//div[@id='fancybox-content']/div/div/div/div/div[1]")));

    /* 
     * ## Step 7
     */
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.exportElement"));
    //Click export Button
    WebElement exportCountryChartButton = this.elemHelper.FindElement(driver,
            By.xpath("//div[@id='export2']/div"));
    assertNotNull(exportCountryChartButton);
    exportCountryChartButton.click();

    //Assert popup and click Export Chart link
    WebElement exportCountryChartLink = this.elemHelper.FindElement(driver,
            By.xpath("//div[contains(text(),'Export Chart2')]"));
    assertNotNull(exportCountryChartLink);
    exportCountryChartLink.click();

    //Assert chart popup
    WebElement exportCountryChartPopup = this.elemHelper.FindElement(driver, By.id("fancybox-content"));
    assertNotNull(exportCountryChartPopup);

    // Check URL of displayed image
    String countryChartSRCUrl = this.elemHelper.GetAttribute(driver,
            By.xpath("//div[@id='fancybox-content']/div/div/div/div[2]/img"), "src");
    assertEquals(baseUrl
            + "plugin/cgg/api/services/draw?outputType=svg&script=%2Fpublic%2FIssues%2FCDF%2FCDF-548%2FcountryChart.js&paramwidth=400&paramheight=300",
            countryChartSRCUrl);
    assertEquals(200, HttpUtils.GetResponseCode(countryChartSRCUrl, "admin", "password"));

    // Export chart and assert export was successful
    WebElement countryChartExportButton = this.elemHelper.FindElement(driver,
            By.cssSelector("div.exportChartPopupButton.exportChartOkButton"));
    assertNotNull(countryChartExportButton);

    //Click export and assert file is correctly downloaded
    try {
        //Delete the existence if exist
        new File(this.exportFilePath2).delete();

        //Click to export
        countryChartExportButton.click();

        //Wait for file to be created in the destination dir
        DirectoryWatcher dw = new DirectoryWatcher();
        dw.WatchForCreate(downloadDir);

        //Check if the file really exist
        File exportFile = new File(this.exportFilePath2);
        // assertTrue(exportFile.exists());

        //Wait for the file to be downloaded totally
        for (int i = 0; i < 50; i++) { //we only try 50 times == 5000 ms
            long nSize = FileUtils.sizeOf(exportFile);
            //Since the file always contents the same data, we wait for the expected bytes
            if (nSize >= 30000) {
                break;
            }
            this.log.info("BeforeSleep " + nSize);
            Thread.sleep(100);
        }

        this.log.info("File size :" + FileUtils.sizeOf(exportFile));

        //Check if the file downloaded is the expected
        String md5 = DigestUtils.md5Hex(Files.readAllBytes(exportFile.toPath()));
        assertEquals(md5, "c0d04625306dd1f32afed115c0bf94be");

        //The delete file
        DeleteFile();

    } catch (Exception e) {
        this.log.error(e.getMessage());
    }

    // Close dialog box
    this.elemHelper.Click(driver, By.id("fancybox-close"));
    assertTrue(this.elemHelper.WaitForElementNotPresent(driver,
            By.xpath("//div[@id='fancybox-content']/div/div/div/div/div[1]")));
}

From source file:edu.umd.cs.guitar.ripper.Ripper.java

/**
 * Rip a component/*w  w w  .  j a  v a2s  .  c om*/
 *
 * As of now this method does not propagate exceptions.
 * It needs to be modified to progate exceptions. All callers
 * need to be modified to handle exceptions.
 *
 * <p>
 * 
 * @param component
 * @return
 */
public ComponentType ripComponent(GComponent component, GWindow window) {
    GUITARLog.log.info("");
    GUITARLog.log.info("----------------------------------");
    GUITARLog.log.info("Ripping component: ");
    GUITARLog.log.info("Signature: ");

    printComponentInfo(component, window);

    // 1. Rip special/customized components
    for (GComponentFilter cm : lComponentFilter) {
        if (cm.isProcess(component, window)) {
            GUITARLog.log.info("Filter " + cm.getClass().getSimpleName() + " is applied");

            return cm.ripComponent(component, window);
        }
    }

    // 2. Rip regular components
    ComponentType retComp = null;
    try {
        retComp = component.extractProperties();
        ComponentTypeWrapper compA = new ComponentTypeWrapper(retComp);

        if (useImage) {
            String sUUID = null;
            try {
                sUUID = captureImage(component);
            } catch (AWTException e) {
                // Ignore AWTException. sUUID is null.
            } catch (IOException e) {
                throw e;
            }

            if (sUUID != null) {
                compA.addProperty(GUITARConstants.UUID_TAG_NAME, sUUID);
            }
        }

        GUIType guiType = null;

        if (window != null) {
            guiType = window.extractGUIProperties();
        }

        retComp = compA.getDComponentType();

        // 2.1 Try to perform action on the component
        // to reveal more windows/components

        // clear window opened cache before performing actions
        monitor.resetWindowCache();

        if (monitor.isExpandable(component, window)) {
            monitor.expandGUI(component);
        } else {
            GUITARLog.log.info("Component is Unexpandable");
        }

        // Trigger terminal widget

        LinkedList<GWindow> lClosedWindows = monitor.getClosedWindowCache();

        String sTitle = window.getTitle();

        if (lClosedWindows.size() > 0) {

            GUITARLog.log.debug("!!!!! Window closed");

            for (GWindow closedWin : lClosedWindows) {
                String sClosedWinTitle = closedWin.getTitle();

                // Only consider widget closing the current window
                if (sTitle.equals(sClosedWinTitle)) {

                    GUITARLog.log.debug("\t" + sClosedWinTitle);

                    List<FullComponentType> lCloseComp = lCloseWindowComp.getFullComponent();

                    FullComponentType cCloseComp = factory.createFullComponentType();
                    cCloseComp.setWindow(closedWin.extractWindow().getWindow());
                    cCloseComp.setComponent(retComp);
                    lCloseComp.add(cCloseComp);
                    lCloseWindowComp.setFullComponent(lCloseComp);
                } // if
            } // for
        } // if

        if (monitor.isNewWindowOpened()) {

            List<FullComponentType> lOpenComp = lOpenWindowComps.getFullComponent();
            FullComponentType cOpenComp = factory.createFullComponentType();
            cOpenComp.setWindow(window.extractWindow().getWindow());
            cOpenComp.setComponent(retComp);
            lOpenComp.add(cOpenComp);
            lOpenWindowComps.setFullComponent(lOpenComp);

            LinkedList<GWindow> lNewWindows = monitor.getOpenedWindowCache();
            monitor.resetWindowCache();
            GUITARLog.log.info(lNewWindows.size() + " new window(s) opened!!!");
            for (GWindow newWins : lNewWindows) {
                GUITARLog.log.info("*\t Title:*" + newWins.getTitle() + "*");
            }

            // Process the opened windows in a FIFO order
            while (!lNewWindows.isEmpty()) {

                GWindow gNewWin = lNewWindows.getLast();
                lNewWindows.removeLast();

                GComponent gWinComp = gNewWin.getContainer();

                if (gWinComp != null) {

                    // Add invokelist property for the component
                    String sWindowTitle = gNewWin.getTitle();
                    compA = new ComponentTypeWrapper(retComp);
                    compA.addValueByName(GUITARConstants.INVOKELIST_TAG_NAME, sWindowTitle);

                    GUITARLog.log.debug(sWindowTitle + " recorded");

                    retComp = compA.getDComponentType();

                    // Check ignore window
                    if (!monitor.isIgnoredWindow(gNewWin)) {

                        if (!monitor.isRippedWindow(gNewWin)) {
                            gNewWin.setRoot(false);
                            monitor.addRippedList(gNewWin);

                            GUIType dWindow = ripWindow(gNewWin);

                            if (dWindow != null)
                                dGUIStructure.getGUI().add(dWindow);
                        } else {
                            GUITARLog.log.info("Window is ripped!!!");
                        }

                    } else {
                        GUITARLog.log.info("Window is ignored!!!");
                    }
                }

                monitor.closeWindow(gNewWin);
            }
        }

        // TODO: check if the component is still available after ripping
        // its child window
        List<GComponent> gChildrenList = component.getChildren();
        int nChildren = gChildrenList.size();
        int i = 0;

        // Debug

        String lChildren = "[";
        for (int j = 0; j < nChildren; j++) {
            lChildren += gChildrenList.get(j).getTitle() + " - " + gChildrenList.get(j).getClassVal() + "; ";
        }
        lChildren += "]";
        GUITARLog.log.debug("*" + component.getTitle() + "* in window *" + window.getTitle() + "* has "
                + nChildren + " children: " + lChildren);

        // End debug

        while (i < nChildren) {
            GComponent gChild = gChildrenList.get(i++);
            ComponentType guiChild = ripComponent(gChild, window);

            if (guiChild != null) {
                ((ContainerType) retComp).getContents().getWidgetOrContainer().add(guiChild);
            }

            if (nChildren < gChildrenList.size()) {
                nChildren = gChildrenList.size();
            }
        }

    } catch (Exception e) {
        if (e.getClass().getName().contains("StaleElementReferenceException")) {
            /**
             * This can happen when performing an action causes a page
             * navigation in the current window, for example, when
             * submitting a form.
             */
            GUITARLog.log.warn("Element went away: " + e.getMessage());
        } else {
            // TODO: Must throw exception
            GUITARLog.log.error("ripComponent exception", e);
        }

        /**
         * We'll return the component we calculated anyway so it
         * gets added to the GUI map. I'm not entirely sure this
         * is the right thing to do, but it gets us further anyway.
         */
        return retComp;
    }

    return retComp;
}

From source file:org.squidy.nodes.ScreenDispatcher.java

/**
 * @param bounds/*from   w  ww . j  a v  a2  s.com*/
 */
private void createCaptureScreen(Rectangle bounds) throws ProcessException {
    try {
        captureScreen = new CaptureScreen(bounds);
    } catch (AWTException e) {
        throw new ProcessException(e.getMessage(), e);
    }
}