Example usage for java.awt.event KeyEvent VK_DOWN

List of usage examples for java.awt.event KeyEvent VK_DOWN

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_DOWN.

Prototype

int VK_DOWN

To view the source code for java.awt.event KeyEvent VK_DOWN.

Click Source Link

Document

Constant for the non-numpad down arrow key.

Usage

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

/**
 * Pan/Shifts a plot if the arrow keys are pressed.
 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
 *///w ww.j  a  v  a 2s .c  om
public void keyPressed(KeyEvent e) {
    if (!plotSupported)
        return;

    int keyCode = e.getKeyCode();

    // we're only interested in arrows (code 37,38,39,40)
    if ((keyCode < 37) || (keyCode > 40))
        return;

    // The axis we're gonna shift
    ValueAxis axis = null;

    // Delta is the amount we'll shift in axis units.
    double delta;

    boolean domainShift = false; // used for PAN_FIXED
    // Calculations for the domain axis
    if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) {
        axis = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        domainShift = true;
    }
    // Calculations for the range axis
    else {
        axis = getPlotAxis(chartPanel.getChart(), axesSwaped);
    }

    // Let's calculate 'delta', the amount by which we'll shift the plot
    switch (shiftType) {
    case SHIFT_PERCENTUAL:
        delta = (axis.getUpperBound() - axis.getLowerBound()) / 100.0;
        break;
    case SHIFT_FIXED:
        delta = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits);
        break;
    case SHIFT_PIXEL: // also the default
    default:
        // Let's find out what's the range for 1 pixel.
        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();
        delta = axis.getRange().getLength() / (scaledDataArea.width);
        break;
    }

    // Shift modifier multiplies delta by 10
    if (e.isShiftDown()) {
        delta *= 10;
    }

    switch (keyCode) {
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_DOWN:
        axis.setRange(axis.getLowerBound() - delta, axis.getUpperBound() - delta);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_RIGHT:
        axis.setRange(axis.getLowerBound() + delta, axis.getUpperBound() + delta);
        break;
    }
}

From source file:com.nbt.TileCanvas.java

protected void keyPressed(KeyEvent e) {
    final int keyCode = e.getKeyCode();
    switch (keyCode) {
    case KeyEvent.VK_UP:
        int z = getTileZ();
        setTileZ(z - 1);/* w  w  w  .  j av  a2 s . c  om*/
        break;
    case KeyEvent.VK_DOWN:
        z = getTileZ();
        setTileZ(z + 1);
        break;
    case KeyEvent.VK_LEFT:
        int x = getTileX();
        setTileX(x - 1);
        break;
    case KeyEvent.VK_RIGHT:
        x = getTileX();
        setTileX(x + 1);
        break;
    case KeyEvent.VK_PAGE_UP:
        int altitude = getAltitude();
        setAltitude(altitude + 1);
        break;
    case KeyEvent.VK_PAGE_DOWN:
        altitude = getAltitude();
        setAltitude(altitude - 1);
        break;
    }

    updateXYZ();
    doRepaint();
    save();
}

From source file:org.executequery.gui.browser.FindAction.java

public void keyPressed(KeyEvent keyEvent) {

    int keyCode = keyEvent.getKeyCode();

    if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_TAB) {

        setFirstListItemSelectedAndFocus();
    }//from   ww  w .j  a v a  2s .co  m
}

From source file:Text2DTest.java

/**
 * Process a keyboard event to move or rotate the viewer.
 *///from  w ww . j  a v  a 2 s .  c  o m
void processManualEvent(AWTEvent[] events) {

    for (int i = 0; i < events.length; ++i) {
        if (events[i] instanceof KeyEvent) {
            KeyEvent event = (KeyEvent) events[i];
            if (event.getKeyCode() == KeyEvent.VK_EQUALS) {
                continue;
            }
            Transform3D t = new Transform3D();
            viewTransformGroup.getTransform(t);
            Vector3f viewDir = new Vector3f(0f, 0f, -1f);
            Vector3f translation = new Vector3f();
            t.get(translation);
            t.transform(viewDir);
            if (event.getKeyCode() == KeyEvent.VK_UP) {
                translation.x += viewDir.x;
                translation.y += viewDir.y;
                translation.z += viewDir.z;
            } else if (event.getKeyCode() == KeyEvent.VK_DOWN) {
                translation.x -= viewDir.x;
                translation.y -= viewDir.y;
                translation.z -= viewDir.z;
            } else if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
                rotation += -.1;
            } else if (event.getKeyCode() == KeyEvent.VK_LEFT) {
                rotation += .1;
            }
            t.rotY(rotation);
            t.setTranslation(translation);
            viewTransformGroup.setTransform(t);
        }
    }
}

From source file:savant.view.swing.NavigationBar.java

NavigationBar() {

    this.setOpaque(false);
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    String buttonStyle = "segmentedCapsule";

    String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl";

    add(getRigidPadding());/*from   w ww  . java 2s  . c  o  m*/

    JButton loadGenomeButton = (JButton) add(new JButton(""));
    loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME));
    loadGenomeButton.setToolTipText("Load or change genome");
    loadGenomeButton.setFocusable(false);
    loadGenomeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().showOpenGenomeDialog();
        }
    });
    loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadGenomeButton.putClientProperty("JButton.segmentPosition", "first");
    loadGenomeButton.setPreferredSize(ICON_SIZE);
    loadGenomeButton.setMinimumSize(ICON_SIZE);
    loadGenomeButton.setMaximumSize(ICON_SIZE);

    JButton loadTrackButton = (JButton) add(new JButton(""));
    loadTrackButton.setFocusable(false);
    loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK));
    loadTrackButton.setToolTipText("Load a track");
    loadTrackButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Savant.getInstance().openTrack();
        }
    });
    loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle);
    loadTrackButton.putClientProperty("JButton.segmentPosition", "last");
    loadTrackButton.setPreferredSize(ICON_SIZE);
    loadTrackButton.setMinimumSize(ICON_SIZE);
    loadTrackButton.setMaximumSize(ICON_SIZE);

    if (!Savant.getInstance().isStandalone()) {
        add(loadGenomeButton);
        add(loadTrackButton);
        add(getRigidPadding());
        add(getRigidPadding());
    } else {
        loadGenomeButton.setVisible(false);
        loadTrackButton.setVisible(false);
    }

    JLabel rangeText = new JLabel("Location ");
    add(rangeText);

    String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " };
    locationField = new JComboBox(a);
    locationField.setEditable(true);
    locationField.setRenderer(new ReferenceListRenderer());

    // When the item is chosen from the menu, navigate to the given feature/reference.
    locationField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (!currentlyPopulating) {
                if (ae.getActionCommand().equals("comboBoxChanged")) {
                    // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)".
                    String itemText = locationField.getSelectedItem().toString();
                    int lastBracketPos = itemText.lastIndexOf('(');
                    if (lastBracketPos > 0) {
                        itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1);
                    }
                    setRangeFromText(itemText);

                }
            }
        }
    });

    // When the combo-box is popped open, we may want to repopulate the menu.
    locationField.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
            String text = (String) locationField.getEditor().getItem();
            if (!text.equals(lastPoppedUp)) {
                try {
                    // Building the menu could take a while.
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    populateCombo();
                } finally {
                    setCursor(Cursor.getDefaultCursor());
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent pme) {
        }
    });

    // Add our special keystroke-handling to the JComboBox' text-field.
    // We have to turn off default tab-handling so that tab can pop up our list.
    Component textField = locationField.getEditor().getEditorComponent();
    textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    textField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == KeyEvent.VK_TAB) {
                locationField.showPopup();
            } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) {
                switch (evt.getKeyCode()) {
                case KeyEvent.VK_LEFT:
                    locationController.shiftRangeLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_RIGHT:
                    locationController.shiftRangeRight();
                    evt.consume();
                    break;
                case KeyEvent.VK_UP:
                    locationController.zoomIn();
                    evt.consume();
                    break;
                case KeyEvent.VK_DOWN:
                    locationController.zoomOut();
                    evt.consume();
                    break;
                case KeyEvent.VK_HOME:
                    locationController.shiftRangeFarLeft();
                    evt.consume();
                    break;
                case KeyEvent.VK_END:
                    locationController.shiftRangeFarRight();
                    evt.consume();
                    break;
                }
            }
        }
    });
    add(locationField);
    locationField.setToolTipText("Current display range");
    locationField.setPreferredSize(LOCATION_SIZE);
    locationField.setMaximumSize(LOCATION_SIZE);
    locationField.setMinimumSize(LOCATION_SIZE);

    add(getRigidPadding());

    JButton goButton = (JButton) add(new JButton("  Go  "));
    goButton.putClientProperty("JButton.buttonType", buttonStyle);
    goButton.putClientProperty("JButton.segmentPosition", "only");
    goButton.setToolTipText("Go to specified range (Enter)");
    goButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setRangeFromText(locationField.getEditor().getItem().toString());
        }
    });

    add(getRigidPadding());

    JLabel l = new JLabel("Length: ");
    add(l);

    lengthLabel = (JLabel) add(new JLabel());
    lengthLabel.setToolTipText("Length of the current range");
    lengthLabel.setPreferredSize(LENGTH_SIZE);
    lengthLabel.setMaximumSize(LENGTH_SIZE);
    lengthLabel.setMinimumSize(LENGTH_SIZE);

    add(Box.createGlue());

    double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth();

    JButton afterGo = null;
    //if (screenwidth > 800) {
    final JButton undoButton = (JButton) add(new JButton(""));
    afterGo = undoButton;
    undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO));
    undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)");
    undoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.undoLocationChange();
        }
    });
    undoButton.putClientProperty("JButton.buttonType", buttonStyle);
    undoButton.putClientProperty("JButton.segmentPosition", "first");
    undoButton.setPreferredSize(ICON_SIZE);
    undoButton.setMinimumSize(ICON_SIZE);
    undoButton.setMaximumSize(ICON_SIZE);

    final JButton redo = (JButton) add(new JButton(""));
    redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO));
    redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)");
    redo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.redoLocationChange();
        }
    });
    redo.putClientProperty("JButton.buttonType", buttonStyle);
    redo.putClientProperty("JButton.segmentPosition", "last");
    redo.setPreferredSize(ICON_SIZE);
    redo.setMinimumSize(ICON_SIZE);
    redo.setMaximumSize(ICON_SIZE);
    //}

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton zoomInButton = (JButton) add(new JButton());
    if (afterGo == null) {
        afterGo = zoomInButton;
    }
    zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN));
    zoomInButton.putClientProperty("JButton.buttonType", buttonStyle);
    zoomInButton.putClientProperty("JButton.segmentPosition", "first");
    zoomInButton.setPreferredSize(ICON_SIZE);
    zoomInButton.setMinimumSize(ICON_SIZE);
    zoomInButton.setMaximumSize(ICON_SIZE);
    zoomInButton.setToolTipText("Zoom in (Shift+Up)");
    zoomInButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomIn();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "in"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton zoomOut = (JButton) add(new JButton(""));
    zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT));
    zoomOut.setToolTipText("Zoom out (Shift+Down)");
    zoomOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.zoomOut();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"),
                    new NameValuePair("navigation-direction", "out"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });
    zoomOut.putClientProperty("JButton.buttonType", buttonStyle);
    zoomOut.putClientProperty("JButton.segmentPosition", "last");
    zoomOut.setPreferredSize(ICON_SIZE);
    zoomOut.setMinimumSize(ICON_SIZE);
    zoomOut.setMaximumSize(ICON_SIZE);

    add(getRigidPadding());
    add(getRigidPadding());

    final JButton shiftFarLeft = (JButton) add(new JButton());
    shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT));
    shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarLeft.putClientProperty("JButton.segmentPosition", "first");
    shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)");
    shiftFarLeft.setPreferredSize(ICON_SIZE);
    shiftFarLeft.setMinimumSize(ICON_SIZE);
    shiftFarLeft.setMaximumSize(ICON_SIZE);
    shiftFarLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftLeft = (JButton) add(new JButton());
    shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT));
    shiftLeft.putClientProperty("JButton.buttonType", buttonStyle);
    shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
    shiftLeft.setToolTipText("Move left (Shift+Left)");
    shiftLeft.setPreferredSize(ICON_SIZE);
    shiftLeft.setMinimumSize(ICON_SIZE);
    shiftLeft.setMaximumSize(ICON_SIZE);
    shiftLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeLeft();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "left"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftRight = (JButton) add(new JButton());
    shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT));
    shiftRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftRight.putClientProperty("JButton.segmentPosition", "middle");
    shiftRight.setToolTipText("Move right (Shift+Right)");
    shiftRight.setPreferredSize(ICON_SIZE);
    shiftRight.setMinimumSize(ICON_SIZE);
    shiftRight.setMaximumSize(ICON_SIZE);
    shiftRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    final JButton shiftFarRight = (JButton) add(new JButton());
    shiftFarRight
            .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT));
    shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle);
    shiftFarRight.putClientProperty("JButton.segmentPosition", "last");
    shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)");
    shiftFarRight.setPreferredSize(ICON_SIZE);
    shiftFarRight.setMinimumSize(ICON_SIZE);
    shiftFarRight.setMaximumSize(ICON_SIZE);
    shiftFarRight.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            locationController.shiftRangeFarRight();
            AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"),
                    new NameValuePair("navigation-direction", "right"),
                    new NameValuePair("navigation-modality", "navbar") });
        }
    });

    add(getRigidPadding());

    locationController.addListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            updateLocation(event.getReference(), (Range) event.getRange());
        }
    });

    // When the genome changes, we may need to invalidate our menu.
    GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            lastPoppedUp = "INVALID";
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent ce) {
            int width = ce.getComponent().getWidth();

            undoButton.setVisible(true);
            redo.setVisible(true);
            zoomInButton.setVisible(true);
            zoomOut.setVisible(true);
            shiftFarLeft.setVisible(true);
            shiftLeft.setVisible(true);
            shiftRight.setVisible(true);
            shiftFarRight.setVisible(true);

            // hide some components if the window isn't wide enough
            if (width < 1200) {
                undoButton.setVisible(false);
                redo.setVisible(false);
            }
            if (width < 1000) {
                shiftFarLeft.setVisible(false);
                shiftFarRight.setVisible(false);

                shiftRight.putClientProperty("JButton.segmentPosition", "last");
                shiftLeft.putClientProperty("JButton.segmentPosition", "first");
            } else {
                shiftRight.putClientProperty("JButton.segmentPosition", "middle");
                shiftLeft.putClientProperty("JButton.segmentPosition", "middle");
            }
        }

        public void componentMoved(ComponentEvent ce) {
        }

        @Override
        public void componentShown(ComponentEvent ce) {
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
        }
    });
}

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

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name: //from   w  ww  .jav a  2s. 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:Report_PRCR_New_ETF_Excel_File_Generator.java

private void monthfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthfieldKeyPressed
    if (monthfield.getText().equals("Jan")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Dec");
            int yr = Integer.parseInt(yearfield.getText());

            yearfield.setText("" + (yr - 1));
            monthfield.selectAll();/*from www . j a  v  a 2  s .c  o m*/

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Feb");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Feb")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jan");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Mar");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Mar")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Feb");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Apr");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Apr")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Mar");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("May");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("May")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Apr");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            monthfield.setText("Jun");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Jun")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("May");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Jul");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Jul")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jun");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Aug");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Aug")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Jul");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Sep");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Sep")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Aug");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Oct");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Oct")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Sep");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Nov");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Nov")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Oct");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Dec");
            monthfield.selectAll();
        }

    } else if (monthfield.getText().equals("Dec")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield.setText("Nov");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield.setText("Jan");
            int yr = Integer.parseInt(yearfield.getText());

            yearfield.setText("" + (yr + 1));
            monthfield.selectAll();
        }

    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        // dayfield.requestFocus();
        // dayfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
        yearfield.requestFocus();
        yearfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE  focus on enter////////////////
        //  dayfield2.requestFocus();
        // dayfield2.selectAll();

    }
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

/**
 * Creates new form MapFrame//from   www .java  2  s .  com
 */
DSWorkbenchMainFrame() {
    initComponents();
    setAlwaysOnTop(false);
    if (!GlobalOptions.isMinimal()) {
        setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION);
    } else {
        setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION);
    }

    jExportDialog.pack();
    jAddROIDialog.pack();

    JOutlookBar outlookBar = new JOutlookBar();
    outlookBar.addBar("Navigation", jNavigationPanel);
    outlookBar.addBar("Information", jInformationPanel);
    outlookBar.addBar("Karte", jMapPanel);
    outlookBar.addBar("ROI", jROIPanel);
    outlookBar.setVisibleBar(1);
    jSettingsScrollPane.setViewportView(outlookBar);

    mAbout = new AboutDialog(this, true);
    mAbout.pack();
    chooser.setDialogTitle("Speichern unter...");
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".png"));
        }

        @Override
        public String getDescription() {
            return "PNG Image (*.png)";
        }
    });

    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg"));
        }

        @Override
        public String getDescription() {
            return "JPEG Image (*.jpeg)";
        }
    });

    //Schedule Backup
    new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000);

    //give focus to map panel if mouse enters map
    jMapPanelHolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            jMapPanelHolder.requestFocusInWindow();
        }
    });

    getContentPane().setBackground(Constants.DS_BACK);
    pack();
    capabilityInfoPanel1.addActionListener(MapPanel.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener ">
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == KeyEvent.KEY_PRESSED) {
                KeyEvent e = (KeyEvent) event;
                if (DSWorkbenchMainFrame.getSingleton().isActive()) {
                    //move shortcuts
                    if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                        scroll(0.0, 2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                        scroll(0.0, -2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                        scroll(-2.0, 0.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                        scroll(2.0, 0.0);
                    } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //shot minimap tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE);
                    } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack axe tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM);
                    } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack ram tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB);
                    } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack snob tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack sword tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT);
                    } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack light tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack heavy tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD);
                    } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) {
                        //search frame shortcut
                        DSWorkbenchSearchFrame.getSingleton()
                                .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible());
                    }
                }

                //misc shortcuts
                if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) {
                    //no tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //measure tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //mark tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //tag tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //res ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //move minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //zoom minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //shot minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT);
                } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //search time shortcut
                    ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible());
                } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    planMapshot();
                } else if (e.getKeyCode() == KeyEvent.VK_F2) {
                    DSWorkbenchAttackFrame.getSingleton()
                            .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F3) {
                    DSWorkbenchMarkerFrame.getSingleton()
                            .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F4) {
                    DSWorkbenchTroopsFrame.getSingleton()
                            .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                    DSWorkbenchRankFrame.getSingleton()
                            .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F6) {
                    DSWorkbenchFormFrame.getSingleton()
                            .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F7) {
                    if (ServerSettings.getSingleton().isChurch()) {
                        DSWorkbenchChurchFrame.getSingleton()
                                .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible());
                    }
                } else if (e.getKeyCode() == KeyEvent.VK_F8) {
                    DSWorkbenchConquersFrame.getSingleton()
                            .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F9) {
                    DSWorkbenchNotepad.getSingleton()
                            .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F10) {
                    DSWorkbenchTagFrame.getSingleton()
                            .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F11) {
                    DSWorkbenchStatsFrame.getSingleton()
                            .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F12) {
                    DSWorkbenchSettingsDialog.getSingleton().setVisible(true);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 1
                    centerROI(0);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 2
                    centerROI(1);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 3
                    centerROI(2);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 4
                    centerROI(3);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 5
                    centerROI(4);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 6
                    centerROI(5);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 7
                    centerROI(6);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 8
                    centerROI(7);
                } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 9
                    centerROI(8);
                } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 10
                    centerROI(9);
                } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setSpaceDown(true);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setShiftDown(true);
                }
            } else if (event.getID() == KeyEvent.KEY_RELEASED) {
                KeyEvent e = (KeyEvent) event;
                if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    MapPanel.getSingleton().setSpaceDown(false);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    MapPanel.getSingleton().setShiftDown(false);
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Load UI Icons ">
    try {
        jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png"));
        jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png"));
        jCenterIngameButton
                .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png")));
        jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png"));
        jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png"));
    } catch (Exception e) {
        logger.error("Failed to load status icon(s)", e);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Check for desktop support ">
    if (!Desktop.isDesktopSupported()) {
        jCenterIngameButton.setEnabled(false);
        jCenterCoordinateIngame.setEnabled(false);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore last map position ">
    try {
        String x = GlobalOptions.getSelectedProfile().getProperty("last.x");
        String y = GlobalOptions.getSelectedProfile().getProperty("last.y");
        centerPosition(Double.parseDouble(x), Double.parseDouble(y));
    } catch (Exception e) {
        centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(),
                ServerSettings.getSingleton().getMapDimension().getCenterY());
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore other settings ">
    jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup"));
    jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info"));
    jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support"));
    jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages"));
    jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler"));
    jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church"));
    jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower"));
    jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
    jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
    ServerSettings.getSingleton().addListener(new ServerSettingsListener() {
        @Override
        public void fireServerSettingsChanged() {
            jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
            jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
        }
    });
    int r = GlobalOptions.getProperties().getInt("radar.size");
    int hour = r / 60;
    jHourField.setText(Integer.toString(hour));
    jMinuteField.setText(Integer.toString(r - hour * 60));
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Skin Setup">
    DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins());
    jGraphicPacks.setModel(gpModel);
    String skin = GlobalOptions.getProperty("default.skin");
    if (gpModel.getIndexOf(skin) != -1) {
        jGraphicPacks.setSelectedItem(skin);
    } else {
        jGraphicPacks.setSelectedItem("default");
    }
    //</editor-fold>

    minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min");
    maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max");
    dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor");

    mNotificationHideThread = new NotificationHideThread();
    mNotificationHideThread.start();
    SystrayHelper.installSystrayIcon();
    //update online state
    onlineStateChanged();
    restoreProperties();
}

From source file:org.eobjects.datacleaner.panels.WelcomePanel.java

@Inject
protected WelcomePanel(AnalyzerBeansConfiguration configuration,
        AnalysisJobBuilderWindow analysisJobBuilderWindow, DCGlassPane glassPane,
        Provider<OptionsDialog> optionsDialogProvider, InjectorBuilder injectorBuilder,
        OpenAnalysisJobActionListener openAnalysisJobActionListener,
        DatabaseDriverCatalog databaseDriverCatalog, UserPreferences userPreferences) {
    super();/*from   w  w w  .  java2s  .  c om*/
    _openAnalysisJobActionListener = openAnalysisJobActionListener;
    _configuration = configuration;
    _datastorePanels = new ArrayList<DatastorePanel>();
    _datastoreCatalog = (MutableDatastoreCatalog) configuration.getDatastoreCatalog();
    _analysisJobBuilderWindow = analysisJobBuilderWindow;
    _glassPane = glassPane;
    _optionsDialogProvider = optionsDialogProvider;
    _injectorBuilder = injectorBuilder;
    _databaseDriverCatalog = databaseDriverCatalog;
    _userPreferences = userPreferences;

    _browseJobsButton = new JButton("Browse jobs",
            imageManager.getImageIcon(IconUtils.MENU_OPEN, IconUtils.ICON_SIZE_SMALL));
    _browseJobsButton.setMargin(new Insets(1, 1, 1, 4));
    _browseJobsButton.addActionListener(openAnalysisJobActionListener);

    // initialize "analyze" button
    _analyzeButton = new JButton("Build job",
            imageManager.getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_SMALL));
    _analyzeButton.setMargin(new Insets(1, 1, 1, 1));
    _analyzeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (DatastorePanel datastorePanel : _datastorePanels) {
                if (datastorePanel.isSelected()) {
                    Datastore datastore = datastorePanel.getDatastore();

                    // open the connection here, to make any connection
                    // issues apparent early
                    try (DatastoreConnection datastoreConnection = datastore.openConnection()) {
                        datastoreConnection.getDataContext().getSchemaNames();
                        _analysisJobBuilderWindow.setDatastore(datastore);
                    }
                    return;
                }
            }
        }
    });

    // initialize search text field
    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter datastores");
    _searchDatastoreTextField
            .setBorder(new CompoundBorder(new EmptyBorder(4, 0, 0, 0), WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.setOpaque(false);
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    datastorePanel.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    String name = datastorePanel.getDatastore().getName().toLowerCase();
                    datastorePanel.setVisible(name.indexOf(text) != -1);
                }
                selectFirstVisibleDatastore();
            }
        }
    });
    _searchDatastoreTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                clickAnalyzeButton();
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                selectNextVisibleDatastore();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                selectPreviousVisibleDatastore();
            }
        }
    });

    setLayout(new VerticalLayout(4));

    add(Box.createVerticalStrut(10));

    final DCLabel jobsHeaderLabel = DCLabel.dark("Jobs");
    jobsHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(jobsHeaderLabel);

    _jobsListPanel = new DCPanel();
    final GridLayout jobsListLayout = new GridLayout(1, MAX_JOB_PANELS);
    jobsListLayout.setHgap(10);
    _jobsListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    _jobsListPanel.setLayout(jobsListLayout);

    final List<FileObject> recentJobFiles = getRecentJobFiles();

    updateJobsListPanel(recentJobFiles);

    add(_jobsListPanel);

    _moreRecentJobsButton = new JButton("More",
            imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL));
    _moreRecentJobsButton.setMargin(new Insets(1, 1, 1, 4));
    if (recentJobFiles.size() <= MAX_JOB_PANELS) {
        _moreRecentJobsButton.setEnabled(false);
    } else {
        _moreRecentJobsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final JPopupMenu popup = new JPopupMenu();
                for (int i = 3; i < recentJobFiles.size(); i++) {
                    final FileObject jobFile = recentJobFiles.get(i);
                    final JMenuItem menuItem = new OpenAnalysisJobMenuItem(jobFile,
                            _openAnalysisJobActionListener);
                    popup.add(menuItem);
                }
                popup.show(_moreRecentJobsButton, 0, _moreRecentJobsButton.getHeight());
            }
        });
    }

    final DCPanel jobsButtonPanel = new DCPanel();
    jobsButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
    jobsButtonPanel.add(_moreRecentJobsButton);
    jobsButtonPanel.add(_browseJobsButton);
    add(jobsButtonPanel);

    add(Box.createVerticalStrut(40));

    final DCLabel datastoreHeaderLabel = DCLabel.dark("Datastores");
    datastoreHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(datastoreHeaderLabel);

    final DCLabel registerNewDatastoreLabel = DCLabel.dark("Register new:");
    registerNewDatastoreLabel.setFont(WidgetUtils.FONT_HEADER2);

    final DCPanel newDatastorePanel = new DCPanel();
    newDatastorePanel.setLayout(new VerticalLayout(4));
    newDatastorePanel.setBorder(new EmptyBorder(10, 10, 10, 0));
    newDatastorePanel.add(registerNewDatastoreLabel);
    newDatastorePanel.add(createNewDatastorePanel());

    add(newDatastorePanel);

    _datastoreListPanel = new DCPanel();
    _datastoreListPanel.setLayout(new VerticalLayout(4));
    _datastoreListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    add(_datastoreListPanel);
    updateDatastores();

    final DCPanel datastoresButtonPanel = new DCPanel();
    datastoresButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    datastoresButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    datastoresButtonPanel.add(_analyzeButton);
    add(datastoresButtonPanel);
}