List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction()
From source file:ConfigFiles.java
public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y, boolean withbutton, ActionListener actionlistener) { JPanel p1 = new JPanel(); p1.setBackground(Color.WHITE); TitledBorder border = BorderFactory.createTitledBorder(title); border.setTitleFont(new Font("Arial", Font.PLAIN, 14)); border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1)); p1.setBorder(border);// w w w .j a va 2 s .c o m p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS)); p1.setBounds(80, Y, 800, 75); paths.add(p1); JTextArea tcpath = new JTextArea(description); tcpath.setWrapStyleWord(true); tcpath.setLineWrap(true); tcpath.setEditable(false); tcpath.setCursor(null); tcpath.setOpaque(false); tcpath.setFocusable(false); tcpath.setFont(new Font("Arial", Font.PLAIN, 12)); tcpath.setBackground(getBackground()); tcpath.setMaximumSize(new Dimension(170, 22)); tcpath.setPreferredSize(new Dimension(170, 22)); tcpath.setBorder(null); JPanel p11 = new JPanel(); p11.setBackground(Color.WHITE); p11.setLayout(new GridLayout()); p11.add(tcpath); p11.setMaximumSize(new Dimension(700, 18)); p11.setPreferredSize(new Dimension(700, 18)); textfield.setMaximumSize(new Dimension(340, 27)); textfield.setPreferredSize(new Dimension(340, 27)); textfield.setText(fieldtext); JButton b = null; if (withbutton) { b = new JButton("..."); if (!PermissionValidator.canChangeFWM()) { b.setEnabled(false); } b.setMaximumSize(new Dimension(50, 20)); b.setPreferredSize(new Dimension(50, 20)); if (actionlistener == null) { b.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent ev) { Container c; if (RunnerRepository.container != null) c = RunnerRepository.container.getParent(); else c = RunnerRepository.window; try { new MySftpBrowser(RunnerRepository.host, RunnerRepository.user, RunnerRepository.password, textfield, c, false); } catch (Exception e) { System.out.println("There was a problem in opening sftp browser!"); e.printStackTrace(); } } }); } else { b.addActionListener(actionlistener); b.setText("Save"); b.setMaximumSize(new Dimension(70, 20)); b.setPreferredSize(new Dimension(70, 20)); } } JPanel p12 = new JPanel(); p12.setBackground(Color.WHITE); p12.add(textfield); if (withbutton) p12.add(b); p12.setMaximumSize(new Dimension(700, 32)); p12.setPreferredSize(new Dimension(700, 32)); p1.add(p11); p1.add(p12); return p12; }
From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java
/** * Creates new form JTicketView/*w w w .j av a2 s. co m*/ */ public JRetailPanelTakeAway() { initComponents(); tnbbutton = new ThumbNailBuilderPopularItems(110, 57, "com/openbravo/images/bluetoit.png"); TextListener txtL; // cusName = (JTextField) m_jCboCustName.getEditor().getEditorComponent(); // cusPhoneNo= (JTextField) m_jCboContactNo.getEditor().getEditorComponent(); itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); m_jTxtItemCode.setFocusable(true); // m_jTxtCustomerId.setFocusable(true); txtL = new TextListener(); // m_jCreditAllowed.setVisible(false); // m_jCreditAllowed.setSelected(false); // cusPhoneNo.addFocusListener(txtL); //cusName.addFocusListener(txtL); itemName.addFocusListener(txtL); Action doMorething = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jPrice.setEnabled(true); // m_jPrice.setFocusable(true); m_jKeyFactory.setFocusable(true); m_jKeyFactory.setText(null); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { m_jKeyFactory.requestFocus(); } }); } }; // InputMap imap = m_jPrice.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK), "doMorething"); // m_jPrice.getActionMap().put("doMorething",doMorething); // Action doLastBill = new AbstractAction() { // public void actionPerformed(ActionEvent e) { // m_jLastBillActionPerformed(e); // stateToZero(); // } // }; // InputMap imapLastBill = m_jLastBill.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapLastBill.put(KeyStroke.getKeyStroke("F7"), "doLastBill"); // m_jLastBill.getActionMap().put("doLastBill",doLastBill); Action cashNoBill = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(3); // setPrinterOn(); } }; InputMap imapCashNoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashNoBill.put(KeyStroke.getKeyStroke("F1"), "cashNoBill"); m_jAction.getActionMap().put("cashNoBill", cashNoBill); // }; Action cashReceipt = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(2); } }; InputMap imapCashReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashReceipt.put(KeyStroke.getKeyStroke("F2"), "cashReceipt"); m_jAction.getActionMap().put("cashReceipt", cashReceipt); Action docashPrint = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(1); } }; InputMap imapCashPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashPrint.put(KeyStroke.getKeyStroke("F3"), "docashPrint"); m_jAction.getActionMap().put("docashPrint", docashPrint); Action doCardnobill = new AbstractAction() { public void actionPerformed(ActionEvent e) { //m_jCloseShiftActionPerformed(e); // cardPayment(1); } }; InputMap imapCardnoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCardnoBill.put(KeyStroke.getKeyStroke("F4"), "doCardnobill"); m_jAction.getActionMap().put("doCardnobill", doCardnobill); Action doNonChargablePrint = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { closeTicketNonChargable(m_oTicket, m_oTicketExt, m_aPaymentInfo); } catch (BasicException ex) { logger.info("exception in closeTicketNonChargable" + ex.getMessage()); Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } } }; InputMap imapNonChargablePrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapNonChargablePrint.put(KeyStroke.getKeyStroke("F7"), "doNonChargablePrint"); m_jAction.getActionMap().put("doNonChargablePrint", doNonChargablePrint); Action doCreditreceipt = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jCreditAmount.setText(Double.toString(m_oTicket.getTotal())); // // try { // closeCreditTicket(m_oTicket, m_oTicketExt, m_aPaymentInfo); // } catch (BasicException ex) { // Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); // } } }; InputMap imapCreditReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCreditReceipt.put(KeyStroke.getKeyStroke("F5"), "doCreditreceipt"); m_jAction.getActionMap().put("doCreditreceipt", doCreditreceipt); Action doHomeDeliveryNotPaid = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jHomeDelivery.setSelected(true); if (getEditSale() == "Edit") { // getServiceCharge("Y"); printPartialTotals(); try { closeTicketHomeDelivery(m_oTicket, m_oTicketExt, m_aPaymentInfo); } catch (BasicException ex) { logger.info("exception in closeTicketHomeDelivery" + ex.getMessage()); Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } } } }; InputMap imapCardPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCardPrint.put(KeyStroke.getKeyStroke("F6"), "doHomeDeliveryNotPaid"); m_jAction.getActionMap().put("doHomeDeliveryNotPaid", doHomeDeliveryNotPaid); Action doLogout = new AbstractAction() { public void actionPerformed(ActionEvent e) { m_jLogoutActionPerformed(e); } }; InputMap imapLog = m_jLogout.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapLog.put(KeyStroke.getKeyStroke("F12"), "doLogout"); m_jLogout.getActionMap().put("doLogout", doLogout); Action doupArrow = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jUpActionPerformed(e); } }; InputMap imapUpArrow = m_jPlus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapUpArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "doupArrow"); m_jPlus.getActionMap().put("doupArrow", doupArrow); // Action doCustomer = new AbstractAction() { // public void actionPerformed(ActionEvent e) { // //// m_jTxtCustomerId.setFocusable(true); // // // cusPhoneNo.setFocusable(true); // // cusName.setFocusable(true); // stateToBarcode(); // } // }; // InputMap imapCustomer= m_jTxtCustomerId.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapCustomer.put(KeyStroke.getKeyStroke("F8"), "doCustomer"); // m_jTxtCustomerId.getActionMap().put("doCustomer", // doCustomer); Action doItem = new AbstractAction() { public void actionPerformed(ActionEvent e) { itemName.setFocusable(true); m_jTxtItemCode.setFocusable(true); stateToItem(); } }; InputMap imapItem = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapItem.put(KeyStroke.getKeyStroke("F9"), "doItem"); m_jAction.getActionMap().put("doItem", doItem); // Action doHomeDelivery = new AbstractAction() { // public void actionPerformed(ActionEvent e) { //// m_jHomeDelivery.setFocusable(true); // // m_jHomeDelivery.setSelected(true); // // m_jHomeDeliveryActionPerformed(e); // // m_jTxtAdvance.setFocusable(true); // stateToHomeDelivery(); // } // }; // // InputMap imapHomeDelivery= m_jHomeDelivery.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapHomeDelivery.put(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.ALT_MASK), "doHomeDelivery"); // m_jHomeDelivery.getActionMap().put("doHomeDelivery", // doHomeDelivery); // Action doPayment = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jCash.setFocusable(true); // m_jCard.setFocusable(true); // m_jCheque.setFocusable(true); // m_jtxtChequeNo.setFocusable(true); // m_jFoodCoupon.setFocusable(true); // m_jVoucher.setFocusable(true); // m_jCreditAmount.setFocusable(true); stateToPayment(); } }; InputMap imapPayment = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapPayment.put(KeyStroke.getKeyStroke("F11"), "doPayment"); m_jAction.getActionMap().put("doPayment", doPayment); Action doDownpArrow = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jDownActionPerformed(e); } }; InputMap imapArrow = m_jMinus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "doDownpArrow"); m_jMinus.getActionMap().put("doDownpArrow", doDownpArrow); itemName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!itemName.getText().equals("") || !itemName.getText().equals(null)) { incProductByItemDetails(pdtId); // itemName.setText(""); // m_jCboItemName.setSelectedIndex(-1); ArrayList<String> itemCode = new ArrayList<String>(); ArrayList<String> itemName1 = new ArrayList<String>(); vItemName.removeAllElements(); try { productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails(); } catch (BasicException ex) { Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } for (ProductInfoExt product : productListDetails) { itemCode.add(product.getItemCode()); itemName1.add(product.getName()); } String[] productName = itemName1.toArray(new String[itemName1.size()]); for (int i = 0; i < itemName1.size(); i++) { vItemName.addElement(productName[i]); } itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); } else { pdtId = ""; ArrayList<String> itemCode = new ArrayList<String>(); ArrayList<String> itemName1 = new ArrayList<String>(); vItemName.removeAllElements(); try { productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails(); } catch (BasicException ex) { Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } for (ProductInfoExt product : productListDetails) { itemCode.add(product.getItemCode()); itemName1.add(product.getName()); } String[] productName = itemName1.toArray(new String[itemName1.size()]); for (int i = 0; i < itemName1.size(); i++) { vItemName.addElement(productName[i]); } itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); } } }); }
From source file:dk.dma.epd.ship.EPDShip.java
private void makeKeyBindings() { JPanel content = (JPanel) mainFrame.getContentPane(); InputMap inputMap = content.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); @SuppressWarnings("serial") Action zoomIn = new AbstractAction() { @Override/*from www . j a v a 2s . c o m*/ public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().doZoom(0.5f); } }; @SuppressWarnings("serial") Action zoomOut = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().doZoom(2f); } }; @SuppressWarnings("serial") Action centreOnShip = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.saveCentreOnShip(); } }; @SuppressWarnings("serial") Action newRoute = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { // newRouteBtn.requestFocusInWindow(); mainFrame.getTopPanel().activateNewRouteButton(); } }; @SuppressWarnings("serial") Action routes = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { RouteManagerDialog routeManagerDialog = new RouteManagerDialog(mainFrame); routeManagerDialog.setVisible(true); } }; @SuppressWarnings("serial") Action ais = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getTopPanel().getAisDialog().setVisible(true); } }; @SuppressWarnings("serial") Action panUp = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().pan(1); } }; @SuppressWarnings("serial") Action panDown = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().pan(2); } }; @SuppressWarnings("serial") Action panLeft = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().pan(3); } }; @SuppressWarnings("serial") Action panRight = new AbstractAction() { @Override public void actionPerformed(ActionEvent actionEvent) { mainFrame.getChartPanel().pan(4); } }; inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, 0), "ZoomIn"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, 0), "ZoomOut"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, 0), "centre"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP, 0), "panUp"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN, 0), "panDown"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT, 0), "panLeft"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT, 0), "panRight"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_KP_UP, 0), "panUp"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_KP_DOWN, 0), "panDown"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_KP_LEFT, 0), "panLeft"); inputMap.put(KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_KP_RIGHT, 0), "panRight"); inputMap.put(KeyStroke.getKeyStroke("control N"), "newRoute"); inputMap.put(KeyStroke.getKeyStroke("control R"), "routes"); inputMap.put(KeyStroke.getKeyStroke("control M"), "msi-nm"); inputMap.put(KeyStroke.getKeyStroke("control A"), "ais"); content.getActionMap().put("ZoomOut", zoomOut); content.getActionMap().put("ZoomIn", zoomIn); content.getActionMap().put("centre", centreOnShip); content.getActionMap().put("newRoute", newRoute); content.getActionMap().put("routes", routes); content.getActionMap().put("ais", ais); content.getActionMap().put("panUp", panUp); content.getActionMap().put("panDown", panDown); content.getActionMap().put("panLeft", panLeft); content.getActionMap().put("panRight", panRight); }
From source file:org.openconcerto.task.TodoListPanel.java
void initPopUp() { TablePopupMouseListener.add(this.t, new ITransformer<MouseEvent, JPopupMenu>() { @Override/*from w w w.j av a2 s. co m*/ public JPopupMenu transformChecked(MouseEvent evt) { final JTable table = (JTable) evt.getSource(); final int modelIndex = TodoListPanel.this.sorter.modelIndex(table.getSelectedRow()); final JPopupMenu res = new JPopupMenu(); // Avancer d'un jour Action act = new AbstractAction() { public void actionPerformed(ActionEvent e) { final TodoListElement element = TodoListPanel.this.model.getTaskAtRow(modelIndex); if (element != null) { final Date ts = element.getExpectedDate(); final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(ts.getTime()); cal.add(Calendar.DAY_OF_YEAR, 1); SwingUtilities.invokeLater(new Runnable() { public void run() { ts.setTime(cal.getTimeInMillis()); element.setExpectedDate(ts); element.commitChangesAndWait(); table.repaint(); } }); } } }; act.putValue(Action.NAME, TM.tr("moveOneDay")); res.add(act); // Marquer comme ralis act = new AbstractAction() { public void actionPerformed(ActionEvent e) { TodoListElement element = TodoListPanel.this.model.getTaskAtRow(modelIndex); if (element != null) { element.setDone(true); element.commitChangesAndWait(); table.repaint(); } } }; act.putValue(Action.NAME, TM.tr("markDone")); res.add(act); // Suppression act = new AbstractAction() { public void actionPerformed(ActionEvent e) { TodoListPanel.this.model.deleteTaskAtIndex(modelIndex); table.repaint(); } }; act.putValue(Action.NAME, TM.tr("delete")); res.add(act); final TodoListElement element = TodoListPanel.this.model.getTaskAtRow(modelIndex); SQLRowValues rowTache = element.getRowValues(); List<AbstractAction> actions = TacheActionManager.getInstance().getActionsForTaskRow(rowTache); for (AbstractAction abstractAction : actions) { res.add(abstractAction); } return res; } }); }
From source file:userinterface.graph.Histogram.java
/** * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram * to plot data on//from w ww. jav a2s .co m * * @param defaultSeriesName * @param handler instance of {@link GUIGraphHandler} * @param minVal the min value in data cache * @param maxVal the max value in data cache * @return Either a new instance of a Histogram or an old one depending on what the user selects */ public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler, double minVal, double maxVal) { // make sure that the probabilities are valid if (maxVal > 1.0) maxVal = 1.0; if (minVal < 0.0) minVal = 0.0; // set properties for the dialog JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true); dialog.setLayout(new BorderLayout()); JPanel p1 = new JPanel(new FlowLayout()); p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Number of buckets")); JPanel p2 = new JPanel(new FlowLayout()); p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1)); buckets.setToolTipText("Select the number of buckets for this Histogram"); // provides the ability to select a new or an old histogram to plot the series on JTextField seriesName = new JTextField(defaultSeriesName); JRadioButton newSeries = new JRadioButton("New Histogram"); JRadioButton existing = new JRadioButton("Existing Histogram"); newSeries.setSelected(true); JPanel seriesSelectPanel = new JPanel(); seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS)); JPanel seriesTypeSelect = new JPanel(new FlowLayout()); JPanel seriesOptionsPanel = new JPanel(new FlowLayout()); seriesTypeSelect.add(newSeries); seriesTypeSelect.add(existing); JComboBox<String> seriesOptions = new JComboBox<>(); seriesOptionsPanel.add(seriesOptions); seriesSelectPanel.add(seriesTypeSelect); seriesSelectPanel.add(seriesOptionsPanel); seriesSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to")); // provides ability to select the min/max range of the plot JLabel minValsLabel = new JLabel("Min range:"); JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01)); minVals.setToolTipText("Does not allow value more than the min value in the probabilities"); JLabel maxValsLabel = new JLabel("Max range:"); JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01)); maxVals.setToolTipText("Does not allow value less than the max value in the probabilities"); JPanel minMaxPanel = new JPanel(); minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS)); JPanel leftValsPanel = new JPanel(new BorderLayout()); JPanel rightValsPanel = new JPanel(new BorderLayout()); minMaxPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range")); leftValsPanel.add(minValsLabel, BorderLayout.WEST); leftValsPanel.add(minVals, BorderLayout.CENTER); rightValsPanel.add(maxValsLabel, BorderLayout.WEST); rightValsPanel.add(maxVals, BorderLayout.CENTER); minMaxPanel.add(leftValsPanel); minMaxPanel.add(rightValsPanel); // fill the old histograms in the property dialog boolean found = false; for (int i = 0; i < handler.getNumModels(); i++) { if (handler.getModel(i) instanceof Histogram) { seriesOptions.addItem(handler.getGraphName(i)); found = true; } } existing.setEnabled(found); seriesOptions.setEnabled(false); // the bottom panel JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton("Plot"); JButton cancel = new JButton("Cancel"); // bind keyboard keys to plot and cancel buttons to improve usability ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = -7324877661936685228L; @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ok"); cancel.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = 2642213543774356676L; @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); //Action listener for the new series radio button newSeries.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newSeries.isSelected()) { existing.setSelected(false); seriesOptions.setEnabled(false); buckets.setEnabled(true); buckets.setToolTipText("Select the number of buckets for this Histogram"); minVals.setEnabled(true); maxVals.setEnabled(true); } } }); //Action listener for the existing series radio button existing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existing.isSelected()) { newSeries.setSelected(false); seriesOptions.setEnabled(true); buckets.setEnabled(false); minVals.setEnabled(false); maxVals.setEnabled(false); buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram"); } } }); //Action listener for the plot button ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); if (newSeries.isSelected()) { hist = new Histogram(); hist.setNumOfBuckets((int) buckets.getValue()); hist.setIsNew(true); } else if (existing.isSelected()) { String HistName = (String) seriesOptions.getSelectedItem(); hist = (Histogram) handler.getModel(HistName); hist.setIsNew(false); } key = hist.addSeries(seriesName.getText()); if (minVals.isEnabled() && maxVals.isEnabled()) { hist.setMinProb((double) minVals.getValue()); hist.setMaxProb((double) maxVals.getValue()); } } }); //Action listener for the cancel button cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); hist = null; } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { hist = null; } }); p1.add(buckets, BorderLayout.CENTER); p2.add(seriesName, BorderLayout.CENTER); options.add(ok); options.add(cancel); // add everything to the main panel of the dialog JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(seriesSelectPanel); mainPanel.add(p1); mainPanel.add(p2); mainPanel.add(minMaxPanel); // add main panel to the dialog dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(options, BorderLayout.SOUTH); // set dialog properties dialog.setSize(320, 290); dialog.setLocationRelativeTo(GUIPrism.getGUI()); dialog.setVisible(true); // return the user selected Histogram with the properties set return new Pair<Histogram, SeriesKey>(hist, key); }
From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java
private void setHotkeyModifiers() { try {//from w w w . j av a 2 s .co m GUIUtil.enableDisposeOnEscapeKey(shortcutManager, "Close window (and discard)", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { setCanceled(true); } }); // ALT+K to show the shortcut map shortcutManager.registerShowKeysKey(); // ALT+S for Select shortcutManager.registerKeyboardShortcut( KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyboardShortcutManager.getToolbarShortcutMask()), "Select/Save selected title", new AbstractAction() { public void actionPerformed(ActionEvent ae) { buttonSelect.doClick(); } }, buttonSelect); // ALT+C for Cancel shortcutManager.registerKeyboardShortcut( KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyboardShortcutManager.getToolbarShortcutMask()), "Cancel (Discard) this movie", new AbstractAction() { public void actionPerformed(ActionEvent ae) { buttonCancel.doClick(); } }, buttonCancel); // ALT+F for search field focus shortcutManager.registerKeyboardShortcut( KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyboardShortcutManager.getToolbarShortcutMask()), "Give search field focus or perform search if already focused.", new AbstractAction() { public void actionPerformed(ActionEvent ae) { if (!searchStringField.hasFocus()) { searchStringField.requestFocusInWindow(); } else { buttonSearch.doClick(); } } }, buttonSearch); shortcutManager.setKeysToolTipComponent(panelMoviesList); } catch (Exception e) { log.warn("Exception:" + e.getMessage(), e); } }
From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java
public void startup() { if (dialog != null) { dialog.toFront();//from ww w . ja v a 2 s . co m return; } NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED); NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED); NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS); NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT); NodeList.COLUMN_DETAILS = TextUtils.getText(PLUGINS_TIME_LIST_XML_DETAILS); NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE); NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES); dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */); String windowTitle; if (showAllNodes) { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES; } else { windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE; } dialog.setTitle(TextUtils.getText(windowTitle)); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); final WindowAdapter windowListener = new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { mFilterTextSearchField.getEditor().selectAll(); } @Override public void windowClosing(final WindowEvent event) { disposeDialog(); } }; dialog.addWindowListener(windowListener); dialog.addWindowFocusListener(windowListener); UITools.addEscapeActionToDialog(dialog, new AbstractAction() { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }); final Container contentPane = dialog.getContentPane(); final GridBagLayout gbl = new GridBagLayout(); contentPane.setLayout(gbl); final GridBagConstraints layoutConstraints = new GridBagConstraints(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.weightx = 0.0; layoutConstraints.weighty = 0.0; layoutConstraints.anchor = GridBagConstraints.WEST; layoutConstraints.fill = GridBagConstraints.HORIZONTAL; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints); layoutConstraints.gridwidth = 1; layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(matchCase, layoutConstraints); layoutConstraints.gridx++; contentPane.add(Box.createHorizontalStrut(40), layoutConstraints); layoutConstraints.gridx++; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInFind, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints); layoutConstraints.gridy++; layoutConstraints.weightx = 0.0; layoutConstraints.gridwidth = 1; contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints); layoutConstraints.gridx = 5; contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints); layoutConstraints.gridx++; contentPane.add(useRegexInReplace, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.weightx = 1.0; layoutConstraints.gridwidth = GridBagConstraints.REMAINDER; layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints); dateRenderer = new DateRenderer(); textRenderer = new TextRenderer(); iconsRenderer = new IconsRenderer(); tableView = new FlatNodeTable(); tableView.addKeyListener(new FlatNodeTableKeyListener()); tableView.addMouseListener(new FlatNodeTableMouseAdapter()); tableView.getTableHeader().setReorderingAllowed(false); tableModel = updateModel(); mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(tableModel, new int[] { NodeList.NODE_TEXT_COLUMN, NodeList.NODE_DETAILS_COLUMN, NodeList.NODE_NOTES_COLUMN }); sorter = new TableSorter(mFlatNodeTableFilterModel); tableView.setModel(sorter); sorter.setTableHeader(tableView.getTableHeader()); sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR); sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR); sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING); final JScrollPane pane = new JScrollPane(tableView); UITools.setScrollbarIncrement(pane); layoutConstraints.gridy++; GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone(); tableConstraints.weightx = 1; tableConstraints.weighty = 10; tableConstraints.fill = GridBagConstraints.BOTH; contentPane.add(pane, tableConstraints); mTreeLabel = new JLabel(); layoutConstraints.gridy++; GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone(); treeConstraints.fill = GridBagConstraints.BOTH; @SuppressWarnings("serial") JScrollPane scrollPane = new JScrollPane(mTreeLabel) { @Override public boolean isValidateRoot() { return false; } }; contentPane.add(scrollPane, treeConstraints); final AbstractAction exportAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Export")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { exportSelectedRowsAndClose(); } }; final JButton exportButton = new JButton(exportAction); final AbstractAction replaceAllAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(false)); } }; final JButton replaceAllButton = new JButton(replaceAllAction); final AbstractAction replaceSelectedAction = new AbstractAction( TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { replace(new HolderAccessor(true)); } }; final JButton replaceSelectedButton = new JButton(replaceSelectedAction); final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { selectSelectedRows(); } }; final JButton gotoButton = new JButton(gotoAction); final AbstractAction disposeAction = new AbstractAction( TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) { /** * */ private static final long serialVersionUID = 1L; public void actionPerformed(final ActionEvent arg0) { disposeDialog(); } }; final JButton cancelButton = new JButton(disposeAction); /* Initial State */ gotoAction.setEnabled(false); exportAction.setEnabled(false); replaceSelectedAction.setEnabled(false); final Box bar = Box.createHorizontalBox(); bar.add(Box.createHorizontalGlue()); bar.add(cancelButton); bar.add(exportButton); bar.add(replaceAllButton); bar.add(replaceSelectedButton); bar.add(gotoButton); bar.add(Box.createHorizontalGlue()); layoutConstraints.gridy++; contentPane.add(/* new JScrollPane */(bar), layoutConstraints); final JMenuBar menuBar = new JMenuBar(); final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions")); final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction, replaceAllAction, exportAction, disposeAction }; for (int i = 0; i < actionList.length; i++) { final AbstractAction action = actionList[i]; final JMenuItem item = menu.add(action); item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE)); } menuBar.add(menu); dialog.setJMenuBar(menuBar); final ListSelectionModel rowSM = tableView.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); final boolean enable = !(lsm.isSelectionEmpty()); replaceSelectedAction.setEnabled(enable); gotoAction.setEnabled(enable); exportAction.setEnabled(enable); } }); rowSM.addListSelectionListener(new ListSelectionListener() { String getNodeText(final NodeModel node) { return TextController.getController().getShortText(node) + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode()))); } public void valueChanged(final ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { mTreeLabel.setText(""); return; } final int selectedRow = lsm.getLeadSelectionIndex(); final NodeModel mindMapNode = getMindMapNode(selectedRow); mTreeLabel.setText(getNodeText(mindMapNode)); } }); final String marshalled = ResourceController.getResourceController() .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY); final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog); final WindowConfigurationStorage storage = result; if (storage != null) { tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); int column = 0; for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage) .getListTimeWindowColumnSettingList()) { tableView.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth()); sorter.setSortingStatus(column, setting.getColumnSorting()); column++; } } mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(), matchCase.isSelected(), useRegexInFind.isSelected()); dialog.setVisible(true); }
From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.UploadJob.java
private void checkDigestStatus() { printDebugInfo("Check digest status"); if (theDigest == null) { return;/*ww w . j a va 2s . c o m*/ } if (theDigest.getFinished()) { isCopyFinished = true; boolean allSucceeded = true; StringBuilder errorMessage = new StringBuilder(); errorMessage.append("The following files were not copied successfully:"); for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { if (!status.getFileCopyIsIdentical()) { allSucceeded = false; errorMessage.append("\n"); errorMessage.append(status.getFSO().getFullPath()); } } if (allSucceeded) { for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { FileSystemObject fso = status.getFSO(); fso.setFile(fso.getDestinationFile()); } } else { for (FileStatus status : theDigest.getFileStatii()) { File parent = status.getFSO().getDestinationFile().getParentFile(); LOG.debug("Deleting file " + status.getFSO().getDestinationFile().getAbsolutePath()); status.getFSO().getDestinationFile().delete(); FileUtils.deleteEmptyDirectoryRecursive(parent); } } if (theJobState == JobState.Requested) { theJobState = JobState.Pending; } saveJob(false); if (allSucceeded) { for (ChecksumDigest.FileStatus status : theDigest.getFileStatii()) { if (status.getFileCopyIsIdentical()) { FileSystemObject fso = status.getFSO(); fso.setFile(fso.getDestinationFile()); } else { allSucceeded = false; errorMessage.append("\n"); errorMessage.append(status.getFSO().getFullPath()); } } } else { jobDetailStatus = errorMessage.toString(); } } else { Action checkDigestStatusAction = new AbstractAction() { private static final long serialVersionUID = 5562669711772031634L; public void actionPerformed(ActionEvent e) { Timer t = (Timer) e.getSource(); t.stop(); checkDigestStatus(); } }; new Timer(500, checkDigestStatusAction).start(); } }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private void addAllKeyCombinationActions() { addKeyCombinationAction("Resets the tool", new AbstractAction() { @Override/*www . j av a2s. c o m*/ public void actionPerformed(ActionEvent e) { resetButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Outputs current design to console", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println(getDesign().toString()); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK)); /* FROM THE OFFLINE ALGORITHM EXECUTION */ addKeyCombinationAction("Execute algorithm", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { executionPane.doClickInExecutionButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK)); /* From the TOPOLOGY PANEL */ addKeyCombinationAction("Load design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Save design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.saveDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom in", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomIn(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom out", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomOut(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom all", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Take snapshot", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.takeSnapshot(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Load traffic demands", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadTrafficDemands(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)); /* FROM REPORT */ addKeyCombinationAction("Close selected report", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { int tab = reportPane.getReportContainer().getSelectedIndex(); if (tab == -1) return; reportPane.getReportContainer().remove(tab); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Close all reports", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { reportPane.getReportContainer().removeAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); /* Online simulation */ addKeyCombinationAction("Run simulation", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (onlineSimulationPane.isRunButtonEnabled()) onlineSimulationPane.runSimulation(false); } catch (Net2PlanException ex) { if (ErrorHandling.isDebugEnabled()) ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation"); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog("An error happened"); } } }, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK)); // Windows addKeyCombinationAction("Show control window", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WindowController.showTablesWindow(true); } }, KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK + ActionEvent.SHIFT_MASK)); viewEditTopTables.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); viewEditTopTables.setActionMap(this.getActionMap()); reportPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); reportPane.setActionMap(this.getActionMap()); executionPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); executionPane.setActionMap(this.getActionMap()); onlineSimulationPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); onlineSimulationPane.setActionMap(this.getActionMap()); whatIfAnalysisPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); whatIfAnalysisPane.setActionMap(this.getActionMap()); }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Constructor with FormView definition. * @param view the definition of the view * @param altView indicates which AltViewIFace we will be using * @param mvParent the mvParent mulitview * @param formValidator the form's formValidator * @param options the options needed for creating the form * @param cellName the name of the outer form's cell for this view (subview) * @param bgColor bg color it should use *///w w w. ja v a 2s . co m public FormViewObj(final ViewIFace view, final AltViewIFace altView, final MultiView mvParent, final FormValidator formValidator, final int options, final String cellName, final Class<?> dataClass, final Color bgColor) { this.view = view; this.altView = altView; this.mvParent = mvParent; this.cellName = cellName; this.dataClass = dataClass; this.bgColor = bgColor; businessRules = view.createBusinessRule(); //XXX bug #9497: isEditing = altView.getMode() == AltViewIFace.CreationMode.EDIT && MultiView.isOptionOn(options, MultiView.IS_EDITTING); isEditing = altView.getMode() == AltViewIFace.CreationMode.EDIT; boolean addSearch = mvParent != null && MultiView.isOptionOn(mvParent.getOptions(), MultiView.ADD_SEARCH_BTN); if (addSearch) { isEditing = false; } this.formViewDef = (FormViewDef) altView.getViewDef(); // Figure columns try { JPanel panel = useDebugForm ? new FormDebugPanel() : (restrictablePanel = new RestrictablePanel()); formLayout = new FormLayout(formViewDef.getColumnDef(), formViewDef.getRowDef()); builder = new PanelBuilder(formLayout, panel); } catch (java.lang.NumberFormatException ex) { String msg = "Error in row or column definition for form: `" + view.getName() + "`\n" + ex.getMessage(); UIRegistry.showError(msg); return; } mainComp = new JPanel(new BorderLayout()); mainComp.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); if (mvParent == null) { builder.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); } if (bgColor != null) { builder.getPanel().setBackground(bgColor); } this.options = options; boolean isSingleObj = MultiView.isOptionOn(options, MultiView.IS_SINGLE_OBJ); boolean createResultSetController = MultiView.isOptionOn(options, MultiView.RESULTSET_CONTROLLER); boolean hideResultSetController = MultiView.isOptionOn(options, MultiView.HIDE_RESULTSET_CONTROLLER); boolean createViewSwitcher = MultiView.isOptionOn(options, MultiView.VIEW_SWITCHER); //boolean isNewObject = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT); boolean hideSaveBtn = MultiView.isOptionOn(options, MultiView.HIDE_SAVE_BTN); isNewlyCreatedDataObj = MultiView.isOptionOn(options, MultiView.IS_NEW_OBJECT); if (formValidator != null) { formValidator.setNewObj(isNewlyCreatedDataObj); } //MultiView.printCreateOptions("Creating Form "+altView.getName(), options); setValidator(formValidator); scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting", "scrdateformat"); AppPreferences.getRemote().addChangeListener("ui.formatting.viewfieldcolor", this); boolean addController = mvParent != null && view.getAltViews().size() > 1; // See if we need to add a Selector ComboBox isSelectorForm = StringUtils.isNotEmpty(view.getSelectorName()); boolean addSelectorCBX = false; //log.debug(altView.getName()+" "+altView.getMode()+" "+AltViewIFace.CreationMode.EDIT); //if (isSelectorForm && isNewObject && altView.getMode() == AltViewIFace.CreationMode.EDIT) if (isSelectorForm && altView.getMode() == AltViewIFace.CreationMode.EDIT) { addSelectorCBX = true; } List<JComponent> comps = new ArrayList<JComponent>(); int y = 1; // Here we create the JComboBox that enables the user to switch between forms // when creating a new object if (addSelectorCBX) { Vector<AltViewIFace> cbxList = new Vector<AltViewIFace>(); cbxList.add(altView); for (AltViewIFace av : view.getAltViews()) { if (av != altView && av.getMode() == AltViewIFace.CreationMode.EDIT) { cbxList.add(av); } } JPanel p = new JPanel(new BorderLayout()); p.setOpaque(false); p.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); selectorCBX = createComboBox(cbxList); selectorCBX.setRenderer(new SelectorCellRenderer()); p.add(selectorCBX, BorderLayout.WEST); mainComp.add(p, BorderLayout.NORTH); if (mvParent != null) { selectorCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { doSelectorWasSelected(mvParent, ev); } }); } y += 2; } // // We will add the switchable UI if we are parented to a MultiView and have multiple AltViews // if (addController) // this says we are the "root" form { boolean saveWasAdded = false; // We want it on the left side of other buttons // so wee need to add it before the Save button JComponent valInfoBtn = createValidationIndicator(getUIComponent(), formValidator); if (valInfoBtn != null) { comps.add(valInfoBtn); } if (createViewSwitcher) // This is passed in outside { // Now we have a Special case that when when there are only two AltViews and // they differ only by Edit & View we hide the switching UI unless we are the root MultiView. // This way when switching the Root View all the other views switch // (This is because they were created that way. It also makes no sense that while in "View" mode // you would want to switch an individual subview to a differe "mode" view than the root). altViewsList = new Vector<AltViewIFace>(); // This will return null if it isn't suppose to have a switcher switcherUI = createMenuSwitcherPanel(mvParent, view, altView, altViewsList, restrictablePanel, cellName, dataClass); Action action = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (switcherUI != null && switcherUI.getSwitcherAL() != null) { switcherUI.getSwitcherAL().actionPerformed(e); } } }; if (restrictablePanel != null) { restrictablePanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke("control E"), actionName); restrictablePanel.getActionMap().put(actionName, action); } if (altViewsList.size() > 0) { if (altView.getMode() == AltViewIFace.CreationMode.EDIT && mvParent != null && mvParent.isTopLevel()) { addSaveBtn(); comps.add(saveControl); saveWasAdded = true; } if (switcherUI != null) { comps.add(switcherUI); } } // rods - 07/21/08 for disabling the switcher when the form is invalid if (formValidator != null && switcherUI != null) { formValidator.addEnableItem(switcherUI, FormValidator.EnableType.ValidNotNew); } } if (!saveWasAdded && altView.getMode() == AltViewIFace.CreationMode.EDIT && mvParent != null && mvParent.isTopLevel() && !hideSaveBtn) { addSaveBtn(); comps.add(saveControl); } } // This here because the Search mode shouldn't be combined with other modes if (altView.getMode() == AltViewIFace.CreationMode.SEARCH) { if (!hideSaveBtn) { saveControl = createButton(UIRegistry.getResourceString("SEARCH"), IconManager.getImage("Search", IconManager.IconSize.Std16));/* { public void setEnabled(boolean enabled) { System.err.println("Save: "+enabled); super.setEnabled(enabled); } };*/ saveControl.setOpaque(false); comps.add(saveControl); addSaveActionMap(saveControl); } } if (ViewFactory.isFormTransparent()) { builder.getPanel().setOpaque(false); } mainComp.add(builder.getPanel(), BorderLayout.CENTER); if (comps.size() > 0 || addController || createResultSetController) { controlPanel = new ControlBarPanel(bgColor); controlPanel.addComponents(comps, false); // false -> right side if (ViewFactory.isFormTransparent()) { controlPanel.setOpaque(false); } mainComp.add(controlPanel, BorderLayout.SOUTH); } if (createResultSetController) { addRSController(addSearch); if (hideResultSetController) { rsController.getPanel().setVisible(false); } if (addSearch) { DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByClassName(view.getClassName()); if (tblInfo != null) { searchName = tblInfo.getSearchDialog(); if (StringUtils.isEmpty(searchName)) { searchName = ""; // Note not null but empty tells it to disable the search btn log.error("The Search Dialog Name is empty or missing for class[" + view.getClassName() + "]"); } } else { log.error("Couldn't find TableInfo for class[" + view.getClassName() + "]"); } if (rsController.getSearchRecBtn() != null) { rsController.getSearchRecBtn().setEnabled(true); rsController.getSearchRecBtn().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearch(); } }); } } } else if (isSingleObj) { createAddDelSearchPanel(); } if (true) { builder.getPanel().addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showContextMenu(e); } @Override public void mouseReleased(MouseEvent e) { showContextMenu(e); } @Override public void mouseClicked(MouseEvent e) { //FormViewObj.this.listFieldChanges(); } }); } if (rsController != null) { rsController.setNewObj(isNewlyCreatedDataObj); } isBuildValid = true; isAutoNumberOn = AppPreferences.getLocalPrefs().getBoolean(AUTO_NUM, true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateAutoNumberFieldState(); } }); }