List of usage examples for javax.swing JMenuItem setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:corelyzer.ui.CorelyzerApp.java
public void mouseReleased(final MouseEvent e) { // From JDK Doc // Note: Popup menus are triggered differently on different systems. // Therefore, isPopupTrigger should be checked in both mousePressed and // mouseReleased for proper cross-platform functionality. Point p = e.getPoint();//from ww w .ja va 2 s . c o m Object actionSource = e.getSource(); if (actionSource instanceof JList) { // find the index of the clicked item in the JList int index = ((JList) e.getSource()).locationToIndex(e.getPoint()); if (index < 0) { return; } // show our popup menu if it was a right/ctrl-click if (e.isPopupTrigger()) { if (actionSource.equals(sessionList)) { Session s = (Session) sessionList.getSelectedValue(); JMenuItem t; // Show label switching if (s == null) { return; } String l = s.isShow() ? "Hide" : "Show"; t = (JMenuItem) sessionPopupMenu.getComponent(0); t.setText(l); sessionPopupMenu.show(e.getComponent(), p.x, p.y); } else if (actionSource.equals(trackList)) { ((JList) e.getSource()).setSelectedIndex(index); // Update context-aware show/hide TrackSceneNode t = (TrackSceneNode) trackList.getSelectedValue(); if ((t != null) && (t.getId() >= 0)) { boolean isShown = SceneGraph.getTrackShow(t.getId()); String label = isShown ? "Hide" : "Show"; ((JMenuItem) trackPopupMenu.getComponent(0)).setText(label); } trackPopupMenu.show(e.getComponent(), p.x, p.y); } else if (actionSource.equals(sectionList)) { int[] rows = getSectionList().getSelectedIndices(); JPopupMenu menu = sectionListPopupMenu(rows); menu.show(e.getComponent(), p.x, p.y); } else if (actionSource.equals(dataFileList)) { ((JList) e.getSource()).setSelectedIndex(index); dataPopupMenu.show(e.getComponent(), p.x, p.y); } } } }
From source file:es.emergya.ui.gis.FleetControlMapViewer.java
@Override protected JPopupMenu getContextMenu() { JPopupMenu menu = new JPopupMenu(); menu.setBackground(Color.decode("#E8EDF6")); // Ttulo//from ww w.j av a2s .com final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico")); titulo.setFont(LogicConstants.deriveBoldFont(10.0f)); titulo.setBackground(Color.decode("#A4A4A4")); titulo.setFocusable(false); menu.add(titulo); menu.addSeparator(); // Actualizar posicin final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P); gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps")); menu.add(gps); gps.addActionListener(this); gps.setEnabled(false); menu.addSeparator(); // Mostrar ms cercanos final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M); mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano")); mmc.addActionListener(this); menu.add(mmc); // Centrar aqui final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C); cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar")); cent.addActionListener(this); menu.add(cent); // Nueva Incidencia final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I); newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence")); newIncidence.addActionListener(this); menu.add(newIncidence); // Calcular ruta desde aqui final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D); from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta")); from.addActionListener(this); menu.add(from); // Calcular ruta hasta aqui final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H); to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta")); to.addActionListener(this); menu.add(to); menu.addSeparator(); // Ver ficha [recurso / incidencia] final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F); summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha")); summary.addActionListener(this); menu.add(summary); summary.setEnabled(false); menu.addPopupMenuListener(new PopupMenuListener() { @SuppressWarnings("unchecked") @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent; gps.setEnabled(false); summary.setEnabled(false); titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico")); menuObjective = null; Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY()); for (Layer l : mapView.getAllLayers()) { // por cada capa... if (l instanceof MarkerLayer) { // ...de marcadores for (Marker marker : ((MarkerLayer) l).data) { // miramos // los // marcadores if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si // estamos // pinchando // en uno CustomMarker m = (CustomMarker) marker; log.trace("Hemos pinchado en " + marker); switch (m.getType()) { case RESOURCE: Recurso r = (Recurso) m.getObject(); log.trace("Es un recurso: " + r); if (r != null) { menuObjective = r; if (r.getPatrullas() != null) { titulo.setText( i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla", r.getIdentificador(), r.getPatrullas())); } else { titulo.setText(r.getIdentificador()); } gps.setEnabled(true); summary.setEnabled(true); } break; case INCIDENCE: Incidencia i = (Incidencia) m.getObject(); log.trace("Es una incidencia: " + i); if (i != null) { menuObjective = i; titulo.setText(i.getTitulo()); gps.setEnabled(false); summary.setEnabled(true); } break; case UNKNOWN: log.trace("Hemos pinchado en un marcador desconocido"); break; } } } } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); return menu; }
From source file:com.maxl.java.amikodesk.AMiKoDesk.java
private static void createAndShowFullGUI() { // Create and setup window final JFrame jframe = new JFrame(Constants.APP_NAME); jframe.setName(Constants.APP_NAME + ".main"); int min_width = CML_OPT_WIDTH; int min_height = CML_OPT_HEIGHT; jframe.setPreferredSize(new Dimension(min_width, min_height)); jframe.setMinimumSize(new Dimension(min_width, min_height)); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - min_width) / 2; int y = (screen.height - min_height) / 2; jframe.setBounds(x, y, min_width, min_height); // Set application icon if (Utilities.appCustomization().equals("ywesee")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("desitin")) { ImageIcon img = new ImageIcon(Constants.DESITIN_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("meddrugs")) { ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("zurrose")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); }/*from w ww . ja va 2 s.co m*/ // ------ Setup menubar ------ JMenuBar menu_bar = new JMenuBar(); // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right! // -- Menu "Datei" -- JMenu datei_menu = new JMenu("Datei"); if (Utilities.appLanguage().equals("fr")) datei_menu.setText("Fichier"); menu_bar.add(datei_menu); JMenuItem print_item = new JMenuItem("Drucken..."); JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "..."); JMenuItem quit_item = new JMenuItem("Beenden"); if (Utilities.appLanguage().equals("fr")) { print_item.setText("Imprimer"); quit_item.setText("Terminer"); } datei_menu.add(print_item); datei_menu.addSeparator(); datei_menu.add(settings_item); datei_menu.addSeparator(); datei_menu.add(quit_item); // -- Menu "Aktualisieren" -- JMenu update_menu = new JMenu("Aktualisieren"); if (Utilities.appLanguage().equals("fr")) update_menu.setText("Mise jour"); menu_bar.add(update_menu); final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei..."); update_menu.add(updatedb_item); update_menu.add(choosedb_item); if (Utilities.appLanguage().equals("fr")) { updatedb_item.setText("Tlcharger la banque de donnes..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); choosedb_item.setText("Ajourner la banque de donnes..."); } // -- Menu "Hilfe" -- JMenu hilfe_menu = new JMenu("Hilfe"); if (Utilities.appLanguage().equals("fr")) hilfe_menu.setText("Aide"); menu_bar.add(hilfe_menu); JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "..."); JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet"); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs im Internet"); JMenuItem report_item = new JMenuItem("Error Report..."); JMenuItem contact_item = new JMenuItem("Kontakt..."); if (Utilities.appLanguage().equals("fr")) { // Extrawunsch med-drugs if (Utilities.appCustomization().equals("meddrugs")) about_item.setText(Constants.APP_NAME); else about_item.setText("A propos de " + Constants.APP_NAME + "..."); contact_item.setText("Contact..."); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs sur Internet"); else ywesee_item.setText(Constants.APP_NAME + " sur Internet"); report_item.setText("Rapport d'erreur..."); } hilfe_menu.add(about_item); hilfe_menu.add(ywesee_item); hilfe_menu.addSeparator(); hilfe_menu.add(report_item); hilfe_menu.addSeparator(); hilfe_menu.add(contact_item); // Menu "Abonnieren" (only for ywesee) JMenu subscribe_menu = new JMenu("Abonnieren"); if (Utilities.appLanguage().equals("fr")) subscribe_menu.setText("Abonnement"); if (Utilities.appCustomization().equals("ywesee")) { menu_bar.add(subscribe_menu); } jframe.setJMenuBar(menu_bar); // ------ Setup toolbar ------ JToolBar toolBar = new JToolBar("Database"); toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64)); final JToggleButton selectAipsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png")); final JToggleButton selectFavoritesButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png")); final JToggleButton selectInteractionsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png")); final JToggleButton selectShoppingCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png")); final JToggleButton selectComparisonCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png")); final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton, selectShoppingCartButton, selectComparisonCartButton }; if (Utilities.appLanguage().equals("de")) { setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } else if (Utilities.appLanguage().equals("fr")) { setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } // Add to toolbar and set up toolBar.setBackground(m_toolbar_bg); toolBar.add(selectAipsButton); toolBar.addSeparator(); toolBar.add(selectFavoritesButton); toolBar.addSeparator(); toolBar.add(selectInteractionsButton); if (!Utilities.appCustomization().equals("zurrose")) { toolBar.addSeparator(); toolBar.add(selectShoppingCartButton); } if (Utilities.appCustomization().equals("zurrorse")) { toolBar.addSeparator(); toolBar.add(selectComparisonCartButton); } toolBar.setRollover(true); toolBar.setFloatable(false); // Progress indicator (not working...) toolBar.addSeparator(new Dimension(32, 32)); toolBar.add(m_progress_indicator); // ------ Setup settingspage ------ final SettingsPage settingsPage = new SettingsPage(jframe, m_rb); // Attach observer to it settingsPage.addObserver(new Observer() { public void update(Observable o, Object arg) { System.out.println(arg); if (m_shopping_cart != null) { // Refresh some stuff m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } } }); jframe.addWindowListener(new WindowListener() { // Use WindowAdapter! @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { m_web_panel.dispose(); Runtime.getRuntime().exit(0); } @Override public void windowClosing(WindowEvent e) { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); print_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { m_web_panel.print(); } }); settings_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { settingsPage.display(); } }); quit_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); // Save settings WindowSaver.saveSettings(); m_web_panel.dispose(); Runtime.getRuntime().exit(0); } catch (Exception e) { System.out.println(e); } } }); subscribe_menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } @Override public void menuDeselected(MenuEvent event) { // do nothing } @Override public void menuCanceled(MenuEvent event) { // do nothing } }); contact_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI.create( "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); report_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { // Check first m_application_folder otherwise resort to // pre-installed report String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; if (!(new File(report_file)).exists()) report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; // Open report file in browser if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new File(report_file).toURI()); } catch (IOException e) { // TODO: } } } }); ywesee_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse( new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { if (Utilities.appLanguage().equals("de")) Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch")); else if (Utilities.appLanguage().equals("fr")) Desktop.getDesktop() .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); about_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); ad.AboutDialog(); } }); // Container final Container container = jframe.getContentPane(); container.setBackground(Color.WHITE); container.setLayout(new BorderLayout()); // ==== Toolbar ===== container.add(toolBar, BorderLayout.NORTH); // ==== Left panel ==== JPanel left_panel = new JPanel(); left_panel.setBackground(Color.WHITE); left_panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 2, 2, 2); // ---- Search field ---- final SearchField searchField = new SearchField("Suche Prparat"); if (Utilities.appLanguage().equals("fr")) searchField.setText("Recherche Specialit"); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(searchField, gbc); left_panel.add(searchField, gbc); // ---- Buttons ---- // Names String l_title = "Prparat"; String l_author = "Inhaberin"; String l_atccode = "Wirkstoff / ATC Code"; String l_regnr = "Zulassungsnummer"; String l_ingredient = "Wirkstoff"; String l_therapy = "Therapie"; String l_search = "Suche"; if (Utilities.appLanguage().equals("fr")) { l_title = "Spcialit"; l_author = "Titulaire"; l_atccode = "Principe Active / Code ATC"; l_regnr = "Nombre Enregistration"; l_ingredient = "Principe Active"; l_therapy = "Thrapie"; l_search = "Recherche"; } ButtonGroup bg = new ButtonGroup(); JToggleButton but_title = new JToggleButton(l_title); setupToggleButton(but_title); bg.add(but_title); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_title, gbc); left_panel.add(but_title, gbc); JToggleButton but_auth = new JToggleButton(l_author); setupToggleButton(but_auth); bg.add(but_auth); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_auth, gbc); left_panel.add(but_auth, gbc); JToggleButton but_atccode = new JToggleButton(l_atccode); setupToggleButton(but_atccode); bg.add(but_atccode); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_atccode, gbc); left_panel.add(but_atccode, gbc); JToggleButton but_regnr = new JToggleButton(l_regnr); setupToggleButton(but_regnr); bg.add(but_regnr); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_regnr, gbc); left_panel.add(but_regnr, gbc); JToggleButton but_therapy = new JToggleButton(l_therapy); setupToggleButton(but_therapy); bg.add(but_therapy); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_therapy, gbc); left_panel.add(but_therapy, gbc); // ---- Card layout ---- final CardLayout cardl = new CardLayout(); cardl.setHgap(-4); // HACK to make things look better!! final JPanel p_results = new JPanel(cardl); m_list_titles = new ListPanel(); m_list_auths = new ListPanel(); m_list_regnrs = new ListPanel(); m_list_atccodes = new ListPanel(); m_list_ingredients = new ListPanel(); m_list_therapies = new ListPanel(); // Contraints gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = 1; gbc.gridheight = 10; gbc.weightx = 1.0; gbc.weighty = 1.0; // p_results.add(m_list_titles, l_title); p_results.add(m_list_auths, l_author); p_results.add(m_list_regnrs, l_regnr); p_results.add(m_list_atccodes, l_atccode); p_results.add(m_list_ingredients, l_ingredient); p_results.add(m_list_therapies, l_therapy); // --> container.add(p_results, gbc); left_panel.add(p_results, gbc); left_panel.setBorder(null); // First card to show cardl.show(p_results, l_title); // ==== Right panel ==== JPanel right_panel = new JPanel(); right_panel.setBackground(Color.WHITE); right_panel.setLayout(new GridBagLayout()); // ---- Section titles ---- m_section_titles = null; if (Utilities.appLanguage().equals("de")) { m_section_titles = new IndexPanel(SectionTitle_DE); } else if (Utilities.appLanguage().equals("fr")) { m_section_titles = new IndexPanel(SectionTitle_FR); } m_section_titles.setMinimumSize(new Dimension(150, 150)); m_section_titles.setMaximumSize(new Dimension(320, 1000)); // ---- Fachinformation ---- m_web_panel = new WebPanel2(); m_web_panel.setMinimumSize(new Dimension(320, 150)); // Add JSplitPane on the RIGHT final int Divider_location = 150; final int Divider_size = 10; final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles, m_web_panel); split_pane_right.setOneTouchExpandable(true); split_pane_right.setDividerLocation(Divider_location); split_pane_right.setDividerSize(Divider_size); // Add JSplitPane on the LEFT JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel, split_pane_right /* right_panel */); split_pane_left.setOneTouchExpandable(true); split_pane_left.setDividerLocation(320); // Sets the pane divider location split_pane_left.setDividerSize(Divider_size); container.add(split_pane_left, BorderLayout.CENTER); // Add status bar on the bottom JPanel statusPanel = new JPanel(); statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); container.add(statusPanel, BorderLayout.SOUTH); final JLabel m_status_label = new JLabel(""); m_status_label.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(m_status_label); // Add mouse listener searchField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { searchField.setText(""); } }); final String final_title = l_title; final String final_author = l_author; final String final_atccode = l_atccode; final String final_regnr = l_regnr; final String final_therapy = l_therapy; final String final_search = l_search; // Internal class that implements switching between buttons final class Toggle { public void toggleButton(JToggleButton jbn) { for (int i = 0; i < list_of_buttons.length; ++i) { if (jbn == list_of_buttons[i]) list_of_buttons[i].setSelected(true); else list_of_buttons[i].setSelected(false); } } } ; // ------ Add toolbar action listeners ------ selectAipsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectAipsButton); // Set state 'aips' if (!m_curr_uistate.getUseMode().equals("aips")) { m_curr_uistate.setUseMode("aips"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); int num_hits = retrieveAipsSearchResults(false); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); // if (med_index < 0 && prev_med_index >= 0) med_index = prev_med_index; m_web_panel.updateText(); if (num_hits == 0) { m_web_panel.emptyPage(); } } }); } } }); selectFavoritesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectFavoritesButton); // Set state 'favorites' if (!m_curr_uistate.getUseMode().equals("favorites")) { m_curr_uistate.setUseMode("favorites"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // m_query_str = searchField.getText(); // Clear the search container med_search.clear(); for (String regnr : favorite_meds_set) { List<Medication> meds = m_sqldb.searchRegNr(regnr); if (!meds.isEmpty()) { // Add med database ID med_search.add(meds.get(0)); } } // Sort list of meds Collections.sort(med_search, new Comparator<Medication>() { @Override public int compare(final Medication m1, final Medication m2) { return m1.getTitle().compareTo(m2.getTitle()); } }); sTitle(); cardl.show(p_results, final_title); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); selectInteractionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectInteractionsButton); // Set state 'interactions' if (!m_curr_uistate.getUseMode().equals("interactions")) { m_curr_uistate.setUseMode("interactions"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_query_str = searchField.getText(); retrieveAipsSearchResults(false); // Switch to interaction mode m_web_panel.updateInteractionsCart(); m_web_panel.repaint(); m_web_panel.validate(); } }); } } }); selectShoppingCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String email_adr = m_prefs.get("emailadresse", ""); if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address m_preferences_ok = true; if (m_preferences_ok) { m_preferences_ok = false; // Check always new Toggle().toggleButton(selectShoppingCartButton); // Set state 'shopping' if (!m_curr_uistate.getUseMode().equals("shopping")) { m_curr_uistate.setUseMode("shopping"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // Set right panel title m_web_panel.setTitle(m_rb.getString("shoppingCart")); // Switch to shopping cart int index = 1; if (m_shopping_cart != null) { index = m_shopping_cart.getCartIndex(); m_web_panel.loadShoppingCartWithIndex(index); // m_shopping_cart.printShoppingBasket(); } // m_web_panel.updateShoppingHtml(); m_web_panel.updateListOfPackages(); if (m_first_pass == true) { m_first_pass = false; if (Utilities.appCustomization().equals("ywesee")) med_search = m_sqldb.searchAuth("ibsa"); else if (Utilities.appCustomization().equals("desitin")) med_search = m_sqldb.searchAuth("desitin"); sAuth(); cardl.show(p_results, final_author); } } } else { selectShoppingCartButton.setSelected(false); settingsPage.display(); } } }); selectComparisonCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectComparisonCartButton); // Set state 'comparison' if (!m_curr_uistate.getUseMode().equals("comparison")) { m_curr_uistate.setUseMode("comparison"); // Hide middle pane m_section_titles.setVisible(false); split_pane_right.setDividerLocation(0); split_pane_right.setDividerSize(0); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // Set right panel title m_web_panel.setTitle(getTitle("priceComp")); if (med_index >= 0) { if (med_id != null && med_index < med_id.size()) { Medication m = m_sqldb.getMediWithId(med_id.get(med_index)); String atc_code = m.getAtcCode(); if (atc_code != null) { String atc = atc_code.split(";")[0]; m_web_panel.fillComparisonBasket(atc); m_web_panel.updateComparisonCartHtml(); // Update pane on the left retrieveAipsSearchResults(false); } } } m_status_label.setText(rose_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); // ------ Add keylistener to text field (type as you go feature) ------ searchField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e) // invokeLater potentially in the wrong place... more testing // required SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); // Queries for SQLite DB if (!m_query_str.isEmpty()) { if (m_query_type == 0) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTitle(m_query_str); } else { med_search = m_sqldb.searchTitle(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTitle(); cardl.show(p_results, final_title); } else if (m_query_type == 1) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchSupplier(m_query_str); } else { med_search = m_sqldb.searchAuth(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sAuth(); cardl.show(p_results, final_author); } else if (m_query_type == 2) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchATC(m_query_str); } else { med_search = m_sqldb.searchATC(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sATC(); cardl.show(p_results, final_atccode); } else if (m_query_type == 3) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchEan(m_query_str); } else { med_search = m_sqldb.searchRegNr(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sRegNr(); cardl.show(p_results, final_regnr); } else if (m_query_type == 4) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTherapy(m_query_str); } else { med_search = m_sqldb.searchApplication(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTherapy(); cardl.show(p_results, final_therapy); } else { // do nothing } int num_hits = 0; if (m_curr_uistate.isComparisonMode()) num_hits = rose_search.size(); else num_hits = med_search.size(); m_status_label.setText(num_hits + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } } }); } }); // Add actionlisteners but_title.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_title); m_curr_uistate.setQueryType(m_query_type = 0); sTitle(); cardl.show(p_results, final_title); } }); but_auth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_author); m_curr_uistate.setQueryType(m_query_type = 1); sAuth(); cardl.show(p_results, final_author); } }); but_atccode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_atccode); m_curr_uistate.setQueryType(m_query_type = 2); sATC(); cardl.show(p_results, final_atccode); } }); but_regnr.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_regnr); m_curr_uistate.setQueryType(m_query_type = 3); sRegNr(); cardl.show(p_results, final_regnr); } }); but_therapy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_therapy); m_curr_uistate.setQueryType(m_query_type = 4); sTherapy(); cardl.show(p_results, final_therapy); } }); // Display window jframe.pack(); // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // jframe.setAlwaysOnTop(true); jframe.setVisible(true); // Check if user has selected an alternative database /* * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution * where the database selected by the user is saved in a default folder * (see variable "m_application_data_folder") */ /* * try { WindowSaver.loadSettings(jframe); String database_path = * WindowSaver.getDbPath(); if (database_path!=null) * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) { * e.printStackTrace(); } */ // Load AIPS database selectAipsButton.setSelected(true); selectFavoritesButton.setSelected(false); m_curr_uistate.setUseMode("aips"); med_search = m_sqldb.searchTitle(""); sTitle(); // Used instead of sTitle (which is slow) cardl.show(p_results, final_title); // Add menu item listeners updatedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (m_mutex_update == false) { m_mutex_update = true; String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder, m_full_db_update); // ... and update time if (m_full_db_update == true) { DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); } // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } } }); choosedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder); // ... and update time DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } }); /** * Observers */ // Attach observer to 'm_update' m_maindb_update.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Reset flag m_full_db_update = true; m_mutex_update = false; // Refresh some stuff after update loadAuthors(); m_emailer.loadMap(); settingsPage.load_gln_codes(); if (m_shopping_cart != null) { m_shopping_cart.load_conditions(); m_shopping_cart.load_glns(); } // Empty shopping basket if (m_curr_uistate.isShoppingMode()) { m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } if (m_curr_uistate.isComparisonMode()) m_web_panel.setTitle(getTitle("priceComp")); } }); // Attach observer to 'm_emailer' m_emailer.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Empty shopping basket m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } }); // Attach observer to "m_comparison_cart" m_comparison_cart.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); m_web_panel.setTitle(getTitle("priceComp")); m_comparison_cart.clearUploadList(); m_web_panel.updateComparisonCartHtml(); new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg); } }); // If command line options are provided start app with a particular title or eancode if (commandLineOptionsProvided()) { if (!CML_OPT_TITLE.isEmpty()) startAppWithTitle(but_title); else if (!CML_OPT_EANCODE.isEmpty()) startAppWithEancode(but_regnr); else if (!CML_OPT_REGNR.isEmpty()) startAppWithRegnr(but_regnr); } // Start timer Timer global_timer = new Timer(); // Time checks all 2 minutes (120'000 milliseconds) global_timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { checkIfUpdateRequired(updatedb_item); } }, 2 * 60 * 1000, 2 * 60 * 1000); }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Constructs DBMenuBar. Adds the menu and menuitems. * * @param graphicsRunner the JFrame that created this * @param desktop the DBDesktopPane in the JFrame *///w w w. j a v a 2 s. c o m public DBMenuBar(GraphicsRunner graphicsRunner, DBDesktopPane desktop) { super(); gr = graphicsRunner; this.desktop = desktop; //Set up the menu JMenu menu = new JMenu("File"); add(menu); //Set up the menu items. JMenuItem menuItem = new JMenuItem("New"); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("new"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Open"); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("open"); menuItem.addActionListener(this); menuItem.setLayout(new MigLayout()); menu.add(menuItem); menuItem = new JMenuItem("Save"); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("save"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Save As"); menuItem.setActionCommand("saveas"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Print Current Page"); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("printpage"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Print Show"); menuItem.setActionCommand("printshow"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Print Dot Sheets"); menuItem.setActionCommand("printdotsheets"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Quit"); menuItem.setMnemonic(KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("quit"); menuItem.addActionListener(this); menu.add(menuItem); menu = new JMenu("Edit"); add(menu); menuItem = new JMenuItem("Undo"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("undo"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Redo"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("redo"); menuItem.addActionListener(this); menu.add(menuItem); menu = new JMenu("Settings"); add(menu); menuItem = new JMenuItem("Toggle Gridlines"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("togglegrid"); menuItem.addActionListener(this); menuItem.setForeground(Main.getState().getSettings().shouldShowGrid() ? Color.BLACK : Color.RED); menu.add(menuItem); menuItem = new JMenuItem("Toggle Dot Names"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)); menuItem.setActionCommand("togglenames"); menuItem.addActionListener(this); menuItem.setForeground(Main.getState().getSettings().shouldShowNames() ? Color.BLACK : Color.RED); menu.add(menuItem); menuItem = new JMenuItem("Toggle Text Box"); menuItem.setActionCommand("toggletext"); menuItem.addActionListener(this); menuItem.setForeground(Main.getState().getSettings().shouldShowText() ? Color.BLACK : Color.RED); menu.add(menuItem); menuItem = new JMenuItem("Color Code Dots by Instrument"); menuItem.setActionCommand("colordots"); menuItem.addActionListener(this); menuItem.setForeground(Main.getState().getSettings().shouldColorDots() ? Color.BLACK : Color.RED); menu.add(menuItem); menuItem = new JMenuItem(); menuItem.setText(Main.getState().getSettings().useCollegeHashes() ? "Change to High School Hashes" : "Change to College Hashes"); menuItem.setActionCommand("changehash"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("Change Font Size"); menuItem.setActionCommand("fontsize"); menuItem.addActionListener(this); menu.add(menuItem); //add(Box.createHorizontalStrut(menu.getPreferredSize().width)); //add these to the menubar itself menuItem = new JMenuItem("Play"); menuItem.setMaximumSize(new Dimension(menuItem.getPreferredSize().width, Integer.MAX_VALUE)); menuItem.setActionCommand("play"); menuItem.addActionListener(this); add(menuItem); add(Box.createHorizontalGlue()); menu = new JMenu("Help"); add(menu); menuItem = new JMenuItem("Help"); menuItem.setActionCommand("help"); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem("About"); menuItem.setActionCommand("about"); menuItem.addActionListener(this); menu.add(menuItem); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenuItem mItem = null; String urlString;/*from w ww . ja v a2s. co m*/ URL url; //============================================================================================ // File Menu //============================================================================================ JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); menuBar.add(fileMenu); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png"; url = this.getClass().getResource(urlString); ImageIcon iconNew = new ImageIcon(url, "New"); mItem = new JMenuItem(new NewTextFileAction("New", iconNew)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png"; url = this.getClass().getResource(urlString); ImageIcon iconOpen = new ImageIcon(url, "Open"); mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png"; url = this.getClass().getResource(urlString); ImageIcon iconSave = new ImageIcon(url, "Save"); mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png"; url = this.getClass().getResource(urlString); ImageIcon iconSaveAs = new ImageIcon(url, "Save As"); mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png"; url = this.getClass().getResource(urlString); ImageIcon iconClose = new ImageIcon(url, "Close All Tabs"); mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C))); fileMenu.add(mItem); fileMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png"; url = this.getClass().getResource(urlString); ImageIcon iconPrint = new ImageIcon(url, "Print"); mItem = new JMenuItem(new PrintAction("Print...", iconPrint)); fileMenu.add(mItem); fileMenu.addSeparator(); // exit menu item urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png"; url = this.getClass().getResource(urlString); ImageIcon iconExit = new ImageIcon(url, "Exit"); mItem = new JMenuItem(new ExitAction("Exit", iconExit)); fileMenu.add(mItem); //============================================================================================ // Edit Menu //============================================================================================ JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png"; url = this.getClass().getResource(urlString); ImageIcon iconCut = new ImageIcon(url, "Cut"); mItem = new JMenuItem(new DefaultEditorKit.CutAction()); mItem.setText("Cut"); mItem.setIcon(iconCut); mItem.setMnemonic(KeyEvent.VK_X); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png"; url = this.getClass().getResource(urlString); ImageIcon iconCopy = new ImageIcon(url, "Copy"); mItem = new JMenuItem(new DefaultEditorKit.CopyAction()); mItem.setText("Copy"); mItem.setIcon(iconCopy); mItem.setMnemonic(KeyEvent.VK_C); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png"; url = this.getClass().getResource(urlString); ImageIcon iconPaste = new ImageIcon(url, "Paste"); mItem = new JMenuItem(new DefaultEditorKit.PasteAction()); mItem.setText("Paste"); mItem.setIcon(iconPaste); mItem.setMnemonic(KeyEvent.VK_V); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png"; url = this.getClass().getResource(urlString); ImageIcon iconUndo = new ImageIcon(url, "Undo"); mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z))); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png"; url = this.getClass().getResource(urlString); ImageIcon iconRedo = new ImageIcon(url, "Redo"); mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y))); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png"; url = this.getClass().getResource(urlString); ImageIcon iconView = new ImageIcon(url, "Preferences"); mItem = new JMenuItem("Preferences"); mItem.setIcon(iconView); mItem.setToolTipText("Edit jMetrik preferences"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikPreferencesManager prefs = new JmetrikPreferencesManager(); prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); prefs.addPropertyChangeListener(statusBar.getStatusListener()); JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs); // propDialog.loadPreferences(); propDialog.setVisible(true); } }); editMenu.setMnemonic('e'); editMenu.add(mItem); menuBar.add(editMenu); //============================================================================================ // Log Menu //============================================================================================ JMenu logMenu = new JMenu("Log"); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png"; url = this.getClass().getResource(urlString); ImageIcon iconLog = new ImageIcon(url, "View Log"); mItem = new JMenuItem(new ViewLogAction("View Log", iconLog)); logMenu.setMnemonic('l'); logMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png"; url = this.getClass().getResource(urlString); ImageIcon iconCommand = new ImageIcon(url, "Script Log"); mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand)); logMenu.setMnemonic('c'); logMenu.add(mItem); menuBar.add(logMenu); //============================================================================================ // Manage Menu //============================================================================================ JMenu manageMenu = new JMenu("Manage"); manageMenu.setMnemonic('m'); mItem = new JMenuItem("New Database...");//create db mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this); newDatabaseDialog.setVisible(true); if (newDatabaseDialog.canRun()) { if (workspace == null) { // workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable); workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable); workspace.addPropertyChangeListener(statusBar.getStatusListener()); workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); } workspace.runProcess(newDatabaseDialog.getCommand()); // workspace.createDatabase(newDatabaseDialog.getCommand()); } } }); manageMenu.add(mItem); mItem = new JMenuItem("Open Database..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open"); JList l = openDbDialog.getDatabaseList(); workspace.setDatabaseListModel(l); openDbDialog.setVisible(true); if (openDbDialog.canRun()) { openWorkspace(openDbDialog.getDatabaseName()); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDelete = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Database..."); mItem.setIcon(iconDelete); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete"); JList l = selectDialog.getDatabaseList(); workspace.setDatabaseListModel(l); selectDialog.setVisible(true); if (selectDialog.canRun()) { int answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete " + selectDialog.getDatabaseName() + " and all of its contents? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { DatabaseCommand command = new DatabaseCommand(); DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName()); command.getFreeOption("name").add(dbName.getName()); command.getSelectOneOption("action").setSelected("delete-db"); DatabaseName currentDb = workspace.getDatabaseName(); if (currentDb.getName().equals(dbName.getName())) { JOptionPane.showMessageDialog(Jmetrik.this, "You cannot delete the current database.\n" + "Close the database before attempting to delete it.", "Database Delete Error", JOptionPane.WARNING_MESSAGE); } else { workspace.runProcess(command); } } } } }); manageMenu.add(mItem); manageMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png"; url = this.getClass().getResource(urlString); ImageIcon iconDesc = new ImageIcon(url, "Descriptions"); mItem = new JMenuItem("Table Descriptions..."); mItem.setIcon(iconDesc); mItem.addActionListener(new TableDescriptionActionListener()); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png"; url = this.getClass().getResource(urlString); ImageIcon iconImport = new ImageIcon(url, "Import"); mItem = new JMenuItem("Import Data..."); mItem.setIcon(iconImport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(), importExportPath); importDialog.setVisible(true); if (importDialog.canRun()) { importExportPath = importDialog.getCurrentDirectory(); workspace.runProcess(importDialog.getCommand()); } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png"; url = this.getClass().getResource(urlString); ImageIcon iconExport = new ImageIcon(url, "Export"); mItem = new JMenuItem("Export Data..."); mItem.setIcon(iconExport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue the export.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, importExportPath); if (exportDialog.canRun()) { importExportPath = exportDialog.getCurrentDirectory(); workspace.runProcess(exportDialog.getCommand()); } } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteTable = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Table..."); mItem.setIcon(iconDeleteTable); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this, workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel()); deleteDialog.setVisible(true); if (deleteDialog.canRun()) { int nSelected = deleteDialog.getNumberOfSelectedTables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " tables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { ArrayList<DataTableName> dList = deleteDialog.getSelectedTables(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the table " + dList.get(0).getTableName() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteDialog.getCommand()); } } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); manageMenu.addSeparator(); SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess(); subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess(); subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables"); mItem = new JMenuItem("Delete Variables..."); mItem.setIcon(iconDeleteVariables); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else if (workspace.tableOpen()) { DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this, workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables()); deleteVariableDialog.setVisible(true); if (deleteVariableDialog.canRun()) { int nSelected = deleteVariableDialog.getNumberOfSelectedVariables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " variables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { VariableAttributes v = deleteVariableDialog.getSelectedVariable(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the variable " + v.getName().toString() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteVariableDialog.getCommand()); } } } } }); manageMenu.add(mItem); menuBar.add(manageMenu); //============================================================================================ // Transform Menu //============================================================================================ JMenu transformMenu = new JMenu("Transform"); transformMenu.setMnemonic('t'); BasicScoringProcess basicScoringProcess = new BasicScoringProcess(); basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); ScoringProcess scoringProcess = new ScoringProcess(); scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); RankingProcess rankingProcess = new RankingProcess(); rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); TestScalingProcess testScalingProcess = new TestScalingProcess(); testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess(); linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess(); irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess(); irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); menuBar.add(transformMenu); //============================================================================================ // Analyze Menu //============================================================================================ JMenu analyzeMenu = new JMenu("Analyze"); analyzeMenu.setMnemonic('a'); FrequencyProcess frequencyProcess = new FrequencyProcess(); frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); DescriptiveProcess descriptiveProcess = new DescriptiveProcess(); descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CorrelationProcess correlationProcess = new CorrelationProcess(); correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess(); itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CmhProcess cmhProcess = new CmhProcess(); cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess(); raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess(); irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess(); irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); menuBar.add(analyzeMenu); //============================================================================================ // Graph Menu //============================================================================================ JMenu graphMenu = new JMenu("Graph"); graphMenu.setMnemonic('g'); BarChartProcess barchartProcess = new BarChartProcess(); barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); PieChartProcess piechartProcess = new PieChartProcess(); piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); HistogramProcess histogramProcess = new HistogramProcess(); histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); DensityProcess densityProcess = new DensityProcess(); densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); LineChartProcess lineChartProcess = new LineChartProcess(); lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); ScatterplotProcess scatterplotProcess = new ScatterplotProcess(); scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess(); nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); mItem = new JMenuItem("Irt Plot..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database and select a table. \n " + "Select a table to continue scoring.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { if (irtPlotDialog == null && workspace.tableOpen()) { //Note that starting this dialog is different because variables //names must be obtained from the rows of a table. DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject(); try { ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn( workspace.getConnection(), workspace.getCurrentDataTable(), new VariableName("name")); irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, tempVar, (SortedListModel<DataTableName>) workspaceList.getModel()); } catch (SQLException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } if (irtPlotDialog != null) irtPlotDialog.setVisible(true); } if (irtPlotDialog != null && irtPlotDialog.canRun()) { workspace.runProcess(irtPlotDialog.getCommand()); } } }); graphMenu.add(mItem); ItemMapProcess itemMapProcess = new ItemMapProcess(); itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); menuBar.add(graphMenu); //============================================================================================ // Command Menu //============================================================================================ JMenu commandMenu = new JMenu("Commands"); commandMenu.setMnemonic('c'); mItem = new JMenuItem("Run command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent(); JViewport vp = pain.getViewport(); Component c = vp.getComponent(0); if (c instanceof JmetrikTextFile) { JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()); JmetrikTextFile textFile = (JmetrikTextFile) c; workspace.runFromSyntax(textFile.getText()); } } }); commandMenu.add(mItem); mItem = new JMenuItem("Stop command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); mItem = new JMenuItem("Command Reference..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); menuBar.add(commandMenu); //============================================================================================ // Help Menu //============================================================================================ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); mItem = new JMenuItem("Quick Start Guide"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Desktop deskTop = Desktop.getDesktop(); try { URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php"); deskTop.browse(uri); } catch (URISyntaxException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } catch (IOException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } }); helpMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png"; url = this.getClass().getResource(urlString); ImageIcon iconAbout = new ImageIcon(url, "About"); mItem = new JMenuItem("About"); mItem.setIcon(iconAbout); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR, RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION); aboutDialog.setVisible(true); } }); helpMenu.add(mItem); menuBar.add(helpMenu); return menuBar; }
From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java
/** This method is called from within the constructor to * initialize the form./*from w w w .ja v a 2 s.com*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); javax.swing.ButtonGroup buttonGroup1 = new javax.swing.ButtonGroup(); javax.swing.ButtonGroup buttonGroup2 = new javax.swing.ButtonGroup(); jPopupMenu1 = new javax.swing.JPopupMenu(); javax.swing.JMenuItem jMenuItem1 = new javax.swing.JMenuItem(); jPopupMenu2 = new javax.swing.JPopupMenu(); javax.swing.JMenuItem jMenuItem2 = new javax.swing.JMenuItem(); jButton1 = new javax.swing.JButton(); javax.swing.JPanel jPanel1 = new javax.swing.JPanel(); stackPanel = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); javax.swing.JPanel jPanel5 = new javax.swing.JPanel(); correctFlux = new javax.swing.JCheckBox(); jTextField8 = new javax.swing.JTextField(); javax.swing.JLabel jLabel11 = new javax.swing.JLabel(); redshiftButton = new javax.swing.JButton(); javax.swing.JLabel jLabel6 = new javax.swing.JLabel(); jRadioButton3 = new javax.swing.JRadioButton(); jRadioButton4 = new javax.swing.JRadioButton(); integrationXMaxText = new javax.swing.JTextField(); integrationMinMaxUnit = new WiderJComboBox(); integrationYUnit = new WiderJComboBox(); integrationValueText = new javax.swing.JTextField(); integrationNormType = new javax.swing.JComboBox(); javax.swing.JLabel integrationNormToLabel = new javax.swing.JLabel(); javax.swing.JLabel integrationXMinLabel = new javax.swing.JLabel(); integrationXMinText = new javax.swing.JTextField(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); javax.swing.JLabel atPointXLabel = new javax.swing.JLabel(); javax.swing.JLabel atPointYLabel = new javax.swing.JLabel(); atPointXText = new javax.swing.JTextField(); atPointYType = new javax.swing.JComboBox(); atPointXUnit = new javax.swing.JComboBox(); atPointYText = new javax.swing.JTextField(); atPointYUnit = new javax.swing.JComboBox(); normalizeButton = new javax.swing.JButton(); javax.swing.JSeparator jSeparator1 = new javax.swing.JSeparator(); javax.swing.JLabel integrationXMaxLabel = new javax.swing.JLabel(); javax.swing.JCheckBox jCheckBox1 = new javax.swing.JCheckBox(); javax.swing.JCheckBox jCheckBox2 = new javax.swing.JCheckBox(); javax.swing.JPanel jPanel4 = new javax.swing.JPanel(); addButton = new javax.swing.JButton(); removeButton = new javax.swing.JButton(); javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane(); sedsTable = new javax.swing.JTable(); javax.swing.JPanel jPanel6 = new javax.swing.JPanel(); javax.swing.JLabel jLabel7 = new javax.swing.JLabel(); stackStatisticComboBox = new javax.swing.JComboBox(); smoothCheckBox = new javax.swing.JCheckBox(); javax.swing.JLabel jLabel8 = new javax.swing.JLabel(); jTextField6 = new javax.swing.JTextField(); logBinningCheckBox = new javax.swing.JCheckBox(); javax.swing.JLabel jLabel9 = new javax.swing.JLabel(); binsizeTextField = new javax.swing.JTextField(); stackBinSizeUnitsComboBox = new javax.swing.JComboBox(); javax.swing.JLabel jLabel10 = new javax.swing.JLabel(); stackButton = new javax.swing.JButton(); stackYUnitComboBox = new javax.swing.JComboBox(); javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); javax.swing.JPanel jPanel2 = new javax.swing.JPanel(); resetButton = new javax.swing.JButton(); javax.swing.JButton deleteButton = new javax.swing.JButton(); createSedButton = new javax.swing.JButton(); jPopupMenu1.setName("jPopupMenu1"); // NOI18N jMenuItem1.setText("Rename..."); jMenuItem1.setName("jMenuItem1"); // NOI18N jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jPopupMenu1.add(jMenuItem1); jPopupMenu2.setName("jPopupMenu2"); // NOI18N jMenuItem2.setText("Change redshift..."); jMenuItem2.setName("jMenuItem2"); // NOI18N jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jPopupMenu2.add(jMenuItem2); setClosable(true); setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); setIconifiable(true); setResizable(true); setTitle("SED Stacker"); jButton1.setText("Create New Stack"); jButton1.setName("jButton1"); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newStack(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Open Stacks")); jPanel1.setName("jPanel1"); // NOI18N stackPanel.setName("stackPanel"); // NOI18N jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); jList1.setName("jList1"); // NOI18N org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${stacks}"); org.jdesktop.swingbinding.JListBinding jListBinding = org.jdesktop.swingbinding.SwingBindings .createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, jList1); jListBinding.setSourceUnreadableValue(null); bindingGroup.addBinding(jListBinding); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedStack}"), jList1, org.jdesktop.beansbinding.BeanProperty.create("selectedElement")); bindingGroup.addBinding(binding); jList1.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { jList1MousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { jList1MouseReleased(evt); } }); stackPanel.setViewportView(jList1); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(stackPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, stackPanel)); jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Redshift and Normalize")); jPanel5.setName("jPanel5"); // NOI18N correctFlux.setText("Correct flux"); correctFlux.setName("correctFlux"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.redshiftConfiguration.correctFlux}"), correctFlux, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); jTextField8.setName("jTextField8"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.redshiftConfiguration.toRedshift}"), jTextField8, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); jLabel11.setText("Move to redshift:"); jLabel11.setName("jLabel11"); // NOI18N redshiftButton.setText("Redshift"); redshiftButton.setName("redshiftButton"); // NOI18N redshiftButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { redshiftButtonActionPerformed(evt); } }); jLabel6.setText("Add or multiply normalization constant:"); jLabel6.setName("jLabel6"); // NOI18N buttonGroup2.add(jRadioButton3); jRadioButton3.setText("Add"); jRadioButton3.setName("jRadioButton3"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.add}"), jRadioButton3, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); buttonGroup2.add(jRadioButton4); jRadioButton4.setText("Multiply"); jRadioButton4.setName("jRadioButton4"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.multiply}"), jRadioButton4, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); integrationXMaxText.setName("integrationXMaxText"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.xmax}"), integrationXMaxText, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationXMaxText, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationMinMaxUnit.setModel(new DefaultComboBoxModel(loadEnum(XUnit.class))); integrationMinMaxUnit.setToolTipText("null"); integrationMinMaxUnit.setName("integrationMinMaxUnit"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.XUnits}"), integrationMinMaxUnit, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationMinMaxUnit, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationYUnit.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "erg/s/cm2", "Jy-Hz", "Watt/m2", "erg/s", "Watt" })); integrationYUnit.setName("integrationYUnit"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty .create("${selectedConfig.normConfiguration.integrateValueYUnits}"), integrationYUnit, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationYUnit, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationValueText.setName("integrationValueText"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.YValue}"), integrationValueText, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty .create("${selectedConfig.normConfiguration.integrateYTextEnabled}"), integrationValueText, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationNormType .setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Value", "Average", "Median" })); integrationNormType.setName("integrationNormType"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.stats}"), integrationNormType, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationNormType, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationNormToLabel.setText("Normalize to"); integrationNormToLabel.setName("integrationNormToLabel"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationNormToLabel, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationXMinLabel.setText("X Min:"); integrationXMinLabel.setName("integrationXMinLabel"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationXMinLabel, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); integrationXMinText.setName("integrationXMinText"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.xmin}"), integrationXMinText, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationXMinText, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); buttonGroup1.add(jRadioButton1); jRadioButton1.setText("Integration"); jRadioButton1.setName("jRadioButton1"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.integrate}"), jRadioButton1, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); buttonGroup1.add(jRadioButton2); jRadioButton2.setText("At point"); jRadioButton2.setName("jRadioButton2"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPoint}"), jRadioButton2, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); atPointXLabel.setText("X:"); atPointXLabel.setName("atPointXLabel"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointXLabel, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointYLabel.setText("Y:"); atPointYLabel.setName("atPointYLabel"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointYLabel, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointXText.setName("atPointXText"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPointXValue}"), atPointXText, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointXText, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointYType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Value", "Average", "Median" })); atPointYType.setName("atPointYType"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPointStats}"), atPointYType, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointYType, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointXUnit.setModel(new DefaultComboBoxModel(loadEnum(XUnit.class))); atPointXUnit.setName("atPointXUnit"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPointXUnits}"), atPointXUnit, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointXUnit, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointYText.setName("atPointYText"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPointYValue}"), atPointYText, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty .create("${selectedConfig.normConfiguration.atPointYTextEnabled}"), atPointYText, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); atPointYUnit.setModel(new DefaultComboBoxModel(loadEnum(SPVYUnit.class))); atPointYUnit.setName("atPointYUnit"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.normConfiguration.atPointYUnits}"), atPointYUnit, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton2, org.jdesktop.beansbinding.ELProperty.create("${selected}"), atPointYUnit, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); normalizeButton.setText("Normalize"); normalizeButton.setName("normalizeButton"); // NOI18N normalizeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { normalizeButtonActionPerformed(evt); } }); jSeparator1.setName("jSeparator1"); // NOI18N integrationXMaxLabel.setText("X Max:"); integrationXMaxLabel.setName("integrationXMaxLabel"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jRadioButton1, org.jdesktop.beansbinding.ELProperty.create("${selected}"), integrationXMaxLabel, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); jCheckBox1.setText("Create SED"); jCheckBox1.setToolTipText("Create and view SED after redshifting"); jCheckBox1.setName("jCheckBox1"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${createSedAfterRedshift}"), jCheckBox1, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); jCheckBox2.setText("Create SED"); jCheckBox2.setToolTipText("Create and view SED after normalizing"); jCheckBox2.setName("jCheckBox2"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${createSedAfterNormalize}"), jCheckBox2, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout .setHorizontalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup().addContainerGap().add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jSeparator1) .add(jPanel5Layout.createSequentialGroup().add(jLabel11) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(correctFlux) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jCheckBox1).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(redshiftButton)) .add(jPanel5Layout.createSequentialGroup().add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup().add(jRadioButton2) .add(26, 26, 26) .add(jPanel5Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup() .add(atPointXLabel) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(atPointXText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(3, 3, 3).add(atPointXUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel5Layout.createSequentialGroup() .add(atPointYLabel) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(atPointYType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(atPointYText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(7, 7, 7) .add(atPointYUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) .add(jPanel5Layout.createSequentialGroup().add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jPanel5Layout.createSequentialGroup() .add(integrationNormToLabel) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(integrationNormType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)) .add(jPanel5Layout.createSequentialGroup().add(jRadioButton1) .add(8, 8, 8).add(integrationXMinLabel).add(3, 3, 3) .add(integrationXMinText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(integrationXMaxLabel).add(3, 3, 3))) .add(jPanel5Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.TRAILING, false) .add(jPanel5Layout .createSequentialGroup() .add(integrationXMaxText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(integrationMinMaxUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel5Layout.createSequentialGroup().add( integrationValueText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED) .add(integrationYUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) .add(jPanel5Layout.createSequentialGroup().add(jLabel6) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jRadioButton3) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jRadioButton4))) .add(0, 0, Short.MAX_VALUE)) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup().add(0, 0, Short.MAX_VALUE) .add(jCheckBox2) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(normalizeButton))) .addContainerGap())); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup() .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(correctFlux) .add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel11)) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(redshiftButton).add(jCheckBox1))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel6).add(jRadioButton3).add(jRadioButton4)) .add(18, 18, 18) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jRadioButton1) .add(integrationMinMaxUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationXMaxText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationXMinText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationXMinLabel).add(integrationXMaxLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(integrationYUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationValueText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationNormType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(integrationNormToLabel)) .add(11, 11, 11) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jRadioButton2) .add(jPanel5Layout.createSequentialGroup().add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(atPointXText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(atPointXLabel)) .add(atPointXUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel5Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(atPointYLabel) .add(atPointYType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(atPointYText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(atPointYUnit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(normalizeButton).add(jCheckBox2)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Added SEDs")); jPanel4.setName("jPanel4"); // NOI18N addButton.setText("Add..."); addButton.setName("addButton"); // NOI18N addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addButtonActionPerformed(evt); } }); removeButton.setText("Remove"); removeButton.setName("removeButton"); // NOI18N removeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeButtonActionPerformed(evt); } }); jScrollPane2.setName("jScrollPane2"); // NOI18N sedsTable.setModel(new StackTableModel()); sedsTable.setName("sedsTable"); // NOI18N sedsTable.getTableHeader().setReorderingAllowed(false); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedSeds}"), sedsTable, org.jdesktop.beansbinding.BeanProperty.create("selectedElements")); bindingGroup.addBinding(binding); sedsTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { sedsTableMousePressed(evt); } }); jScrollPane2.setViewportView(sedsTable); org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout .setHorizontalGroup(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup() .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(addButton).add(removeButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE))); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel4Layout.createSequentialGroup().add(addButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(removeButton)) .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 160, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)); jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Stacking Options")); jPanel6.setName("jPanel6"); // NOI18N jLabel7.setText("Statistic:"); jLabel7.setName("jLabel7"); // NOI18N stackStatisticComboBox .setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Average", "Weighted Avg", "Sum" })); stackStatisticComboBox.setName("stackStatisticComboBox"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.statistic}"), stackStatisticComboBox, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); smoothCheckBox.setText("Smooth"); smoothCheckBox.setName("smoothCheckBox"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.smooth}"), smoothCheckBox, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); jLabel8.setText("Box Size:"); jLabel8.setName("jLabel8"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, smoothCheckBox, org.jdesktop.beansbinding.ELProperty.create("${selected}"), jLabel8, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); jTextField6.setName("jTextField6"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.smoothBinsize}"), jTextField6, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, smoothCheckBox, org.jdesktop.beansbinding.ELProperty.create("${selected}"), jTextField6, org.jdesktop.beansbinding.BeanProperty.create("enabled")); bindingGroup.addBinding(binding); logBinningCheckBox.setText("Logarithmic Binning"); logBinningCheckBox.setToolTipText( "java.lang.String \"Note: If logarithmic binning is on, the Bin Size is also logarithmic (e.g., a bin size of 1.0 with logarithmic binning spans 1 decade).\""); // NOI18N logBinningCheckBox.setName("logBinningCheckBox"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.logbin}"), logBinningCheckBox, org.jdesktop.beansbinding.BeanProperty.create("selected")); bindingGroup.addBinding(binding); jLabel9.setText("Bin Size:"); jLabel9.setName("jLabel9"); // NOI18N binsizeTextField.setName("binsizeTextField"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.binsize}"), binsizeTextField, org.jdesktop.beansbinding.BeanProperty.create("text")); bindingGroup.addBinding(binding); stackBinSizeUnitsComboBox.setModel(new DefaultComboBoxModel(loadEnum(XUnit.class))); stackBinSizeUnitsComboBox.setName("stackBinSizeUnitsComboBox"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.binsizeUnit}"), stackBinSizeUnitsComboBox, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); jLabel10.setText("Bin Size Units:"); jLabel10.setName("jLabel10"); // NOI18N stackButton.setText("Stack!"); stackButton.setName("stackButton"); // NOI18N stackButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { stackButtonActionPerformed(evt); } }); stackYUnitComboBox.setModel(new DefaultComboBoxModel(loadEnum(SPVYUnit.class))); stackYUnitComboBox.setName("stackYUnitComboBox"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${selectedConfig.stackConfiguration.YUnits}"), stackYUnitComboBox, org.jdesktop.beansbinding.BeanProperty.create("selectedItem")); bindingGroup.addBinding(binding); jLabel1.setText("Y Axis:"); jLabel1.setName("jLabel1"); // NOI18N org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel6Layout.createSequentialGroup().addContainerGap().add(jPanel6Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel6Layout.createSequentialGroup().add(0, 0, Short.MAX_VALUE).add(stackButton) .addContainerGap()) .add(jPanel6Layout.createSequentialGroup().add(29, 29, 29).add(jLabel8) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jTextField6) .add(17, 17, 17)) .add(jPanel6Layout.createSequentialGroup() .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel6Layout.createSequentialGroup().add(jLabel10) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(stackBinSizeUnitsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel6Layout.createSequentialGroup().add(jPanel6Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel7).add(jLabel1)) .add(jPanel6Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel6Layout.createSequentialGroup().add(12, 12, 12) .add(stackYUnitComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 143, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(jPanel6Layout.createSequentialGroup() .addPreferredGap( org.jdesktop.layout.LayoutStyle.UNRELATED) .add(stackStatisticComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 143, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) .add(smoothCheckBox).add(logBinningCheckBox) .add(jPanel6Layout.createSequentialGroup().add(jLabel9).add(43, 43, 43).add( binsizeTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 115, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel6Layout.createSequentialGroup().addContainerGap() .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel7).add(stackStatisticComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(stackYUnitComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel9).add(binsizeTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel10).add(stackBinSizeUnitsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(9, 9, 9).add(logBinningCheckBox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(smoothCheckBox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel8).add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18).add(stackButton).add(18, 18, 18))); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Managment")); jPanel2.setName("jPanel2"); // NOI18N resetButton.setText("Reset"); resetButton.setToolTipText("Reset SEDs to their original values"); resetButton.setName("resetButton"); // NOI18N resetButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resetButtonActionPerformed(evt); } }); deleteButton.setText("Delete"); deleteButton.setToolTipText("Delete the currently selected Stack"); deleteButton.setName("deleteButton"); // NOI18N deleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deleteButtonActionPerformed(evt); } }); createSedButton.setText("Create SED"); createSedButton.setToolTipText("Create new SED of the current Stack."); createSedButton.setName("createSedButton"); // NOI18N createSedButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { createSedButtonActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(resetButton).add(createSedButton).add(deleteButton)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup().addContainerGap().add(resetButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(deleteButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(createSedButton).addContainerGap())); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout .createSequentialGroup().addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jButton1).add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .add(0, 10, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(jButton1).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 301, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); bindingGroup.bind(); pack(); }
From source file:com.hexidec.ekit.EkitCore.java
/** * Master Constructor//from w w w . ja va 2s.c o m * * @param sDocument * [String] A text or HTML document to load in the editor upon * startup. * @param sStyleSheet * [String] A CSS stylesheet to load in the editor upon startup. * @param sRawDocument * [String] A document encoded as a String to load in the editor * upon startup. * @param sdocSource * [StyledDocument] Optional document specification, using * javax.swing.text.StyledDocument. * @param urlStyleSheet * [URL] A URL reference to the CSS style sheet. * @param includeToolBar * [boolean] Specifies whether the app should include the * toolbar(s). * @param showViewSource * [boolean] Specifies whether or not to show the View Source * window on startup. * @param showMenuIcons * [boolean] Specifies whether or not to show icon pictures in * menus. * @param sLanguage * [String] The language portion of the Internationalization * Locale to run Ekit in. * @param sCountry * [String] The country portion of the Internationalization * Locale to run Ekit in. * @param base64 * [boolean] Specifies whether the raw document is Base64 encoded * or not. * @param debugMode * [boolean] Specifies whether to show the Debug menu or not. * @param hasSpellChecker * [boolean] Specifies whether or not this uses the SpellChecker * module * @param multiBar * [boolean] Specifies whether to use multiple toolbars or one * big toolbar. * @param toolbarSeq * [String] Code string specifying the toolbar buttons to show. * @param keepUnknownTags * [boolean] Specifies whether or not the parser should retain * unknown tags. * @param enterBreak * [boolean] Specifies whether the ENTER key should insert breaks * instead of paragraph tags. * @param inlineEdit * [boolean] Should edit inline content only (no line breaks) */ public EkitCore(boolean isParentApplet, String sDocument, String sStyleSheet, String sRawDocument, StyledDocument sdocSource, URL urlStyleSheet, boolean includeToolBar, boolean showViewSource, boolean showMenuIcons, String sLanguage, String sCountry, boolean base64, boolean debugMode, boolean hasSpellChecker, boolean multiBar, String toolbarSeq, boolean keepUnknownTags, boolean enterBreak, boolean inlineEdit, List<HTMLDocumentBehavior> behaviors) { super(); if (behaviors != null) { this.behaviors.addAll(behaviors); } preserveUnknownTags = keepUnknownTags; enterIsBreak = enterBreak; this.inlineEdit = inlineEdit; frameHandler = new Frame(); // Determine if system clipboard is available (SecurityManager version) /* * SecurityManager secManager = System.getSecurityManager(); * if(secManager != null) { try { * secManager.checkSystemClipboardAccess(); sysClipboard = * Toolkit.getDefaultToolkit().getSystemClipboard(); } * catch(SecurityException se) { sysClipboard = null; } } */ // Obtain system clipboard if available try { sysClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); } catch (Exception ex) { sysClipboard = null; } // Plain text DataFlavor for unformatted paste try { dfPlainText = new DataFlavor("text/plain; class=java.lang.String; charset=Unicode"); // Charsets // usually // available // include // Unicode, // UTF-16, // UTF-8, // & // US-ASCII } catch (ClassNotFoundException cnfe) { // it would be nice to use DataFlavor.plainTextFlavor, but that is // deprecated // this will not work as desired, but it will prevent errors from // being thrown later // alternately, we could flag up here that Unformatted Paste is not // available and adjust the UI accordingly // however, the odds of java.lang.String not being found are pretty // slim one imagines dfPlainText = DataFlavor.stringFlavor; } /* Localize for language */ Locale baseLocale = Locale.getDefault(); if (sLanguage != null && sCountry != null) { baseLocale = new Locale(sLanguage, sCountry); } Translatrix.init("EkitLanguageResources", baseLocale); /* Initialise system-specific control key value */ if (!(GraphicsEnvironment.isHeadless())) { CTRLKEY = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } /* Create the editor kit, document, and stylesheet */ jtpMain = new EkitTextPane(); htmlKit = new ExtendedHTMLEditorKit(); htmlDoc = (ExtendedHTMLDocument) (htmlKit.createDefaultDocument()); htmlDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); htmlDoc.setPreservesUnknownTags(preserveUnknownTags); styleSheet = htmlDoc.getStyleSheet(); htmlKit.setDefaultCursor(new Cursor(Cursor.TEXT_CURSOR)); jtpMain.setCursor(new Cursor(Cursor.TEXT_CURSOR)); /* Set up the text pane */ jtpMain.setEditorKit(htmlKit); jtpMain.setDocument(htmlDoc); // jtpMain.addMouseMotionListener(new EkitMouseMotionListener()); jtpMain.addFocusListener(this); jtpMain.setMargin(new Insets(4, 4, 4, 4)); jtpMain.addKeyListener(this); // jtpMain.setDragEnabled(true); // this causes an error in older Java // versions /* Create the source text area */ if (sdocSource == null) { jtpSource = new JTextArea(); jtpSource.setText(jtpMain.getText()); } else { jtpSource = new JTextArea(sdocSource); jtpMain.setText(jtpSource.getText()); } jtpSource.setBackground(new Color(212, 212, 212)); jtpSource.setSelectionColor(new Color(255, 192, 192)); jtpSource.setMargin(new Insets(4, 4, 4, 4)); jtpSource.getDocument().addDocumentListener(this); jtpSource.addFocusListener(this); jtpSource.setCursor(new Cursor(Cursor.TEXT_CURSOR)); jtpSource.setColumns(1024); jtpSource.setEditable(false); /* Add CaretListener for tracking caret location events */ jtpMain.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent ce) { handleCaretPositionChange(ce); } }); // Default text if (!inlineEdit) { setDocumentText("<p></p>"); } /* Set up the undo features */ undoMngr = new UndoManager(); undoAction = new UndoAction(); redoAction = new RedoAction(); jtpMain.getDocument().addUndoableEditListener(new CustomUndoableEditListener()); /* Insert raw document, if exists */ if (sRawDocument != null && sRawDocument.length() > 0) { if (base64) { jtpMain.setText(Base64Codec.decode(sRawDocument)); } else { jtpMain.setText(sRawDocument); } } jtpMain.setCaretPosition(0); jtpMain.getDocument().addDocumentListener(this); /* Import CSS from reference, if exists */ if (urlStyleSheet != null) { try { String currDocText = jtpMain.getText(); htmlDoc = (ExtendedHTMLDocument) (htmlKit.createDefaultDocument()); htmlDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); htmlDoc.setPreservesUnknownTags(preserveUnknownTags); styleSheet = htmlDoc.getStyleSheet(); BufferedReader br = new BufferedReader(new InputStreamReader(urlStyleSheet.openStream())); styleSheet.loadRules(br, urlStyleSheet); br.close(); htmlDoc = new ExtendedHTMLDocument(styleSheet); registerDocument(htmlDoc); jtpMain.setText(currDocText); jtpSource.setText(jtpMain.getText()); } catch (Exception e) { log.error(e.getMessage(), e); } } /* Preload the specified HTML document, if exists */ if (sDocument != null) { File defHTML = new File(sDocument); if (defHTML.exists()) { try { openDocument(defHTML); } catch (Exception e) { logException("Exception in preloading HTML document", e); } } } /* Preload the specified CSS document, if exists */ if (sStyleSheet != null) { File defCSS = new File(sStyleSheet); if (defCSS.exists()) { try { openStyleSheet(defCSS); } catch (Exception e) { logException("Exception in preloading CSS stylesheet", e); } } } /* Collect the actions that the JTextPane is naturally aware of */ Hashtable<Object, Action> actions = new Hashtable<Object, Action>(); Action[] actionsArray = jtpMain.getActions(); for (Action a : actionsArray) { actions.put(a.getValue(Action.NAME), a); } /* Create shared actions */ actionFontBold = new StyledEditorKit.BoldAction(); actionFontItalic = new StyledEditorKit.ItalicAction(); actionFontUnderline = new StyledEditorKit.UnderlineAction(); actionFontStrike = new FormatAction(this, Translatrix.getTranslationString("FontStrike"), HTML.Tag.STRIKE); actionFontSuperscript = new FormatAction(this, Translatrix.getTranslationString("FontSuperscript"), HTML.Tag.SUP); actionFontSubscript = new FormatAction(this, Translatrix.getTranslationString("FontSubscript"), HTML.Tag.SUB); actionListUnordered = new ListAutomationAction(this, Translatrix.getTranslationString("ListUnordered"), HTML.Tag.UL); actionListOrdered = new ListAutomationAction(this, Translatrix.getTranslationString("ListOrdered"), HTML.Tag.OL); actionSelectFont = new SetFontFamilyAction(this, "[MENUFONTSELECTOR]"); actionAlignLeft = new AlignmentAction(Translatrix.getTranslationString("AlignLeft"), StyleConstants.ALIGN_LEFT); actionAlignCenter = new AlignmentAction(Translatrix.getTranslationString("AlignCenter"), StyleConstants.ALIGN_CENTER); actionAlignRight = new AlignmentAction(Translatrix.getTranslationString("AlignRight"), StyleConstants.ALIGN_RIGHT); actionAlignJustified = new AlignmentAction(Translatrix.getTranslationString("AlignJustified"), StyleConstants.ALIGN_JUSTIFIED); actionInsertAnchor = new CustomAction(this, Translatrix.getTranslationString("InsertAnchor") + menuDialog, HTML.Tag.A); actionClearFormat = new ClearFormatAction(this); actionSpecialChar = new SpecialCharAction(this); // actionTableButtonMenu Action actionTableInsert = new CommandAction(Translatrix.getTranslationString("InsertTable") + menuDialog, getEkitIcon("TableCreate"), CMD_TABLE_INSERT, this); Action actionTableDelete = new CommandAction(Translatrix.getTranslationString("DeleteTable"), getEkitIcon("TableDelete"), CMD_TABLE_DELETE, this); Action actionTableRow = new CommandAction(Translatrix.getTranslationString("InsertTableRow"), getEkitIcon("InsertRow"), CMD_TABLE_ROW_INSERT, this); Action actionTableRowAfter = new CommandAction(Translatrix.getTranslationString("InsertTableRowAfter"), getEkitIcon("InsertRowAfter"), CMD_TABLE_ROW_INSERT_AFTER, this); Action actionTableCol = new CommandAction(Translatrix.getTranslationString("InsertTableColumn"), getEkitIcon("InsertColumn"), CMD_TABLE_COLUMN_INSERT, this); Action actionTableColAfter = new CommandAction(Translatrix.getTranslationString("InsertTableColumnAfter"), getEkitIcon("InsertColumnAfter"), CMD_TABLE_COLUMN_INSERT_AFTER, this); Action actionTableRowDel = new CommandAction(Translatrix.getTranslationString("DeleteTableRow"), getEkitIcon("DeleteRow"), CMD_TABLE_ROW_DELETE, this); Action actionTableColDel = new CommandAction(Translatrix.getTranslationString("DeleteTableColumn"), getEkitIcon("DeleteColumn"), CMD_TABLE_COLUMN_DELETE, this); Action actionTableColFmt = new CommandAction(Translatrix.getTranslationString("FormatTableColumn"), getEkitIcon("FormatColumn"), CMD_TABLE_COLUMN_FORMAT, this); actionTableButtonMenu = new ButtonMenuAction(Translatrix.getTranslationString("TableMenu"), getEkitIcon("TableMenu"), actionTableInsert, actionTableDelete, null, actionTableRow, actionTableRowAfter, actionTableCol, actionTableColAfter, null, actionTableRowDel, actionTableColDel, null, actionTableColFmt); /* Build the menus */ /* FILE Menu */ jMenuFile = new JMenu(Translatrix.getTranslationString("File")); htMenus.put(KEY_MENU_FILE, jMenuFile); JMenuItem jmiNew = new JMenuItem(Translatrix.getTranslationString("NewDocument")); jmiNew.setActionCommand(CMD_DOC_NEW); jmiNew.addActionListener(this); jmiNew.setAccelerator(KeyStroke.getKeyStroke('N', CTRLKEY, false)); if (showMenuIcons) { jmiNew.setIcon(getEkitIcon("New")); } ; jMenuFile.add(jmiNew); JMenuItem jmiNewStyled = new JMenuItem(Translatrix.getTranslationString("NewStyledDocument")); jmiNewStyled.setActionCommand(CMD_DOC_NEW_STYLED); jmiNewStyled.addActionListener(this); if (showMenuIcons) { jmiNewStyled.setIcon(getEkitIcon("NewStyled")); } ; jMenuFile.add(jmiNewStyled); JMenuItem jmiOpenHTML = new JMenuItem(Translatrix.getTranslationString("OpenDocument") + menuDialog); jmiOpenHTML.setActionCommand(CMD_DOC_OPEN_HTML); jmiOpenHTML.addActionListener(this); jmiOpenHTML.setAccelerator(KeyStroke.getKeyStroke('O', CTRLKEY, false)); if (showMenuIcons) { jmiOpenHTML.setIcon(getEkitIcon("Open")); } ; jMenuFile.add(jmiOpenHTML); JMenuItem jmiOpenCSS = new JMenuItem(Translatrix.getTranslationString("OpenStyle") + menuDialog); jmiOpenCSS.setActionCommand(CMD_DOC_OPEN_CSS); jmiOpenCSS.addActionListener(this); jMenuFile.add(jmiOpenCSS); jMenuFile.addSeparator(); JMenuItem jmiSave = new JMenuItem(Translatrix.getTranslationString("Save")); jmiSave.setActionCommand(CMD_DOC_SAVE); jmiSave.addActionListener(this); jmiSave.setAccelerator(KeyStroke.getKeyStroke('S', CTRLKEY, false)); if (showMenuIcons) { jmiSave.setIcon(getEkitIcon("Save")); } ; jMenuFile.add(jmiSave); JMenuItem jmiSaveAs = new JMenuItem(Translatrix.getTranslationString("SaveAs") + menuDialog); jmiSaveAs.setActionCommand(CMD_DOC_SAVE_AS); jmiSaveAs.addActionListener(this); jMenuFile.add(jmiSaveAs); JMenuItem jmiSaveBody = new JMenuItem(Translatrix.getTranslationString("SaveBody") + menuDialog); jmiSaveBody.setActionCommand(CMD_DOC_SAVE_BODY); jmiSaveBody.addActionListener(this); jMenuFile.add(jmiSaveBody); JMenuItem jmiSaveRTF = new JMenuItem(Translatrix.getTranslationString("SaveRTF") + menuDialog); jmiSaveRTF.setActionCommand(CMD_DOC_SAVE_RTF); jmiSaveRTF.addActionListener(this); jMenuFile.add(jmiSaveRTF); jMenuFile.addSeparator(); JMenuItem jmiPrint = new JMenuItem(Translatrix.getTranslationString("Print")); jmiPrint.setActionCommand(CMD_DOC_PRINT); jmiPrint.addActionListener(this); jMenuFile.add(jmiPrint); jMenuFile.addSeparator(); JMenuItem jmiSerialOut = new JMenuItem(Translatrix.getTranslationString("Serialize") + menuDialog); jmiSerialOut.setActionCommand(CMD_DOC_SERIALIZE_OUT); jmiSerialOut.addActionListener(this); jMenuFile.add(jmiSerialOut); JMenuItem jmiSerialIn = new JMenuItem(Translatrix.getTranslationString("ReadFromSer") + menuDialog); jmiSerialIn.setActionCommand(CMD_DOC_SERIALIZE_IN); jmiSerialIn.addActionListener(this); jMenuFile.add(jmiSerialIn); jMenuFile.addSeparator(); JMenuItem jmiExit = new JMenuItem(Translatrix.getTranslationString("Exit")); jmiExit.setActionCommand(CMD_EXIT); jmiExit.addActionListener(this); jMenuFile.add(jmiExit); /* EDIT Menu */ jMenuEdit = new JMenu(Translatrix.getTranslationString("Edit")); htMenus.put(KEY_MENU_EDIT, jMenuEdit); if (sysClipboard != null) { // System Clipboard versions of menu commands JMenuItem jmiCut = new JMenuItem(Translatrix.getTranslationString("Cut")); jmiCut.setActionCommand(CMD_CLIP_CUT); jmiCut.addActionListener(this); jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', CTRLKEY, false)); if (showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); } jMenuEdit.add(jmiCut); JMenuItem jmiCopy = new JMenuItem(Translatrix.getTranslationString("Copy")); jmiCopy.setActionCommand(CMD_CLIP_COPY); jmiCopy.addActionListener(this); jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', CTRLKEY, false)); if (showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); } jMenuEdit.add(jmiCopy); JMenuItem jmiPaste = new JMenuItem(Translatrix.getTranslationString("Paste")); jmiPaste.setActionCommand(CMD_CLIP_PASTE); jmiPaste.addActionListener(this); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', CTRLKEY, false)); if (showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste); JMenuItem jmiPasteX = new JMenuItem(Translatrix.getTranslationString("PasteUnformatted")); jmiPasteX.setActionCommand(CMD_CLIP_PASTE_PLAIN); jmiPasteX.addActionListener(this); jmiPasteX.setAccelerator(KeyStroke.getKeyStroke('V', CTRLKEY + KeyEvent.SHIFT_MASK, false)); if (showMenuIcons) { jmiPasteX.setIcon(getEkitIcon("PasteUnformatted")); } jMenuEdit.add(jmiPasteX); } else { // DefaultEditorKit versions of menu commands JMenuItem jmiCut = new JMenuItem(new DefaultEditorKit.CutAction()); jmiCut.setText(Translatrix.getTranslationString("Cut")); jmiCut.setAccelerator(KeyStroke.getKeyStroke('X', CTRLKEY, false)); if (showMenuIcons) { jmiCut.setIcon(getEkitIcon("Cut")); } jMenuEdit.add(jmiCut); JMenuItem jmiCopy = new JMenuItem(new DefaultEditorKit.CopyAction()); jmiCopy.setText(Translatrix.getTranslationString("Copy")); jmiCopy.setAccelerator(KeyStroke.getKeyStroke('C', CTRLKEY, false)); if (showMenuIcons) { jmiCopy.setIcon(getEkitIcon("Copy")); } jMenuEdit.add(jmiCopy); JMenuItem jmiPaste = new JMenuItem(new DefaultEditorKit.PasteAction()); jmiPaste.setText(Translatrix.getTranslationString("Paste")); jmiPaste.setAccelerator(KeyStroke.getKeyStroke('V', CTRLKEY, false)); if (showMenuIcons) { jmiPaste.setIcon(getEkitIcon("Paste")); } jMenuEdit.add(jmiPaste); JMenuItem jmiPasteX = new JMenuItem(Translatrix.getTranslationString("PasteUnformatted")); jmiPasteX.setActionCommand(CMD_CLIP_PASTE_PLAIN); jmiPasteX.addActionListener(this); jmiPasteX.setAccelerator(KeyStroke.getKeyStroke('V', CTRLKEY + KeyEvent.SHIFT_MASK, false)); if (showMenuIcons) { jmiPasteX.setIcon(getEkitIcon("PasteUnformatted")); } jMenuEdit.add(jmiPasteX); } jMenuEdit.addSeparator(); JMenuItem jmiUndo = new JMenuItem(undoAction); jmiUndo.setAccelerator(KeyStroke.getKeyStroke('Z', CTRLKEY, false)); if (showMenuIcons) { jmiUndo.setIcon(getEkitIcon("Undo")); } jMenuEdit.add(jmiUndo); JMenuItem jmiRedo = new JMenuItem(redoAction); jmiRedo.setAccelerator(KeyStroke.getKeyStroke('Y', CTRLKEY, false)); if (showMenuIcons) { jmiRedo.setIcon(getEkitIcon("Redo")); } jMenuEdit.add(jmiRedo); jMenuEdit.addSeparator(); JMenuItem jmiSelAll = new JMenuItem((Action) actions.get(DefaultEditorKit.selectAllAction)); jmiSelAll.setText(Translatrix.getTranslationString("SelectAll")); jmiSelAll.setAccelerator(KeyStroke.getKeyStroke('A', CTRLKEY, false)); jMenuEdit.add(jmiSelAll); JMenuItem jmiSelPara = new JMenuItem((Action) actions.get(DefaultEditorKit.selectParagraphAction)); jmiSelPara.setText(Translatrix.getTranslationString("SelectParagraph")); jMenuEdit.add(jmiSelPara); JMenuItem jmiSelLine = new JMenuItem((Action) actions.get(DefaultEditorKit.selectLineAction)); jmiSelLine.setText(Translatrix.getTranslationString("SelectLine")); jMenuEdit.add(jmiSelLine); JMenuItem jmiSelWord = new JMenuItem((Action) actions.get(DefaultEditorKit.selectWordAction)); jmiSelWord.setText(Translatrix.getTranslationString("SelectWord")); jMenuEdit.add(jmiSelWord); jMenuEdit.addSeparator(); JMenu jMenuEnterKey = new JMenu(Translatrix.getTranslationString("EnterKeyMenu")); jcbmiEnterKeyParag = new JCheckBoxMenuItem(Translatrix.getTranslationString("EnterKeyParag"), !enterIsBreak); jcbmiEnterKeyParag.setActionCommand(CMD_ENTER_PARAGRAPH); jcbmiEnterKeyParag.addActionListener(this); jMenuEnterKey.add(jcbmiEnterKeyParag); jcbmiEnterKeyBreak = new JCheckBoxMenuItem(Translatrix.getTranslationString("EnterKeyBreak"), enterIsBreak); jcbmiEnterKeyBreak.setActionCommand(CMD_ENTER_BREAK); jcbmiEnterKeyBreak.addActionListener(this); jMenuEnterKey.add(jcbmiEnterKeyBreak); jMenuEdit.add(jMenuEnterKey); /* VIEW Menu */ jMenuView = new JMenu(Translatrix.getTranslationString("View")); htMenus.put(KEY_MENU_VIEW, jMenuView); if (includeToolBar) { if (multiBar) { jMenuToolbars = new JMenu(Translatrix.getTranslationString("ViewToolbars")); jcbmiViewToolbarMain = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbarMain"), false); jcbmiViewToolbarMain.setActionCommand(CMD_TOGGLE_TOOLBAR_MAIN); jcbmiViewToolbarMain.addActionListener(this); jMenuToolbars.add(jcbmiViewToolbarMain); jcbmiViewToolbarFormat = new JCheckBoxMenuItem( Translatrix.getTranslationString("ViewToolbarFormat"), false); jcbmiViewToolbarFormat.setActionCommand(CMD_TOGGLE_TOOLBAR_FORMAT); jcbmiViewToolbarFormat.addActionListener(this); jMenuToolbars.add(jcbmiViewToolbarFormat); jcbmiViewToolbarStyles = new JCheckBoxMenuItem( Translatrix.getTranslationString("ViewToolbarStyles"), false); jcbmiViewToolbarStyles.setActionCommand(CMD_TOGGLE_TOOLBAR_STYLES); jcbmiViewToolbarStyles.addActionListener(this); jMenuToolbars.add(jcbmiViewToolbarStyles); jMenuView.add(jMenuToolbars); } else { jcbmiViewToolbar = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewToolbar"), false); jcbmiViewToolbar.setActionCommand(CMD_TOGGLE_TOOLBAR_SINGLE); jcbmiViewToolbar.addActionListener(this); jMenuView.add(jcbmiViewToolbar); } } jcbmiViewSource = new JCheckBoxMenuItem(Translatrix.getTranslationString("ViewSource"), false); jcbmiViewSource.setActionCommand(CMD_TOGGLE_SOURCE_VIEW); jcbmiViewSource.addActionListener(this); jMenuView.add(jcbmiViewSource); /* FONT Menu */ jMenuFont = new JMenu(Translatrix.getTranslationString("Font")); htMenus.put(KEY_MENU_FONT, jMenuFont); JMenuItem jmiBold = new JMenuItem(actionFontBold); jmiBold.setText(Translatrix.getTranslationString("FontBold")); jmiBold.setAccelerator(KeyStroke.getKeyStroke('B', CTRLKEY, false)); if (showMenuIcons) { jmiBold.setIcon(getEkitIcon("Bold")); } jMenuFont.add(jmiBold); JMenuItem jmiItalic = new JMenuItem(actionFontItalic); jmiItalic.setText(Translatrix.getTranslationString("FontItalic")); jmiItalic.setAccelerator(KeyStroke.getKeyStroke('I', CTRLKEY, false)); if (showMenuIcons) { jmiItalic.setIcon(getEkitIcon("Italic")); } jMenuFont.add(jmiItalic); JMenuItem jmiUnderline = new JMenuItem(actionFontUnderline); jmiUnderline.setText(Translatrix.getTranslationString("FontUnderline")); jmiUnderline.setAccelerator(KeyStroke.getKeyStroke('U', CTRLKEY, false)); if (showMenuIcons) { jmiUnderline.setIcon(getEkitIcon("Underline")); } jMenuFont.add(jmiUnderline); JMenuItem jmiStrike = new JMenuItem(actionFontStrike); jmiStrike.setText(Translatrix.getTranslationString("FontStrike")); if (showMenuIcons) { jmiStrike.setIcon(getEkitIcon("Strike")); } jMenuFont.add(jmiStrike); JMenuItem jmiSupscript = new JMenuItem(actionFontSuperscript); if (showMenuIcons) { jmiSupscript.setIcon(getEkitIcon("Super")); } jMenuFont.add(jmiSupscript); JMenuItem jmiSubscript = new JMenuItem(actionFontSubscript); if (showMenuIcons) { jmiSubscript.setIcon(getEkitIcon("Sub")); } jMenuFont.add(jmiSubscript); jMenuFont.addSeparator(); jMenuFont.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatBig"), HTML.Tag.BIG))); jMenuFont.add(new JMenuItem( new FormatAction(this, Translatrix.getTranslationString("FormatSmall"), HTML.Tag.SMALL))); JMenu jMenuFontSize = new JMenu(Translatrix.getTranslationString("FontSize")); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize1"), 8))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize2"), 10))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize3"), 12))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize4"), 14))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize5"), 18))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize6"), 24))); jMenuFontSize.add(new JMenuItem( new StyledEditorKit.FontSizeAction(Translatrix.getTranslationString("FontSize7"), 32))); jMenuFont.add(jMenuFontSize); jMenuFont.addSeparator(); JMenu jMenuFontSub = new JMenu(Translatrix.getTranslationString("Font")); JMenuItem jmiSelectFont = new JMenuItem(actionSelectFont); jmiSelectFont.setText(Translatrix.getTranslationString("FontSelect") + menuDialog); if (showMenuIcons) { jmiSelectFont.setIcon(getEkitIcon("FontFaces")); } jMenuFontSub.add(jmiSelectFont); JMenuItem jmiSerif = new JMenuItem((Action) actions.get("font-family-Serif")); jmiSerif.setText(Translatrix.getTranslationString("FontSerif")); jMenuFontSub.add(jmiSerif); JMenuItem jmiSansSerif = new JMenuItem((Action) actions.get("font-family-SansSerif")); jmiSansSerif.setText(Translatrix.getTranslationString("FontSansserif")); jMenuFontSub.add(jmiSansSerif); JMenuItem jmiMonospaced = new JMenuItem((Action) actions.get("font-family-Monospaced")); jmiMonospaced.setText(Translatrix.getTranslationString("FontMonospaced")); jMenuFontSub.add(jmiMonospaced); jMenuFont.add(jMenuFontSub); jMenuFont.addSeparator(); JMenu jMenuFontColor = new JMenu(Translatrix.getTranslationString("Color")); Hashtable<String, String> customAttr = new Hashtable<String, String>(); customAttr.put("color", "black"); jMenuFontColor.add(new JMenuItem(new CustomAction(this, Translatrix.getTranslationString("CustomColor") + menuDialog, HTML.Tag.FONT, customAttr))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorAqua"), new Color(0, 255, 255)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorBlack"), new Color(0, 0, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorBlue"), new Color(0, 0, 255)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorFuschia"), new Color(255, 0, 255)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorGray"), new Color(128, 128, 128)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorGreen"), new Color(0, 128, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorLime"), new Color(0, 255, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorMaroon"), new Color(128, 0, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorNavy"), new Color(0, 0, 128)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorOlive"), new Color(128, 128, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorPurple"), new Color(128, 0, 128)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorRed"), new Color(255, 0, 0)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorSilver"), new Color(192, 192, 192)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorTeal"), new Color(0, 128, 128)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorWhite"), new Color(255, 255, 255)))); jMenuFontColor.add(new JMenuItem(new StyledEditorKit.ForegroundAction( Translatrix.getTranslationString("ColorYellow"), new Color(255, 255, 0)))); jMenuFont.add(jMenuFontColor); /* FORMAT Menu */ jMenuFormat = new JMenu(Translatrix.getTranslationString("Format")); htMenus.put(KEY_MENU_FORMAT, jMenuFormat); JMenuItem jmiClearFormat = new JMenuItem(actionClearFormat); jMenuFormat.add(jmiClearFormat); jMenuFormat.addSeparator(); JMenu jMenuFormatAlign = new JMenu(Translatrix.getTranslationString("Align")); JMenuItem jmiAlignLeft = new JMenuItem(actionAlignLeft); if (showMenuIcons) { jmiAlignLeft.setIcon(getEkitIcon("AlignLeft")); } ; jMenuFormatAlign.add(jmiAlignLeft); JMenuItem jmiAlignCenter = new JMenuItem(actionAlignCenter); if (showMenuIcons) { jmiAlignCenter.setIcon(getEkitIcon("AlignCenter")); } ; jMenuFormatAlign.add(jmiAlignCenter); JMenuItem jmiAlignRight = new JMenuItem(actionAlignRight); if (showMenuIcons) { jmiAlignRight.setIcon(getEkitIcon("AlignRight")); } ; jMenuFormatAlign.add(jmiAlignRight); JMenuItem jmiAlignJustified = new JMenuItem(actionAlignJustified); if (showMenuIcons) { jmiAlignJustified.setIcon(getEkitIcon("AlignJustified")); } ; jMenuFormatAlign.add(jmiAlignJustified); jMenuFormat.add(jMenuFormatAlign); jMenuFormat.addSeparator(); JMenu jMenuFormatHeading = new JMenu(Translatrix.getTranslationString("Heading")); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading1"), HTML.Tag.H1))); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading2"), HTML.Tag.H2))); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading3"), HTML.Tag.H3))); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading4"), HTML.Tag.H4))); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading5"), HTML.Tag.H5))); jMenuFormatHeading.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("Heading6"), HTML.Tag.H6))); jMenuFormat.add(jMenuFormatHeading); jMenuFormat.addSeparator(); JMenuItem jmiUList = new JMenuItem(actionListUnordered); if (showMenuIcons) { jmiUList.setIcon(getEkitIcon("UList")); } jMenuFormat.add(jmiUList); JMenuItem jmiOList = new JMenuItem(actionListOrdered); if (showMenuIcons) { jmiOList.setIcon(getEkitIcon("OList")); } jMenuFormat.add(jmiOList); jMenuFormat.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("ListItem"), HTML.Tag.LI))); jMenuFormat.addSeparator(); jMenuFormat.add(new JMenuItem( new FormatAction(this, Translatrix.getTranslationString("FormatBlockquote"), HTML.Tag.BLOCKQUOTE))); jMenuFormat.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatPre"), HTML.Tag.PRE))); jMenuFormat.add(new JMenuItem( new FormatAction(this, Translatrix.getTranslationString("FormatStrong"), HTML.Tag.STRONG))); jMenuFormat.add(new JMenuItem( new FormatAction(this, Translatrix.getTranslationString("FormatEmphasis"), HTML.Tag.EM))); jMenuFormat.add( new JMenuItem(new FormatAction(this, Translatrix.getTranslationString("FormatTT"), HTML.Tag.TT))); jMenuFormat.add(new JMenuItem( new FormatAction(this, Translatrix.getTranslationString("FormatSpan"), HTML.Tag.SPAN))); /* INSERT Menu */ jMenuInsert = new JMenu(Translatrix.getTranslationString("Insert")); htMenus.put(KEY_MENU_INSERT, jMenuInsert); JMenuItem jmiInsertAnchor = new JMenuItem(actionInsertAnchor); if (showMenuIcons) { jmiInsertAnchor.setIcon(getEkitIcon("Anchor")); } ; jMenuInsert.add(jmiInsertAnchor); JMenuItem jmiBreak = new JMenuItem(Translatrix.getTranslationString("InsertBreak")); jmiBreak.setActionCommand(CMD_INSERT_BREAK); jmiBreak.addActionListener(this); jmiBreak.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_MASK, false)); jMenuInsert.add(jmiBreak); JMenuItem jmiNBSP = new JMenuItem(Translatrix.getTranslationString("InsertNBSP")); jmiNBSP.setActionCommand(CMD_INSERT_NBSP); jmiNBSP.addActionListener(this); jmiNBSP.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.SHIFT_MASK, false)); jMenuInsert.add(jmiNBSP); JMenu jMenuUnicode = new JMenu(Translatrix.getTranslationString("InsertUnicodeCharacter")); if (showMenuIcons) { jMenuUnicode.setIcon(getEkitIcon("Unicode")); } ; JMenuItem jmiUnicodeAll = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterAll") + menuDialog); if (showMenuIcons) { jmiUnicodeAll.setIcon(getEkitIcon("Unicode")); } ; jmiUnicodeAll.setActionCommand(CMD_INSERT_UNICODE_CHAR); jmiUnicodeAll.addActionListener(this); jMenuUnicode.add(jmiUnicodeAll); JMenuItem jmiUnicodeMath = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterMath") + menuDialog); if (showMenuIcons) { jmiUnicodeMath.setIcon(getEkitIcon("Math")); } ; jmiUnicodeMath.setActionCommand(CMD_INSERT_UNICODE_MATH); jmiUnicodeMath.addActionListener(this); jMenuUnicode.add(jmiUnicodeMath); JMenuItem jmiUnicodeDraw = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterDraw") + menuDialog); if (showMenuIcons) { jmiUnicodeDraw.setIcon(getEkitIcon("Draw")); } ; jmiUnicodeDraw.setActionCommand(CMD_INSERT_UNICODE_DRAW); jmiUnicodeDraw.addActionListener(this); jMenuUnicode.add(jmiUnicodeDraw); JMenuItem jmiUnicodeDing = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterDing") + menuDialog); jmiUnicodeDing.setActionCommand(CMD_INSERT_UNICODE_DING); jmiUnicodeDing.addActionListener(this); jMenuUnicode.add(jmiUnicodeDing); JMenuItem jmiUnicodeSigs = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterSigs") + menuDialog); jmiUnicodeSigs.setActionCommand(CMD_INSERT_UNICODE_SIGS); jmiUnicodeSigs.addActionListener(this); jMenuUnicode.add(jmiUnicodeSigs); JMenuItem jmiUnicodeSpec = new JMenuItem( Translatrix.getTranslationString("InsertUnicodeCharacterSpec") + menuDialog); jmiUnicodeSpec.setActionCommand(CMD_INSERT_UNICODE_SPEC); jmiUnicodeSpec.addActionListener(this); jMenuUnicode.add(jmiUnicodeSpec); jMenuInsert.add(jMenuUnicode); JMenuItem jmiHRule = new JMenuItem(Translatrix.getTranslationString("InsertHorizontalRule")); jmiHRule.setActionCommand(CMD_INSERT_HR); jmiHRule.addActionListener(this); jMenuInsert.add(jmiHRule); jMenuInsert.addSeparator(); if (!isParentApplet) { JMenuItem jmiImageLocal = new JMenuItem( Translatrix.getTranslationString("InsertLocalImage") + menuDialog); jmiImageLocal.setActionCommand(CMD_INSERT_IMAGE_LOCAL); jmiImageLocal.addActionListener(this); jMenuInsert.add(jmiImageLocal); } JMenuItem jmiImageURL = new JMenuItem(Translatrix.getTranslationString("InsertURLImage") + menuDialog); jmiImageURL.setActionCommand(CMD_INSERT_IMAGE_URL); jmiImageURL.addActionListener(this); jMenuInsert.add(jmiImageURL); /* TABLE Menu */ jMenuTable = new JMenu(Translatrix.getTranslationString("Table")); htMenus.put(KEY_MENU_TABLE, jMenuTable); JMenuItem jmiTable = new JMenuItem(actionTableInsert); if (!showMenuIcons) { jmiTable.setIcon(null); } jMenuTable.add(jmiTable); jMenuTable.addSeparator(); Action actionTableEdit = new CommandAction(Translatrix.getTranslationString("TableEdit") + menuDialog, getEkitIcon("TableEdit"), CMD_TABLE_EDIT, this); JMenuItem jmiEditTable = new JMenuItem(actionTableEdit); if (!showMenuIcons) { jmiEditTable.setIcon(null); } jMenuTable.add(jmiEditTable); Action actionCellEdit = new CommandAction(Translatrix.getTranslationString("TableCellEdit") + menuDialog, getEkitIcon("CellEdit"), CMD_TABLE_CELL_EDIT, this); JMenuItem jmiEditCell = new JMenuItem(actionCellEdit); if (!showMenuIcons) { jmiEditCell.setIcon(null); } jmiEditCell.setActionCommand(CMD_TABLE_CELL_EDIT); jmiEditCell.addActionListener(this); jMenuTable.add(jmiEditCell); jMenuTable.addSeparator(); JMenuItem jmiTableRow = new JMenuItem(actionTableRow); if (!showMenuIcons) { jmiTableRow.setIcon(null); } jMenuTable.add(jmiTableRow); JMenuItem jmiTableCol = new JMenuItem(actionTableCol); if (!showMenuIcons) { jmiTableCol.setIcon(null); } jMenuTable.add(jmiTableCol); jMenuTable.addSeparator(); JMenuItem jmiTableRowDel = new JMenuItem(actionTableRowDel); if (!showMenuIcons) { jmiTableRowDel.setIcon(null); } jMenuTable.add(jmiTableRowDel); JMenuItem jmiTableColDel = new JMenuItem(actionTableColDel); if (!showMenuIcons) { jmiTableColDel.setIcon(null); } jMenuTable.add(jmiTableColDel); /* FORMS Menu */ jMenuForms = new JMenu(Translatrix.getTranslationString("Forms")); htMenus.put(KEY_MENU_FORMS, jMenuForms); JMenuItem jmiFormInsertForm = new JMenuItem(Translatrix.getTranslationString("FormInsertForm")); jmiFormInsertForm.setActionCommand(CMD_FORM_INSERT); jmiFormInsertForm.addActionListener(this); jMenuForms.add(jmiFormInsertForm); jMenuForms.addSeparator(); JMenuItem jmiFormTextfield = new JMenuItem(Translatrix.getTranslationString("FormTextfield")); jmiFormTextfield.setActionCommand(CMD_FORM_TEXTFIELD); jmiFormTextfield.addActionListener(this); jMenuForms.add(jmiFormTextfield); JMenuItem jmiFormTextarea = new JMenuItem(Translatrix.getTranslationString("FormTextarea")); jmiFormTextarea.setActionCommand(CMD_FORM_TEXTAREA); jmiFormTextarea.addActionListener(this); jMenuForms.add(jmiFormTextarea); JMenuItem jmiFormCheckbox = new JMenuItem(Translatrix.getTranslationString("FormCheckbox")); jmiFormCheckbox.setActionCommand(CMD_FORM_CHECKBOX); jmiFormCheckbox.addActionListener(this); jMenuForms.add(jmiFormCheckbox); JMenuItem jmiFormRadio = new JMenuItem(Translatrix.getTranslationString("FormRadio")); jmiFormRadio.setActionCommand(CMD_FORM_RADIO); jmiFormRadio.addActionListener(this); jMenuForms.add(jmiFormRadio); JMenuItem jmiFormPassword = new JMenuItem(Translatrix.getTranslationString("FormPassword")); jmiFormPassword.setActionCommand(CMD_FORM_PASSWORD); jmiFormPassword.addActionListener(this); jMenuForms.add(jmiFormPassword); jMenuForms.addSeparator(); JMenuItem jmiFormButton = new JMenuItem(Translatrix.getTranslationString("FormButton")); jmiFormButton.setActionCommand(CMD_FORM_BUTTON); jmiFormButton.addActionListener(this); jMenuForms.add(jmiFormButton); JMenuItem jmiFormButtonSubmit = new JMenuItem(Translatrix.getTranslationString("FormButtonSubmit")); jmiFormButtonSubmit.setActionCommand(CMD_FORM_SUBMIT); jmiFormButtonSubmit.addActionListener(this); jMenuForms.add(jmiFormButtonSubmit); JMenuItem jmiFormButtonReset = new JMenuItem(Translatrix.getTranslationString("FormButtonReset")); jmiFormButtonReset.setActionCommand(CMD_FORM_RESET); jmiFormButtonReset.addActionListener(this); jMenuForms.add(jmiFormButtonReset); /* TOOLS Menu */ if (hasSpellChecker) { jMenuTools = new JMenu(Translatrix.getTranslationString("Tools")); htMenus.put(KEY_MENU_TOOLS, jMenuTools); JMenuItem jmiSpellcheck = new JMenuItem(Translatrix.getTranslationString("ToolSpellcheck")); jmiSpellcheck.setActionCommand(CMD_SPELLCHECK); jmiSpellcheck.addActionListener(this); jMenuTools.add(jmiSpellcheck); } /* SEARCH Menu */ jMenuSearch = new JMenu(Translatrix.getTranslationString("Search")); htMenus.put(KEY_MENU_SEARCH, jMenuSearch); JMenuItem jmiFind = new JMenuItem(Translatrix.getTranslationString("SearchFind")); if (showMenuIcons) { jmiFind.setIcon(getEkitIcon("Find")); } ; jmiFind.setActionCommand(CMD_SEARCH_FIND); jmiFind.addActionListener(this); jmiFind.setAccelerator(KeyStroke.getKeyStroke('F', CTRLKEY, false)); jMenuSearch.add(jmiFind); JMenuItem jmiFindAgain = new JMenuItem(Translatrix.getTranslationString("SearchFindAgain")); if (showMenuIcons) { jmiFindAgain.setIcon(getEkitIcon("FindAgain")); } ; jmiFindAgain.setActionCommand(CMD_SEARCH_FIND_AGAIN); jmiFindAgain.addActionListener(this); jmiFindAgain.setAccelerator(KeyStroke.getKeyStroke('G', CTRLKEY, false)); jMenuSearch.add(jmiFindAgain); JMenuItem jmiReplace = new JMenuItem(Translatrix.getTranslationString("SearchReplace")); if (showMenuIcons) { jmiReplace.setIcon(getEkitIcon("Replace")); } ; jmiReplace.setActionCommand(CMD_SEARCH_REPLACE); jmiReplace.addActionListener(this); jmiReplace.setAccelerator(KeyStroke.getKeyStroke('R', CTRLKEY, false)); jMenuSearch.add(jmiReplace); /* HELP Menu */ jMenuHelp = new JMenu(Translatrix.getTranslationString("Help")); htMenus.put(KEY_MENU_HELP, jMenuHelp); JMenuItem jmiAbout = new JMenuItem(Translatrix.getTranslationString("About")); jmiAbout.setActionCommand(CMD_HELP_ABOUT); jmiAbout.addActionListener(this); jMenuHelp.add(jmiAbout); /* DEBUG Menu */ jMenuDebug = new JMenu(Translatrix.getTranslationString("Debug")); htMenus.put(KEY_MENU_DEBUG, jMenuDebug); JMenuItem jmiDesc = new JMenuItem(Translatrix.getTranslationString("DescribeDoc")); jmiDesc.setActionCommand(CMD_DEBUG_DESCRIBE_DOC); jmiDesc.addActionListener(this); jMenuDebug.add(jmiDesc); JMenuItem jmiDescCSS = new JMenuItem(Translatrix.getTranslationString("DescribeCSS")); jmiDescCSS.setActionCommand(CMD_DEBUG_DESCRIBE_CSS); jmiDescCSS.addActionListener(this); jMenuDebug.add(jmiDescCSS); JMenuItem jmiTag = new JMenuItem(Translatrix.getTranslationString("WhatTags")); jmiTag.setActionCommand(CMD_DEBUG_CURRENT_TAGS); jmiTag.addActionListener(this); jMenuDebug.add(jmiTag); /* Create menubar and add menus */ jMenuBar = new JMenuBar(); jMenuBar.add(jMenuFile); jMenuBar.add(jMenuEdit); jMenuBar.add(jMenuView); jMenuBar.add(jMenuFont); jMenuBar.add(jMenuFormat); jMenuBar.add(jMenuSearch); jMenuBar.add(jMenuInsert); jMenuBar.add(jMenuTable); jMenuBar.add(jMenuForms); if (jMenuTools != null) { jMenuBar.add(jMenuTools); } jMenuBar.add(jMenuHelp); if (debugMode) { jMenuBar.add(jMenuDebug); } /* Create toolbar tool objects */ jbtnNewHTML = new JButtonNoFocus(getEkitIcon("New")); jbtnNewHTML.setToolTipText(Translatrix.getTranslationString("NewDocument")); jbtnNewHTML.setActionCommand(CMD_DOC_NEW); jbtnNewHTML.addActionListener(this); htTools.put(KEY_TOOL_NEW, jbtnNewHTML); jbtnNewStyledHTML = new JButtonNoFocus(getEkitIcon("NewStyled")); jbtnNewStyledHTML.setToolTipText(Translatrix.getTranslationString("NewStyledDocument")); jbtnNewStyledHTML.setActionCommand(CMD_DOC_NEW_STYLED); jbtnNewStyledHTML.addActionListener(this); htTools.put(KEY_TOOL_NEWSTYLED, jbtnNewStyledHTML); jbtnOpenHTML = new JButtonNoFocus(getEkitIcon("Open")); jbtnOpenHTML.setToolTipText(Translatrix.getTranslationString("OpenDocument")); jbtnOpenHTML.setActionCommand(CMD_DOC_OPEN_HTML); jbtnOpenHTML.addActionListener(this); htTools.put(KEY_TOOL_OPEN, jbtnOpenHTML); jbtnSaveHTML = new JButtonNoFocus(getEkitIcon("Save")); jbtnSaveHTML.setToolTipText(Translatrix.getTranslationString("SaveDocument")); jbtnSaveHTML.setActionCommand(CMD_DOC_SAVE_AS); jbtnSaveHTML.addActionListener(this); htTools.put(KEY_TOOL_SAVE, jbtnSaveHTML); jbtnPrint = new JButtonNoFocus(getEkitIcon("Print")); jbtnPrint.setToolTipText(Translatrix.getTranslationString("PrintDocument")); jbtnPrint.setActionCommand(CMD_DOC_PRINT); jbtnPrint.addActionListener(this); htTools.put(KEY_TOOL_PRINT, jbtnPrint); // jbtnCut = new JButtonNoFocus(new DefaultEditorKit.CutAction()); jbtnCut = new JButtonNoFocus(); jbtnCut.setActionCommand(CMD_CLIP_CUT); jbtnCut.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EkitCore.this.actionPerformed(evt); } }); jbtnCut.setIcon(getEkitIcon("Cut")); jbtnCut.setText(null); jbtnCut.setToolTipText(Translatrix.getTranslationString("Cut")); htTools.put(KEY_TOOL_CUT, jbtnCut); // jbtnCopy = new JButtonNoFocus(new DefaultEditorKit.CopyAction()); jbtnCopy = new JButtonNoFocus(); jbtnCopy.setActionCommand(CMD_CLIP_COPY); jbtnCopy.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EkitCore.this.actionPerformed(evt); } }); jbtnCopy.setIcon(getEkitIcon("Copy")); jbtnCopy.setText(null); jbtnCopy.setToolTipText(Translatrix.getTranslationString("Copy")); htTools.put(KEY_TOOL_COPY, jbtnCopy); // jbtnPaste = new JButtonNoFocus(new DefaultEditorKit.PasteAction()); jbtnPaste = new JButtonNoFocus(); jbtnPaste.setActionCommand(CMD_CLIP_PASTE); jbtnPaste.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EkitCore.this.actionPerformed(evt); } }); jbtnPaste.setIcon(getEkitIcon("Paste")); jbtnPaste.setText(null); jbtnPaste.setToolTipText(Translatrix.getTranslationString("Paste")); htTools.put(KEY_TOOL_PASTE, jbtnPaste); jbtnPasteX = new JButtonNoFocus(); jbtnPasteX.setActionCommand(CMD_CLIP_PASTE_PLAIN); jbtnPasteX.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EkitCore.this.actionPerformed(evt); } }); jbtnPasteX.setIcon(getEkitIcon("PasteUnformatted")); jbtnPasteX.setText(null); jbtnPasteX.setToolTipText(Translatrix.getTranslationString("PasteUnformatted")); htTools.put(KEY_TOOL_PASTEX, jbtnPasteX); jbtnUndo = new JButtonNoFocus(undoAction); jbtnUndo.setIcon(getEkitIcon("Undo")); jbtnUndo.setText(null); jbtnUndo.setToolTipText(Translatrix.getTranslationString("Undo")); htTools.put(KEY_TOOL_UNDO, jbtnUndo); jbtnRedo = new JButtonNoFocus(redoAction); jbtnRedo.setIcon(getEkitIcon("Redo")); jbtnRedo.setText(null); jbtnRedo.setToolTipText(Translatrix.getTranslationString("Redo")); htTools.put(KEY_TOOL_REDO, jbtnRedo); jbtnBold = new JButtonNoFocus(actionFontBold); jbtnBold.setIcon(getEkitIcon("Bold")); jbtnBold.setText(null); jbtnBold.setToolTipText(Translatrix.getTranslationString("FontBold")); htTools.put(KEY_TOOL_BOLD, jbtnBold); jbtnItalic = new JButtonNoFocus(actionFontItalic); jbtnItalic.setIcon(getEkitIcon("Italic")); jbtnItalic.setText(null); jbtnItalic.setToolTipText(Translatrix.getTranslationString("FontItalic")); htTools.put(KEY_TOOL_ITALIC, jbtnItalic); jbtnUnderline = new JButtonNoFocus(actionFontUnderline); jbtnUnderline.setIcon(getEkitIcon("Underline")); jbtnUnderline.setText(null); jbtnUnderline.setToolTipText(Translatrix.getTranslationString("FontUnderline")); htTools.put(KEY_TOOL_UNDERLINE, jbtnUnderline); jbtnStrike = new JButtonNoFocus(actionFontStrike); jbtnStrike.setIcon(getEkitIcon("Strike")); jbtnStrike.setText(null); jbtnStrike.setToolTipText(Translatrix.getTranslationString("FontStrike")); htTools.put(KEY_TOOL_STRIKE, jbtnStrike); jbtnSuperscript = new JButtonNoFocus(actionFontSuperscript); jbtnSuperscript.setIcon(getEkitIcon("Super")); jbtnSuperscript.setText(null); jbtnSuperscript.setToolTipText(Translatrix.getTranslationString("FontSuperscript")); htTools.put(KEY_TOOL_SUPER, jbtnSuperscript); jbtnSubscript = new JButtonNoFocus(actionFontSubscript); jbtnSubscript.setIcon(getEkitIcon("Sub")); jbtnSubscript.setText(null); jbtnSubscript.setToolTipText(Translatrix.getTranslationString("FontSubscript")); htTools.put(KEY_TOOL_SUB, jbtnSubscript); jbtnUList = new JButtonNoFocus(actionListUnordered); jbtnUList.setIcon(getEkitIcon("UList")); jbtnUList.setText(null); jbtnUList.setToolTipText(Translatrix.getTranslationString("ListUnordered")); htTools.put(KEY_TOOL_ULIST, jbtnUList); jbtnOList = new JButtonNoFocus(actionListOrdered); jbtnOList.setIcon(getEkitIcon("OList")); jbtnOList.setText(null); jbtnOList.setToolTipText(Translatrix.getTranslationString("ListOrdered")); htTools.put(KEY_TOOL_OLIST, jbtnOList); jbtnAlignLeft = new JButtonNoFocus(actionAlignLeft); jbtnAlignLeft.setIcon(getEkitIcon("AlignLeft")); jbtnAlignLeft.setText(null); jbtnAlignLeft.setToolTipText(Translatrix.getTranslationString("AlignLeft")); htTools.put(KEY_TOOL_ALIGNL, jbtnAlignLeft); jbtnAlignCenter = new JButtonNoFocus(actionAlignCenter); jbtnAlignCenter.setIcon(getEkitIcon("AlignCenter")); jbtnAlignCenter.setText(null); jbtnAlignCenter.setToolTipText(Translatrix.getTranslationString("AlignCenter")); htTools.put(KEY_TOOL_ALIGNC, jbtnAlignCenter); jbtnAlignRight = new JButtonNoFocus(actionAlignRight); jbtnAlignRight.setIcon(getEkitIcon("AlignRight")); jbtnAlignRight.setText(null); jbtnAlignRight.setToolTipText(Translatrix.getTranslationString("AlignRight")); htTools.put(KEY_TOOL_ALIGNR, jbtnAlignRight); jbtnAlignJustified = new JButtonNoFocus(actionAlignJustified); jbtnAlignJustified.setIcon(getEkitIcon("AlignJustified")); jbtnAlignJustified.setText(null); jbtnAlignJustified.setToolTipText(Translatrix.getTranslationString("AlignJustified")); htTools.put(KEY_TOOL_ALIGNJ, jbtnAlignJustified); jbtnUnicode = new JButtonNoFocus(); jbtnUnicode.setActionCommand(CMD_INSERT_UNICODE_CHAR); jbtnUnicode.addActionListener(this); jbtnUnicode.setIcon(getEkitIcon("Unicode")); jbtnUnicode.setText(null); jbtnUnicode.setToolTipText(Translatrix.getTranslationString("ToolUnicode")); htTools.put(KEY_TOOL_UNICODE, jbtnUnicode); jbtnUnicodeMath = new JButtonNoFocus(); jbtnUnicodeMath.setActionCommand(CMD_INSERT_UNICODE_MATH); jbtnUnicodeMath.addActionListener(this); jbtnUnicodeMath.setIcon(getEkitIcon("Math")); jbtnUnicodeMath.setText(null); jbtnUnicodeMath.setToolTipText(Translatrix.getTranslationString("ToolUnicodeMath")); htTools.put(KEY_TOOL_UNIMATH, jbtnUnicodeMath); jbtnFind = new JButtonNoFocus(); jbtnFind.setActionCommand(CMD_SEARCH_FIND); jbtnFind.addActionListener(this); jbtnFind.setIcon(getEkitIcon("Find")); jbtnFind.setText(null); jbtnFind.setToolTipText(Translatrix.getTranslationString("SearchFind")); htTools.put(KEY_TOOL_FIND, jbtnFind); jbtnAnchor = new JButtonNoFocus(actionInsertAnchor); jbtnAnchor.setIcon(getEkitIcon("Anchor")); jbtnAnchor.setText(null); jbtnAnchor.setToolTipText(Translatrix.getTranslationString("ToolAnchor")); htTools.put(KEY_TOOL_ANCHOR, jbtnAnchor); jtbtnViewSource = new JToggleButtonNoFocus(getEkitIcon("Source")); jtbtnViewSource.setText(null); jtbtnViewSource.setToolTipText(Translatrix.getTranslationString("ViewSource")); jtbtnViewSource.setActionCommand(CMD_TOGGLE_SOURCE_VIEW); jtbtnViewSource.addActionListener(this); jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); htTools.put(KEY_TOOL_SOURCE, jtbtnViewSource); jcmbStyleSelector = new JComboBoxNoFocus(); jcmbStyleSelector.setToolTipText(Translatrix.getTranslationString("PickCSSStyle")); jcmbStyleSelector.setAction(new StylesAction(jcmbStyleSelector)); htTools.put(KEY_TOOL_STYLES, jcmbStyleSelector); String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); Vector<String> vcFontnames = new Vector<String>(fonts.length + 1); vcFontnames.add(Translatrix.getTranslationString("SelectorToolFontsDefaultFont")); for (String fontname : fonts) { vcFontnames.add(fontname); } Collections.sort(vcFontnames); jcmbFontSelector = new JComboBoxNoFocus(vcFontnames); jcmbFontSelector.setAction(new SetFontFamilyAction(this, "[EKITFONTSELECTOR]")); htTools.put(KEY_TOOL_FONTS, jcmbFontSelector); jbtnInsertTable = new JButtonNoFocus(); jbtnInsertTable.setActionCommand(CMD_TABLE_INSERT); jbtnInsertTable.addActionListener(this); jbtnInsertTable.setIcon(getEkitIcon("TableCreate")); jbtnInsertTable.setText(null); jbtnInsertTable.setToolTipText(Translatrix.getTranslationString("InsertTable")); htTools.put(KEY_TOOL_INSTABLE, jbtnInsertTable); jbtnEditTable = new JButtonNoFocus(); jbtnEditTable.setActionCommand(CMD_TABLE_EDIT); jbtnEditTable.addActionListener(this); jbtnEditTable.setIcon(getEkitIcon("TableEdit")); jbtnEditTable.setText(null); jbtnEditTable.setToolTipText(Translatrix.getTranslationString("TableEdit")); htTools.put(KEY_TOOL_EDITTABLE, jbtnEditTable); jbtnEditCell = new JButtonNoFocus(); jbtnEditCell.setActionCommand(CMD_TABLE_CELL_EDIT); jbtnEditCell.addActionListener(this); jbtnEditCell.setIcon(getEkitIcon("CellEdit")); jbtnEditCell.setText(null); jbtnEditCell.setToolTipText(Translatrix.getTranslationString("TableCellEdit")); htTools.put(KEY_TOOL_EDITCELL, jbtnEditCell); jbtnInsertRow = new JButtonNoFocus(); jbtnInsertRow.setActionCommand(CMD_TABLE_ROW_INSERT); jbtnInsertRow.addActionListener(this); jbtnInsertRow.setIcon(getEkitIcon("InsertRow")); jbtnInsertRow.setText(null); jbtnInsertRow.setToolTipText(Translatrix.getTranslationString("InsertTableRow")); htTools.put(KEY_TOOL_INSERTROW, jbtnInsertRow); jbtnInsertColumn = new JButtonNoFocus(); jbtnInsertColumn.setActionCommand(CMD_TABLE_COLUMN_INSERT); jbtnInsertColumn.addActionListener(this); jbtnInsertColumn.setIcon(getEkitIcon("InsertColumn")); jbtnInsertColumn.setText(null); jbtnInsertColumn.setToolTipText(Translatrix.getTranslationString("InsertTableColumn")); htTools.put(KEY_TOOL_INSERTCOL, jbtnInsertColumn); jbtnDeleteRow = new JButtonNoFocus(); jbtnDeleteRow.setActionCommand(CMD_TABLE_ROW_DELETE); jbtnDeleteRow.addActionListener(this); jbtnDeleteRow.setIcon(getEkitIcon("DeleteRow")); jbtnDeleteRow.setText(null); jbtnDeleteRow.setToolTipText(Translatrix.getTranslationString("DeleteTableRow")); htTools.put(KEY_TOOL_DELETEROW, jbtnDeleteRow); jbtnDeleteColumn = new JButtonNoFocus(); jbtnDeleteColumn.setActionCommand(CMD_TABLE_COLUMN_DELETE); jbtnDeleteColumn.addActionListener(this); jbtnDeleteColumn.setIcon(getEkitIcon("DeleteColumn")); jbtnDeleteColumn.setText(null); jbtnDeleteColumn.setToolTipText(Translatrix.getTranslationString("DeleteTableColumn")); htTools.put(KEY_TOOL_DELETECOL, jbtnDeleteColumn); jbtnMaximize = new JButtonNoFocus(); jbtnMaximize.setActionCommand(CMD_MAXIMIZE); jbtnMaximize.addActionListener(this); jbtnMaximize.setIcon(getEkitIcon("Maximize")); jbtnMaximize.setText(null); jbtnMaximize.setToolTipText(Translatrix.getTranslationString("Maximize")); htTools.put(KEY_TOOL_MAXIMIZE, jbtnMaximize); jbtnClearFormat = new JButtonNoFocus(actionClearFormat); jbtnClearFormat.setIcon(getEkitIcon("ClearFormat")); jbtnClearFormat.setText(null); jbtnClearFormat.setToolTipText(Translatrix.getTranslationString("ClearFormat")); htTools.put(KEY_TOOL_CLEAR_FORMAT, jbtnClearFormat); jbtnSpecialChar = new JButtonNoFocus(actionSpecialChar); jbtnSpecialChar.setIcon(getEkitIcon("SpecialChar")); jbtnSpecialChar.setText(null); jbtnSpecialChar.setToolTipText(Translatrix.getTranslationString("SpecialChar")); htTools.put(KEY_TOOL_SPECIAL_CHAR, jbtnSpecialChar); jbtnTableButtonMenu = new JButtonNoFocus(actionTableButtonMenu); jbtnTableButtonMenu.setText(null); htTools.put(KEY_TOOL_TABLE_MENU, jbtnTableButtonMenu); /* Create the toolbar */ if (multiBar) { jToolBarMain = new JToolBar(JToolBar.HORIZONTAL); jToolBarMain.setFloatable(false); jToolBarFormat = new JToolBar(JToolBar.HORIZONTAL); jToolBarFormat.setFloatable(false); jToolBarStyles = new JToolBar(JToolBar.HORIZONTAL); jToolBarStyles.setFloatable(false); initializeMultiToolbars(toolbarSeq); // fix the weird size preference of toggle buttons jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); } else if (includeToolBar) { jToolBar = new JToolBar(JToolBar.HORIZONTAL); jToolBar.setFloatable(false); initializeSingleToolbar(toolbarSeq); // fix the weird size preference of toggle buttons jtbtnViewSource.setPreferredSize(jbtnAnchor.getPreferredSize()); jtbtnViewSource.setMinimumSize(jbtnAnchor.getMinimumSize()); jtbtnViewSource.setMaximumSize(jbtnAnchor.getMaximumSize()); } /* Create the scroll area for the text pane */ jspViewport = new JScrollPane(jtpMain); jspViewport.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); jspViewport.setPreferredSize(new Dimension(400, 400)); jspViewport.setMinimumSize(new Dimension(32, 32)); /* Create the scroll area for the source viewer */ jspSource = new JScrollPane(jtpSource); jspSource.setPreferredSize(new Dimension(400, 100)); jspSource.setMinimumSize(new Dimension(32, 32)); displayPanel = new JPanel(); displayPanel.setLayout(new CardLayout()); displayPanel.add(jspViewport, PANEL_NAME_MAIN); displayPanel.add(jspSource, PANEL_NAME_SOURCE); if (showViewSource) { toggleSourceWindow(); } registerDocumentStyles(); tableCtl = new TableController(this); htmlDoc.setInlineEdit(inlineEdit); htmlDoc.addFilter(new HTMLTableDocumentFilter()); // Inicializa documento pelos behaviors for (HTMLDocumentBehavior b : this.behaviors) { b.initializeDocument(jtpMain); } htmlDoc.getBehaviors().addAll(this.behaviors); /* Add the components to the app */ this.setLayout(new BorderLayout()); this.add(displayPanel, BorderLayout.CENTER); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
/** * Creates new form FAdmin// w w w . j ava 2s .c om */ public FAdmin() { addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { timer.stop(); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { Uses.closeSplash(); } @Override public void windowDeactivated(WindowEvent e) { } }); initComponents(); setTitle(getTitle() + " " + Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF())); try { setIconImage( ImageIO.read(FAdmin.class.getResource("/ru/apertum/qsystem/client/forms/resources/admin.png"))); } catch (IOException ex) { System.err.println(ex); } // final Toolkit kit = Toolkit.getDefaultToolkit(); setLocation((Math.round(kit.getScreenSize().width - getWidth()) / 2), (Math.round(kit.getScreenSize().height - getHeight()) / 2)); // ? ? final JFrame fr = this; tray = QTray.getInstance(fr, "/ru/apertum/qsystem/client/forms/resources/admin.png", getLocaleMessage("tray.caption")); tray.addItem(getLocaleMessage("tray.caption"), (ActionEvent e) -> { setVisible(true); setState(JFrame.NORMAL); }); tray.addItem("-", (ActionEvent e) -> { }); tray.addItem(getLocaleMessage("tray.exit"), (ActionEvent e) -> { dispose(); System.exit(0); }); int ii = 1; final ButtonGroup bg = new ButtonGroup(); final String currLng = Locales.getInstance().getLangCurrName(); for (String lng : Locales.getInstance().getAvailableLocales()) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem( org.jdesktop.application.Application.getInstance(ru.apertum.qsystem.QSystem.class).getContext() .getActionMap(FAdmin.class, fr).get("setCurrentLang")); bg.add(item); item.setSelected(lng.equals(currLng)); item.setText(lng); // NOI18N item.setName("QRadioButtonMenuItem" + (ii++)); // NOI18N menuLangs.add(item); } // ?? ??. listUsers.addListSelectionListener((ListSelectionEvent e) -> { userListChange(); }); // ?? ??. listResponse.addListSelectionListener((ListSelectionEvent e) -> { responseListChange(); }); listSchedule.addListSelectionListener((ListSelectionEvent e) -> { scheduleListChange(); }); listCalendar.addListSelectionListener(new ListSelectionListener() { private int oldSelectedValue = 0; private int tmp = 0; public int getOldSelectedValue() { return oldSelectedValue; } public void setOldSelectedValue(int oldSelectedValue) { this.oldSelectedValue = tmp; this.tmp = oldSelectedValue; } private boolean canceled = false; @Override public void valueChanged(ListSelectionEvent e) { if (canceled) { canceled = false; } else { if (tableCalendar.getModel() instanceof CalendarTableModel) { final CalendarTableModel model = (CalendarTableModel) tableCalendar.getModel(); if (!model.isSaved()) { final int res = JOptionPane.showConfirmDialog(null, getLocaleMessage("calendar.change.title"), getLocaleMessage("calendar.change.caption"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (res) { case 0: // ? ?? model.save(); calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); break; case 1: // ?? ?? calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); break; case 2: // ?? ??? canceled = true; listCalendar.setSelectedIndex(getOldSelectedValue()); break; } } else { calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); } } else { calendarListChange(); setOldSelectedValue(listCalendar.getSelectedIndex()); } } } }); // ?? ? ??. treeServices.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); treeInfo.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); /* treeServices.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); setText(((Element) value).attributeValue(Uses.TAG_NAME)); return this; } });*/ treeServices.addTreeSelectionListener((TreeSelectionEvent e) -> { serviceListChange(); }); treeInfo.addTreeSelectionListener((TreeSelectionEvent e) -> { infoListChange(); }); textFieldStartTime.setInputVerifier(DateVerifier); textFieldFinishTime.setInputVerifier(DateVerifier); // ? loadSettings(); // ? ?. startTimer(); // loadConfig(); spinnerPropServerPort.getModel().addChangeListener(new ChangeNet()); spinnerPropClientPort.getModel().addChangeListener(new ChangeNet()); spinnerWebServerPort.getModel().addChangeListener(new ChangeNet()); spinnerServerPort.getModel().addChangeListener(new ChangeSettings()); spinnerClientPort.getModel().addChangeListener(new ChangeSettings()); spinnerUserRS.getModel().addChangeListener(new ChangeUser()); //? . final Helper helper = Helper.getHelp("ru/apertum/qsystem/client/help/admin.hs"); helper.setHelpListener(menuItemHelp); helper.enableHelpKey(jPanel1, "introduction"); helper.enableHelpKey(jPanel3, "monitoring"); helper.enableHelpKey(jPanel4, "configuring"); helper.enableHelpKey(jPanel8, "net"); helper.enableHelpKey(jPanel17, "schedulers"); helper.enableHelpKey(jPanel19, "calendars"); helper.enableHelpKey(jPanel2, "infoSystem"); helper.enableHelpKey(jPanel13, "responses"); helper.enableHelpKey(jPanel18, "results"); treeServices.setTransferHandler(new TransferHandler() { @Override public boolean canImport(TransferHandler.TransferSupport info) { final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation(); if (dl.getChildIndex() == -1) { return false; } // Get the string that is being dropped. final Transferable t = info.getTransferable(); final QService data; try { data = (QService) t.getTransferData(DataFlavor.stringFlavor); return (data.getParent().getId() .equals(((QService) dl.getPath().getLastPathComponent()).getId())); } catch (UnsupportedFlavorException | IOException e) { return false; } } @Override public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } final QService data; try { data = (QService) info.getTransferable().getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException | IOException e) { System.err.println(e); return false; } final JTree.DropLocation dl = (JTree.DropLocation) info.getDropLocation(); final TreePath tp = dl.getPath(); final QService parent = (QService) tp.getLastPathComponent(); ((QServiceTree) treeServices.getModel()).moveNode(data, parent, dl.getChildIndex()); return true; } @Override public int getSourceActions(JComponent c) { return MOVE; } @Override protected Transferable createTransferable(JComponent c) { return (QService) ((JTree) c).getLastSelectedPathComponent(); } }); treeServices.setDropMode(DropMode.INSERT); // ? final AnnotationSessionFactoryBean as = (AnnotationSessionFactoryBean) Spring.getInstance().getFactory() .getBean("conf"); if (as.getServers().size() > 1) { final JMenu menu = new JMenu(getLocaleMessage("admin.servers")); as.getServers().stream().map((ser) -> { final JMenuItem mi1 = new JMenuItem(as); mi1.setText(ser.isCurrent() ? "<html><u><i>" + ser.getName() + "</i></u>" : ser.getName()); return mi1; }).forEach((mi1) -> { menu.add(mi1); }); jMenuBar1.add(menu, 4); jMenuBar1.add(new JLabel( "<html><span style='font-size:13.0pt;color:red'> [" + as.getName() + "]")); } comboBoxVoices.setVisible(false); }
From source file:com.peterbochs.PeterBochsDebugger.java
void loadSBButton() { jSBButton.removeAll();/*from w ww . j av a2 s . c om*/ Object[] a = Setting.getInstance().sbAddress.toArray(); for (int x = a.length - 1; x >= 0; x--) { JMenuItem menu = new JMenuItem(); menu.setText(String.valueOf(a[x])); jSBButton.add(menu); } }
From source file:com.peterbochs.PeterBochsDebugger.java
void loadSBAButton() { jSBAButton.removeAll();//from ww w . j a v a 2s .co m Object[] a = Setting.getInstance().sbaAddress.toArray(); for (int x = a.length - 1; x >= 0; x--) { JMenuItem menu = new JMenuItem(); menu.setText(String.valueOf(a[x])); jSBAButton.add(menu); } }