List of usage examples for java.awt AWTEvent KEY_EVENT_MASK
long KEY_EVENT_MASK
To view the source code for java.awt AWTEvent KEY_EVENT_MASK.
Click Source Link
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
/** * Creates new form MapFrame//from w ww .java2s. c om */ 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:brainflow.app.toplevel.BrainFlow.java
private void initializeToolBar() { CommandGroup mainToolbarGroup = new CommandGroup("main-toolbar"); mainToolbarGroup.bind(getApplicationFrame()); ToggleGroup interpToggleGroup = new ToggleGroup("toggle-interp-group"); interpToggleGroup.bind(getApplicationFrame()); bindCommand(new OpenImageCommand(), true); bindCommand(new SnapshotCommand(), true); bindCommand(new NewCanvasCommand(), true); bindCommand(new CreateAxialViewCommand(), true); bindCommand(new CreateSagittalViewCommand(), true); bindCommand(new CreateCoronalViewCommand(), true); bindCommand(new CreateMontageViewCommand(), true); bindCommand(new CreateVerticalOrthogonalCommand(), true); bindCommand(new CreateHorizontalOrthogonalCommand(), true); bindCommand(new CreateTriangularOrthogonalCommand(), true); CommandGroup orthoGroup = new CommandGroup("ortho-view-group"); orthoGroup.bind(getApplicationFrame()); final NextSliceCommand nextSliceCommand = new NextSliceCommand(); bindCommand(nextSliceCommand, false); final PreviousSliceCommand previousSliceCommand = new PreviousSliceCommand(); bindCommand(previousSliceCommand, false); bindCommand(new PageBackSliceCommand(), true); bindCommand(new PageForwardSliceCommand(), true); bindCommand(new IncreaseContrastCommand(), true); bindCommand(new DecreaseContrastCommand(), true); bindCommand(new NearestInterpolationToggleCommand(), true); bindCommand(new LinearInterpolationToggleCommand(), true); bindCommand(new CubicInterpolationToggleCommand(), true); bindCommand(new ToggleAxisLabelCommand(), true); bindCommand(new ToggleCrossCommand(), true); //JToolBar mainToolbar = mainToolbarGroup.createToolBar(); final CommandBar mainToolbar = new CommandBar(); // for nimbus look and feel mainToolbar.setPaintBackground(false); // for nimbus look and feel mainToolbar.setBorder(new EmptyBorder(0, 0, 0, 0)); final ButtonFactory buttonFactory = createToolBarButtonFactory(); mainToolbarGroup.visitMembers(new GroupVisitor() { @Override//from www . java2 s . co m public void visit(ActionCommand actionCommand) { JideButton jb = new JideButton(actionCommand.getActionAdapter()); jb.setButtonStyle(JideButton.TOOLBAR_STYLE); jb.setText(""); mainToolbar.add(jb); } @Override public void visit(CommandGroup commandGroup) { JComponent jc = commandGroup.createButton(buttonFactory); mainToolbar.add(jc); } }); mainToolbar.setKey("toolbar"); brainFrame.getDockableBarManager().addDockableBar(mainToolbar); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event.getID() == KeyEvent.KEY_PRESSED) { KeyEvent ke = (KeyEvent) event; Component comp = ke.getComponent(); if (ke.getKeyCode() == KeyEvent.VK_LEFT) { ImageView view = BrainFlow.get().getSelectedView(); if (/*view.hasFocus() || */ parentIsImageView(comp)) { previousSliceCommand.execute(); } } else if (ke.getKeyCode() == KeyEvent.VK_RIGHT) { ImageView view = BrainFlow.get().getSelectedView(); if ( /*view.hasFocus() */ parentIsImageView(comp)) { nextSliceCommand.execute(); } else { System.out.println("no focus"); } } } } }, AWTEvent.KEY_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent me = (MouseEvent) event; if (me.isPopupTrigger()) { showActionMenu(me); } } } }, AWTEvent.MOUSE_EVENT_MASK); }
From source file:javazoom.jlgui.player.amp.Player.java
/** * Instantiate Buttons Panel with ActiveComponent. * Add them to window and ActionListener. */// ww w . jav a 2 s .c o m protected void setButtonsPanel() { int l = 0; setLayout(null); acPrevious = new ActiveComponent(releasedImage[0], pressedImage[0], AWTEvent.MOUSE_EVENT_MASK); acPrevious.setLocation(panelLocation[l++], panelLocation[l++]); add(acPrevious); acPrevious.setActionCommand("Previous"); acPrevious.addActionListener(this); acPlay = new ActiveComponent(releasedImage[1], pressedImage[1], AWTEvent.MOUSE_EVENT_MASK); acPlay.setLocation(panelLocation[l++], panelLocation[l++]); add(acPlay); acPlay.setActionCommand("Play"); acPlay.addActionListener(this); acPause = new ActiveComponent(releasedImage[2], pressedImage[2], AWTEvent.MOUSE_EVENT_MASK); acPause.setLocation(panelLocation[l++], panelLocation[l++]); add(acPause); acPause.setActionCommand("Pause"); acPause.addActionListener(this); acStop = new ActiveComponent(releasedImage[3], pressedImage[3], AWTEvent.MOUSE_EVENT_MASK); acStop.setLocation(panelLocation[l++], panelLocation[l++]); add(acStop); acStop.setActionCommand("Stop"); acStop.addActionListener(this); acNext = new ActiveComponent(releasedImage[4], pressedImage[4], AWTEvent.MOUSE_EVENT_MASK); acNext.setLocation(panelLocation[l++], panelLocation[l++]); add(acNext); acNext.setActionCommand("Next"); acNext.addActionListener(this); acEject = new ActiveComponent(releasedImage[5], pressedImage[5], AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); acEject.setLocation(panelLocation[l++], panelLocation[l++]); add(acEject); acEject.setActionCommand("Eject"); acEject.addActionListener(this); }
From source file:op.FrmMain.java
public FrmMain() { initPhase = true;/*from ww w. ja va 2 s . com*/ initComponents(); if (OPDE.isTraining()) { pnlMainMessage.setBackground(SYSConst.mediumorchid2.brighter().brighter()); } // pbTimeout.setToolTipText(SYSTools.xx("opde.mainframe.pbTimeout.tooltip")); // for the timeout function Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (OPDE.getLogin() != null) { displayManager.touch(); } } }, AWTEvent.MOUSE_MOTION_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (OPDE.getLogin() != null) { displayManager.touch(); } } }, AWTEvent.KEY_EVENT_MASK); currentVisiblePanel = null; currentResident = null; lblWait.setText(SYSTools.xx("misc.msg.wait")); lblWait.setVisible(false); listOfNursingrecords = new ArrayList<CollapsiblePane>(); btnHelp.setToolTipText(SYSTools.xx("opde.mainframe.btnHelp.tooltip")); iconPanels = Collections.synchronizedMap(new HashMap<Resident, JPanel>()); if (OPDE.isDebug()) { setSize(1366, 768); } else { this.setExtendedState(JFrame.MAXIMIZED_BOTH); } setTitle(SYSTools.getWindowTitle("")); displayManager = new DisplayManager(pbMsg, lblMainMsg, lblSubMsg, pnlIcons, pbTimeout, new Closure() { @Override public void execute(Object o) { OPDE.debug("TIMEOUT"); logout(); showLogin(); } }); displayManager.start(); printProcessor = new PrintProcessor(); printProcessor.start(); // StatusBar Setup final LabelStatusBarItem label = new LabelStatusBarItem("Line"); label.setText(OPDE.getUrl() + " [Build " + OPDE.getAppInfo().getBuildnum() + "]" + " [JVM " + System.getProperty("java.version") + "]"); if (OPDE.isCustomUrl()) { label.setForeground(Color.RED); } label.setFont(new Font("Arial", Font.PLAIN, 14)); statusBar.add(label, JideBoxLayout.FLEXIBLE); labelUSER = new LabelStatusBarItem("Line"); labelUSER.setText("--"); labelUSER.setAlignment(JLabel.CENTER); labelUSER.setFont(new Font("Arial", Font.PLAIN, 14)); statusBar.add(labelUSER, JideBoxLayout.FLEXIBLE); final TimeStatusBarItem time = new TimeStatusBarItem(); time.setFont(new Font("Arial", Font.PLAIN, 14)); time.setUpdateInterval(10000); time.setTextFormat(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT)); time.setAlignment(JLabel.CENTER); statusBar.add(time, JideBoxLayout.FLEXIBLE); final MemoryStatusBarItem gc = new MemoryStatusBarItem(); gc.setFont(new Font("Arial", Font.PLAIN, 14)); statusBar.add(gc, JideBoxLayout.FLEXIBLE); btnResetSplitpane.setToolTipText(SYSTools.xx("opde.mainframe.btnSplitReset.tooltip")); initPhase = false; // JDialog dlg = new JDialog(this, false); // // JPanel pnl = new JPanel(); // pnl.setLayout(new VerticalLayout()); // // for (float f = 0.0f; f <= 1.0; f = f + 0.01f){ // JLabel lbl = new JLabel(Float.toString(f)); // lbl.setForeground(GUITools.blend(Color.red, Color.WHITE, f)); // pnl.add(lbl); // } // // dlg.setContentPane(new JScrollPane(pnl)); // // dlg.pack(); // dlg.setVisible(true); }
From source file:org.apache.cayenne.modeler.CayenneModelerFrame.java
/** Initializes main toolbar. */ protected void initToolbar() { JToolBar toolBar = new JToolBar(); toolBar.add(getAction(NewProjectAction.class).buildButton()); toolBar.add(getAction(OpenProjectAction.class).buildButton()); toolBar.add(getAction(SaveAction.class).buildButton()); toolBar.addSeparator();/*from ww w . j av a 2 s.co m*/ toolBar.add(getAction(RemoveAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CutAction.class).buildButton()); toolBar.add(getAction(CopyAction.class).buildButton()); toolBar.add(getAction(PasteAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(UndoAction.class).buildButton()); toolBar.add(getAction(RedoAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateNodeAction.class).buildButton()); toolBar.add(getAction(CreateDataMapAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateDbEntityAction.class).buildButton()); toolBar.add(getAction(CreateProcedureAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateObjEntityAction.class).buildButton()); toolBar.add(getAction(CreateEmbeddableAction.class).buildButton()); toolBar.add(getAction(CreateQueryAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(NavigateBackwardAction.class).buildButton()); toolBar.add(getAction(NavigateForwardAction.class).buildButton()); JPanel east = new JPanel(new BorderLayout()); // is used to place search feature // components the most right on a // toolbar final JTextField findField = new JTextField(10); findField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) { findField.setBackground(Color.white); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); findField.setAction(getAction(FindAction.class)); JLabel findLabel = new JLabel("Search:"); findLabel.setLabelFor(findField); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event instanceof KeyEvent) { if (((KeyEvent) event).getModifiers() == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_F) { findField.requestFocus(); } } } }, AWTEvent.KEY_EVENT_MASK); JPanel box = new JPanel(); // is used to place label and text field one after // another box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); box.add(findLabel); box.add(findField); east.add(box, BorderLayout.EAST); toolBar.add(east); getContentPane().add(toolBar, BorderLayout.NORTH); }
From source file:org.eclipse.jubula.rc.common.driver.KeyTyper.java
/** * Types the given keystroke.//from w ww. j a v a 2 s . co m * If any of the intercepting and event matching arguments are * <code>null</code>, this method will not wait for event confirmation. It * will simply assume that the events were received correctly. Otherwise, * this method will use the given interceptor and event matcher arguments to * handle event confirmation. * * @param keyStroke The key stroke. May not be null. * @param interceptor The interceptor that will be used to wait for event * confirmation. * @param keyDownMatcher The event matcher to be used for key press event * confirmation. * @param keyUpMatcher The event matcher to be used for key release event * confirmation. */ public void type(KeyStroke keyStroke, IRobotEventInterceptor interceptor, IEventMatcher keyDownMatcher, IEventMatcher keyUpMatcher) { try { Validate.notNull(keyStroke); boolean waitForConfirm = interceptor != null && keyDownMatcher != null && keyUpMatcher != null; InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); List keycodes = modifierKeyCodes(keyStroke); keycodes.add(new Integer(keyStroke.getKeyCode())); if (log.isDebugEnabled()) { String keyModifierText = KeyEvent.getKeyModifiersText(keyStroke.getModifiers()); String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode()); log.debug("Key stroke: " + keyStroke); //$NON-NLS-1$ log.debug("Modifiers, Key: " + keyModifierText + ", " + keyText); //$NON-NLS-1$//$NON-NLS-2$ log.debug("number of keycodes: " + keycodes.size()); //$NON-NLS-1$ } m_robot.setAutoWaitForIdle(true); // FIXME Hack for MS Windows for keys that also appear on the numpad. // Turns NumLock off. Does nothing if locking key functionality // isn't implemented for the operating system. boolean isNumLockToggled = hackWindowsNumpadKeys1(keyStroke.getKeyCode()); // first press all keys, then release all keys, but // avoid to press and release any key twice (even if perhaps alt // and meta should have the same keycode(??) Set alreadyDown = new HashSet(); ListIterator i = keycodes.listIterator(); try { while (i.hasNext()) { Integer keycode = (Integer) i.next(); if (log.isDebugEnabled()) { log.debug("trying to press: " + keycode); //$NON-NLS-1$ } if (!alreadyDown.contains(keycode)) { IRobotEventConfirmer confirmer = null; if (waitForConfirm) { confirmer = interceptor.intercept(options); } if (log.isDebugEnabled()) { log.debug("pressing: " + keycode); //$NON-NLS-1$ } alreadyDown.add(keycode); m_robot.keyPress(keycode.intValue()); if (waitForConfirm) { confirmer.waitToConfirm(null, keyDownMatcher); } } } } finally { releaseKeys(options, alreadyDown, i, interceptor, keyUpMatcher); // FIXME Hack for MS Windows for keys that also appear on the numpad. // Turns NumLock back on, if necessary. if (isNumLockToggled) { hackWindowsNumpadKeys2(); } } } catch (IllegalArgumentException e) { throw new RobotException(e); } }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * {@inheritDoc} <br>// w w w . j ava 2 s .c o m * <b>* Currently delegates the key type to the Robot </b> */ public void type(final Object graphicsComponent, char c) throws RobotException { Validate.notNull(graphicsComponent, "The graphic component must not be null"); //$NON-NLS-1$ final KeyEvent event = new KeyEvent(KeyEvent.KEY_TYPED, String.valueOf(c), StringUtils.EMPTY, null, false, false, false, false); InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); IRobotEventConfirmer confirmer = m_interceptor.intercept(options); m_queuer.invokeLater("Type character", new Runnable() { //$NON-NLS-1$ @Override public void run() { final Scene scene; if (graphicsComponent instanceof Stage) { scene = ((Stage) graphicsComponent).getScene(); } else { scene = ((Node) graphicsComponent).getScene(); } Node focusOwner = scene.getFocusOwner(); EventTarget eventTarget = focusOwner != null ? focusOwner : scene; Event.fireEvent(eventTarget, event); } }); confirmer.waitToConfirm(graphicsComponent, new KeyJavaFXEventMatcher(KeyEvent.KEY_TYPED)); }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * @param graphicsComponent The graphics component the key code is typed in, may be null * @param keycode The key code./*from w w w. ja v a2 s . c o m*/ * @param isUpperCase Boolean whether character is upper case. */ public void keyType(Object graphicsComponent, int keycode, boolean isUpperCase) throws RobotException { try { InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); IRobotEventConfirmer confirmer = m_interceptor.intercept(options); try { if (isUpperCase) { m_robot.keyPress(java.awt.event.KeyEvent.VK_SHIFT); } m_robot.keyPress(keycode); } finally { m_robot.keyRelease(keycode); if (isUpperCase) { m_robot.keyRelease(java.awt.event.KeyEvent.VK_SHIFT); } } confirmer.waitToConfirm(graphicsComponent, new KeyJavaFXEventMatcher(KeyEvent.KEY_RELEASED)); } catch (IllegalArgumentException e) { throw new RobotException(e); } }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Implements the key press or release.//from w w w. ja va 2 s .c o m * * @param graphicsComponent * The component, may be <code>null</code> * @param keyCode * The key code * @param press * If <code>true</code>, the key is pressed, otherwise released */ private void keyPressReleaseImpl(Object graphicsComponent, int keyCode, boolean press) { InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); IRobotEventConfirmer confirmer = m_interceptor.intercept(options); if (press) { m_robot.keyPress(keyCode); } else { m_robot.keyRelease(keyCode); } confirmer.waitToConfirm(graphicsComponent, new KeyJavaFXEventMatcher(press ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED)); }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * {@inheritDoc}/* w w w . j a va2 s .c om*/ */ public void type(Object graphicsComponent, char character) throws RobotException { Validate.notNull(graphicsComponent, "The graphic component must not be null"); //$NON-NLS-1$ try { int modifier = 0; Component component = (Component) graphicsComponent; KeyEvent ke = new KeyEvent(component, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); ke = new KeyEvent(component, KeyEvent.KEY_TYPED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); IRobotEventConfirmer confirmer = m_interceptor .intercept(new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK })); ke = new KeyEvent(component, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), modifier, KeyEvent.VK_UNDEFINED, character); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ke); confirmer.waitToConfirm(component, new DefaultAwtEventMatcher(KeyEvent.KEY_RELEASED)); } catch (AWTError awte) { log.error(awte); throw new RobotException(awte); } catch (SecurityException se) { log.error(se); throw new RobotException(se); } }