|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.cvsclient;
import org.openide.util.*;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.DialogDescriptor;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JMenuItem;
import org.openide.awt.JMenuPlus;
import javax.swing.JMenu;
import javax.swing.event.MenuListener;
import javax.swing.event.MenuEvent;
import javax.swing.SwingUtilities;
import javax.swing.JButton;
import java.awt.Dialog;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import org.openide.DialogDisplayer;
/** The action that enables access to cvs from tools menu.
*
* @author Milos Kleint
*/
public class CvsMenuAction extends CallableSystemAction
{
private ArrayList switchableList;
boolean CTRL_Down = false;
private ToolsCvsExecutionPanel execPanel = null;
/** Creates new CvsMenuAction */
public CvsMenuAction() {
// System.out.println("Creating CvsMenu action..."); // NOI18N
}
/** Human presentable name of the action. This should be
* presented as an item in a menu.
* @return the name of the action
*/
public String getName () {
return NbBundle.getBundle (CvsMenuAction.class).
getString ("CTL_CvsMenuAction"); // NOI18N
}
/** Help context where to find more about the action.
* @return the help context for this action
*/
public HelpCtx getHelpCtx () {
return new HelpCtx(CvsMenuAction.class);
}
public boolean isEnabled() {
if (execPanel == null || !execPanel.isShowing()) return true;
return false;
}
private ToolsCvsExecutionPanel getToolsPanel() {
/* JavaCvsSettings settings = (JavaCvsSettings)SharedClassObject.findObject(
JavaCvsSettings.class, true);
*/
if (execPanel == null) {
execPanel = new ToolsCvsExecutionPanel();
}
return execPanel;
}
/** The action's icon location.
* @return the action's icon location
*/
protected String iconResource () {
return "org/netbeans/modules/cvsclient/commandIcon.gif"; // NOI18N
}
/** Opens packaging view. */
public void performAction () {
}
public void actionPerformed(java.awt.event.ActionEvent e){
// System.out.println("Performing cvs command.. :)");
final ToolsCvsExecutionPanel toolsPanel = getToolsPanel();
if (toolsPanel.isShowing()) return;
final Object[] paramOptions = new Object[2];
JButton btnRun = new JButton(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.RunCommandButton")); // NOI18N
btnRun.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.RunCommandButton_dsc")); // NOI18N
btnRun.setMnemonic(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.RunCommandButton_mnc").charAt(0)); // NOI18N
btnRun.setDefaultCapable(true);
paramOptions[0] = btnRun;
JButton btnCancel = new JButton(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.CancelButton")); // NOI18N
btnCancel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.CancelButton_dsc")); // NOI18N
btnCancel.setMnemonic(NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.CanceldButton_mnc").charAt(0)); // NOI18N
paramOptions[1] = btnCancel;
String toolsTitle = NbBundle.getBundle(CvsMenuAction.class)
.getString("CvsMenuAction.dialogTitle"); // NOI18N
DialogDescriptor dd = new DialogDescriptor(toolsPanel,
toolsTitle);
dd.setValue(btnRun);
dd.setClosingOptions(new Object [0]);
dd.setOptions(paramOptions);
dd.setModal(false);
final Dialog dial = DialogDisplayer.getDefault().createDialog(dd);
dd.setButtonListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (evt.getSource().equals(paramOptions[1])) {
// return;
}
if (evt.getSource().equals(paramOptions[0])) {
if (toolsPanel.isValid()) { toolsPanel.executeCommand(); }
else { javax.swing.JOptionPane.showMessageDialog(null, NbBundle.getBundle(CvsMenuAction.class).getString(
"CvsMenuAction.warningValueMessage"), "WARNING", javax.swing.JOptionPane.WARNING_MESSAGE); // NOI18N
return;
}
}
dial.dispose();
}
});
dial.setModal(false);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
dial.show();
}
});
}
//-------------------------------------------
private JMenuItem createItem(String name, boolean switchable){
JMenuItem item=null ;
item=new JMenuItem(g(name));
item.setActionCommand(name);
item.addActionListener(this);
// item.addMenuKeyListener(this);
assignHelp (item, name);
/* if (switchable && switchableList != null && fileSystem.getUiMode() == JavaCvsFileSystem.MODE_NOVICE) {
switchableList.add(item);
}
*/
return item;
}
private void assignHelp (JMenuItem item, String commandName) {
HelpCtx.setHelpIDString (item, CvsMenuAction.class.getName () + "." + commandName); // NOI18N
}
//-------------------------------------------
String g(String s) {
return NbBundle.getBundle
("org.netbeans.modules.cvsclient.Bundle").getString (s); // NOI18N
}
}
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.