Roman Dawydkin avatar Roman Dawydkin committed 4a44192

Clearing result implemented as action.

Comments (0)

Files changed (1)

src/ru/ezsk/ldapshell/LdapWindow.java

 import javax.naming.directory.Attributes;
 import javax.naming.directory.SearchResult;
 
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
 import org.eclipse.jface.window.ApplicationWindow;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.TraverseEvent;
 import org.eclipse.swt.events.TraverseListener;
 import org.eclipse.swt.widgets.Composite;
 		window.open();
 	}
 
+	// ================================================================== Fields
 	private LdapDirectory ldapDirectory;
 	StyledText console;
 	Text input;
 
+	// ============================================================ Constructors
 	public LdapWindow(LdapDirectory ldapDirectory) {
 		super(null);
+		addMenuBar();
 		this.ldapDirectory = ldapDirectory;
 	}
 
+	// ================================================================= Methods
+
 	protected boolean showTopSeperator() {
 		return false;
 	}
 		}
 	}
 
+	protected MenuManager createMenuManager() {
+		final MenuManager mainMenu = super.createMenuManager();
+
+		final MenuManager fileMenu = new MenuManager("&File");
+		mainMenu.add(fileMenu);
+
+		fileMenu.add(new Action("Clear\tCtrl+L") {
+			public void run() {
+				clearResult();
+			}
+		});
+
+		fileMenu.add(new Separator());
+
+		fileMenu.add(new Action("E&xit\tAlt+X") {
+			public void run() {
+				close();
+			}
+		});
+
+		return mainMenu;
+	}
+
 	protected Control createContents(Composite parent) {
 		final Composite composite = (Composite) super.createContents(parent);
 		GridLayoutFactory.swtDefaults().applyTo(composite);
 		});
 		input.setFocus();
 
-		final KeyAdapter keyListener = new KeyAdapter() {
-			public void keyPressed(KeyEvent ev) {
-				if ((ev.keyCode == 'l') &&
-				    ((ev.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL))
-				{
-					ev.doit = false;
-					console.setText("");
-				}
-			}
-		};
-		console.addKeyListener(keyListener);
-		input.addKeyListener(keyListener);
-
 		return composite;
 	}
 
 		}
 	}
 
+	void clearResult() {
+		console.setText("");
+	}
+
 	private static List<Attribute> toList(
 			NamingEnumeration<? extends Attribute> enumeration)
 			throws NamingException
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.