01: /*
02: * MakeNonCharInListAction.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#makeInListForNonChar()
24: * @author support@sql-workbench.net
25: */
26: public class MakeNonCharInListAction extends WbAction implements
27: TextSelectionListener {
28: private EditorPanel client;
29:
30: public MakeNonCharInListAction(EditorPanel aClient) {
31: super ();
32: this .client = aClient;
33: this .client.addSelectionListener(this );
34: this .initMenuDefinition("MnuTxtMakeNonCharInList");
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.makeInListForNonChar();
42: }
43:
44: public void selectionChanged(int newStart, int newEnd) {
45: //this.setEnabled(newEnd > newStart);
46: if (newEnd > newStart) {
47: int startLine = this .client.getSelectionStartLine();
48: int endLine = this .client.getSelectionEndLine();
49: this .setEnabled(startLine < endLine);
50: } else {
51: this .setEnabled(false);
52: }
53: }
54:
55: }
|