KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > perspective > BrowserPerspective


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.ui.perspective;
22
23
24 import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
25 import org.apache.directory.ldapstudio.browser.ui.views.connection.ConnectionView;
26 import org.apache.directory.ldapstudio.browser.ui.views.modificationlogs.ModificationLogsView;
27 import org.apache.directory.ldapstudio.browser.ui.wizards.BatchOperationWizard;
28 import org.apache.directory.ldapstudio.browser.ui.wizards.NewBookmarkWizard;
29 import org.apache.directory.ldapstudio.browser.ui.wizards.NewEntryWizard;
30 import org.apache.directory.ldapstudio.browser.ui.wizards.NewSearchWizard;
31 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator;
32 import org.apache.directory.ldapstudio.browser.common.wizards.NewConnectionWizard;
33 import org.apache.directory.ldapstudio.ldifeditor.wizards.NewLdifFileWizard;
34 import org.eclipse.ui.IFolderLayout;
35 import org.eclipse.ui.IPageLayout;
36 import org.eclipse.ui.IPerspectiveFactory;
37
38
39 /**
40  * This class implements the {@link IPerspectiveFactory} for the browser
41  * plugin. It is responsible for creating the perspective layout.
42  *
43  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
44  * @version $Rev$, $Date$
45  */

46 public class BrowserPerspective implements IPerspectiveFactory
47 {
48
49     /**
50      * Gets the ID of the browser perspective.
51      *
52      * @return the ID of the browser perspective
53      */

54     public static String JavaDoc getId()
55     {
56         return BrowserPerspective.class.getName();
57     }
58
59
60     /**
61      * {@inheritDoc}
62      */

63     public void createInitialLayout( IPageLayout layout )
64     {
65         defineActions( layout );
66         defineLayout( layout );
67
68         layout.addPerspectiveShortcut( "org.apache.directory.ldapstudio.schemas.perspective" ); //$NON-NLS-1$
69
layout.addPerspectiveShortcut( "org.apache.directory.ldapstudio.browser.ui.perspective.BrowserPerspective" ); //$NON-NLS-1$
70
}
71
72
73     /**
74      * Defines the actions in the "New..." menu and the "Show views..." menu.
75      *
76      * @param layout the layout
77      */

78     private void defineActions( IPageLayout layout )
79     {
80         // Add "new wizards".
81
layout.addNewWizardShortcut( NewConnectionWizard.getId() );
82         layout.addNewWizardShortcut( NewEntryWizard.getId() );
83         layout.addNewWizardShortcut( NewSearchWizard.getId() );
84         layout.addNewWizardShortcut( NewBookmarkWizard.getId() );
85         layout.addNewWizardShortcut( BatchOperationWizard.getId() );
86         layout.addNewWizardShortcut( NewLdifFileWizard.getId() );
87
88         // Add "show views".
89
layout.addShowViewShortcut( ConnectionView.getId() );
90         layout.addShowViewShortcut( BrowserView.getId() );
91         layout.addShowViewShortcut( ModificationLogsView.getId() );
92         layout.addShowViewShortcut( IPageLayout.ID_OUTLINE );
93         layout.addShowViewShortcut( "org.eclipse.ui.views.ProgressView" );
94     }
95
96
97     /**
98      * Defines the layout.
99      *
100      * @param layout the layout
101      */

102     private void defineLayout( IPageLayout layout )
103     {
104
105         // Editor area
106
String JavaDoc editorArea = layout.getEditorArea();
107
108         // Browser folder
109
IFolderLayout browserFolder = layout.createFolder( "browserFolder", IPageLayout.LEFT, ( float ) 0.25,
110             editorArea );
111         browserFolder.addView( BrowserView.getId() );
112
113         // Connection folder
114
IFolderLayout connectionFolder = layout.createFolder( "connectionFolder", IPageLayout.BOTTOM, ( float ) 0.75,
115             "browserFolder" );
116         connectionFolder.addView( ConnectionView.getId() );
117
118         // Outline folder
119
IFolderLayout outlineFolder = layout.createFolder( "outlineFolder", IPageLayout.RIGHT, ( float ) 0.75,
120             editorArea );
121         outlineFolder.addView( IPageLayout.ID_OUTLINE );
122
123         // Progress folder
124
IFolderLayout progessFolder = layout.createFolder( "progressFolder", IPageLayout.BOTTOM, ( float ) 0.75,
125             "outlineFolder" );
126         progessFolder.addView( "org.eclipse.ui.views.ProgressView" );
127
128         // Log folder
129
IFolderLayout logFolder = layout.createFolder( "logFolder", IPageLayout.BOTTOM, ( float ) 0.75, editorArea );
130         logFolder.addView( ModificationLogsView.getId() );
131         logFolder.addPlaceholder( "*" );
132
133         // non-closable?
134
boolean isIDE = BrowserCommonActivator.isIDEEnvironment();
135         if ( !isIDE )
136         {
137             layout.getViewLayout( BrowserView.getId() ).setCloseable( false );
138             layout.getViewLayout( ConnectionView.getId() ).setCloseable( false );
139             layout.getViewLayout( IPageLayout.ID_OUTLINE ).setCloseable( false );
140             layout.getViewLayout( "org.eclipse.ui.views.ProgressView" ).setCloseable( false );
141             layout.getViewLayout( ModificationLogsView.getId() ).setCloseable( false );
142         }
143     }
144
145 }
146
Popular Tags