Commits

Roman Dawydkin committed 2d8f824

Actions to quick view console or tree.

  • Participants
  • Parent commits 8734367

Comments (0)

Files changed (1)

src/ru/ezsk/ldapshell/LdapWindow.java

 import org.eclipse.jface.layout.GridLayoutFactory;
 import org.eclipse.jface.resource.FontRegistry;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.window.ApplicationWindow;
 import org.eclipse.jface.window.Window;
 
 public class LdapWindow extends ApplicationWindow
 {
+	private static final String ICON_KEY = "icon";
+
 	private static class AttributeComparator implements Comparator<Attribute>
 	{
 		static final Comparator<Attribute> INSTANCE = new AttributeComparator();
 	public static void main(String[] args) throws Exception {
 		final Display display = new Display();
 		try {
-//			final ImageRegistry imageRegistry = new ImageRegistry(display);
-//			imageRegistry.
-			final Image windowImage = ImageDescriptor.createFromFile(
-					LdapWindow.class, "ldap.gif")
-					.createImage(display);
+			final ImageRegistry imageRegistry = new ImageRegistry(display);
+			imageRegistry.put(ICON_KEY, ImageDescriptor.createFromFile(
+					LdapWindow.class, "ldap.gif"));
+			final Image windowImage = imageRegistry.get(ICON_KEY);
 			Window.setDefaultImage(windowImage);
 
 			final Properties properties = LdapWindow.loadProperties();
 	private LdapDirectory ldapDirectory;
 	StyledText console;
 	Text input;
-	private Tree tree;
+	Tree tree;
 	private Font boldFont;
 	private FontRegistry fontRegistry;
+	TabFolder tabFolder;
 
 	// ============================================================ Constructors
 	public LdapWindow(LdapDirectory ldapDirectory) {
 	protected MenuManager createMenuManager() {
 		final MenuManager mainMenu = super.createMenuManager();
 
-		final MenuManager fileMenu = new MenuManager("&File");
-		mainMenu.add(fileMenu);
+		final MenuManager viewMenu = new MenuManager("&View");
+		mainMenu.add(viewMenu);
 
-		fileMenu.add(new Action("Clear\tCtrl+L") {
+		viewMenu.add(new Action("Console\tAlt+1") {
+			public void run() {
+				tabFolder.setSelection(0);
+				console.setFocus();
+			}
+		});
+		viewMenu.add(new Action("Tree\tAlt+2") {
+			public void run() {
+				tabFolder.setSelection(1);
+				tree.setFocus();
+			}
+		});
+
+		viewMenu.add(new Action("Clear\tCtrl+L") {
 			public void run() {
 				clearResult();
 			}
 		});
 
-		fileMenu.add(new Separator());
+		viewMenu.add(new Separator());
 
-		fileMenu.add(new Action("E&xit\tAlt+X") {
+		viewMenu.add(new Action("E&xit\tAlt+X") {
 			public void run() {
 				close();
 			}
 		final Composite composite = new Composite(parent, SWT.NONE);
 		GridLayoutFactory.swtDefaults().applyTo(composite);
 
-		final TabFolder tabFolder = new TabFolder(composite, SWT.TOP);
+		tabFolder = new TabFolder(composite, SWT.TOP);
 		tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
 		final Control consolePanel = createConsolePanel(tabFolder);