List of usage examples for javax.swing JButton setToolTipText
@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.") public void setToolTipText(String text)
From source file:org.genedb.jogra.plugins.TermRationaliser.java
/** * Return a new JFrame which is the main interface to the Rationaliser. *//*from w w w . j a va 2s . c o m*/ public JFrame getMainPanel() { /* JFRAME */ frame.setTitle(WINDOW_TITLE); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); frame.setLayout(new BorderLayout()); /* MENU */ JMenuBar menuBar = new JMenuBar(); JMenu actions_menu = new JMenu("Actions"); JMenuItem actions_mitem_1 = new JMenuItem("Refresh lists"); actions_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { initModels(); } }); actions_menu.add(actions_mitem_1); JMenu about_menu = new JMenu("About"); JMenuItem about_mitem_1 = new JMenuItem("About"); about_mitem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JOptionPane.showMessageDialog(null, "Term Rationaliser \n" + "Wellcome Trust Sanger Institute, UK \n" + "2009", "Term Rationaliser", JOptionPane.PLAIN_MESSAGE); } }); about_menu.add(about_mitem_1); menuBar.add(about_menu); menuBar.add(actions_menu); frame.add(menuBar, BorderLayout.NORTH); /* MAIN BOX */ Box center = Box.createHorizontalBox(); //A box that displays contents from left to right center.add(Box.createHorizontalStrut(5)); //Invisible fixed-width component /* FROM LIST AND PANEL */ fromList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //Allow multiple products to be selected fromList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) { synchroniseLists(fromList, toList); //synchronise from left to right } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box fromPanel = this.createRationaliserPanel(FROM_LIST_NAME, fromList); //Box on left hand side fromPanel.add(Box.createVerticalStrut(55)); //Add some space center.add(fromPanel); //Add to main box center.add(Box.createHorizontalStrut(3)); //Add some space /* MIDDLE PANE */ Box middlePane = Box.createVerticalBox(); ClassLoader classLoader = this.getClass().getClassLoader(); //Needed to access the images later on ImageIcon leftButtonIcon = new ImageIcon(classLoader.getResource("left_arrow.gif")); ImageIcon rightButtonIcon = new ImageIcon(classLoader.getResource("right_arrow.gif")); leftButtonIcon = new ImageIcon(leftButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! rightButtonIcon = new ImageIcon(rightButtonIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH)); //TODO: Investigate simpler way to resize an icon! JButton rightSynch = new JButton(rightButtonIcon); rightSynch.setToolTipText("Synchronise TO list. \n Shortcut: Right-arrow key"); rightSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(fromList, toList); } }); JButton leftSynch = new JButton(leftButtonIcon); leftSynch.setToolTipText("Synchronise FROM list. \n Shortcut: Left-arrow key"); leftSynch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { synchroniseLists(toList, fromList); } }); middlePane.add(rightSynch); middlePane.add(leftSynch); center.add(middlePane); //Add middle pane to main box center.add(Box.createHorizontalStrut(3)); /* TO LIST AND PANEL */ toList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //Single product selection in TO list toList.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_LEFT) { synchroniseLists(toList, fromList); //synchronise from right to left } } @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyTyped(KeyEvent arg0) { } }); Box toPanel = this.createRationaliserPanel(TO_LIST_NAME, toList); Box newTerm = Box.createVerticalBox(); textField = new JTextArea(1, 1); //textfield to let the user edit the name of an existing term textField.setMaximumSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().height, 10)); textField.setForeground(Color.BLUE); JScrollPane jsp = new JScrollPane(textField); //scroll pane so that there is a horizontal scrollbar jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); newTerm.add(jsp); TitledBorder editBorder = BorderFactory.createTitledBorder("Edit term name"); editBorder.setTitleColor(Color.DARK_GRAY); newTerm.setBorder(editBorder); toPanel.add(newTerm); //add textfield to panel center.add(toPanel); //add panel to main box center.add(Box.createHorizontalStrut(5)); frame.add(center); //add the main panel to the frame initModels(); //load the lists with data /* BOTTOM HALF OF FRAME */ Box main = Box.createVerticalBox(); TitledBorder border = BorderFactory.createTitledBorder("Information"); border.setTitleColor(Color.DARK_GRAY); /* INFORMATION BOX */ Box info = Box.createVerticalBox(); Box scope = Box.createHorizontalBox(); scope.add(Box.createHorizontalStrut(5)); scope.add(scopeLabel); //label showing the scope of the terms scope.add(Box.createHorizontalGlue()); Box productCount = Box.createHorizontalBox(); productCount.add(Box.createHorizontalStrut(5)); productCount.add(productCountLabel); //display the label showing the number of terms productCount.add(Box.createHorizontalGlue()); info.add(scope); info.add(productCount); info.setBorder(border); /* ACTION BUTTONS */ Box actionButtons = Box.createHorizontalBox(); actionButtons.add(Box.createHorizontalGlue()); actionButtons.add(Box.createHorizontalStrut(10)); JButton findFix = new JButton(new FindClosestMatchAction()); actionButtons.add(findFix); actionButtons.add(Box.createHorizontalStrut(10)); RationaliserAction ra = new RationaliserAction(); // RationaliserAction2 ra2 = new RationaliserAction2(); JButton go = new JButton(ra); actionButtons.add(go); actionButtons.add(Box.createHorizontalGlue()); /* MORE INFORMATION TOGGLE */ Box buttonBox = Box.createHorizontalBox(); final JButton toggle = new JButton("Hide information <<"); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(toggle); buttonBox.add(Box.createHorizontalGlue()); Box textBox = Box.createHorizontalBox(); final JScrollPane scrollPane = new JScrollPane(information); scrollPane.setPreferredSize(new Dimension(frame.getWidth(), 100)); scrollPane.setVisible(true); textBox.add(Box.createHorizontalStrut(5)); textBox.add(scrollPane); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (toggle.getText().equals("Show information >>")) { scrollPane.setVisible(true); toggle.setText("Hide information <<"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() + 100)); frame.pack(); } else if (toggle.getText().equals("Hide information <<")) { scrollPane.setVisible(false); toggle.setText("Show information >>"); frame.setPreferredSize(new Dimension(frame.getWidth(), frame.getHeight() - 100)); frame.pack(); } } }; toggle.addActionListener(actionListener); main.add(Box.createVerticalStrut(5)); main.add(info); main.add(Box.createVerticalStrut(5)); main.add(Box.createVerticalStrut(5)); main.add(actionButtons); main.add(Box.createVerticalStrut(10)); main.add(buttonBox); main.add(textBox); frame.add(main, BorderLayout.SOUTH); frame.pack(); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setVisible(true); //initModels(); return frame; }
From source file:org.graphwalker.GUI.App.java
private JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText, boolean enabled) { // Look for the image. String imgLocation = "resources/icons/" + imageName + ".png"; URL imageURL = App.class.getResource(imgLocation); // Create and initialize the button. JButton button = new JButton(); button.setActionCommand(actionCommand); button.setToolTipText(toolTipText); button.addActionListener(this); button.setEnabled(enabled);//from w w w . j a v a2s . com if (imageURL != null) { // image found button.setIcon(new ImageIcon(imageURL, altText)); } else { // no image found button.setText(altText); logger.error("Resource not found: " + imgLocation); } return button; }
From source file:org.interreg.docexplore.authoring.AuthoringToolFrame.java
public AuthoringToolFrame(final DocExploreDataLink link, final Startup startup) throws Exception { super("Authoring Tool"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.startup = startup; this.displayHelp = startup.showHelp; startup.screen.setText("Initializing history"); this.historyManager = new HistoryManager(50, new File(DocExploreTool.getHomeDir(), ".at-cache")); this.historyDialog = new JDialog(this, XMLResourceBundle.getBundledString("generalHistory")); historyDialog.add(new HistoryPanel(historyManager)); historyDialog.pack();// ww w.ja v a2 s. c o m setJMenuBar(this.menu = new AuthoringMenu(this)); startup.screen.setText("Initializing plugins"); plugins = new Vector<MetaDataPlugin>(); List<PluginConfig> pluginConfigs = startup.filterPlugins(MetaDataPlugin.class); for (PluginConfig config : pluginConfigs) { MetaDataPlugin plugin = null; if ((plugin = (MetaDataPlugin) config.clazz.newInstance()) != null) { plugins.add(plugin); plugin.setHost(config.jarFile, config.dependencies); System.out.println( "Loaded plugin '" + plugin.getName() + "' (" + plugin.getClass().getSimpleName() + ")"); } } startup.screen.setText("Initializing filters"); //filter = new FilterPanel(link); this.importOptions = new ImportOptions(this); startup.screen.setText("Initializing styles"); this.styleManager = new StyleManager(this); startup.screen.setText("Creating explorer data link"); this.linkExplorer = new DataLinkExplorer(this, link, null); //linkExplorer.toolPanel.add(filter); //linkExplorer.setFilter(filter); startup.screen.setText("Creating explorer"); //this.fileExplorer = new FileExplorer(this); this.explorer = new JPanel(new BorderLayout()); explorer.add( new JLabel("<html><font style=\"font-size:16\">" + XMLResourceBundle.getBundledString("generalLibraryLabel") + "</font></html>"), BorderLayout.NORTH); explorer.add(linkExplorer, BorderLayout.CENTER); //explorer.addTab(XMLResourceBundle.getBundledString("generalFilesLabel"), fileExplorer); startup.screen.setText("Creating editor data link"); recovery = defaultFile.exists(); DataLink fslink = new DataLinkFS2Source(defaultFile.getAbsolutePath()).getDataLink(); fslink.setProperty("autoWrite", false); final DocExploreDataLink editorLink = new DocExploreDataLink(); final JLabel titleLabel = new JLabel(); editorLink.addListener(new DocExploreDataLink.Listener() { public void dataLinkChanged(DataLink link) { String bookName = ""; try { List<Integer> books = editorLink.getLink().getAllBookIds(); if (!books.isEmpty()) { Book book = editorLink.getBook(books.get(0)); bookName = book.getName(); MetaDataKey key = editorLink.getOrCreateKey("styles", ""); List<MetaData> mds = book.getMetaDataListForKey(key); MetaData md = null; if (mds.isEmpty()) { md = new MetaData(editorLink, key, ""); book.addMetaData(md); } else md = mds.get(0); styleManager.setMD(md); } } catch (Exception e) { e.printStackTrace(); } String linkTitle = menu.curFile == null ? null : menu.curFile.getAbsolutePath(); titleLabel.setText("<html><font style=\"font-size:14\">" + XMLResourceBundle.getBundledString("generalPresentationLabel") + " : <b>" + bookName + "</b>" + (linkTitle != null ? " (" + linkTitle + ")" : "") + "</font></html>"); setTitle(XMLResourceBundle.getBundledString("frameTitle") + " " + (linkTitle != null ? linkTitle : "")); historyManager.reset(-1); repaint(); } }); editorLink.setLink(fslink); startup.screen.setText("Creating editor"); this.editor = new DataLinkExplorer(this, editorLink, new BookImporter()); for (ExplorerView view : editor.views) if (view instanceof PageEditorView) { this.mdEditor = new MetaDataEditor(((PageEditorView) view).editor); } editor.addListener(new Explorer.Listener() { @Override public void exploringChanged(Object object) { try { boolean isRegion = object instanceof Region; int div = splitPane.getDividerLocation(); mdEditor.setDocument(null); if (isRegion) mdEditor.setDocument((Region) object); if (isRegion != regionMode) splitPane.setRightComponent(isRegion ? mdEditor : explorer); regionMode = isRegion; validate(); splitPane.setDividerLocation(div); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } } }); final JButton editBook = new JButton(new AbstractAction("", ImageUtils.getIcon("pencil-24x24.png")) { @Override public void actionPerformed(ActionEvent e) { try { Book book = editorLink.getBook(editorLink.getLink().getAllBookIds().get(0)); String name = JOptionPane.showInputDialog(AuthoringToolFrame.this, XMLResourceBundle.getBundledString("collectionAddBookMessage"), book.getName()); if (name == null) return; book.setName(name); editorLink.notifyDataLinkChanged(); editor.refreshPath(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); editBook.setToolTipText(XMLResourceBundle.getBundledString("generalToolbarEdit")); this.splitPane = new JSplitPane(); JPanel editorPanel = new JPanel(new BorderLayout()); JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); titlePanel.add(titleLabel); titlePanel.add(editBook); //editorPanel.add(titlePanel, BorderLayout.NORTH); editorPanel.add(editor, BorderLayout.CENTER); splitPane.setLeftComponent(editorPanel); splitPane.setRightComponent(explorer); getContentPane().setLayout(new BorderLayout()); add(titlePanel, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); this.clipboard = new MetaDataClipboard(this, new File(DocExploreTool.getHomeDir(), ".at-clipboard")); startup.screen.setText("Initializing exporter"); this.readerExporter = new ReaderExporter(this); this.webExporter = new WebExporter(this); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { quit(); } public void windowOpened(WindowEvent e) { splitPane.setDividerLocation(getWidth() / 2); } }); this.oldSize = getWidth(); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { splitPane.setDividerLocation(splitPane.getDividerLocation() * getWidth() / oldSize); oldSize = getWidth(); } }); }
From source file:org.jab.docsearch.DocSearch.java
private JToolBar createToolBar() { // tool bar// www . ja v a2 s.c om JToolBar toolBar = new JToolBar(); // file open JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png"))); buttonOpen.setToolTipText(I18n.getString("tooltip.open")); buttonOpen.setActionCommand("ac_open"); buttonOpen.addActionListener(this); buttonOpen.setMnemonic(KeyEvent.VK_O); buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonOpen); // file save JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png"))); buttonSave.setToolTipText(I18n.getString("tooltip.save")); buttonSave.setActionCommand("ac_save"); buttonSave.addActionListener(this); buttonSave.setMnemonic(KeyEvent.VK_S); buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonSave); toolBar.addSeparator(); // open browser JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png"))); buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser")); buttonBrowser.setActionCommand("ac_openinbrowser"); buttonBrowser.addActionListener(this); buttonBrowser.setMnemonic(KeyEvent.VK_E); buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonBrowser); toolBar.addSeparator(); // home JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png"))); buttonHome.setToolTipText(I18n.getString("tooltip.home")); buttonHome.setActionCommand("ac_home"); buttonHome.addActionListener(this); buttonHome.setMnemonic(KeyEvent.VK_H); toolBar.add(buttonHome); // refresh JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png"))); buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh")); buttonRefresh.setActionCommand("ac_refresh"); buttonRefresh.addActionListener(this); buttonRefresh.setMnemonic(KeyEvent.VK_L); toolBar.add(buttonRefresh); toolBar.addSeparator(); // result JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png"))); buttonResult.setToolTipText(I18n.getString("tooltip.results")); buttonResult.setActionCommand("ac_result"); buttonResult.addActionListener(this); buttonResult.setMnemonic(KeyEvent.VK_R); toolBar.add(buttonResult); toolBar.addSeparator(); // bookmark JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png"))); buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark")); buttonBookMark.setActionCommand("ac_addbookmark"); buttonBookMark.addActionListener(this); buttonBookMark.setMnemonic(KeyEvent.VK_M); toolBar.add(buttonBookMark); toolBar.addSeparator(); // print JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png"))); buttonPrint.setToolTipText(I18n.getString("tooltip.print")); buttonPrint.setActionCommand("ac_print"); buttonPrint.addActionListener(this); buttonPrint.setMnemonic(KeyEvent.VK_P); toolBar.add(buttonPrint); toolBar.addSeparator(); // setting JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png"))); buttonSetting.setToolTipText(I18n.getString("tooltip.settings")); buttonSetting.setActionCommand("ac_settings"); buttonSetting.addActionListener(this); buttonSetting.setMnemonic(KeyEvent.VK_HOME); toolBar.add(buttonSetting); toolBar.addSeparator(); // stop buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png"))); buttonStop.setToolTipText(I18n.getString("tooltip.stop")); buttonStop.setActionCommand("ac_stop"); buttonStop.addActionListener(this); buttonStop.setMnemonic(KeyEvent.VK_X); toolBar.add(buttonStop); toolBar.addSeparator(); // toolBar.setFloatable(false); // finished return toolBar; }
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Initialises the application's GUI elements. *//* ww w .j a va2 s.com*/ private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(cockpitLiteProperties.getProperties()); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } // Primary panel that contains all other items. JPanel primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel"); primaryPanel.setLayout(new GridBagLayout()); this.getContentPane().add(primaryPanel); // Setup the stack panel, which contains all other panels as a stack. stackPanel = skinsFactory.createSkinnedJPanel("StackPanel"); stackPanelCardLayout = new CardLayout(); stackPanel.setLayout(stackPanelCardLayout); primaryPanel.add(stackPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Progress notification panel progressNotificationPanel = skinsFactory.createSkinnedJPanel("ProgressNotificationPanel"); progressNotificationPanel.setLayout(new GridBagLayout()); primaryPanel.add(progressNotificationPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 0), 0, 0)); int row = 0; // Login panel. row = 0; loginPanel = skinsFactory.createSkinnedJPanel("LoginPanel"); loginPanel.setLayout(new GridBagLayout()); userInputFields = new UserInputFields(insetsDefault, null, skinsFactory); userInputFields.buildFieldsPanel(loginPanel, cockpitLiteProperties); loginButton = skinsFactory.createSkinnedJButton("LoginButton"); loginButton.setText("Log me in"); loginButton.addActionListener(this); loginPanel.add(loginButton, new GridBagConstraints(0, loginPanel.getComponentCount(), 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Filter panel. filterObjectsPanel = skinsFactory.createSkinnedJPanel("FilterPanel"); filterObjectsPanel.setLayout(new GridBagLayout()); filterObjectsPrefix = skinsFactory.createSkinnedJTextField("FilterPrefix"); filterObjectsPrefix.setToolTipText("Only show files starting with this string"); filterObjectsPrefix.addActionListener(this); filterObjectsPrefix.setActionCommand("RefreshObjects"); JLabel filterPrefixLabel = skinsFactory.createSkinnedJHtmlLabel("FilterPrefixLable", this); filterPrefixLabel.setText("File name starts with: "); filterObjectsPanel.add(filterPrefixLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); filterObjectsPanel.setVisible(false); // Objects panel. row = 0; JPanel objectsPanel = skinsFactory.createSkinnedJPanel("ObjectsPanel"); objectsPanel.setLayout(new GridBagLayout()); filterObjectsCheckBox = skinsFactory.createSkinnedJCheckBox("FilterCheckbox"); filterObjectsCheckBox.setText("Search files"); filterObjectsCheckBox.setEnabled(true); filterObjectsCheckBox.addActionListener(this); filterObjectsCheckBox.setToolTipText("Check this option to search your files"); objectsHeadingLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsHeadingLabel", this); objectsHeadingLabel.setText("Not logged in"); objectsPanel.add(objectsHeadingLabel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); JButton objectActionButton = skinsFactory.createSkinnedJButton("ObjectMenuButton"); objectActionButton.setToolTipText("File actions menu"); guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png"); objectActionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton) e.getSource(); objectActionMenu.show(sourceButton, 0, sourceButton.getHeight()); } }); objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsTable = skinsFactory.createSkinnedJTable("ObjectsTable"); objectTableModel = new CLObjectTableModel(); objectTableModelSorter = new TableSorter(objectTableModel); objectTableModelSorter.setTableHeader(objectsTable.getTableHeader()); objectsTable.setModel(objectTableModelSorter); objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = 7229656175879985698L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue()); return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column); } }); objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = -4983176028291916397L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Date date = (Date) value; return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus, row, column); } }); objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); objectsTable.getSelectionModel().addListSelectionListener(this); objectsTable.setShowHorizontalLines(true); objectsTable.setShowVerticalLines(true); objectsTable.addMouseListener(new ContextMenuListener()); objectsTableSP = skinsFactory.createSkinnedJScrollPane("ObjectsTableSP", objectsTable); objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); objectsSummaryLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsSummary", this); objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER); objectsSummaryLabel.setFocusable(false); objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Object action menu. objectActionMenu = skinsFactory.createSkinnedJPopupMenu("ObjectPopupMenu"); refreshObjectMenuItem = skinsFactory.createSkinnedJMenuItem("RefreshMenuItem"); refreshObjectMenuItem.setText("Refresh file listing"); refreshObjectMenuItem.setActionCommand("RefreshObjects"); refreshObjectMenuItem.addActionListener(this); guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png"); objectActionMenu.add(refreshObjectMenuItem); viewObjectPropertiesMenuItem = skinsFactory.createSkinnedJMenuItem("PropertiesMenuItem"); viewObjectPropertiesMenuItem.setText("View file properties..."); viewObjectPropertiesMenuItem.setActionCommand("ViewObjectProperties"); viewObjectPropertiesMenuItem.addActionListener(this); guiUtils.applyIcon(viewObjectPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); objectActionMenu.add(viewObjectPropertiesMenuItem); downloadObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DownloadMenuItem"); downloadObjectMenuItem.setText("Download file(s)..."); downloadObjectMenuItem.setActionCommand("DownloadObjects"); downloadObjectMenuItem.addActionListener(this); guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png"); objectActionMenu.add(downloadObjectMenuItem); uploadFilesMenuItem = skinsFactory.createSkinnedJMenuItem("UploadMenuItem"); uploadFilesMenuItem.setText("Upload file(s)..."); uploadFilesMenuItem.setActionCommand("UploadFiles"); uploadFilesMenuItem.addActionListener(this); guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png"); objectActionMenu.add(uploadFilesMenuItem); objectActionMenu.add(new JSeparator()); togglePublicMenuItem = skinsFactory.createSkinnedJMenuItem("AclToggleMenuItem"); togglePublicMenuItem.setText("Change privacy setting..."); togglePublicMenuItem.setActionCommand("TogglePublicPrivate"); togglePublicMenuItem.addActionListener(this); guiUtils.applyIcon(togglePublicMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); objectActionMenu.add(togglePublicMenuItem); generatePublicGetUrl = skinsFactory.createSkinnedJMenuItem("PublicUrlMenuItem"); generatePublicGetUrl.setText("Public web link..."); generatePublicGetUrl.setActionCommand("GeneratePublicGetURL"); generatePublicGetUrl.addActionListener(this); guiUtils.applyIcon(generatePublicGetUrl, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generatePublicGetUrl); objectActionMenu.add(new JSeparator()); deleteObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DeleteMenuItem"); deleteObjectMenuItem.setText("Delete file(s)..."); deleteObjectMenuItem.setActionCommand("DeleteObjects"); deleteObjectMenuItem.addActionListener(this); guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png"); objectActionMenu.add(deleteObjectMenuItem); viewObjectPropertiesMenuItem.setEnabled(false); refreshObjectMenuItem.setEnabled(false); togglePublicMenuItem.setEnabled(false); downloadObjectMenuItem.setEnabled(false); generatePublicGetUrl.setEnabled(false); deleteObjectMenuItem.setEnabled(false); // Card layout in stack panel stackPanel.add(loginPanel, "LoginPanel"); stackPanel.add(objectsPanel, "ObjectsPanel"); // Set preferred sizes int preferredWidth = 800; int preferredHeight = 600; this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); // Initialize drop target. initDropTarget(new JComponent[] { objectsPanel }); objectsPanel.getDropTarget().setActive(true); }
From source file:org.jtrfp.trcl.gui.ConfigWindow.java
public ConfigWindow() { setTitle("Settings"); setSize(340, 540);// ww w . j a v a 2 s .c om if (config == null) config = new TRConfiguration(); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel generalTab = new JPanel(); tabbedPane.addTab("General", new ImageIcon(ConfigWindow.class .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")), generalTab, null); GridBagLayout gbl_generalTab = new GridBagLayout(); gbl_generalTab.columnWidths = new int[] { 0, 0 }; gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 }; gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; generalTab.setLayout(gbl_generalTab); JPanel settingsLoadSavePanel = new JPanel(); GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints(); gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0); gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST; gbc_settingsLoadSavePanel.gridx = 0; gbc_settingsLoadSavePanel.gridy = 0; generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel); settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); JButton btnSave = new JButton("Export..."); btnSave.setToolTipText("Export these settings to an external file"); settingsLoadSavePanel.add(btnSave); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { exportSettings(); } }); JButton btnLoad = new JButton("Import..."); btnLoad.setToolTipText("Import an external settings file"); settingsLoadSavePanel.add(btnLoad); btnLoad.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { importSettings(); } }); JButton btnConfigReset = new JButton("Reset"); btnConfigReset.setToolTipText("Reset all settings to defaults"); settingsLoadSavePanel.add(btnConfigReset); btnConfigReset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { defaultSettings(); } }); JPanel registeredPODsPanel = new JPanel(); registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null)); GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints(); gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0); gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH; gbc_registeredPODsPanel.gridx = 0; gbc_registeredPODsPanel.gridy = 1; generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel); GridBagLayout gbl_registeredPODsPanel = new GridBagLayout(); gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 }; gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 }; gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; registeredPODsPanel.setLayout(gbl_registeredPODsPanel); JPanel podListPanel = new JPanel(); GridBagConstraints gbc_podListPanel = new GridBagConstraints(); gbc_podListPanel.insets = new Insets(0, 0, 5, 0); gbc_podListPanel.fill = GridBagConstraints.BOTH; gbc_podListPanel.gridx = 0; gbc_podListPanel.gridy = 0; registeredPODsPanel.add(podListPanel, gbc_podListPanel); podListPanel.setLayout(new BorderLayout(0, 0)); JScrollPane podListScrollPane = new JScrollPane(); podListPanel.add(podListScrollPane, BorderLayout.CENTER); podList = new JList(podLM); podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); podListScrollPane.setViewportView(podList); JPanel podListOpButtonPanel = new JPanel(); podListOpButtonPanel.setBorder(null); GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints(); gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_podListOpButtonPanel.gridx = 0; gbc_podListOpButtonPanel.gridy = 1; registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel); FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); JButton addPodButton = new JButton("Add..."); addPodButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game."); podListOpButtonPanel.add(addPodButton); addPodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addPOD(); } }); JButton removePodButton = new JButton("Remove"); removePodButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removePodButton.setToolTipText("Remove a POD file from being considered when playing a game"); podListOpButtonPanel.add(removePodButton); removePodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { podLM.removeElement(podList.getSelectedValue()); } }); JButton podEditButton = new JButton("Edit..."); podEditButton.setIcon(null); podEditButton.setToolTipText("Edit the selected POD path"); podListOpButtonPanel.add(podEditButton); podEditButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editPODPath(); } }); JPanel missionPanel = new JPanel(); GridBagConstraints gbc_missionPanel = new GridBagConstraints(); gbc_missionPanel.fill = GridBagConstraints.BOTH; gbc_missionPanel.gridx = 0; gbc_missionPanel.gridy = 2; generalTab.add(missionPanel, gbc_missionPanel); missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gbl_missionPanel = new GridBagLayout(); gbl_missionPanel.columnWidths = new int[] { 0, 0 }; gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; missionPanel.setLayout(gbl_missionPanel); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; missionPanel.add(scrollPane, gbc_scrollPane); missionList = new JList(missionLM); missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(missionList); JPanel missionListOpButtonPanel = new JPanel(); GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints(); gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_missionListOpButtonPanel.gridx = 0; gbc_missionListOpButtonPanel.gridy = 1; missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel); JButton addVOXButton = new JButton("Add..."); addVOXButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addVOXButton.setToolTipText("Add an external VOX file as a mission"); missionListOpButtonPanel.add(addVOXButton); addVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addVOX(); } }); final JButton removeVOXButton = new JButton("Remove"); removeVOXButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removeVOXButton.setToolTipText("Remove the selected mission"); missionListOpButtonPanel.add(removeVOXButton); removeVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { missionLM.remove(missionList.getSelectedIndex()); } }); final JButton editVOXButton = new JButton("Edit..."); editVOXButton.setToolTipText("Edit the selected Mission's VOX path"); missionListOpButtonPanel.add(editVOXButton); editVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editVOXPath(); } }); missionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { final String val = (String) missionList.getSelectedValue(); if (val == null) missionList.setSelectedIndex(0); else if (isBuiltinVOX(val)) { removeVOXButton.setEnabled(false); editVOXButton.setEnabled(false); } else { removeVOXButton.setEnabled(true); editVOXButton.setEnabled(true); } } }); JPanel soundTab = new JPanel(); tabbedPane.addTab("Sound", new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")), soundTab, null); GridBagLayout gbl_soundTab = new GridBagLayout(); gbl_soundTab.columnWidths = new int[] { 0, 0 }; gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 }; gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; soundTab.setLayout(gbl_soundTab); JPanel checkboxPanel = new JPanel(); GridBagConstraints gbc_checkboxPanel = new GridBagConstraints(); gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0); gbc_checkboxPanel.fill = GridBagConstraints.BOTH; gbc_checkboxPanel.gridx = 0; gbc_checkboxPanel.gridy = 0; soundTab.add(checkboxPanel, gbc_checkboxPanel); chckbxLinearInterpolation = new JCheckBox("Linear Filtering"); chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples."); chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT); checkboxPanel.add(chckbxLinearInterpolation); chckbxLinearInterpolation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { needRestart = true; } }); chckbxBufferLag = new JCheckBox("Buffer Lag"); chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency."); checkboxPanel.add(chckbxBufferLag); JPanel modStereoWidthPanel = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints(); gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH; gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0); gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_modStereoWidthPanel.gridx = 0; gbc_modStereoWidthPanel.gridy = 1; soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel); modStereoWidthSlider = new JSlider(); modStereoWidthSlider.setPaintTicks(true); modStereoWidthSlider.setMinorTickSpacing(25); modStereoWidthPanel.add(modStereoWidthSlider); final JLabel modStereoWidthLbl = new JLabel("NN%"); modStereoWidthPanel.add(modStereoWidthLbl); JPanel bufferSizePanel = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); bufferSizePanel.setBorder( new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints(); gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH; gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0); gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL; gbc_bufferSizePanel.gridx = 0; gbc_bufferSizePanel.gridy = 2; soundTab.add(bufferSizePanel, gbc_bufferSizePanel); audioBufferSizeCB = new JComboBox(); audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values())); bufferSizePanel.add(audioBufferSizeCB); soundOutputSelectorGUI = new SoundOutputSelectorGUI(); soundOutputSelectorGUI.setBorder( new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints(); gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH; gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0); gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL; gbc_soundOutputSelectorGUI.gridx = 0; gbc_soundOutputSelectorGUI.gridy = 3; soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI); modStereoWidthSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%"); needRestart = true; } }); JPanel okCancelPanel = new JPanel(); getContentPane().add(okCancelPanel, BorderLayout.SOUTH); okCancelPanel.setLayout(new BorderLayout(0, 0)); JButton btnOk = new JButton("OK"); btnOk.setToolTipText("Apply these settings and close the window"); okCancelPanel.add(btnOk, BorderLayout.WEST); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { applySettings(); ConfigWindow.this.setVisible(false); } }); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Close the window without applying settings"); okCancelPanel.add(btnCancel, BorderLayout.EAST); JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath()); lblConfigpath.setIcon(null); lblConfigpath.setToolTipText("Default config file path"); lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER); lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6)); okCancelPanel.add(lblConfigpath, BorderLayout.CENTER); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ConfigWindow.this.setVisible(false); } }); }
From source file:org.n52.ifgicopter.spf.output.GpxOutputPlugin.java
/** * /*from w w w . j ava2 s . c o m*/ * @return */ private JPanel makeGUI() { if (this.panel == null) { this.panel = new JPanel(new BorderLayout()); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton selectFileButton = new JButton(SELECT_GPX_FILE_TEXT); selectFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectGpxFileAction(); } }); controlPanel.add(selectFileButton); this.outputFileLabel = new JLabel(); controlPanel.add(this.outputFileLabel); JButton saveFileButton = new JButton(SAVE_CURRENT_FILE_TEXT); saveFileButton.setToolTipText("Does also save manual changes undless model changes were made."); saveFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveCurrentFile(); } }); controlPanel.add(saveFileButton); // JCheckBox scrollLockCheckBox = new JCheckBox("scroll lock"); // scrollLockCheckBox.setSelected(true); // scrollLockCheckBox.addActionListener(new ActionListener() { // @Override // public void actionPerformed(final ActionEvent e) { // EventQueue.invokeLater(new Runnable() { // // @Override // public void run() { // JCheckBox source = (JCheckBox) e.getSource(); // // GpxOutputPlugin.this.textPane.setAutoscrolls(source.isSelected()); // } // }); // } // }); // controlPanel.add(scrollLockCheckBox); this.panel.add(controlPanel, BorderLayout.NORTH); JPanel valuesPanel = new JPanel(new VerticalLayout(5, VerticalLayout.LEFT)); DefaultListModel listModel = new DefaultListModel(); listModel.addElement(NO_DATA_LIST_ELEMENT); this.valuesToSaveList = new JList(listModel); this.valuesToSaveList.setVisibleRowCount(2); this.valuesToSaveList .setToolTipText("Select (multiple) values to include in the GPX file [Multiple using <Ctrl>]."); this.valuesToSaveList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(final ListSelectionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { JList list = (JList) e.getSource(); // DefaultListModel listModel = (DefaultListModel) list.getModel(); Object[] selectedValues = list.getSelectedValues(); log.debug("New selection in value list:" + Arrays.toString(selectedValues)); GpxOutputPlugin.this.valuesToSave.clear(); for (Object o : selectedValues) { if (o instanceof String) { String s = (String) o; if (!GpxOutputPlugin.this.valuesToSave.contains(s)) GpxOutputPlugin.this.valuesToSave.add(s); } } } }); } }); this.valuesToSaveList.setSize(200, 22); this.valuesToSaveList.setAlignmentY(Component.CENTER_ALIGNMENT); valuesPanel.add(new JLabel("Saved attributes:")); valuesPanel.add(this.valuesToSaveList); valuesPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); this.panel.add(valuesPanel, BorderLayout.EAST); this.textPane = new XmlTextPane(); this.textPane.setEditable(true); this.textPane.setFont(Font.getFont(Font.MONOSPACED)); JScrollPane scrollPane = new JScrollPane(this.textPane); this.panel.add(scrollPane, BorderLayout.CENTER); JButton refreshTextFieldButton = new JButton("Update"); refreshTextFieldButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { updateGUI(); } }); } }); this.panel.add(refreshTextFieldButton, BorderLayout.SOUTH); updateGUI(); } return this.panel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createLocationsPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;// ww w.j a v a2 s.co m JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Working folder")); folderField = new JTextField(); folderField.setText((new File("").getAbsolutePath())); folderField.setToolTipText("The folder where all output will be written"); folderPanel.add(folderField); JButton pickButton = new JButton("Pick folder"); pickButton.setToolTipText("Pick a different working folder"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickFolder(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel sourcePanel = new JPanel(); sourcePanel.setLayout(new GridLayout(0, 2)); sourcePanel.setBorder(BorderFactory.createTitledBorder("Source data location")); sourcePanel.add(new JLabel("Data type")); sourceType = new JComboBox<String>(new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL", "MS Access", "PDW", "Redshift", "Teradata" }); sourceType.setToolTipText("Select the type of source data available"); sourceType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { sourceIsFiles = arg0.getItem().toString().equals("Delimited text files"); sourceServerField.setEnabled(!sourceIsFiles); sourceUserField.setEnabled(!sourceIsFiles); sourcePasswordField.setEnabled(!sourceIsFiles); sourceDatabaseField.setEnabled(!sourceIsFiles); sourceDelimiterField.setEnabled(sourceIsFiles); addAllButton.setEnabled(!sourceIsFiles); if (!sourceIsFiles && arg0.getItem().toString().equals("Oracle")) { sourceServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); sourceUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); sourcePasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); sourceDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!sourceIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { sourceServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!sourceIsFiles) { sourceServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) sourceUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else sourceUserField.setToolTipText("The user used to log in to the server"); sourcePasswordField.setToolTipText("The password used to log in to the server"); sourceDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); sourcePanel.add(sourceType); sourcePanel.add(new JLabel("Server location")); sourceServerField = new JTextField("127.0.0.1"); sourceServerField.setEnabled(false); sourcePanel.add(sourceServerField); sourcePanel.add(new JLabel("User name")); sourceUserField = new JTextField(""); sourceUserField.setEnabled(false); sourcePanel.add(sourceUserField); sourcePanel.add(new JLabel("Password")); sourcePasswordField = new JPasswordField(""); sourcePasswordField.setEnabled(false); sourcePanel.add(sourcePasswordField); sourcePanel.add(new JLabel("Database name")); sourceDatabaseField = new JTextField(""); sourceDatabaseField.setEnabled(false); sourcePanel.add(sourceDatabaseField); sourcePanel.add(new JLabel("Delimiter")); sourceDelimiterField = new JTextField(","); sourceDelimiterField.setToolTipText("The delimiter that separates values. Enter 'tab' for tab."); sourcePanel.add(sourceDelimiterField); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(sourcePanel, c); JPanel testConnectionButtonPanel = new JPanel(); testConnectionButtonPanel.setLayout(new BoxLayout(testConnectionButtonPanel, BoxLayout.X_AXIS)); testConnectionButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getSourceDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); testConnectionButtonPanel.add(testConnectionButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(testConnectionButtonPanel, c); return panel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createScanPanel() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel tablePanel = new JPanel(); tablePanel.setLayout(new BorderLayout()); tablePanel.setBorder(new TitledBorder("Tables to scan")); tableList = new JList<String>(); tableList.setToolTipText("Specify the tables (or CSV files) to be scanned here"); tablePanel.add(new JScrollPane(tableList), BorderLayout.CENTER); JPanel tableButtonPanel = new JPanel(); tableButtonPanel.setLayout(new GridLayout(3, 1)); addAllButton = new JButton("Add all in DB"); addAllButton.setToolTipText("Add all tables in the database"); addAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addAllTables();/*from ww w . ja va 2 s . c o m*/ } }); addAllButton.setEnabled(false); tableButtonPanel.add(addAllButton); JButton addButton = new JButton("Add"); addButton.setToolTipText("Add tables to list"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickTables(); } }); tableButtonPanel.add(addButton); JButton removeButton = new JButton("Remove"); removeButton.setToolTipText("Remove tables from list"); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeTables(); } }); tableButtonPanel.add(removeButton); tablePanel.add(tableButtonPanel, BorderLayout.EAST); panel.add(tablePanel, BorderLayout.CENTER); JPanel southPanel = new JPanel(); southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS)); JPanel scanOptionsPanel = new JPanel(); scanOptionsPanel.setLayout(new BoxLayout(scanOptionsPanel, BoxLayout.X_AXIS)); scanValueScan = new JCheckBox("Scan field values", true); scanValueScan.setToolTipText("Include a frequency count of field values in the scan report"); scanValueScan.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { scanMinCellCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanRowCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); scanValuesCount.setEnabled(((JCheckBox) arg0.getSource()).isSelected()); } }); scanOptionsPanel.add(scanValueScan); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Min cell count ")); scanMinCellCount = new JSpinner(); scanMinCellCount.setValue(5); scanMinCellCount.setToolTipText("Minimum frequency for a field value to be included in the report"); scanOptionsPanel.add(scanMinCellCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Max distinct values ")); scanValuesCount = new JComboBox<String>(new String[] { "100", "1,000", "10,000" }); scanValuesCount.setSelectedIndex(1); scanValuesCount.setToolTipText("Maximum number of distinct values per field to be reported"); scanOptionsPanel.add(scanValuesCount); scanOptionsPanel.add(Box.createHorizontalGlue()); scanOptionsPanel.add(new JLabel("Rows per table ")); scanRowCount = new JComboBox<String>(new String[] { "100,000", "500,000", "1 million", "all" }); scanRowCount.setSelectedIndex(0); scanRowCount.setToolTipText("Maximum number of rows per table to be scanned for field values"); scanOptionsPanel.add(scanRowCount); southPanel.add(scanOptionsPanel); southPanel.add(Box.createVerticalStrut(3)); JPanel scanButtonPanel = new JPanel(); scanButtonPanel.setLayout(new BoxLayout(scanButtonPanel, BoxLayout.X_AXIS)); scanButtonPanel.add(Box.createHorizontalGlue()); JButton scanButton = new JButton("Scan tables"); scanButton.setBackground(new Color(151, 220, 141)); scanButton.setToolTipText("Scan the selected tables"); scanButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scanRun(); } }); componentsToDisableWhenRunning.add(scanButton); scanButtonPanel.add(scanButton); southPanel.add(scanButtonPanel); panel.add(southPanel, BorderLayout.SOUTH); return panel; }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createFakeDataPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;/*from ww w. j a va 2 s. c o m*/ JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file")); scanReportFileField = new JTextField(); scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath())); scanReportFileField.setToolTipText( "The path to the scan report that will be used as a template to generate the fake data"); folderPanel.add(scanReportFileField); JButton pickButton = new JButton("Pick file"); pickButton.setToolTipText("Pick a scan report file"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickScanReportFile(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel targetPanel = new JPanel(); targetPanel.setLayout(new GridLayout(0, 2)); targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location")); targetPanel.add(new JLabel("Data type")); targetType = new JComboBox<String>( new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" }); // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" }); targetType.setToolTipText("Select the type of source data available"); targetType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { targetIsFiles = arg0.getItem().toString().equals("Delimited text files"); targetServerField.setEnabled(!targetIsFiles); targetUserField.setEnabled(!targetIsFiles); targetPasswordField.setEnabled(!targetIsFiles); targetDatabaseField.setEnabled(!targetIsFiles); targetCSVFormat.setEnabled(targetIsFiles); if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) { targetServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); targetUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); targetPasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); targetDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { targetServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!targetIsFiles) { targetServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) targetUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); targetPanel.add(targetType); targetPanel.add(new JLabel("Server location")); targetServerField = new JTextField("127.0.0.1"); targetServerField.setEnabled(false); targetPanel.add(targetServerField); targetPanel.add(new JLabel("User name")); targetUserField = new JTextField(""); targetUserField.setEnabled(false); targetPanel.add(targetUserField); targetPanel.add(new JLabel("Password")); targetPasswordField = new JPasswordField(""); targetPasswordField.setEnabled(false); targetPanel.add(targetPasswordField); targetPanel.add(new JLabel("Database name")); targetDatabaseField = new JTextField(""); targetDatabaseField.setEnabled(false); targetPanel.add(targetDatabaseField); targetPanel.add(new JLabel("CSV Format")); targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)", "MySQL (tab, LF)", "RFC4180", "Excel CSV" }); targetCSVFormat.setToolTipText("The format of the output"); targetCSVFormat.setEnabled(true); targetPanel.add(targetCSVFormat); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(targetPanel, c); JPanel fakeDataButtonPanel = new JPanel(); fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS)); fakeDataButtonPanel.add(new JLabel("Max rows per table")); generateRowCount = new JSpinner(); generateRowCount.setValue(10000); fakeDataButtonPanel.add(generateRowCount); fakeDataButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getTargetDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); fakeDataButtonPanel.add(testConnectionButton); JButton fakeDataButton = new JButton("Generate fake data"); fakeDataButton.setBackground(new Color(151, 220, 141)); fakeDataButton.setToolTipText("Generate fake data based on the scan report"); fakeDataButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fakeDataRun(); } }); componentsToDisableWhenRunning.add(fakeDataButton); fakeDataButtonPanel.add(fakeDataButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(fakeDataButtonPanel, c); return panel; }