01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.gui.action;
20:
21: import java.awt.event.ActionEvent;
22: import java.util.Set;
23:
24: import javax.swing.JOptionPane;
25:
26: import org.apache.jmeter.gui.GuiPackage;
27: import org.apache.jmeter.util.JMeterUtils;
28: import org.apache.jorphan.logging.LoggingManager;
29: import org.apache.log.Logger;
30:
31: public abstract class AbstractAction implements Command {
32: private static final Logger log = LoggingManager
33: .getLoggerForClass();
34:
35: /**
36: * @see Command#doAction(ActionEvent)
37: */
38: public void doAction(ActionEvent e) {
39: }
40:
41: /**
42: * @see Command#getActionNames()
43: */
44: abstract public Set getActionNames();
45:
46: /**
47: * @param e
48: */
49: protected void popupShouldSave(ActionEvent e) {
50: log.debug("popupShouldSave");
51: if (GuiPackage.getInstance().getTestPlanFile() == null) {
52: if (JOptionPane.showConfirmDialog(GuiPackage.getInstance()
53: .getMainFrame(),
54: JMeterUtils.getResString("should_save"), //$NON-NLS-1$
55: JMeterUtils.getResString("warning"), //$NON-NLS-1$
56: JOptionPane.YES_NO_OPTION,
57: JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
58: ActionRouter.getInstance().doActionNow(
59: new ActionEvent(e.getSource(), e.getID(),
60: ActionNames.SAVE));
61: }
62: }
63: }
64: }
|