Hello, Is there a reason for making IconToolbarBean getter methods synchronized ?
Regards Philippe On Sun, Oct 23, 2011 at 8:41 PM, <milam...@apache.org> wrote: > Author: milamber > Date: Sun Oct 23 18:41:08 2011 > New Revision: 1187947 > > URL: http://svn.apache.org/viewvc?rev=1187947&view=rev > Log: > Bug 52040 - Add a toolbar in JMeter main window > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clear.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clearall.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/close.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/collapse.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/copy.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/cut.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/expand.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/function.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/help.png > (with props) > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/new.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/open.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/paste.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/save.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/saveastp.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/search.png > (with props) > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/searchreset.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdown.png > (with props) > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdownremoteall.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/start.png > (with props) > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/startremoteall.png > (with props) > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stop.png > (with props) > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stopremoteall.png > (with props) > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/toggle.png > (with props) > Modified: > jakarta/jmeter/trunk/bin/jmeter.properties > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties > jakarta/jmeter/trunk/xdocs/changes.xml > > Modified: jakarta/jmeter/trunk/bin/jmeter.properties > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- jakarta/jmeter/trunk/bin/jmeter.properties (original) > +++ jakarta/jmeter/trunk/bin/jmeter.properties Sun Oct 23 18:41:08 2011 > @@ -115,6 +115,12 @@ jmeter.laf.mac=System > # See https://issues.apache.org/bugzilla/show_bug.cgi?id=52026 for > details > # N.B. the laf can be defined in user.properties. > > +# Toolbar display > +# default: > +#jmeter.toolbar.display=true > +# Toolbar icon definitions > > +#jmeter.toolbar.icons=org/apache/jmeter/images/toolbar/icons-toolbar.properties > + > # Icon definitions > # default: > #jmeter.icons=org/apache/jmeter/images/icon.properties > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java > (original) > +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java Sun > Oct 23 18:41:08 2011 > @@ -29,8 +29,10 @@ import java.util.Iterator; > import java.util.List; > import java.util.Map; > > +import javax.swing.JCheckBoxMenuItem; > import javax.swing.JOptionPane; > import javax.swing.JPopupMenu; > +import javax.swing.JToolBar; > import javax.swing.SwingUtilities; > > import org.apache.jmeter.engine.util.ValueReplacer; > @@ -103,7 +105,13 @@ public final class GuiPackage implements > > /** The main JMeter frame. */ > private MainFrame mainFrame; > + > + /** The main JMeter toolbar. */ > + private JToolBar toolbar; > > + /** The menu item toolbar. */ > + private JCheckBoxMenuItem menuToolBar; > + > /** > * Private constructor to permit instantiation only from within this > class. > * Use {@link #getInstance()} to retrieve a singleton instance. > @@ -513,6 +521,44 @@ public final class GuiPackage implements > public JMeterTreeListener getTreeListener() { > return treeListener; > } > + > + /** > + * Set the main JMeter toolbar. > + * > + * @param newToolbar > + * the new JMeter main toolbar > + */ > + public void setMainToolbar(JToolBar newToolbar) { > + toolbar = newToolbar; > + } > + > + /** > + * Get the main JMeter toolbar. > + * > + * @return the main JMeter toolbar > + */ > + public JToolBar getMainToolbar() { > + return toolbar; > + } > + > + /** > + * Set the menu item toolbar. > + * > + * @param newMenuToolBar > + * the new menu item toolbar > + */ > + public void setMenuItemToolbar(JCheckBoxMenuItem newMenuToolBar) { > + menuToolBar = newMenuToolBar; > + } > + > + /** > + * Get the menu item toolbar. > + * > + * @return the menu item toolbar > + */ > + public JCheckBoxMenuItem getMenuItemToolbar() { > + return menuToolBar; > + } > > /** > * Display the specified popup menu with the source component and > location > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java > (original) > +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java Sun > Oct 23 18:41:08 2011 > @@ -45,6 +45,7 @@ import javax.swing.JPanel; > import javax.swing.JPopupMenu; > import javax.swing.JScrollPane; > import javax.swing.JSplitPane; > +import javax.swing.JToolBar; > import javax.swing.JTree; > import javax.swing.MenuElement; > import javax.swing.SwingUtilities; > @@ -60,6 +61,7 @@ import org.apache.jmeter.gui.action.Acti > import org.apache.jmeter.gui.tree.JMeterCellRenderer; > import org.apache.jmeter.gui.tree.JMeterTreeListener; > import org.apache.jmeter.gui.util.JMeterMenuBar; > +import org.apache.jmeter.gui.util.JMeterToolBar; > import org.apache.jmeter.samplers.Remoteable; > import org.apache.jmeter.testelement.TestElement; > import org.apache.jmeter.testelement.TestListener; > @@ -83,6 +85,10 @@ public class MainFrame extends JFrame im > // The default title for the Menu bar > private static final String DEFAULT_TITLE = > "Apache JMeter ("+JMeterUtils.getJMeterVersion()+")"; // > $NON-NLS-1$ $NON-NLS-2$ > + > + // Allow display/hide toolbar > + private static final boolean DISPLAY_TOOLBAR = > + JMeterUtils.getPropDefault("jmeter.toolbar.display", true); // > $NON-NLS-1$ > > /** The menu bar. */ > private JMeterMenuBar menuBar; > @@ -428,6 +434,13 @@ public class MainFrame extends JFrame im > */ > private Component createToolBar() { > Box toolPanel = new Box(BoxLayout.X_AXIS); > + // add the toolbar > + JToolBar toolbar = JMeterToolBar.createToolbar(DISPLAY_TOOLBAR); > + GuiPackage guiInstance = GuiPackage.getInstance(); > + guiInstance.setMainToolbar(toolbar); > + > guiInstance.getMenuItemToolbar().getModel().setSelected(DISPLAY_TOOLBAR); > + toolPanel.add(toolbar); > + > toolPanel.add(Box.createRigidArea(new Dimension(10, 15))); > toolPanel.add(Box.createGlue()); > toolPanel.add(activeThreads); > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java > (original) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionNames.java > Sun Oct 23 18:41:08 2011 > @@ -83,6 +83,7 @@ public class ActionNames { > public static final String SUB_TREE_MERGED = "sub_tree_merged"; // > $NON-NLS-1$ > public static final String SUB_TREE_SAVED = "sub_tree_saved"; // > $NON-NLS-1$ > public static final String TOGGLE = "toggle"; // $NON-NLS-1$ > enable/disable > + public static final String TOOLBAR = "toolbar"; // > $NON-NLS-1$ > public static final String WHAT_CLASS = "what_class"; // > $NON-NLS-1$ > public static final String SEARCH_TREE = "search_tree"; // > $NON-NLS-1$ > public static final String SEARCH_RESET = "search_reset"; // > $NON-NLS-1$ > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java?rev=1187947&view=auto > > ============================================================================== > --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > (added) > +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > Sun Oct 23 18:41:08 2011 > @@ -0,0 +1,70 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + * > + */ > + > +package org.apache.jmeter.gui.action; > + > +import java.awt.event.ActionEvent; > +import java.util.HashSet; > +import java.util.Set; > + > +import org.apache.jmeter.gui.GuiPackage; > + > +/** > + * Hide / unhide toolbar. > + * > + */ > +public class ToolBar implements Command { > + > + private static final Set<String> commands = new HashSet<String>(); > + > + static { > + commands.add(ActionNames.TOOLBAR); > + } > + > + /** > + * Constructor for object. > + */ > + public ToolBar() { > + } > + > + /** > + * Gets the ActionNames attribute of the action > + * > + * @return the ActionNames value > + */ > + public Set<String> getActionNames() { > + return commands; > + } > + > + /** > + * This method performs the actual command processing. > + * > + * @param e > + * the generic UI action event > + */ > + public void doAction(ActionEvent e) { > + if (ActionNames.TOOLBAR.equals(e.getActionCommand())) { > + GuiPackage guiInstance = GuiPackage.getInstance(); > + if (guiInstance.getMenuItemToolbar().getModel().isSelected()) > { > + guiInstance.getMainToolbar().setVisible(true); > + } else { > + guiInstance.getMainToolbar().setVisible(false); > + } > + } > + } > +} > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ToolBar.java > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java?rev=1187947&view=auto > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > (added) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > Sun Oct 23 18:41:08 2011 > @@ -0,0 +1,103 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > + * implied. > + * > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +package org.apache.jmeter.gui.util; > + > +import org.apache.jmeter.gui.action.ActionNames; > +import org.apache.jorphan.logging.LoggingManager; > +import org.apache.jorphan.util.JMeterException; > +import org.apache.log.Logger; > + > +public final class IconToolbarBean { > + > + private static final Logger log = LoggingManager.getLoggerForClass(); > + > + private final String i18nKey; > + > + private final String actionName; > + > + private final String iconPath; > + > + private final String iconPathPressed; > + > + /** > + * Constructor to transform a line value (from icon set file) to a > icon bean for toolbar. > + * @param strToSplit - the line value (i18n key, ActionNames ID, icon > path, optional icon pressed path) > + * @throws JMeterException if error in parsing. > + */ > + public IconToolbarBean(final String strToSplit) throws JMeterException > { > + if (strToSplit == null) { > + throw new JMeterException("No icon definition"); //$NON-NLS-1$ > + } > + final String tmp[] = strToSplit.split(";"); //$NON-NLS-1$ > + if (tmp.length > 2) { > + this.i18nKey = tmp[0]; > + this.actionName = tmp[1]; > + final String icons[] = tmp[2].split(" "); //$NON-NLS-1$ > + this.iconPath = icons[0]; > + this.iconPathPressed = (icons.length > 1) ? icons[1] : > icons[0]; > + } else { > + throw new JMeterException(); > + } > + } > + > + /** > + * Resolve action name ID declared in icon set file to ActionNames > value > + * @return the resolve actionName > + */ > + public synchronized String getActionNameResolve() { > + final String aName; > + try { > + aName = (String) > (ActionNames.class.getField(this.actionName).get(null)); > + } catch (Exception e) { > + log.warn("Toolbar icon Action names error: " + this.actionName > + ", use unknown action."); //$NON-NLS-1$ > + return this.actionName; // return unknown action names for > display error msg > + } > + return aName; > + } > + > + /** > + * @return the i18nKey > + */ > + public synchronized String getI18nKey() { > + return i18nKey; > + } > + > + /** > + * @return the actionName > + */ > + public synchronized String getActionName() { > + return actionName; > + } > + > + /** > + * @return the iconPath > + */ > + public synchronized String getIconPath() { > + return iconPath; > + } > + > + /** > + * @return the iconPathPressed > + */ > + public synchronized String getIconPathPressed() { > + return iconPathPressed; > + } > + > +} > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/IconToolbarBean.java > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java > (original) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java > Sun Oct 23 18:41:08 2011 > @@ -26,6 +26,8 @@ import java.util.Iterator; > import java.util.LinkedList; > import java.util.List; > import java.util.Locale; > + > +import javax.swing.JCheckBoxMenuItem; > import javax.swing.JComponent; > import javax.swing.JMenu; > import javax.swing.JMenuBar; > @@ -36,6 +38,7 @@ import javax.swing.MenuElement; > import javax.swing.UIManager; > import javax.swing.UIManager.LookAndFeelInfo; > > +import org.apache.jmeter.gui.GuiPackage; > import org.apache.jmeter.gui.action.ActionNames; > import org.apache.jmeter.gui.action.ActionRouter; > import org.apache.jmeter.gui.action.KeyStrokes; > @@ -44,8 +47,8 @@ import org.apache.jmeter.util.JMeterUtil > import org.apache.jmeter.util.LocaleChangeEvent; > import org.apache.jmeter.util.LocaleChangeListener; > import org.apache.jmeter.util.SSLManager; > -import org.apache.jorphan.util.JOrphanUtils; > import org.apache.jorphan.logging.LoggingManager; > +import org.apache.jorphan.util.JOrphanUtils; > import org.apache.log.Logger; > > public class JMeterMenuBar extends JMenuBar implements > LocaleChangeListener { > @@ -310,6 +313,14 @@ public class JMeterMenuBar extends JMenu > } > optionsMenu.add(functionHelper); > optionsMenu.add(lafMenu); > + > + JCheckBoxMenuItem menuToolBar = > makeCheckBoxMenuItemRes("menu_toolbar", ActionNames.TOOLBAR); //$NON-NLS-1$ > + GuiPackage guiInstance = GuiPackage.getInstance(); > + if (guiInstance != null) { //avoid error in ant task tests (good > way?) > + guiInstance.setMenuItemToolbar(menuToolBar); > + } > + optionsMenu.add(menuToolBar); > + > if (SSLManager.isSSLSupported()) { > sslManager = makeMenuItemRes("sslmanager", 'S', > ActionNames.SSL_MANAGER, KeyStrokes.SSL_MANAGER); //$NON-NLS-1$ > optionsMenu.add(sslManager); > @@ -750,4 +761,18 @@ public class JMeterMenuBar extends JMenu > menuItem.addActionListener(ActionRouter.getInstance()); > return menuItem; > } > + > + private static JCheckBoxMenuItem makeCheckBoxMenuItemRes(String > resource, String actionCommand) { > + return makeCheckBoxMenuItemRes(resource, actionCommand, null); > + } > + > + private static JCheckBoxMenuItem makeCheckBoxMenuItemRes(String > resource, > + String actionCommand, KeyStroke keyStroke){ > + JCheckBoxMenuItem cbkMenuItem = new > JCheckBoxMenuItem(JMeterUtils.getResString(resource)); > + cbkMenuItem.setName(resource); > + cbkMenuItem.setActionCommand(actionCommand); > + cbkMenuItem.setAccelerator(keyStroke); > + cbkMenuItem.addActionListener(ActionRouter.getInstance()); > + return cbkMenuItem; > + } > } > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java?rev=1187947&view=auto > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > (added) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > Sun Oct 23 18:41:08 2011 > @@ -0,0 +1,134 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > + * implied. > + * > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +package org.apache.jmeter.gui.util; > + > +import java.net.URL; > +import java.util.Collection; > +import java.util.LinkedHashMap; > +import java.util.Properties; > + > +import javax.swing.ImageIcon; > +import javax.swing.JButton; > +import javax.swing.JOptionPane; > +import javax.swing.JToolBar; > + > +import org.apache.jmeter.gui.action.ActionRouter; > +import org.apache.jmeter.util.JMeterUtils; > +import org.apache.jorphan.logging.LoggingManager; > +import org.apache.jorphan.util.JMeterException; > +import org.apache.log.Logger; > + > +/** > + * The JMeter main toolbar class > + * > + */ > +public class JMeterToolBar { > + > + private static final Logger log = LoggingManager.getLoggerForClass(); > + > + // protected fields: JMeterToolBar class can be use to create another > toolbar (plugin, etc.) > + protected static final String defaultIconProp = > "org/apache/jmeter/images/toolbar/icons-toolbar.properties"; //$NON-NLS-1$ > + > + protected static final String keyIconProp = "jmeter.toolbar.icons"; > //$NON-NLS-1$ > + > + /** > + * Create the default JMeter toolbar > + * @return the JMeter toolbar > + */ > + public static JToolBar createToolbar(boolean visible) { > + JToolBar toolBar = new JToolBar(); > + toolBar.setFloatable(false); > + toolBar.setVisible(visible); > + > + LinkedHashMap<String, IconToolbarBean> icons = getIconMappings(); > + if (icons != null) { > + Collection<IconToolbarBean> enumIcons = icons.values(); > + for (IconToolbarBean iconToolbarBean : enumIcons) { > + if (iconToolbarBean == null) { > + toolBar.addSeparator(); > + } else { > + toolBar.add(makeButtonItemRes(iconToolbarBean)); > + } > + } > + } > + // implicit return empty toolbar if icons == null > + return toolBar; > + } > + > + /** > + * Generate a button component from icon bean > + * @param iconBean contains I18N key, ActionNames, icon path, optional > icon path pressed > + * @return a button for toolbar > + */ > + private static JButton makeButtonItemRes(IconToolbarBean iconBean) { > + final URL imageURL = > JMeterUtils.class.getClassLoader().getResource(iconBean.getIconPath()); > + JButton button = new JButton(new ImageIcon(imageURL)); > + > button.setToolTipText(JMeterUtils.getResString(iconBean.getI18nKey())); > + final URL imageURLPressed = > JMeterUtils.class.getClassLoader().getResource(iconBean.getIconPathPressed()); > + button.setPressedIcon(new ImageIcon(imageURLPressed)); > + button.addActionListener(ActionRouter.getInstance()); > + button.setActionCommand(iconBean.getActionNameResolve()); > + return button; > + } > + > + /** > + * Parse icon set file. > + * @return List of icons/action definition > + */ > + private static LinkedHashMap<String, IconToolbarBean> > getIconMappings() { > + String iconProp = JMeterUtils.getPropDefault(keyIconProp, > defaultIconProp); //$NON-NLS-1$ > + Properties p = JMeterUtils.loadProperties(iconProp); > + if (p == null && !iconProp.equals(defaultIconProp)) { > + log.info(iconProp + " not found - using " + defaultIconProp); > + iconProp = defaultIconProp; > + p = JMeterUtils.loadProperties(defaultIconProp); > + } > + if (p == null) { > + JOptionPane.showMessageDialog(null, JMeterUtils > + .getResString("toolbar_icon_set_not_found"), // > $NON-NLS-1$ > + > JMeterUtils.getResString("toolbar_icon_set_not_found"), // $NON-NLS-1$ > + JOptionPane.WARNING_MESSAGE); > + return null; > + } > + log.info("Loading toolbar icons properties from " + iconProp); > //$NON-NLS-1$ > + > + String order = p.getProperty("toolbar"); //$NON-NLS-1$ > + p.remove("toolbar"); //$NON-NLS-1$ > + String[] oList = order.split(","); //$NON-NLS-1$ > + > + LinkedHashMap<String, IconToolbarBean> listIcons = new > LinkedHashMap<String, IconToolbarBean>(); > + int ctr = 1; > + for (String key : oList) { > + log.debug("Toolbar icon key: " + key); //$NON-NLS-1$ > + if (key.trim().equals("|")) { //$NON-NLS-1$ > + listIcons.put("space" + ctr++, null); //$NON-NLS-1$ > + } else { > + try { > + IconToolbarBean itb = new > IconToolbarBean(p.getProperty(key)); > + listIcons.put(key, itb); > + } catch (JMeterException je) { > + log.error("Toolbar icon loading error - key: " + key); > //$NON-NLS-1$ > + } > + } > + } > + return listIcons; > + } > + > +} > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JMeterToolBar.java > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clear.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clear.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clear.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clearall.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clearall.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/clearall.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/close.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/close.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/close.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/collapse.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/collapse.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/collapse.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/copy.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/copy.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/copy.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/cut.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/cut.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/cut.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/expand.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/expand.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/expand.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/function.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/function.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/function.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/help.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/help.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/help.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties?rev=1187947&view=auto > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > (added) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > Sun Oct 23 18:41:08 2011 > @@ -0,0 +1,44 @@ > +# Licensed to the Apache Software Foundation (ASF) under one or more > +# contributor license agreements. See the NOTICE file distributed with > +# this work for additional information regarding copyright ownership. > +# The ASF licenses this file to You under the Apache License, Version > 2.0 > +# (the "License"); you may not use this file except in compliance with > +# the License. You may obtain a copy of the License at > +# > +# http://www.apache.org/licenses/LICENSE-2.0 > +# > +# Unless required by applicable law or agreed to in writing, software > +# distributed under the License is distributed on an "AS IS" BASIS, > +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > implied. > +# See the License for the specific language governing permissions and > +# limitations under the License. > + > +# Icons order. Keys separate by comma. Use a pipe | to have a space > between two icons. > > +toolbar=new,open,close,save,save_as_testplan,|,cut,copy,paste,|,expand,collapse,toggle,|,test_start,test_stop,test_shutdown,|,test_start_remote_all,test_stop_remote_all,test_shutdown_remote_all,|,test_clear,test_clear_all,|,search,search_reset,|,function_helper,help > + > +# Icon / action definition file. > +# Key: button names > +# Value: I18N key in messages.properties; ActionNames key field; > icon path, optionally followed by space and then the pressed icon name > +new=new;CLOSE;org/apache/jmeter/images/toolbar/new.png > +open=menu_open;OPEN;org/apache/jmeter/images/toolbar/open.png > +close=menu_close;CLOSE;org/apache/jmeter/images/toolbar/close.png > +save=save;SAVE;org/apache/jmeter/images/toolbar/save.png > > +save_as_testplan=save_as;SAVE_AS;org/apache/jmeter/images/toolbar/saveastp.png > +cut=cut;CUT;org/apache/jmeter/images/toolbar/cut.png > +copy=copy;COPY;org/apache/jmeter/images/toolbar/copy.png > +paste=paste;PASTE;org/apache/jmeter/images/toolbar/paste.png > +test_start=start;ACTION_START;org/apache/jmeter/images/toolbar/start.png > +test_stop=stop;ACTION_STOP;org/apache/jmeter/images/toolbar/stop.png > > +test_shutdown=shutdown;ACTION_SHUTDOWN;org/apache/jmeter/images/toolbar/shutdown.png > > +test_start_remote_all=remote_start_all;REMOTE_START_ALL;org/apache/jmeter/images/toolbar/startremoteall.png > > +test_stop_remote_all=remote_stop_all;REMOTE_STOP_ALL;org/apache/jmeter/images/toolbar/stopremoteall.png > > +test_shutdown_remote_all=remote_shut_all;REMOTE_SHUT_ALL;org/apache/jmeter/images/toolbar/shutdownremoteall.png > +test_clear=clear;CLEAR;org/apache/jmeter/images/toolbar/clear.png > > +test_clear_all=clear_all;CLEAR_ALL;org/apache/jmeter/images/toolbar/clearall.png > +toggle=toggle;TOGGLE;org/apache/jmeter/images/toolbar/toggle.png > > +expand=menu_expand_all;EXPAND_ALL;org/apache/jmeter/images/toolbar/expand.png > > +collapse=menu_collapse_all;COLLAPSE_ALL;org/apache/jmeter/images/toolbar/collapse.png > +search=menu_search;SEARCH_TREE;org/apache/jmeter/images/toolbar/search.png > > +search_reset=menu_search_reset;SEARCH_RESET;org/apache/jmeter/images/toolbar/searchreset.png > > +function_helper=function_dialog_menu_item;FUNCTIONS;org/apache/jmeter/images/toolbar/function.png > +help=help;HELP;org/apache/jmeter/images/toolbar/help.png > \ No newline at end of file > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > > ------------------------------------------------------------------------------ > svn:eol-style = native > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/icons-toolbar.properties > > ------------------------------------------------------------------------------ > svn:mime-type = text/plain > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/new.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/new.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/new.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/open.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/open.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/open.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/paste.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/paste.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/paste.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/save.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/save.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/save.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/saveastp.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/saveastp.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/saveastp.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/search.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/search.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/search.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/searchreset.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/searchreset.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/searchreset.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdown.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdown.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdown.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdownremoteall.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdownremoteall.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/shutdownremoteall.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/start.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/start.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/start.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/startremoteall.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/startremoteall.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/startremoteall.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stop.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stop.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stop.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stopremoteall.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stopremoteall.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/stopremoteall.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Added: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/toggle.png > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/toggle.png?rev=1187947&view=auto > > ============================================================================== > Binary file - no diff available. > > Propchange: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/images/toolbar/toggle.png > > ------------------------------------------------------------------------------ > svn:mime-type = image/png > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > (original) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > Sun Oct 23 18:41:08 2011 > @@ -512,6 +512,7 @@ menu_search_reset=Reset Search > menu_tables=Table > menu_threads=Threads (Users) > menu_timer=Timer > +menu_toolbar=Toolbar > metadata=MetaData > method=Method\: > mimetype=Mimetype > @@ -944,6 +945,7 @@ throughput_control_tplabel=Throughput > time_format=Format string for SimpleDateFormat (optional) > timelim=Time limit > toggle=Toggle > +toolbar_icon_set_not_found=The file description of toolbar icon set is not > found. See logs. > tr=Turkish > transaction_controller_include_timers=Include timer duration in generated > sample > transaction_controller_parent=Generate parent sample > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties > (original) > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties > Sun Oct 23 18:41:08 2011 > @@ -469,6 +469,7 @@ menu_search=Rechercher > menu_search_reset=Effacer la recherche > menu_threads=Moteurs d'utilisateurs > menu_timer=Compteurs de temps > +menu_toolbar=Barre d'outils > metadata=M\u00E9ta-donn\u00E9es > method=M\u00E9thode \: > mimetype=Type MIME > @@ -850,6 +851,7 @@ throughput_control_tplabel=D\u00E9bit \: > time_format=Chaine de formatage sur le mod\u00E8le SimpleDateFormat > (optionnel) > timelim=Limiter le temps de r\u00E9ponses \u00E0 (ms) > toggle=Permuter > +toolbar_icon_set_not_found=Le fichier de description des ic\u00F4nes de la > barre d'outils n'est pas trouv\u00E9. Voir les journaux. > tr=Turc > transaction_controller_include_timers=Inclure la dur\u00E9e des compteurs > de temps dans le calcul du temps > transaction_controller_parent=G\u00E9n\u00E9rer en \u00E9chantillon parent > > Modified: jakarta/jmeter/trunk/xdocs/changes.xml > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1187947&r1=1187946&r2=1187947&view=diff > > ============================================================================== > --- jakarta/jmeter/trunk/xdocs/changes.xml (original) > +++ jakarta/jmeter/trunk/xdocs/changes.xml Sun Oct 23 18:41:08 2011 > @@ -178,6 +178,7 @@ Mirror server now uses default port 8081 > <li>Bug 52027 - Allow System or CrossPlatform LAF to be set from options > menu</li> > <li>Bug 52037 - Remember user-set LaF over restarts.</li> > <li>Bug 51861 - Improve HTTP Request GUI to better show parameters without > name (GWT RPC requests for example) (UNDER DEVELOPMENT)</li> > +<li>Bug 52040 - Add a toolbar in JMeter main window</li> > </ul> > > <h2>Non-functional changes</h2> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: notifications-unsubscr...@jakarta.apache.org > For additional commands, e-mail: notifications-h...@jakarta.apache.org > > -- Cordialement. Philippe Mouawad.