01: /*
02: * MakeInListAction.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.gui.actions;
13:
14: import java.awt.event.ActionEvent;
15:
16: import workbench.gui.editor.CodeTools;
17: import workbench.gui.sql.EditorPanel;
18: import workbench.interfaces.TextSelectionListener;
19: import workbench.resource.ResourceMgr;
20:
21: /**
22: * Make an "IN" List
23: * @see workbench.gui.editor.CodeTools#makeInListForChar()
24: * @author support@sql-workbench.net
25: */
26: public class MakeInListAction extends WbAction implements
27: TextSelectionListener {
28: private EditorPanel client;
29:
30: public MakeInListAction(EditorPanel aClient) {
31: super ();
32: this .client = aClient;
33: this .client.addSelectionListener(this );
34: this .initMenuDefinition("MnuTxtMakeCharInList");
35: this .setMenuItemName(ResourceMgr.MNU_TXT_SQL);
36: this .setEnabled(false);
37: }
38:
39: public void executeAction(ActionEvent e) {
40: CodeTools tools = new CodeTools(client);
41: tools.makeInListForChar();
42: }
43:
44: public void selectionChanged(int newStart, int newEnd) {
45: if (newEnd > newStart) {
46: int startLine = this .client.getSelectionStartLine();
47: int endLine = this .client.getSelectionEndLine();
48: this .setEnabled(startLine < endLine);
49: } else {
50: this .setEnabled(false);
51: }
52: }
53:
54: }
|