You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:57:49 UTC
svn commit: r488371 [3/14] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/jobs/
ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/perspective/
ldapstudio-browser-ui...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewActionGroup.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewActionGroup.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyDnAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyEntryAsCsvAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyEntryAsLdifAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyUrlAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.DeleteAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.ImportExportAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.LocateEntryInDitAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.MoveAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewBatchOperationAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewBookmarkAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewEntryAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewSearchAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.PasteAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.RenameAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserViewActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserActionGroup;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.commands.ICommandService;
+
+
+public class BrowserViewActionGroup extends BrowserActionGroup
+{
+
+ private ShowDITAction showDITAction;
+
+ private ShowSearchesAction showSearchesAction;
+
+ private ShowBookmarksAction showBookmarksAction;
+
+ private ShowDirectoryMetadataEntriesAction showDirectoryMetadataEntriesAction;
+
+ private OpenBrowserPreferencePageAction openBrowserPreferencePageAction;
+
+ private static final String locateEntryInDitAction = "locateEntryInDitAction";
+
+ private static final String newEntryAction = "newEntryAction";
+
+ private static final String newSearchAction = "newSearchAction";
+
+ private static final String newBookmarkAction = "newBookmarkAction";
+
+ private static final String newBatchOperationAction = "newBatchOperationAction";
+
+ private static final String copyAction = "copyAction";
+
+ private static final String pasteAction = "pasteAction";
+
+ private static final String deleteAction = "deleteAction";
+
+ private static final String moveAction = "moveAction";
+
+ private static final String renameAction = "renameAction";
+
+ private static final String copyDnAction = "copyDnAction";
+
+ private static final String copyUrlAction = "copyUrlAction";
+
+ private static final String copyEntryAsLdifDnOnlyAction = "copyEntryAsLdifDnOnlyAction";
+
+ private static final String copyEntryAsLdifReturningAttributesOnlyAction = "copyEntryAsLdifReturningAttributesOnlyAction";
+
+ private static final String copyEntryAsLdifAction = "copyEntryAsLdifAction";
+
+ private static final String copyEntryAsLdifOperationalAction = "copyEntryAsLdifOperationalAction";
+
+ private static final String copyEntryAsCsvDnOnlyAction = "copyEntryAsCsvDnOnlyAction";
+
+ private static final String copyEntryAsCsvReturningAttributesOnlyAction = "copyEntryAsCsvReturningAttributesOnlyAction";
+
+ private static final String copyEntryAsCsvAction = "copyEntryAsCsvAction";
+
+ private static final String copyEntryAsCsvOperationalAction = "copyEntryAsCsvOperationalAction";
+
+ private static final String importLdifAction = "importLdifAction";
+
+ private static final String exportLdifAction = "exportLdifAction";
+
+ private static final String exportCsvAction = "exportCsvAction";
+
+ private static final String exportExcelAction = "exportExcelAction";
+
+
+ public BrowserViewActionGroup( BrowserView view )
+ {
+ super( view.getMainWidget(), view.getConfiguration() );
+ TreeViewer viewer = view.getMainWidget().getViewer();
+
+ this.showDITAction = new ShowDITAction();
+ this.showSearchesAction = new ShowSearchesAction();
+ this.showBookmarksAction = new ShowBookmarksAction();
+ this.showDirectoryMetadataEntriesAction = new ShowDirectoryMetadataEntriesAction();
+ this.openBrowserPreferencePageAction = new OpenBrowserPreferencePageAction();
+
+ this.browserActionMap.put( newEntryAction, new BrowserViewActionProxy( viewer, new NewEntryAction( view
+ .getSite().getWorkbenchWindow() ) ) );
+ this.browserActionMap.put( newSearchAction, new BrowserViewActionProxy( viewer, new NewSearchAction() ) );
+ this.browserActionMap.put( newBookmarkAction, new BrowserViewActionProxy( viewer, new NewBookmarkAction() ) );
+ this.browserActionMap.put( newBatchOperationAction, new BrowserViewActionProxy( viewer,
+ new NewBatchOperationAction() ) );
+
+ this.browserActionMap.put( locateEntryInDitAction, new BrowserViewActionProxy( viewer,
+ new LocateEntryInDitAction() ) );
+
+ this.browserActionMap.put( pasteAction, new BrowserViewActionProxy( viewer, new PasteAction() ) );
+ this.browserActionMap.put( copyAction, new BrowserViewActionProxy( viewer, new CopyAction(
+ ( BrowserActionProxy ) this.browserActionMap.get( pasteAction ) ) ) );
+ this.browserActionMap.put( deleteAction, new BrowserViewActionProxy( viewer, new DeleteAction() ) );
+ this.browserActionMap.put( moveAction, new BrowserViewActionProxy( viewer, new MoveAction() ) );
+ this.browserActionMap.put( renameAction, new BrowserViewActionProxy( viewer, new RenameAction() ) );
+
+ this.browserActionMap.put( copyDnAction, new BrowserViewActionProxy( viewer, new CopyDnAction() ) );
+ this.browserActionMap.put( copyUrlAction, new BrowserViewActionProxy( viewer, new CopyUrlAction() ) );
+
+ this.browserActionMap.put( copyEntryAsLdifAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_NORMAL ) ) );
+ this.browserActionMap.put( copyEntryAsLdifDnOnlyAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) );
+ this.browserActionMap.put( copyEntryAsLdifReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) );
+ this.browserActionMap.put( copyEntryAsLdifOperationalAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) );
+ this.browserActionMap.put( copyEntryAsCsvAction, new BrowserViewActionProxy( viewer, new CopyEntryAsCsvAction(
+ CopyEntryAsLdifAction.MODE_NORMAL ) ) );
+ this.browserActionMap.put( copyEntryAsCsvDnOnlyAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) );
+ this.browserActionMap.put( copyEntryAsCsvReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) );
+ this.browserActionMap.put( copyEntryAsCsvOperationalAction, new BrowserViewActionProxy( viewer,
+ new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) );
+
+ this.browserActionMap.put( importLdifAction, new BrowserViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_IMPORT_LDIF ) ) );
+ this.browserActionMap.put( exportLdifAction, new BrowserViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_LDIF ) ) );
+ this.browserActionMap.put( exportCsvAction, new BrowserViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_CSV ) ) );
+ this.browserActionMap.put( exportExcelAction, new BrowserViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_EXCEL ) ) );
+
+ }
+
+
+ public void dispose()
+ {
+ if ( this.openBrowserPreferencePageAction != null )
+ {
+
+ this.showDITAction.dispose();
+ this.showDITAction = null;
+ this.showSearchesAction.dispose();
+ this.showSearchesAction = null;
+ this.showBookmarksAction.dispose();
+ this.showBookmarksAction = null;
+ this.showDirectoryMetadataEntriesAction.dispose();
+ this.showDirectoryMetadataEntriesAction = null;
+ this.openBrowserPreferencePageAction.dispose();
+ this.openBrowserPreferencePageAction = null;
+
+ this.openBrowserPreferencePageAction = null;
+ }
+
+ super.dispose();
+ }
+
+
+ public void fillMenu( IMenuManager menuManager )
+ {
+
+ menuManager.add( this.openSortDialogAction );
+ menuManager.add( new Separator() );
+ menuManager.add( this.showDITAction );
+ menuManager.add( this.showSearchesAction );
+ menuManager.add( this.showBookmarksAction );
+ menuManager.add( this.showDirectoryMetadataEntriesAction );
+ menuManager.add( new Separator() );
+ menuManager.add( this.openBrowserPreferencePageAction );
+ menuManager.update( true );
+ }
+
+
+ public void menuAboutToShow( IMenuManager menuManager )
+ {
+
+ // new
+ menuManager.add( ( IAction ) this.browserActionMap.get( newEntryAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( newSearchAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( newBookmarkAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( newBatchOperationAction ) );
+ menuManager.add( new Separator() );
+
+ // navigation
+ BrowserViewActionProxy leid = ( BrowserViewActionProxy ) this.browserActionMap.get( locateEntryInDitAction );
+ leid.setImageDescriptor( leid.getAction().getImageDescriptor() );
+ menuManager.add( leid );
+ menuManager.add( ( IAction ) this.browserActionMap.get( upAction ) );
+ menuManager.add( new Separator() );
+
+ // copy/paste/...
+ menuManager.add( ( IAction ) this.browserActionMap.get( copyAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( pasteAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( deleteAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( moveAction ) );
+ menuManager.add( ( IAction ) this.browserActionMap.get( renameAction ) );
+ MenuManager advancedMenuManager = new MenuManager( "Advanced" );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyDnAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyUrlAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsLdifDnOnlyAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsLdifReturningAttributesOnlyAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsLdifAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsLdifOperationalAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsCsvDnOnlyAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsCsvReturningAttributesOnlyAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsCsvAction ) );
+ advancedMenuManager.add( ( IAction ) this.browserActionMap.get( copyEntryAsCsvOperationalAction ) );
+ advancedMenuManager.add( new Separator() );
+ menuManager.add( advancedMenuManager );
+ menuManager.add( new Separator() );
+
+ // filter, batch
+ menuManager.add( ( IAction ) this.browserActionMap.get( filterSubtreeAction ) );
+ if ( ( ( IAction ) this.browserActionMap.get( unfilterSubtreeAction ) ).isEnabled() )
+ {
+ menuManager.add( ( IAction ) this.browserActionMap.get( unfilterSubtreeAction ) );
+ }
+ menuManager.add( new Separator() );
+
+ // import/export
+ MenuManager importMenuManager = new MenuManager( "Import" );
+ importMenuManager.add( ( IAction ) this.browserActionMap.get( importLdifAction ) );
+ importMenuManager.add( new Separator() );
+ menuManager.add( importMenuManager );
+
+ MenuManager exportMenuManager = new MenuManager( "Export" );
+ exportMenuManager.add( ( IAction ) this.browserActionMap.get( exportLdifAction ) );
+ exportMenuManager.add( new Separator() );
+ exportMenuManager.add( ( IAction ) this.browserActionMap.get( exportCsvAction ) );
+ exportMenuManager.add( ( IAction ) this.browserActionMap.get( exportExcelAction ) );
+ menuManager.add( exportMenuManager );
+ menuManager.add( new Separator() );
+
+ // refresh
+ menuManager.add( ( IAction ) this.browserActionMap.get( refreshAction ) );
+ menuManager.add( new Separator() );
+
+ // additions
+ menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+ // properties
+ menuManager.add( ( IAction ) this.browserActionMap.get( propertyDialogAction ) );
+
+ }
+
+
+ public void activateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) this.browserActionMap
+ .get( copyAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), ( IAction ) this.browserActionMap
+ .get( pasteAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), ( IAction ) this.browserActionMap
+ .get( deleteAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), ( IAction ) this.browserActionMap
+ .get( moveAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), ( IAction ) this.browserActionMap
+ .get( renameAction ) );
+ }
+
+ super.activateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction leid = ( IAction ) this.browserActionMap.get( locateEntryInDitAction );
+ commandService.getCommand( leid.getActionDefinitionId() ).setHandler( new ActionHandler( leid ) );
+ }
+
+ }
+
+
+ public void deactivateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), null );
+ }
+
+ super.deactivateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction leid = ( IAction ) this.browserActionMap.get( locateEntryInDitAction );
+ commandService.getCommand( leid.getActionDefinitionId() ).setHandler( null );
+ }
+
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewLabelDecorator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewLabelDecorator.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewLabelDecorator.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewLabelDecorator.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+
+
+public class BrowserViewLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
+{
+
+ public void decorate( Object element, IDecoration decoration )
+ {
+
+ IEntry entry = null;
+
+ if ( element instanceof ISearchResult )
+ {
+ ISearchResult searchResult = ( ISearchResult ) element;
+ entry = searchResult.getEntry();
+ decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_OVR_SEARCHRESULT ), IDecoration.BOTTOM_RIGHT );
+ }
+ else if ( element instanceof IEntry )
+ {
+ entry = ( IEntry ) element;
+ if ( entry.getChildrenFilter() != null )
+ {
+ decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_OVR_FILTERED ), IDecoration.BOTTOM_RIGHT );
+ }
+ }
+ else
+ {
+ decoration.addOverlay( null, IDecoration.BOTTOM_RIGHT );
+ }
+
+ if ( entry != null )
+ {
+ if ( !entry.isConsistent() )
+ {
+ decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_OVR_ERROR ), IDecoration.BOTTOM_LEFT );
+ }
+ else if ( !entry.isDirectoryEntry() )
+ {
+ decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_OVR_WARNING ), IDecoration.BOTTOM_LEFT );
+ }
+ else
+ {
+ decoration.addOverlay( null, IDecoration.BOTTOM_LEFT );
+ }
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/BrowserViewUniversalListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,427 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.core.events.AttributesInitializedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EntryAddedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryMovedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryRenamedEvent;
+import org.apache.directory.ldapstudio.browser.core.events.EntryUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.events.EventRegistry;
+import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent;
+import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateListener;
+import org.apache.directory.ldapstudio.browser.core.model.IBookmark;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectionUtils;
+import org.apache.directory.ldapstudio.browser.ui.editors.entry.EntryEditorManager;
+import org.apache.directory.ldapstudio.browser.ui.editors.searchresult.SearchResultEditorManager;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserCategory;
+import org.apache.directory.ldapstudio.browser.ui.widgets.browser.BrowserUniversalListener;
+
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+
+
+public class BrowserViewUniversalListener extends BrowserUniversalListener implements ISelectionListener,
+ SearchUpdateListener, EntryUpdateListener, ConnectionUpdateListener, BookmarkUpdateListener, IPartListener2
+{
+
+ private Map connectionToExpandedElementsMap;
+
+ private Map connectionToSelectedElementMap;
+
+ private BrowserView view;
+
+ private IContextActivation contextActivation;
+
+
+ public BrowserViewUniversalListener( BrowserView view )
+ {
+ super( view.getMainWidget().getViewer() );
+ this.view = view;
+
+ this.connectionToExpandedElementsMap = new HashMap();
+ this.connectionToSelectedElementMap = new HashMap();
+
+ EventRegistry.addSearchUpdateListener( this );
+ EventRegistry.addBookmarkUpdateListener( this );
+ EventRegistry.addEntryUpdateListener( this );
+ EventRegistry.addConnectionUpdateListener( this );
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener( this );
+ view.getSite().getPage().addPartListener( this );
+ }
+
+
+ public void dispose()
+ {
+ if ( this.view != null )
+ {
+ view.getSite().getPage().removePartListener( this );
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().removeSelectionListener( this );
+ EventRegistry.removeSearchUpdateListener( this );
+ EventRegistry.removeBookmarkUpdateListener( this );
+ EventRegistry.removeEntryUpdateListener( this );
+ EventRegistry.removeConnectionUpdateListener( this );
+
+ this.view = null;
+ this.connectionToExpandedElementsMap.clear();
+ this.connectionToExpandedElementsMap = null;
+ this.connectionToSelectedElementMap.clear();
+ this.connectionToSelectedElementMap = null;
+ }
+
+ super.dispose();
+ }
+
+
+ public void selectionChanged( IWorkbenchPart part, ISelection selection )
+ {
+
+ if ( part.getClass() == BrowserView.class )
+ {
+ this.sendSelectionHints( selection );
+ }
+
+ }
+
+
+ private void sendSelectionHints( ISelection selection )
+ {
+
+ IEntry[] entries = SelectionUtils.getEntries( selection );
+ ISearchResult[] searchResults = SelectionUtils.getSearchResults( selection );
+ IBookmark[] bookmarks = SelectionUtils.getBookmarks( selection );
+
+ ISearch[] searches = SelectionUtils.getSearches( selection );
+
+ ISearch search = null;
+ IEntry entry = null;
+ if ( entries.length + searchResults.length + bookmarks.length + searches.length == 1 )
+ {
+ if ( entries.length == 1 )
+ {
+ entry = entries[0];
+ }
+ else if ( searchResults.length == 1 )
+ {
+ entry = searchResults[0].getEntry();
+ }
+ else if ( bookmarks.length == 1 )
+ {
+ entry = bookmarks[0].getEntry();
+ }
+ else if ( searches.length == 1 )
+ {
+ search = searches[0];
+ }
+ }
+
+ EntryEditorManager.setInput( entry );
+ SearchResultEditorManager.setInput( search );
+ }
+
+
+ void setInput( IConnection connection )
+ {
+
+ // only if another connection is selected
+ if ( connection != this.viewer.getInput() )
+ {
+
+ IConnection currentConnection = this.viewer.getInput() instanceof IConnection ? ( IConnection ) this.viewer
+ .getInput() : null;
+
+ // save expanded elements and selection
+ if ( currentConnection != null )
+ {
+ this.connectionToExpandedElementsMap.put( currentConnection, this.viewer.getExpandedElements() );
+ if ( !this.viewer.getSelection().isEmpty() )
+ {
+ this.connectionToSelectedElementMap.put( currentConnection, this.viewer.getSelection() );
+ }
+ }
+
+ // change input
+ this.viewer.setInput( connection );
+ this.view.getActionGroup().setInput( connection );
+
+ // restore expanded elements and selection
+ if ( this.view != null && connection != null )
+ {
+ if ( this.connectionToExpandedElementsMap.containsKey( connection ) )
+ {
+ this.viewer
+ .setExpandedElements( ( Object[] ) this.connectionToExpandedElementsMap.get( connection ) );
+ }
+ if ( this.connectionToSelectedElementMap.containsKey( connection )
+ && this.view.getSite().getPage().isPartVisible( this.view ) )
+ {
+ this.viewer.setSelection( ( ISelection ) this.connectionToSelectedElementMap.get( connection ),
+ true );
+ }
+ }
+
+ // send selection hint
+ this.sendSelectionHints( this.viewer.getSelection() );
+ }
+ }
+
+
+ public void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent )
+ {
+
+ if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_OPENED )
+ {
+ this.viewer.refresh( connectionUpdateEvent.getConnection() );
+ this.viewer.expandToLevel( 2 );
+
+ if ( this.view.getConfiguration().getPreferences().isExpandBaseEntries() )
+ {
+ Object[] expandedElements = this.viewer.getExpandedElements();
+ for ( int i = 0; i < expandedElements.length; i++ )
+ {
+ Object object = expandedElements[i];
+ if ( object instanceof BrowserCategory )
+ {
+ BrowserCategory bc = ( BrowserCategory ) object;
+ if ( bc.getType() == BrowserCategory.TYPE_DIT )
+ {
+ this.viewer.expandToLevel( bc, 3 );
+ }
+ }
+ }
+ }
+ // this.viewer.expandToLevel(this.view.getConfiguration().getPreferences().isExpandBaseEntries()?3:2);
+
+ }
+ else if ( connectionUpdateEvent.getDetail() == ConnectionUpdateEvent.CONNECTION_CLOSED )
+ {
+ this.viewer.collapseAll();
+ this.connectionToExpandedElementsMap.remove( connectionUpdateEvent.getConnection() );
+ this.connectionToSelectedElementMap.remove( connectionUpdateEvent.getConnection() );
+ this.sendSelectionHints( this.viewer.getSelection() );
+ this.viewer.refresh( connectionUpdateEvent.getConnection() );
+ }
+ else
+ {
+ this.viewer.refresh( connectionUpdateEvent.getConnection() );
+ }
+ }
+
+
+ public void searchUpdated( SearchUpdateEvent searchUpdateEvent )
+ {
+ ISearch search = searchUpdateEvent.getSearch();
+ this.viewer.refresh();
+ if ( search.getSearchResults() != null && search.getSearchResults().length > 0 )
+ {
+ // this.viewer.refresh(search);
+ // this.viewer.expandToLevel(search, TreeViewer.ALL_LEVELS);
+ }
+
+ if ( Arrays.asList( search.getConnection().getSearchManager().getSearches() ).contains( search ) )
+ {
+ this.viewer.setSelection( new StructuredSelection( search ), true );
+ }
+ else
+ {
+ Object searchCategory = ( ( ITreeContentProvider ) this.viewer.getContentProvider() ).getParent( search );
+ this.viewer.setSelection( new StructuredSelection( searchCategory ), true );
+ }
+ }
+
+
+ public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent )
+ {
+ this.viewer.refresh();
+ }
+
+
+ public void entryUpdated( EntryModificationEvent event )
+ {
+
+ // Don't handle attribute initalization, could cause double
+ // retrieval of children
+ if ( event instanceof AttributesInitializedEvent )
+ {
+ return;
+ }
+
+ if ( event instanceof EntryAddedEvent )
+ {
+ this.viewer.refresh( event.getModifiedEntry(), true );
+ this.viewer.refresh( event.getModifiedEntry().getParententry(), true );
+ this.viewer.setSelection( new StructuredSelection( event.getModifiedEntry() ), true );
+ }
+ else if ( event instanceof EntryRenamedEvent )
+ {
+ EntryRenamedEvent ere = ( EntryRenamedEvent ) event;
+ this.viewer.refresh( ere.getNewEntry().getParententry(), true );
+ this.viewer.refresh( ere.getNewEntry(), true );
+ this.viewer.setSelection( new StructuredSelection( ere.getNewEntry() ), true );
+ }
+ else if ( event instanceof EntryMovedEvent )
+ {
+ EntryMovedEvent eme = ( EntryMovedEvent ) event;
+ this.viewer.refresh( eme.getOldEntry().getParententry(), true );
+ this.viewer.refresh( eme.getNewEntry().getParententry(), true );
+ this.viewer.refresh( eme.getNewEntry(), true );
+ this.viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true );
+ }
+
+ // else if(event instanceof EntryDeletedEvent) {
+ // this.viewer.refresh(event.getModifiedEntry(), true);
+ // this.viewer.refresh(event.getModifiedEntry().getParententry(), true);
+ // this.viewer.setSelection(new
+ // StructuredSelection(event.getModifiedEntry().getParententry()),
+ // true);
+ // }
+ // else if(event instanceof EntryRenamedEvent) {
+ // EntryRenamedEvent ere = (EntryRenamedEvent) event;
+ // this.viewer.refresh(ere.getModifiedEntry(), true);
+ // this.viewer.refresh(ere.getOriginalParent(), true);
+ // this.viewer.refresh(ere.getNewParent(), true);
+ // }
+ // else if(event instanceof EntryMovedEvent) {
+ // EntryMovedEvent eme = (EntryMovedEvent) event;
+ // this.viewer.refresh(eme.getModifiedEntry(), true);
+ // this.viewer.refresh(eme.getOriginalParent(), true);
+ // this.viewer.refresh(eme.getNewParent(), true);
+ // }
+ // else {
+ // this.viewer.refresh(event.getModifiedEntry(), true);
+ // }
+
+ this.viewer.refresh( event.getModifiedEntry(), true );
+ }
+
+
+ public void doubleClick( DoubleClickEvent event )
+ {
+
+ // special behaviour for searches:
+ // perform search on doouble-click but do not expand the tree.
+ // if(event.getSelection() instanceof IStructuredSelection) {
+ // Object obj =
+ // ((IStructuredSelection)event.getSelection()).getFirstElement();
+ //
+ // // perform search
+ // if(obj instanceof ISearch) {
+ // ISearch search = (ISearch) obj;
+ // if(search.getSearchResults() == null) {
+ // IAction action = view.getActionGroup().getRefreshAction();
+ // if(action.isEnabled()) {
+ // action.run();
+ // return;
+ // }
+ // }
+ // }
+ // }
+
+ super.doubleClick( event );
+ }
+
+
+ public void partDeactivated( IWorkbenchPartReference partRef )
+ {
+ if ( partRef.getPart( false ) == this.view && contextActivation != null )
+ {
+
+ this.view.getActionGroup().deactivateGlobalActionHandlers();
+
+ IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+ IContextService.class );
+ contextService.deactivateContext( contextActivation );
+ contextActivation = null;
+ }
+ }
+
+
+ public void partActivated( IWorkbenchPartReference partRef )
+ {
+ if ( partRef.getPart( false ) == this.view )
+ {
+
+ IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter(
+ IContextService.class );
+ contextActivation = contextService
+ .activateContext( "org.apache.directory.ldapstudio.browser.action.context" );
+ // org.eclipse.ui.contexts.dialogAndWindow
+ // org.eclipse.ui.contexts.window
+ // org.eclipse.ui.text_editor_context
+
+ this.view.getActionGroup().activateGlobalActionHandlers();
+ }
+ }
+
+
+ public void partBroughtToTop( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partClosed( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partOpened( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partHidden( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partVisible( IWorkbenchPartReference partRef )
+ {
+ }
+
+
+ public void partInputChanged( IWorkbenchPartReference partRef )
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DragListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DragListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DragListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DragListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+public class DragListener /* implements DragSourceListener */
+{
+
+ // private Clipboard systemClipboard;
+ // private InternalClipboard internalClipboard;
+ //
+ // public DragListener(Shell shell, Clipboard systemClipboard,
+ // InternalClipboard internalClipboard) {
+ // super(shell, "Drag", null, null);
+ // this.systemClipboard = systemClipboard;
+ // this.internalClipboard = internalClipboard;
+ // }
+ // public void dispose() {
+ // this.systemClipboard = null;
+ // this.internalClipboard = null;
+ // super.dispose();
+ // }
+ // protected void updateEnabledState() {
+ // }
+ //
+ // public void dragStart(DragSourceEvent event) {
+ // //System.out.println("dragStart: " + event);
+ //
+ // if(this.selectedEntries.length > 0 && this.selectedSearches.length ==
+ // 0 && this.selectedSearchResults.length == 0) {
+ // /*
+ // IEntry parent = this.selectedEntries[0].getParententry();
+ // for(int i=1; i<this.selectedEntries.length; i++) {
+ // if(this.selectedEntries[i].getParententry() != parent) {
+ // event.doit = false;
+ // return;
+ // }
+ // }
+ // */
+ // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+ // this.selectedEntries);
+ // event.doit = true;
+ // }
+ // else if(this.selectedSearchResults.length > 0 &&
+ // this.selectedEntries.length == 0 && this.selectedSearches.length ==
+ // 0) {
+ // /*
+ // IEntry parent =
+ // this.selectedSearchResults[0].getEntry().getParententry();
+ // for(int i=1; i<this.selectedSearchResults.length; i++) {
+ // if(this.selectedSearchResults[i].getEntry().getParententry() !=
+ // parent) {
+ // event.doit = false;
+ // return;
+ // }
+ // }
+ // */
+ // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+ // this.selectedSearchResults);
+ // event.doit = true;
+ // }
+ // else if(this.selectedSearches.length > 0 &&
+ // this.selectedEntries.length == 0 && this.selectedSearchResults.length
+ // == 0) {
+ // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN,
+ // this.selectedSearches);
+ // event.doit = true;
+ // }
+ // else {
+ // event.doit = false;
+ // }
+ // }
+ //
+ // public void dragSetData(DragSourceEvent event) {
+ // //System.out.println("dragSetDataA: " + event);
+ // //System.out.println("dragSetDataT: " + event.dataType);
+ // //System.out.println("dragSetDataS: " +
+ // BrowserTransfer.getInstance().isSupportedType(event.dataType));
+ // //System.out.println("dragSetDataE: " +
+ // TextTransfer.getInstance().isSupportedType(event.dataType));
+ //
+ // if (BrowserTransfer.getInstance().isSupportedType(event.dataType)) {
+ // event.data = this.internalClipboard.getClass().getName();
+ // }
+ // else if (TextTransfer.getInstance().isSupportedType(event.dataType))
+ // {
+ // String text = "";
+ // Object objectToTransfer =
+ // this.internalClipboard.getObjectToTransfer();
+ // if(objectToTransfer instanceof IEntry[]) {
+ // IEntry[] entries = (IEntry[])objectToTransfer;
+ // if(entries.length > 0) {
+ // text = entries[0].getDn().toString();
+ // for(int i=1; i<entries.length; i++) {
+ // text += "\n"+entries[i].getDn().toString();
+ // }
+ // }
+ // }
+ // else if(objectToTransfer instanceof ISearchResult[]) {
+ // ISearchResult[] searchresults = (ISearchResult[])objectToTransfer;
+ // if(searchresults.length > 0) {
+ // text = searchresults[0].getDn().toString();
+ // for(int i=1; i<searchresults.length; i++) {
+ // text += "\n"+searchresults[i].getDn().toString();
+ // }
+ // }
+ // }
+ // else if(objectToTransfer instanceof ISearch[]) {
+ // ISearch[] searches = (ISearch[])objectToTransfer;
+ // if(searches.length > 0) {
+ // text = searches[0].getName();
+ // for(int i=1; i<searches.length; i++) {
+ // text += "\n"+searches[i].getName();
+ // }
+ // }
+ // }
+ // event.data = text;
+ // }
+ // else {
+ // event.data = null;
+ // }
+ //
+ // //System.out.println("dragSetData2: " + event);
+ // }
+ //
+ // public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event) {
+ // //System.out.println("dragFinished: " + event);
+ // this.internalClipboard.clear();
+ // }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DropListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DropListener.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DropListener.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/DropListener.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+public class DropListener /* implements DropTargetListener, ModelModifier */
+{/*
+ *
+ * private Shell shell; private Clipboard systemClipboard; private
+ * InternalClipboard internalClipboard;
+ *
+ *
+ * public DropListener(Shell shell, Clipboard systemClipboard,
+ * InternalClipboard internalClipboard) { this.shell = shell;
+ * this.systemClipboard = systemClipboard; this.internalClipboard =
+ * internalClipboard;
+ * } public void dispose() { this.shell = null; this.systemClipboard =
+ * null; this.internalClipboard = null;
+ * }
+ *
+ * private int dragOperation = DND.DROP_NONE;
+ *
+ * public void dragEnter(DropTargetEvent event) {
+ * //System.out.println("dragEnter: " + event.detail); dragOperation =
+ * event.detail; event.currentDataType =
+ * BrowserTransfer.getInstance().getSupportedTypes()[0];
+ * this.check(event); }
+ *
+ * public void dragLeave(DropTargetEvent event) {
+ * //System.out.println("dragLeave: " + event.detail); dragOperation =
+ * DND.DROP_NONE; }
+ *
+ * public void dragOperationChanged(DropTargetEvent event) {
+ * //System.out.println("dragOperationChanged: " + event.detail);
+ * dragOperation = event.detail; this.check(event); }
+ *
+ * public void dragOver(DropTargetEvent event) {
+ * //System.out.println("dragOver: " + event.item.getData());
+ *
+ * this.check(event);
+ *
+ * //System.out.println("dragOver: " + event.detail);
+ *
+ * //System.out.println();
+ * //System.out.println(event.item.getClass().getName());
+ * //System.out.println(event.item.getData().getClass().getName());
+ * //System.out.println(event.currentDataType.type); }
+ *
+ * private void check(DropTargetEvent event) { if(event.item != null &&
+ * event.item.getData() != null) { if
+ * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ * if(event.item.getData() instanceof ISearch &&
+ * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) {
+ * event.detail = dragOperation; return; } else if(event.item.getData()
+ * instanceof BrowserCategory &&
+ * ((BrowserCategory)event.item.getData()).getType() ==
+ * BrowserCategory.TYPE_SEARCHES &&
+ * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) {
+ * event.detail = dragOperation; return; } else if(event.item.getData()
+ * instanceof IEntry && this.internalClipboard.getObjectToTransfer()
+ * instanceof IEntry[]) { event.detail = dragOperation;
+ *
+ * IEntry[] entries =
+ * (IEntry[])this.internalClipboard.getObjectToTransfer(); for(int i=0;
+ * i<entries.length; i++) { if(entries[i].hasChildren()) { event.detail =
+ * DND.DROP_COPY; return; } }
+ *
+ * return; } else if(event.item.getData() instanceof IEntry &&
+ * this.internalClipboard.getObjectToTransfer() instanceof
+ * ISearchResult[]) { event.detail = dragOperation;
+ *
+ * ISearchResult[] srs =
+ * (ISearchResult[])this.internalClipboard.getObjectToTransfer();
+ * for(int i=0; i<srs.length; i++) {
+ * if(!srs[i].getEntry().hasChildren()) { event.detail = DND.DROP_COPY;
+ * return; } }
+ *
+ * return; } else { event.detail = DND.DROP_NONE; } } else {
+ * event.detail = DND.DROP_NONE; } } else { event.detail =
+ * DND.DROP_NONE; } }
+ *
+ * public void drop(DropTargetEvent event) {
+ *
+ * //System.out.println("drop: " + event);
+ *
+ * try {
+ *
+ * if
+ * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType) &&
+ * event.data instanceof String &&
+ * this.internalClipboard.getClass().getName().equals(event.data)) {
+ *
+ * if(event.detail == DND.DROP_MOVE) {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_MOVE_OPERATION); }
+ * else if(event.detail == DND.DROP_COPY) {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_DUPLICATE_OPERATION); }
+ * else {
+ * this.internalClipboard.setOperationType(InternalClipboard.TYPE_UNKNOWN); }
+ *
+ *
+ * ISearch[] selectedSearches = new ISearch[0]; IEntry[] selectedEntries =
+ * new IEntry[0]; ISearchResult[] selectedSearchResults = new
+ * ISearchResult[0]; BrowserCategory[] selectedBrowserViewCategories =
+ * new BrowserCategory[0];
+ *
+ * if (event.item != null && event.item.getData() instanceof ISearch) {
+ * selectedSearches = new ISearch[]{(ISearch) event.item.getData()}; }
+ * else if (event.item != null && event.item.getData() instanceof
+ * IEntry) { selectedEntries = new IEntry[]{(IEntry)
+ * event.item.getData()}; } else if (event.item != null &&
+ * event.item.getData() instanceof ISearchResult) {
+ * selectedSearchResults = new ISearchResult[]{(ISearchResult)
+ * event.item.getData()}; } else if (event.item != null &&
+ * event.item.getData() instanceof BrowserCategory) {
+ * selectedBrowserViewCategories = new
+ * BrowserCategory[]{(BrowserCategory) event.item.getData()}; }
+ *
+ * this.runPaste(this.internalClipboard, selectedSearches,
+ * selectedEntries, selectedSearchResults,
+ * selectedBrowserViewCategories);
+ *
+ *
+ * // // get search to handle and its search manager // ISearch[]
+ * searches = (ISearch[]) event.data; // for(int i=0; i<searches.length;
+ * i++) { // ISearch search = searches[i]; // IConnection connection =
+ * search.getConnection(); // SearchManager dragSearchManager =
+ * connection.getSearchManager(); // // // get position // //int
+ * position = dragSearchManager.indexOf(search); // // // get drop
+ * search manager and drop position, // // default is last and the drop
+ * search // int dropPosition = -1; // SearchManager dropSearchManager =
+ * null; // if (event.item != null && event.item.getData() instanceof
+ * ISearch) { // ISearch dropSearch = (ISearch) event.item.getData(); //
+ * dropSearchManager = dropSearch.getConnection().getSearchManager(); //
+ * dropPosition = dropSearchManager.indexOf(dropSearch); // } else { //
+ * dropSearchManager = this.selectedConnection.getSearchManager(); //
+ * dropPosition = dropSearchManager.getSearchCount(); // } // if
+ * (dropPosition == -1) { // dropSearchManager = dragSearchManager; //
+ * dropPosition = dragSearchManager.getSearchCount(); // } // // // if
+ * MOVE operation, first remove from old position // if (event.detail ==
+ * DND.DROP_MOVE && dragSearchManager == dropSearchManager) { //
+ * dragSearchManager.removeSearch(search); //
+ * if(dropPosition>dragSearchManager.getSearchCount()) { //
+ * dropPosition--; // } // dropSearchManager.addSearch(dropPosition,
+ * search); // event.detail = DND.DROP_NONE; // // } else if
+ * (event.detail == DND.DROP_COPY || // (event.detail == DND.DROP_MOVE &&
+ * dragSearchManager != dropSearchManager)) { // ISearch newSearch =
+ * (ISearch) search.clone(); //
+ * newSearch.setConnection(dropSearchManager.getConnection()); //
+ * dropSearchManager.addSearch(dropPosition, newSearch); // // } // else { //
+ * event.detail = DND.DROP_NONE; // } // } } } catch (Exception e) {
+ * event.detail = DND.DROP_NONE; e.printStackTrace(); }
+ * }
+ *
+ * public void dropAccept(DropTargetEvent event) {
+ * //System.out.println("dropAccept: " + event.detail + event.feedback);
+ * event.currentDataType =
+ * BrowserTransfer.getInstance().getSupportedTypes()[0]; check(event); }
+ *
+ *
+ *
+ *
+ * public void runPaste(InternalClipboard internalClipboard, ISearch[]
+ * selectedSearches, IEntry[] selectedEntries, ISearchResult[]
+ * selectedSearchResults, BrowserCategory[]
+ * selectedBrowserViewCategories) { Object objectToTransfer =
+ * internalClipboard.getObjectToTransfer();
+ *
+ * if (objectToTransfer != null && objectToTransfer instanceof ISearch[] &&
+ * selectedSearches.length > 0 && selectedEntries.length == 0 &&
+ * selectedSearchResults.length == 0) { ISearch[] searchesToTransfer =
+ * (ISearch[]) objectToTransfer; if (searchesToTransfer != null &&
+ * searchesToTransfer.length > 0) { ISearch pasteSearch =
+ * selectedSearches[selectedSearches.length-1]; IConnection connection =
+ * pasteSearch.getConnection(); SearchManager searchManager =
+ * connection.getSearchManager();
+ *
+ * int index = searchManager.indexOf(pasteSearch);
+ *
+ * for(int i=0; i<searchesToTransfer.length; i++) { ISearch newSearch =
+ * (ISearch) searchesToTransfer[i].clone();
+ * newSearch.setConnection(connection);
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) {
+ * searchManager.addSearch(index+1+i, newSearch); } else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) {
+ * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName());
+ * searchManager.addSearch(index+i, newSearch);
+ * if(searchManager.indexOf(pasteSearch) < index) { index =
+ * searchManager.indexOf(pasteSearch); } } } } } else if
+ * (objectToTransfer != null && objectToTransfer instanceof ISearch[] &&
+ * selectedBrowserViewCategories.length == 1 &&
+ * selectedBrowserViewCategories[0].getType()==BrowserCategory.TYPE_SEARCHES) {
+ * ISearch[] searchesToTransfer = (ISearch[]) objectToTransfer; if
+ * (searchesToTransfer != null && searchesToTransfer.length > 0) {
+ * IConnection connection =
+ * selectedBrowserViewCategories[0].getParent(); SearchManager
+ * searchManager = connection.getSearchManager(); for(int i=0; i<searchesToTransfer.length;
+ * i++) { ISearch newSearch = (ISearch) searchesToTransfer[i].clone();
+ * newSearch.setConnection(connection);
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) {
+ * searchManager.addSearch(searchManager.getSearchCount(), newSearch); }
+ * else if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) {
+ * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName());
+ * searchManager.addSearch(searchManager.getSearchCount(), newSearch); } } } }
+ * else if (objectToTransfer != null && objectToTransfer instanceof
+ * IEntry[] && selectedEntries.length == 1 && selectedSearches.length ==
+ * 0 && selectedSearchResults.length == 0) { IEntry[] entries =
+ * (IEntry[]) objectToTransfer; if (entries != null && entries.length >
+ * 0) { if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) new
+ * CopyEntriesJob(selectedEntries[0], entries).execute(); else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0],
+ * entries); } } else if (objectToTransfer != null && objectToTransfer
+ * instanceof ISearchResult[] && selectedEntries.length == 1 &&
+ * selectedSearches.length == 0 && selectedSearchResults.length == 0) {
+ * ISearchResult[] searchResults = (ISearchResult[]) objectToTransfer;
+ * IEntry[] entries = new IEntry[searchResults.length]; for(int i=0; i<searchResults.length;
+ * i++) { entries[i] = searchResults[i].getEntry(); } if (entries !=
+ * null && entries.length > 0) { if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_DUPLICATE_OPERATION) new
+ * CopyEntriesJob(selectedEntries[0], entries).execute(); else
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0],
+ * entries); } }
+ *
+ * if(internalClipboard.getOperationType() ==
+ * InternalClipboard.TYPE_MOVE_OPERATION) { internalClipboard.clear(); } }
+ *
+ * private void move (final IEntry newParent, final IEntry[]
+ * entriesToMove) {
+ *
+ * for(int i=0; i<entriesToMove.length; i++) { try {
+ * entriesToMove[i].moveTo(newParent, this); }
+ * catch(ModelModificationException mme) {
+ * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(mme.getMessage(),
+ * mme); } catch(Exception e) {
+ * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(e.getMessage(),
+ * e); } }
+ *
+ * //EventRegistry.fireEntryUpdated(new
+ * ChildrenInitializedEvent(newParent, newParent.getConnection()),
+ * this); }
+ */
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/OpenBrowserPreferencePageAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/OpenBrowserPreferencePageAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/OpenBrowserPreferencePageAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/OpenBrowserPreferencePageAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+
+public class OpenBrowserPreferencePageAction extends Action
+{
+
+ public OpenBrowserPreferencePageAction()
+ {
+ super.setText( "Preferences..." );
+ super.setToolTipText( "Preferences..." );
+ super.setEnabled( true );
+ }
+
+
+ public void run()
+ {
+ Shell shell = Display.getCurrent().getActiveShell();
+ String pageId = BrowserUIConstants.PREFERENCEPAGEID_BROWSER;
+ PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[]
+ { pageId }, null ).open();
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowBookmarksAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowBookmarksAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowBookmarksAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowBookmarksAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+public class ShowBookmarksAction extends Action
+{
+
+ public ShowBookmarksAction()
+ {
+ super( "Show Bookmarks", IAction.AS_CHECK_BOX );
+ super.setEnabled( true );
+ super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS ) );
+ }
+
+
+ public void run()
+ {
+ BrowserUIPlugin.getDefault().getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS, super.isChecked() );
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDITAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDITAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDITAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDITAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+public class ShowDITAction extends Action
+{
+
+ public ShowDITAction()
+ {
+ super( "Show DIT", IAction.AS_CHECK_BOX );
+ super.setEnabled( true );
+ super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_DIT ) );
+ }
+
+
+ public void run()
+ {
+ BrowserUIPlugin.getDefault().getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_BROWSER_SHOW_DIT,
+ super.isChecked() );
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+public class ShowDirectoryMetadataEntriesAction extends Action
+{
+
+ public ShowDirectoryMetadataEntriesAction()
+ {
+ super( "Show Directory Metadata", IAction.AS_CHECK_BOX );
+ super.setEnabled( true );
+ super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES ) );
+ }
+
+
+ public void run()
+ {
+ BrowserUIPlugin.getDefault().getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES, super.isChecked() );
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowSearchesAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowSearchesAction.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowSearchesAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/browser/ShowSearchesAction.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.browser;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+
+public class ShowSearchesAction extends Action
+{
+
+ public ShowSearchesAction()
+ {
+ super( "Show Searches", IAction.AS_CHECK_BOX );
+ super.setEnabled( true );
+ super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_SEARCHES ) );
+ }
+
+
+ public void run()
+ {
+ BrowserUIPlugin.getDefault().getPreferenceStore().setValue(
+ BrowserUIConstants.PREFERENCE_BROWSER_SHOW_SEARCHES, super.isChecked() );
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionView.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.connection;
+
+
+import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
+import org.apache.directory.ldapstudio.browser.core.model.IConnection;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionConfiguration;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionWidget;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+
+public class ConnectionView extends ViewPart
+{
+
+ private ConnectionConfiguration configuration;
+
+ private ConnectionViewActionGroup actionGroup;
+
+ private ConnectionWidget mainWidget;
+
+ private ConnectionViewUniversalListener universalListener;
+
+
+ public static String getId()
+ {
+ return ConnectionView.class.getName();
+ }
+
+
+ public ConnectionView()
+ {
+ super();
+ }
+
+
+ public void setFocus()
+ {
+ mainWidget.getViewer().getControl().setFocus();
+ }
+
+
+ public void dispose()
+ {
+ if ( this.configuration != null )
+ {
+ this.actionGroup.dispose();
+ this.actionGroup = null;
+ this.configuration.dispose();
+ this.configuration = null;
+ this.universalListener.dispose();
+ this.universalListener = null;
+ this.mainWidget.dispose();
+ this.mainWidget = null;
+ getSite().setSelectionProvider( null );
+ }
+
+ super.dispose();
+ }
+
+
+ public void createPartControl( Composite parent )
+ {
+
+ Composite composite = new Composite( parent, SWT.NONE );
+ composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ composite.setLayout( layout );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_connections_view" );
+
+ // create configuration
+ this.configuration = new ConnectionConfiguration();
+
+ // create main widget
+ this.mainWidget = new ConnectionWidget( this.configuration, getViewSite().getActionBars() );
+ this.mainWidget.createWidget( composite );
+ this.mainWidget.setInput( BrowserCorePlugin.getDefault().getConnectionManager() );
+
+ // create actions and context menu (and register global actions)
+ this.actionGroup = new ConnectionViewActionGroup( this );
+ this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+ this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+ this.actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
+ this.actionGroup.fillContextMenu( this.configuration.getContextMenuManager( this.mainWidget.getViewer() ) );
+
+ // create the listener
+ getSite().setSelectionProvider( this.mainWidget.getViewer() );
+ this.universalListener = new ConnectionViewUniversalListener( this );
+
+ // default selection
+ IConnection[] connections = BrowserCorePlugin.getDefault().getConnectionManager().getConnections();
+ if ( connections.length > 0 )
+ {
+ ISelection selection = new StructuredSelection( connections[0] );
+ this.mainWidget.getViewer().setSelection( selection );
+ this.universalListener.selectionChanged( this, selection );
+ }
+
+ }
+
+
+ public ConnectionViewActionGroup getActionGroup()
+ {
+ return actionGroup;
+ }
+
+
+ public ConnectionConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ public ConnectionWidget getMainWidget()
+ {
+ return mainWidget;
+ }
+
+
+ public ConnectionViewUniversalListener getUniversalListener()
+ {
+ return universalListener;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java?view=auto&rev=488371
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/views/connection/ConnectionViewActionGroup.java Mon Dec 18 09:57:38 2006
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.ldapstudio.browser.ui.views.connection;
+
+
+import org.apache.directory.ldapstudio.browser.ui.actions.ImportExportAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.OpenSchemaBrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.SelectAllAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.ConnectionViewActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.dnd.ConnectionTransfer;
+import org.apache.directory.ldapstudio.browser.ui.dnd.SearchTransfer;
+import org.apache.directory.ldapstudio.browser.ui.widgets.connection.ConnectionActionGroup;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionFactory;
+
+
+public class ConnectionViewActionGroup extends ConnectionActionGroup
+{
+
+ private ConnectionView view;
+
+ private static final String selectAllAction = "selectAllAction";
+
+ private static final String importLdifAction = "importLdifAction";
+
+ private static final String exportLdifAction = "exportLdifAction";
+
+ private static final String exportCsvAction = "exportCsvAction";
+
+ private static final String exportExcelAction = "exportExcelAction";
+
+ private static final String openSchemaBrowserAction = "openSchemaBrowserAction";
+
+ private DragConnectionListener dragConnectionListener;
+
+ private DropConnectionListener dropConnectionListener;
+
+
+ public ConnectionViewActionGroup( ConnectionView view )
+ {
+ super( view.getMainWidget(), view.getConfiguration() );
+ this.view = view;
+ TableViewer viewer = view.getMainWidget().getViewer();
+
+ this.connectionActionMap.put( selectAllAction, new ConnectionViewActionProxy( viewer, new SelectAllAction(
+ viewer ) ) );
+ this.connectionActionMap.put( importLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_IMPORT_LDIF ) ) );
+ this.connectionActionMap.put( exportLdifAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_LDIF ) ) );
+ this.connectionActionMap.put( exportCsvAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_CSV ) ) );
+ this.connectionActionMap.put( exportExcelAction, new ConnectionViewActionProxy( viewer, new ImportExportAction(
+ ImportExportAction.TYPE_EXPORT_EXCEL ) ) );
+
+ this.connectionActionMap.put( openSchemaBrowserAction, new ConnectionViewActionProxy( viewer,
+ new OpenSchemaBrowserAction() ) );
+
+ // DND support
+ this.dropConnectionListener = new DropConnectionListener();
+ this.dragConnectionListener = new DragConnectionListener();
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[]
+ { ConnectionTransfer.getInstance(), SearchTransfer.getInstance() };
+ viewer.addDragSupport( ops, transfers, this.dragConnectionListener );
+ viewer.addDropSupport( ops, transfers, this.dropConnectionListener );
+ }
+
+
+ public void dispose()
+ {
+ if ( this.view != null )
+ {
+
+ this.dragConnectionListener.dispose();
+ this.dragConnectionListener = null;
+ this.dropConnectionListener.dispose();
+ this.dropConnectionListener = null;
+
+ this.view = null;
+ }
+ }
+
+
+ public void menuAboutToShow( IMenuManager menuManager )
+ {
+
+ // add
+ menuManager.add( ( IAction ) this.connectionActionMap.get( newConnectionAction ) );
+ menuManager.add( new Separator() );
+
+ // open/close
+ if ( ( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) ).isEnabled() )
+ menuManager.add( ( IAction ) this.connectionActionMap.get( closeConnectionAction ) );
+ else if ( ( ( IAction ) this.connectionActionMap.get( openConnectionAction ) ).isEnabled() )
+ menuManager.add( ( IAction ) this.connectionActionMap.get( openConnectionAction ) );
+ menuManager.add( new Separator() );
+
+ menuManager.add( ( IAction ) this.connectionActionMap.get( openSchemaBrowserAction ) );
+ menuManager.add( new Separator() );
+
+ // copy/paste/...
+ menuManager.add( ( IAction ) this.connectionActionMap.get( copyConnectionAction ) );
+ menuManager.add( ( IAction ) this.connectionActionMap.get( pasteConnectionAction ) );
+ menuManager.add( ( IAction ) this.connectionActionMap.get( deleteConnectionAction ) );
+ menuManager.add( ( IAction ) this.connectionActionMap.get( selectAllAction ) );
+ menuManager.add( ( IAction ) this.connectionActionMap.get( renameConnectionAction ) );
+ menuManager.add( new Separator() );
+
+ // import/export
+ MenuManager importMenuManager = new MenuManager( "Import" );
+ importMenuManager.add( ( IAction ) this.connectionActionMap.get( importLdifAction ) );
+ importMenuManager.add( new Separator() );
+ menuManager.add( importMenuManager );
+ MenuManager exportMenuManager = new MenuManager( "Export" );
+ exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportLdifAction ) );
+ exportMenuManager.add( new Separator() );
+ exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportCsvAction ) );
+ exportMenuManager.add( ( IAction ) this.connectionActionMap.get( exportExcelAction ) );
+ menuManager.add( exportMenuManager );
+ menuManager.add( new Separator() );
+
+ // additions
+ menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+ // properties
+ menuManager.add( ( IAction ) this.connectionActionMap.get( propertyDialogAction ) );
+ }
+
+
+ public void activateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), ( IAction ) this.connectionActionMap
+ .get( selectAllAction ) );
+ }
+
+ super.activateGlobalActionHandlers();
+
+ }
+
+
+ public void deactivateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), null );
+ }
+
+ super.deactivateGlobalActionHandlers();
+
+ }
+
+}