directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1692332 - in /directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor: AbstractCombinedEntryEditorPage.java CombinedEntryEditor.java
Date Wed, 22 Jul 2015 22:54:07 GMT
Author: elecharny
Date: Wed Jul 22 22:54:06 2015
New Revision: 1692332

URL: http://svn.apache.org/r1692332
Log:
A bit of formating and code reorganisation

Modified:
    directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/AbstractCombinedEntryEditorPage.java
    directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/CombinedEntryEditor.java

Modified: directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/AbstractCombinedEntryEditorPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/AbstractCombinedEntryEditorPage.java?rev=1692332&r1=1692331&r2=1692332&view=diff
==============================================================================
--- directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/AbstractCombinedEntryEditorPage.java
(original)
+++ directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/AbstractCombinedEntryEditorPage.java
Wed Jul 22 22:54:06 2015
@@ -45,8 +45,7 @@ public abstract class AbstractCombinedEn
     /**
      * Creates a new instance of AbstractTemplateEntryEditorPage.
      *
-     * @param editor
-     *      the associated editor
+     * @param editor the associated editor
      */
     public AbstractCombinedEntryEditorPage( CombinedEntryEditor editor )
     {

Modified: directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/CombinedEntryEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/CombinedEntryEditor.java?rev=1692332&r1=1692331&r2=1692332&view=diff
==============================================================================
--- directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/CombinedEntryEditor.java
(original)
+++ directory/studio/trunk/plugins/combinededitor/src/main/java/org/apache/directory/studio/combinededitor/editor/CombinedEntryEditor.java
Wed Jul 22 22:54:06 2015
@@ -67,8 +67,10 @@ public abstract class CombinedEntryEdito
 {
     /** The Template Editor page */
     private TemplateEditorPage templateEditorPage;
+    
     /** The Table Editor page */
     private TableEditorPage tableEditorPage;
+    
     /** The LDIF Editor page */
     private LdifEditorPage ldifEditorPage;
 
@@ -77,8 +79,10 @@ public abstract class CombinedEntryEdito
 
     /** The tab associated with the Template Editor */
     private CTabItem templateEditorTab;
+    
     /** The tab associated with the Table Editor */
     private CTabItem tableEditorTab;
+    
     /** The tab associated with the LDIF Editor */
     private CTabItem ldifEditorTab;
 
@@ -102,10 +106,15 @@ public abstract class CombinedEntryEdito
         tabFolder = new CTabFolder( parent, SWT.BOTTOM );
 
         // Creating the editor pages and tab items
+        // The Template editor item
         templateEditorPage = new TemplateEditorPage( this );
         templateEditorTab = templateEditorPage.getTabItem();
+        
+        // The Table editor item
         tableEditorPage = new TableEditorPage( this );
         tableEditorTab = tableEditorPage.getTabItem();
+        
+        // The LDIF editor item
         ldifEditorPage = new LdifEditorPage( this );
         ldifEditorTab = ldifEditorPage.getTabItem();
 
@@ -114,45 +123,60 @@ public abstract class CombinedEntryEdito
 
         // Getting the default editor
         int defaultEditor = store.getInt( CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR
);
-        if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TEMPLATE
)
+        
+        switch ( defaultEditor )
         {
-            // Getting the boolean indicating if the user wants to auto-switch the template
editor
-            boolean autoSwitchToAnotherEditor = store
-                .getBoolean( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_TO_ANOTHER_EDITOR
);
-            if ( autoSwitchToAnotherEditor && !canBeHandledWithATemplate() )
-            {
-                int autoSwitchEditor = store.getInt( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR
);
-                if ( autoSwitchEditor == CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_TABLE
)
+            case CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TEMPLATE :
+                // Getting the boolean indicating if the user wants to auto-switch the template
editor
+                boolean autoSwitchToAnotherEditor = store
+                    .getBoolean( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_TO_ANOTHER_EDITOR
);
+                
+                if ( autoSwitchToAnotherEditor && !canBeHandledWithATemplate() )
                 {
-                    // Selecting the Table Editor
-                    tabFolder.setSelection( tableEditorTab );
-                    tableEditorPage.init(); // Forcing the initialization of the first tab
item, because the listener is not triggered when selecting a tab item programmatically
+                    switch ( store.getInt( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR
) )
+                    {
+                        case CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_TABLE
:
+                            // Selecting the Table Editor
+                            tabFolder.setSelection( tableEditorTab );
+                            // Forcing the initialization of the first tab item, 
+                            // because the listener is not triggered when selecting a tab
item programmatically
+                            tableEditorPage.init();
+                            break;
+                            
+                        case  CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_LDIF
:
+                            // Selecting the LDIF Editor
+                            tabFolder.setSelection( ldifEditorTab );
+                            // Forcing the initialization of the first tab item, 
+                            // because the listener is not triggered when selecting a tab
item programmatically
+                            ldifEditorPage.init();
+                    }
                 }
-                else if ( autoSwitchEditor == CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_LDIF
)
+                else
                 {
-                    // Selecting the LDIF Editor
-                    tabFolder.setSelection( ldifEditorTab );
-                    ldifEditorPage.init(); // Forcing the initialization of the first tab
item, because the listener is not triggered when selecting a tab item programmatically
+                    // Selecting the Template Editor
+                    tabFolder.setSelection( templateEditorTab );
+                    // Forcing the initialization of the first tab item, 
+                    // because the listener is not triggered when selecting a tab item programmatically
+                    templateEditorPage.init();
                 }
-            }
-            else
-            {
-                // Selecting the Template Editor
-                tabFolder.setSelection( templateEditorTab );
-                templateEditorPage.init(); // Forcing the initialization of the first tab
item, because the listener is not triggered when selecting a tab item programmatically
-            }
-        }
-        else if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TABLE
)
-        {
-            // Selecting the Table Editor
-            tabFolder.setSelection( tableEditorTab );
-            tableEditorPage.init(); // Forcing the initialization of the first tab item,
because the listener is not triggered when selecting a tab item programmatically
-        }
-        else if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_LDIF
)
-        {
-            // Selecting the LDIF Editor
-            tabFolder.setSelection( ldifEditorTab );
-            ldifEditorPage.init(); // Forcing the initialization of the first tab item, because
the listener is not triggered when selecting a tab item programmatically
+                
+                break;
+            
+            case CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TABLE :
+                // Selecting the Table Editor
+                tabFolder.setSelection( tableEditorTab );
+                // Forcing the initialization of the first tab item, 
+                // because the listener is not triggered when selecting a tab item programmatically
+                tableEditorPage.init();
+                
+                break;
+        
+            case CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_LDIF :
+                // Selecting the LDIF Editor
+                tabFolder.setSelection( ldifEditorTab );
+                // Forcing the initialization of the first tab item, 
+                // because the listener is not triggered when selecting a tab item programmatically
+                ldifEditorPage.init(); 
         }
     }
 
@@ -239,11 +263,9 @@ public abstract class CombinedEntryEdito
     /**
      * Indicates whether or not the entry can be handled with a (at least) template.
      *
-     * @param entry
-     *      the entry
-     * @return
-     *      <code>true</code> if the entry can be handled with a template,
-     *      <code>false</code> if not.
+     * @param entry the entry
+     * @return <code>true</code> if the entry can be handled with a template,
+     * <code>false</code> if not.
      */
     private boolean canBeHandledWithATemplate( IEntry entry )
     {
@@ -254,16 +276,17 @@ public abstract class CombinedEntryEdito
     /**
      * Indicates whether or not the input entry can be handled with a (at least) template.
      *
-     * @return
-     *      <code>true</code> if the input entry can be handled with a template,
+     * @return <code>true</code> if the input entry can be handled with a template,
      *      <code>false</code> if not.
      */
     private boolean canBeHandledWithATemplate()
     {
         IEditorInput editorInput = getEditorInput();
+        
         if ( ( editorInput != null ) && ( editorInput instanceof EntryEditorInput
) )
         {
             IEntry entry = ( ( EntryEditorInput ) editorInput ).getResolvedEntry();
+            
             if ( entry != null )
             {
                 return canBeHandledWithATemplate( entry );
@@ -332,6 +355,7 @@ public abstract class CombinedEntryEdito
     public EntryEditorInput getEntryEditorInput()
     {
         Object editorInput = getEditorInput();
+        
         if ( ( editorInput != null ) && ( editorInput instanceof EntryEditorInput
) )
         {
             return ( EntryEditorInput ) editorInput;
@@ -347,6 +371,7 @@ public abstract class CombinedEntryEdito
     private void update()
     {
         ICombinedEntryEditorPage selectedPage = getEditorPageFromSelectedTab();
+        
         if ( selectedPage != null )
         {
             selectedPage.update();
@@ -412,6 +437,7 @@ public abstract class CombinedEntryEdito
             ISearchResult searchResultInput = eei.getSearchResultInput();
             IBookmark bookmarkInput = eei.getBookmarkInput();
             EntryEditorInput dummyInput;
+            
             if ( entryInput != null )
             {
                 dummyInput = new EntryEditorInput( entryInput, null );
@@ -424,6 +450,7 @@ public abstract class CombinedEntryEdito
             {
                 dummyInput = new EntryEditorInput( bookmarkInput, null );
             }
+            
             setInput( dummyInput );
             firePropertyChange( IEditorPart.PROP_INPUT );
 
@@ -435,46 +462,59 @@ public abstract class CombinedEntryEdito
             IPreferenceStore store = CombinedEditorPlugin.getDefault().getPreferenceStore();
 
             // Getting the default editor
-            int defaultEditor = store.getInt( CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR
);
-            if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TEMPLATE
)
+            switch ( store.getInt( CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR ) )
             {
-                // Getting the boolean indicating if the user wants to auto-switch the template
editor
-                boolean autoSwitchToAnotherEditor = store
-                    .getBoolean( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_TO_ANOTHER_EDITOR
);
-                if ( autoSwitchToAnotherEditor && !canBeHandledWithATemplate() )
-                {
-                    int autoSwitchEditor = store.getInt( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR
);
-                    if ( autoSwitchEditor == CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_TABLE
)
+                case CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TEMPLATE :
+                    // Getting the boolean indicating if the user wants to auto-switch the
template editor
+                    boolean autoSwitchToAnotherEditor = store
+                        .getBoolean( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_TO_ANOTHER_EDITOR
);
+                    
+                    if ( autoSwitchToAnotherEditor && !canBeHandledWithATemplate()
)
                     {
-                        // Selecting the Table Editor
-                        tabFolder.setSelection( tableEditorTab );
-                        tableEditorPage.init(); // Forcing the initialization of the first
tab item, because the listener is not triggered when selecting a tab item programmatically
+                        switch ( store.getInt( CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR
) )
+                        {
+                            case  CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_TABLE
:
+                                // Selecting the Table Editor
+                                tabFolder.setSelection( tableEditorTab );
+                                // Forcing the initialization of the first tab item, 
+                                // because the listener is not triggered when selecting a
tab item programmatically
+                                tableEditorPage.init();
+                                break;
+                                
+                            case CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_LDIF
:
+                                // Selecting the LDIF Editor
+                                tabFolder.setSelection( ldifEditorTab );
+                                // Forcing the initialization of the first tab item, 
+                                // because the listener is not triggered when selecting a
tab item programmatically
+                                ldifEditorPage.init();
+                        }
                     }
-                    else if ( autoSwitchEditor == CombinedEditorPluginConstants.PREF_AUTO_SWITCH_EDITOR_LDIF
)
+                    else
                     {
-                        // Selecting the LDIF Editor
-                        tabFolder.setSelection( ldifEditorTab );
-                        ldifEditorPage.init(); // Forcing the initialization of the first
tab item, because the listener is not triggered when selecting a tab item programmatically
+                        // Selecting the Template Editor
+                        tabFolder.setSelection( templateEditorTab );
+                        // Forcing the initialization of the first tab item, 
+                        // because the listener is not triggered when selecting a tab item
programmatically
+                        templateEditorPage.init();
                     }
-                }
-                else
-                {
-                    // Selecting the Template Editor
-                    tabFolder.setSelection( templateEditorTab );
-                    templateEditorPage.init(); // Forcing the initialization of the first
tab item, because the listener is not triggered when selecting a tab item programmatically
-                }
-            }
-            else if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TABLE
)
-            {
-                // Selecting the Table Editor
-                tabFolder.setSelection( tableEditorTab );
-                tableEditorPage.init(); // Forcing the initialization of the first tab item,
because the listener is not triggered when selecting a tab item programmatically
-            }
-            else if ( defaultEditor == CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_LDIF
)
-            {
-                // Selecting the LDIF Editor
-                tabFolder.setSelection( ldifEditorTab );
-                ldifEditorPage.init(); // Forcing the initialization of the first tab item,
because the listener is not triggered when selecting a tab item programmatically
+                    
+                    break;
+
+                case CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_TABLE :
+                    // Selecting the Table Editor
+                    tabFolder.setSelection( tableEditorTab );
+                    // Forcing the initialization of the first tab item, 
+                    // because the listener is not triggered when selecting a tab item programmatically
+                    tableEditorPage.init();
+                    break;
+                    
+                case  CombinedEditorPluginConstants.PREF_DEFAULT_EDITOR_LDIF :
+                    // Selecting the LDIF Editor
+                    tabFolder.setSelection( ldifEditorTab );
+                    // Forcing the initialization of the first tab item, 
+                    // because the listener is not triggered when selecting a tab item programmatically
+                    ldifEditorPage.init(); 
+                    break;
             }
 
             // Noticing all pages that the editor input has changed
@@ -488,12 +528,12 @@ public abstract class CombinedEntryEdito
     /**
      * Gets the {@link ICombinedEntryEditorPage} associated with the selected tab.
      *
-     * @return
-     *      the {@link ICombinedEntryEditorPage} associated with the selected tab
+     * @return the {@link ICombinedEntryEditorPage} associated with the selected tab
      */
     private ICombinedEntryEditorPage getEditorPageFromSelectedTab()
     {
         CTabItem selectedTabItem = getSelectedTabItem();
+        
         if ( selectedTabItem != null )
         {
             // Template Editor Tab
@@ -532,8 +572,7 @@ public abstract class CombinedEntryEdito
     /**
      * Returns the {@link CTabFolder} associated with the editor.
      *
-     * @return
-     *      the {@link CTabFolder} associated with the editor
+     * @return the {@link CTabFolder} associated with the editor
      */
     public CTabFolder getTabFolder()
     {
@@ -544,8 +583,7 @@ public abstract class CombinedEntryEdito
     /**
      * Returns the currently selected {@link CTabItem}.
      *
-     * @return
-     *      the currently selected {@link CTabItem}
+     * @return the currently selected {@link CTabItem}
      */
     public CTabItem getSelectedTabItem()
     {
@@ -556,9 +594,8 @@ public abstract class CombinedEntryEdito
     /**
      * Get the {@link TemplateEditorPage} page.
      *
-     * @return
-     *      the {@link TemplateEditorPage} page
-     */
+     * @return the {@link TemplateEditorPage} page
+     *
     public TemplateEditorPage getTemplateEditorPage()
     {
         return templateEditorPage;
@@ -568,9 +605,8 @@ public abstract class CombinedEntryEdito
     /**
      * Get the {@link TableEditorPage} page.
      *
-     * @return
-     *      the {@link TableEditorPage} page
-     */
+     * @return the {@link TableEditorPage} page
+     *
     public TableEditorPage getTableEditorPage()
     {
         return tableEditorPage;
@@ -580,11 +616,10 @@ public abstract class CombinedEntryEdito
     /**
      * Get the {@link LdifEditorPage} page.
      *
-     * @return
-     *      the {@link LdifEditorPage} page
-     */
+     * @return the {@link LdifEditorPage} page
+     *
     public LdifEditorPage getLdifEditorPage()
     {
         return ldifEditorPage;
-    }
+    }*/
 }



Mime
View raw message