001 /* 002 * Copyright (C) 2008-2010 by Holger Arndt 003 * 004 * This file is part of the Universal Java Matrix Package (UJMP). 005 * See the NOTICE file distributed with this work for additional 006 * information regarding copyright ownership and licensing. 007 * 008 * UJMP is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation; either version 2 011 * of the License, or (at your option) any later version. 012 * 013 * UJMP is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public 019 * License along with UJMP; if not, write to the 020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 021 * Boston, MA 02110-1301 USA 022 */ 023 024 package org.ujmp.gui.menu; 025 026 import java.awt.event.ActionEvent; 027 import java.awt.event.KeyEvent; 028 029 import javax.swing.AbstractAction; 030 import javax.swing.Action; 031 import javax.swing.JComponent; 032 import javax.swing.JMenu; 033 import javax.swing.JMenuItem; 034 import javax.swing.JSeparator; 035 036 import org.ujmp.core.enums.FileFormat; 037 import org.ujmp.core.util.JMathLib; 038 import org.ujmp.core.util.matrices.MatrixAvailableProcessors; 039 import org.ujmp.core.util.matrices.MatrixMemoryUsage; 040 import org.ujmp.core.util.matrices.MatrixRandomSeed; 041 import org.ujmp.core.util.matrices.MatrixRunningThreads; 042 import org.ujmp.core.util.matrices.MatrixSystemEnvironment; 043 import org.ujmp.core.util.matrices.MatrixSystemProperties; 044 import org.ujmp.core.util.matrices.MatrixSystemTime; 045 import org.ujmp.core.util.matrices.UJMPPluginsMatrix; 046 import org.ujmp.gui.actions.ShowInFrameAction; 047 import org.ujmp.gui.util.MatrixUIDefaults; 048 049 public class UJMPToolsMenu extends JMenu { 050 private static final long serialVersionUID = 853886481708901509L; 051 052 public UJMPToolsMenu(JComponent component) { 053 super("Tools"); 054 setMnemonic(KeyEvent.VK_T); 055 add(new JMenuItem(new ShowInFrameAction(component, "UJMP Plugins", 056 UJMPPluginsMatrix.class))); 057 add(new JSeparator()); 058 add(new JMenuItem(new ShowInFrameAction(component, 059 "Supported File Formats", FileFormat.class))); 060 add(new JMenuItem(new ShowInFrameAction(component, "System Properties", 061 MatrixSystemProperties.class))); 062 add(new JMenuItem(new ShowInFrameAction(component, 063 "System Environment", MatrixSystemEnvironment.class))); 064 add(new JMenuItem(new ShowInFrameAction(component, "UI Defaults", 065 MatrixUIDefaults.class))); 066 add(new JSeparator()); 067 add(new JMenuItem(new ShowInFrameAction(component, "Memory Usage", 068 MatrixMemoryUsage.class))); 069 add(new JMenuItem(new ShowInFrameAction(component, "Running Threads", 070 MatrixRunningThreads.class))); 071 add(new JMenuItem(new ShowInFrameAction(component, "System Time", 072 MatrixSystemTime.class))); 073 add(new JMenuItem(new ShowInFrameAction(component, "Random Seed", 074 MatrixRandomSeed.class))); 075 add(new JMenuItem(new ShowInFrameAction(component, 076 "Available Processors", MatrixAvailableProcessors.class))); 077 078 if (JMathLib.isAvailable()) { 079 add(new JSeparator()); 080 add(new JMathLibAction()); 081 } 082 } 083 084 class JMathLibAction extends AbstractAction { 085 private static final long serialVersionUID = 1895232937545702538L; 086 087 public JMathLibAction() { 088 putValue(Action.NAME, "JMathLib"); 089 putValue(Action.SHORT_DESCRIPTION, "Show JMathlib in a new Window"); 090 } 091 092 public void actionPerformed(ActionEvent e) { 093 JMathLib.showGUI(); 094 } 095 096 } 097 }