directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r558021 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view: widget/DifferencesWidget.java wizards/CommitChangesDifferencesWizardPage.java
Date Fri, 20 Jul 2007 15:33:08 GMT
Author: pamarcelot
Date: Fri Jul 20 08:33:07 2007
New Revision: 558021

URL: http://svn.apache.org/viewvc?view=rev&rev=558021
Log:
Added a toolbar Menu with 'Sorting...' and 'Preferences...' Actions from the SchemaView.

Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidget.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidget.java?view=diff&rev=558021&r1=558020&r2=558021
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidget.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/DifferencesWidget.java
Fri Jul 20 08:33:07 2007
@@ -20,15 +20,20 @@
 package org.apache.directory.studio.apacheds.schemaeditor.view.widget;
 
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenSchemaViewPreferenceAction;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.actions.OpenSchemaViewSortingDialogAction;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.AttributeTypeDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.DifferenceType;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.ObjectClassDifference;
 import org.apache.directory.studio.apacheds.schemaeditor.model.difference.SchemaDifference;
 import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -71,6 +76,31 @@
     /** The PreferenceStore*/
     private IPreferenceStore store;
 
+    /** The authorized Preferences keys*/
+    private List<String> authorizedPrefs;
+
+    /** The preference listener */
+    private IPropertyChangeListener preferenceListener = new IPropertyChangeListener()
+    {
+        /* (non-Javadoc)
+         * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+         */
+        public void propertyChange( PropertyChangeEvent event )
+        {
+            if ( authorizedPrefs.contains( event.getProperty() ) )
+            {
+                //                    if ( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING ==
event.getProperty() )
+                //                    {
+                //                        view.reloadViewer();
+                //                    }
+                //                    else
+                //                    {
+                treeViewer.refresh();
+                //                    }
+            }
+        }
+    };
+
     // The MenuItems
     private MenuItem groupByType;
     private MenuItem groupByProperty;
@@ -118,6 +148,53 @@
         leftComposite.setLayout( gridLayout );
         leftComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
 
+        // ToolBar
+        final ToolBar leftToolBar = new ToolBar( leftComposite, SWT.HORIZONTAL );
+        leftToolBar.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) );
+        // Creating the 'Menu' ToolBar item
+        final ToolItem leftMenuToolItem = new ToolItem( leftToolBar, SWT.PUSH );
+        leftMenuToolItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_TOOLBAR_MENU ).createImage() );
+        leftMenuToolItem.setToolTipText( "Menu" );
+        // Creating the associated Menu
+        final Menu leftMenu = new Menu( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.POP_UP );
+        // Adding the action to display the Menu when the item is clicked
+        leftMenuToolItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent event )
+            {
+                Rectangle rect = leftMenuToolItem.getBounds();
+                Point pt = new Point( rect.x, rect.y + rect.height );
+                pt = leftToolBar.toDisplay( pt );
+                leftMenu.setLocation( pt.x, pt.y );
+                leftMenu.setVisible( true );
+            }
+        } );
+        // Adding the 'Sorting...' MenuItem
+        MenuItem sortingMenuItem = new MenuItem( leftMenu, SWT.PUSH );
+        sortingMenuItem.setText( "Sorting..." );
+        sortingMenuItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SORTING ).createImage() );
+        sortingMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                new OpenSchemaViewSortingDialogAction().run();
+            }
+        } );
+        // Adding the 'Separator' MenuItem
+        new MenuItem( leftMenu, SWT.SEPARATOR );
+        // Adding the 'Preferences...' MenuItem
+        MenuItem preferencesMenuItem = new MenuItem( leftMenu, SWT.PUSH );
+        preferencesMenuItem.setText( "Preferences..." );
+        preferencesMenuItem.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent arg0 )
+            {
+                new OpenSchemaViewPreferenceAction().run();
+            }
+        } );
+
         // TreeViewer
         treeViewer = new TreeViewer( leftComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.BORDER );
         treeViewer.getTree().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true
) );
@@ -178,29 +255,29 @@
         rightComposite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
 
         // ToolBar
-        final ToolBar toolBar = new ToolBar( rightComposite, SWT.HORIZONTAL );
-        toolBar.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) );
+        final ToolBar rightToolBar = new ToolBar( rightComposite, SWT.HORIZONTAL );
+        rightToolBar.setLayoutData( new GridData( SWT.RIGHT, SWT.NONE, false, false ) );
         // Creating the 'Menu' ToolBar item
-        final ToolItem menuToolItem = new ToolItem( toolBar, SWT.PUSH );
-        menuToolItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+        final ToolItem rightMenuToolItem = new ToolItem( rightToolBar, SWT.PUSH );
+        rightMenuToolItem.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
             PluginConstants.IMG_TOOLBAR_MENU ).createImage() );
-        menuToolItem.setToolTipText( "Menu" );
+        rightMenuToolItem.setToolTipText( "Menu" );
         // Creating the associated Menu
-        final Menu menu = new Menu( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.POP_UP );
+        final Menu rightMenu = new Menu( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
SWT.POP_UP );
         // Adding the action to display the Menu when the item is clicked
-        menuToolItem.addSelectionListener( new SelectionAdapter()
+        rightMenuToolItem.addSelectionListener( new SelectionAdapter()
         {
             public void widgetSelected( SelectionEvent event )
             {
-                Rectangle rect = menuToolItem.getBounds();
+                Rectangle rect = rightMenuToolItem.getBounds();
                 Point pt = new Point( rect.x, rect.y + rect.height );
-                pt = toolBar.toDisplay( pt );
-                menu.setLocation( pt.x, pt.y );
-                menu.setVisible( true );
+                pt = rightToolBar.toDisplay( pt );
+                rightMenu.setLocation( pt.x, pt.y );
+                rightMenu.setVisible( true );
             }
         } );
         // Adding the 'Group By Property' MenuItem
-        groupByProperty = new MenuItem( menu, SWT.CHECK );
+        groupByProperty = new MenuItem( rightMenu, SWT.CHECK );
         groupByProperty.setText( "Group By Property" );
         groupByProperty.addSelectionListener( new SelectionAdapter()
         {
@@ -210,7 +287,7 @@
             }
         } );
         // Adding the 'Group By Type' MenuItem
-        groupByType = new MenuItem( menu, SWT.CHECK );
+        groupByType = new MenuItem( rightMenu, SWT.CHECK );
         groupByType.setText( "Group By Type" );
         groupByType.addSelectionListener( new SelectionAdapter()
         {
@@ -226,6 +303,9 @@
         tableViewer.getTable().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true
) );
         tableViewer.setContentProvider( new DifferencesWidgetPropertiesContentProvider()
);
         tableViewer.setLabelProvider( new DifferencesWidgetPropertiesLabelProvider() );
+
+        initAuthorizedPrefs();
+        initPreferencesListener();
     }
 
 
@@ -276,5 +356,42 @@
             groupByProperty.setSelection( false );
             groupByType.setSelection( false );
         }
+    }
+
+
+    /**
+     * Initializes the Authorized Prefs IDs.
+     */
+    private void initAuthorizedPrefs()
+    {
+        authorizedPrefs = new ArrayList<String>();
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_LABEL );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_ABBREVIATE_MAX_LENGTH );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_DISPLAY );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE
);
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SECONDARY_LABEL_ABBREVIATE_MAX_LENGTH
);
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_GROUPING );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_BY );
+        authorizedPrefs.add( PluginConstants.PREFS_SCHEMA_VIEW_SORTING_ORDER );
+    }
+
+
+    /**
+     * Initializes the listener on the preferences store
+     */
+    private void initPreferencesListener()
+    {
+        store.addPropertyChangeListener( preferenceListener );
+    }
+
+
+    /**
+     * Disposes the SWT resources allocated by this dialog page.
+     */
+    public void dispose()
+    {
+        store.removePropertyChangeListener( preferenceListener );
     }
 }

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java?view=diff&rev=558021&r1=558020&r2=558021
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
Fri Jul 20 08:33:07 2007
@@ -54,6 +54,10 @@
  */
 public class CommitChangesDifferencesWizardPage extends WizardPage
 {
+    // UI Fields
+    private DifferencesWidget differencesWidget;
+
+
     /**
      * Creates a new instance of ExportSchemasAsXmlWizardPage.
      */
@@ -76,7 +80,7 @@
         GridLayout layout = new GridLayout();
         composite.setLayout( layout );
 
-        DifferencesWidget differencesWidget = new DifferencesWidget();
+        differencesWidget = new DifferencesWidget();
         differencesWidget.createWidget( composite );
 
         SchemaImpl schema1Old = new SchemaImpl( "Schema1" );
@@ -111,7 +115,7 @@
         schema1Old.addAttributeType( at2 );
         schema1New.addAttributeType( at2Bis );
         schema1New.addAttributeType( at3 );
-        
+
         ObjectClassImpl oc1 = new ObjectClassImpl( "1.2.10" );
         oc1.setNames( new String[]
             { "OC1", "ObjectClass1" } );
@@ -165,5 +169,16 @@
     private void initFields()
     {
 
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+     */
+    public void dispose()
+    {
+        differencesWidget.dispose();
+
+        super.dispose();
     }
 }



Mime
View raw message