You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:01:46 UTC
svn commit: r592087 [5/16] - in
/directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src/...
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,356 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.INavigationLocationProvider;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+
+/**
+ * The EntryEditor is an {@link IEditorPart} is used to display and edit the attributes of an entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditor extends EditorPart implements INavigationLocationProvider, IReusableEditor
+{
+
+ /** The editor configuration. */
+ private EntryEditorConfiguration configuration;
+
+ /** The action group. */
+ private EntryEditorActionGroup actionGroup;
+
+ /** The main widget. */
+ private EntryEditorWidget mainWidget;
+
+ /** The universal listener. */
+ private EntryEditorUniversalListener universalListener;
+
+ /** The outline page. */
+ private EntryEditorOutlinePage outlinePage;
+
+
+ /**
+ * Gets the ID of the EntryEditor.
+ *
+ * @return the id of the EntryEditor
+ */
+ public static String getId()
+ {
+ return EntryEditor.class.getName();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setInput( IEditorInput input )
+ {
+ super.setInput( input );
+
+ if ( input instanceof EntryEditorInput && universalListener != null )
+ {
+ EntryEditorInput eei = ( EntryEditorInput ) input;
+ IEntry entry = eei.getResolvedEntry();
+
+ // inform listener
+ universalListener.setInput( entry );
+
+ // mark location for back/forward history navigation
+ if ( entry != null )
+ {
+ // enable one instance hack before fireing the input change event
+ // otherwise the navigation history is cleared.
+ EntryEditorInput.enableOneInstanceHack( true );
+ firePropertyChange( IEditorPart.PROP_INPUT );
+
+ // disable one instance hack for marking the location
+ EntryEditorInput.enableOneInstanceHack( false );
+ getSite().getPage().getNavigationHistory().markLocation( this );
+ }
+
+ // refresh outline
+ if ( outlinePage != null )
+ {
+ outlinePage.refresh();
+ }
+
+ // finally enable the one instance hack
+ EntryEditorInput.enableOneInstanceHack( true );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+ {
+ super.setSite( site );
+
+ // mark dummy location, necessary because the first marked
+ // location doesn't appear in history
+ setInput( new EntryEditorInput( ( IEntry ) null ) );
+ getSite().getPage().getNavigationHistory().markLocation( this );
+
+ setInput( input );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ 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;
+ layout.verticalSpacing = 0;
+ composite.setLayout( layout );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_entry_editor" );
+
+ // create configuration
+ configuration = new EntryEditorConfiguration();
+
+ // create main widget
+ mainWidget = new EntryEditorWidget( this.configuration );
+ mainWidget.createWidget( composite );
+
+ // create actions and context menu and register global actions
+ actionGroup = new EntryEditorActionGroup( this );
+ actionGroup.fillToolBar( mainWidget.getToolBarManager() );
+ actionGroup.fillMenu( mainWidget.getMenuManager() );
+ actionGroup.enableGlobalActionHandlers( getEditorSite().getActionBars() );
+ actionGroup.fillContextMenu( mainWidget.getContextMenuManager() );
+
+ // create the listener
+ getSite().setSelectionProvider( mainWidget.getViewer() );
+ universalListener = new EntryEditorUniversalListener( this );
+ setInput( getEditorInput() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setFocus()
+ {
+ mainWidget.setFocus();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter( Class required )
+ {
+ if ( IContentOutlinePage.class.equals( required ) )
+ {
+ if ( outlinePage == null || outlinePage.getControl() == null || outlinePage.getControl().isDisposed() )
+ {
+ outlinePage = new EntryEditorOutlinePage( this );
+ }
+ return outlinePage;
+ }
+
+ if ( IShowInTargetList.class.equals( required ) )
+ {
+ return new IShowInTargetList()
+ {
+ public String[] getShowInTargetIds()
+ {
+ return new String[]
+ { BrowserView.getId() };
+ }
+ };
+ }
+
+ if ( IShowInSource.class.equals( required ) )
+ {
+ return new IShowInSource()
+ {
+ public ShowInContext getShowInContext()
+ {
+ return new ShowInContext( getMainWidget().getViewer().getInput(), getMainWidget().getViewer()
+ .getSelection() );
+ }
+ };
+ }
+
+ return super.getAdapter( required );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose()
+ {
+ if ( configuration != null )
+ {
+ universalListener.dispose();
+ universalListener = null;
+ mainWidget.dispose();
+ mainWidget = null;
+ actionGroup.dispose();
+ actionGroup = null;
+ configuration.dispose();
+ configuration = null;
+ getSite().setSelectionProvider( null );
+ }
+
+ super.dispose();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSave( IProgressMonitor monitor )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doSaveAs()
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDirty()
+ {
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSaveAsAllowed()
+ {
+ return false;
+ }
+
+
+ /**
+ * Gets the action group.
+ *
+ * @return the action group
+ */
+ public EntryEditorActionGroup getActionGroup()
+ {
+ return actionGroup;
+ }
+
+
+ /**
+ * Gets the configuration.
+ *
+ * @return the configuration
+ */
+ public EntryEditorConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ /**
+ * Gets the main widget.
+ *
+ * @return the main widget
+ */
+ public EntryEditorWidget getMainWidget()
+ {
+ return mainWidget;
+ }
+
+
+ /**
+ * Gets the outline page.
+ *
+ * @return the outline page
+ */
+ public EntryEditorOutlinePage getOutlinePage()
+ {
+ return outlinePage;
+ }
+
+
+ /**
+ * Gets the universal listener.
+ *
+ * @return the universal listener
+ */
+ public EntryEditorUniversalListener getUniversalListener()
+ {
+ return universalListener;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public INavigationLocation createEmptyNavigationLocation()
+ {
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public INavigationLocation createNavigationLocation()
+ {
+ return new EntryEditorNavigationLocation( this );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,437 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.common.actions.CollapseAllAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAllValuesAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.NewAttributeAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.RefreshAction;
+import org.apache.directory.studio.ldapbrowser.common.actions.proxy.EntryEditorActionProxy;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EditAttributeDescriptionAction;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.OpenDefaultEditorAction;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyAttributeDescriptionAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyDnAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopySearchFilterAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyUrlAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyValueAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.ExpandAllAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.LocateDnInDitAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewBatchOperationAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.NewSearchAction;
+import org.apache.directory.studio.ldapbrowser.ui.actions.OpenSchemaBrowserAction;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+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.actions.ContributionItemFactory;
+import org.eclipse.ui.commands.ICommandService;
+
+
+/**
+ * The EntryEditorWidgetActionGroup manages all actions of the entry editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorActionGroup extends EntryEditorWidgetActionGroup
+{
+
+ /** The show operational attributes action. */
+ private ShowOperationalAttributesAction showOperationalAttributesAction;
+
+ /** The open entry editor preference page. */
+ private OpenEntryEditorPreferencePageAction openEntryEditorPreferencePage;
+
+ /** The collapse all action. */
+ private CollapseAllAction collapseAllAction;
+
+ /** The expand all action. */
+ private ExpandAllAction expandAllAction;
+
+ /** The Constant editAttributeDescriptionAction. */
+ private static final String editAttributeDescriptionAction = "editAttributeDescriptionAction";
+
+ /** The Constant refreshAttributesAction. */
+ private static final String refreshAttributesAction = "refreshAttributesAction";
+
+ /** The Constant newAttributeAction. */
+ private static final String newAttributeAction = "newAttributeAction";
+
+ /** The Constant newSearchAction. */
+ private static final String newSearchAction = "newSearchDialogAction";
+
+ /** The Constant newBatchOperationAction. */
+ private static final String newBatchOperationAction = "newBatchOperationAction";
+
+ /** The Constant copyDnAction. */
+ private static final String copyDnAction = "copyDnAction";
+
+ /** The Constant copyUrlAction. */
+ private static final String copyUrlAction = "copyUrlAction";
+
+ /** The Constant copyAttriuteDescriptionAction. */
+ private static final String copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction";
+
+ /** The Constant copyValueUtf8Action. */
+ private static final String copyValueUtf8Action = "copyValueUtf8Action";
+
+ /** The Constant copyValueBase64Action. */
+ private static final String copyValueBase64Action = "copyValueBase64Action";
+
+ /** The Constant copyValueHexAction. */
+ private static final String copyValueHexAction = "copyValueHexAction";
+
+ /** The Constant copyValueAsLdifAction. */
+ private static final String copyValueAsLdifAction = "copyValueAsLdifAction";
+
+ /** The Constant copySearchFilterAction. */
+ private static final String copySearchFilterAction = "copySearchFilterAction";
+
+ /** The Constant copyNotSearchFilterAction. */
+ private static final String copyNotSearchFilterAction = "copyNotSearchFilterAction";
+
+ /** The Constant copyAndSearchFilterAction. */
+ private static final String copyAndSearchFilterAction = "copyAndSearchFilterAction";
+
+ /** The Constant copyOrSearchFilterAction. */
+ private static final String copyOrSearchFilterAction = "copyOrSearchFilterAction";
+
+ /** The Constant deleteAllValuesAction. */
+ private static final String deleteAllValuesAction = "deleteAllValuesAction";
+
+ /** The Constant locateDnInDitAction. */
+ private static final String locateDnInDitAction = "locateDnInDitAction";
+
+ /** The Constant showOcdAction. */
+ private static final String showOcdAction = "showOcdAction";
+
+ /** The Constant showAtdAction. */
+ private static final String showAtdAction = "showAtdAction";
+
+ /** The Constant showEqualityMrdAction. */
+ private static final String showEqualityMrdAction = "showEqualityMrdAction";
+
+ /** The Constant showSubstringMrdAction. */
+ private static final String showSubstringMrdAction = "showSubstringMrdAction";
+
+ /** The Constant showOrderingMrdAction. */
+ private static final String showOrderingMrdAction = "showOrderingMrdAction";
+
+ /** The Constant showLsdAction. */
+ private static final String showLsdAction = "showLsdAction";
+
+
+ /**
+ * Creates a new instance of EntryEditorActionGroup.
+ *
+ * @param entryEditor the entry editor
+ */
+ public EntryEditorActionGroup( EntryEditor entryEditor )
+ {
+ super( entryEditor.getMainWidget(), entryEditor.getConfiguration() );
+ TreeViewer viewer = entryEditor.getMainWidget().getViewer();
+
+ // create OpenDefaultEditorAction with enabled rename action flag
+ openDefaultValueEditorActionProxy.dispose();
+ openDefaultValueEditorActionProxy = new EntryEditorActionProxy( viewer, this, new OpenDefaultEditorAction(
+ viewer, openBestValueEditorActionProxy, true ) );
+
+ showOperationalAttributesAction = new ShowOperationalAttributesAction();
+ openEntryEditorPreferencePage = new OpenEntryEditorPreferencePageAction();
+ collapseAllAction = new CollapseAllAction( viewer );
+ expandAllAction = new ExpandAllAction( viewer );
+
+ entryEditorActionMap.put( editAttributeDescriptionAction, new EntryEditorActionProxy( viewer, this,
+ new EditAttributeDescriptionAction( viewer ) ) );
+
+ entryEditorActionMap.put( refreshAttributesAction, new EntryEditorActionProxy( viewer, this,
+ new RefreshAction() ) );
+
+ entryEditorActionMap.put( newAttributeAction, new EntryEditorActionProxy( viewer, this,
+ new NewAttributeAction() ) );
+ entryEditorActionMap.put( newSearchAction, new EntryEditorActionProxy( viewer, this, new NewSearchAction() ) );
+ entryEditorActionMap.put( newBatchOperationAction, new EntryEditorActionProxy( viewer, this,
+ new NewBatchOperationAction() ) );
+
+ entryEditorActionMap.put( locateDnInDitAction, new EntryEditorActionProxy( viewer, this,
+ new LocateDnInDitAction() ) );
+ entryEditorActionMap.put( showOcdAction, new EntryEditorActionProxy( viewer, this, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) );
+ entryEditorActionMap.put( showAtdAction, new EntryEditorActionProxy( viewer, this, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) );
+ entryEditorActionMap.put( showEqualityMrdAction, new EntryEditorActionProxy( viewer, this,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) );
+ entryEditorActionMap.put( showSubstringMrdAction, new EntryEditorActionProxy( viewer, this,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) );
+ entryEditorActionMap.put( showOrderingMrdAction, new EntryEditorActionProxy( viewer, this,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) );
+ entryEditorActionMap.put( showLsdAction, new EntryEditorActionProxy( viewer, this, new OpenSchemaBrowserAction(
+ OpenSchemaBrowserAction.MODE_SYNTAX ) ) );
+
+ entryEditorActionMap.put( copyDnAction, new EntryEditorActionProxy( viewer, this, new CopyDnAction() ) );
+ entryEditorActionMap.put( copyUrlAction, new EntryEditorActionProxy( viewer, this, new CopyUrlAction() ) );
+ entryEditorActionMap.put( copyAttriuteDescriptionAction, new EntryEditorActionProxy( viewer, this,
+ new CopyAttributeDescriptionAction() ) );
+ entryEditorActionMap.put( copyValueUtf8Action, new EntryEditorActionProxy( viewer, this, new CopyValueAction(
+ CopyValueAction.MODE_UTF8 ) ) );
+ entryEditorActionMap.put( copyValueBase64Action, new EntryEditorActionProxy( viewer, this, new CopyValueAction(
+ CopyValueAction.MODE_BASE64 ) ) );
+ entryEditorActionMap.put( copyValueHexAction, new EntryEditorActionProxy( viewer, this, new CopyValueAction(
+ CopyValueAction.MODE_HEX ) ) );
+ entryEditorActionMap.put( copyValueAsLdifAction, new EntryEditorActionProxy( viewer, this, new CopyValueAction(
+ CopyValueAction.MODE_LDIF ) ) );
+
+ entryEditorActionMap.put( copySearchFilterAction, new EntryEditorActionProxy( viewer, this,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) );
+ entryEditorActionMap.put( copyNotSearchFilterAction, new EntryEditorActionProxy( viewer, this,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) );
+ entryEditorActionMap.put( copyAndSearchFilterAction, new EntryEditorActionProxy( viewer, this,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) );
+ entryEditorActionMap.put( copyOrSearchFilterAction, new EntryEditorActionProxy( viewer, this,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) );
+
+ entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer, this,
+ new DeleteAllValuesAction() ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose()
+ {
+ if ( showOperationalAttributesAction != null )
+ {
+ deactivateGlobalActionHandlers();
+
+ openEntryEditorPreferencePage = null;
+ showOperationalAttributesAction = null;
+ expandAllAction.dispose();
+ expandAllAction = null;
+ collapseAllAction.dispose();
+ collapseAllAction = null;
+ }
+
+ super.dispose();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fillToolBar( IToolBarManager toolBarManager )
+ {
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
+ toolBarManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) );
+ toolBarManager.add( ( IAction ) entryEditorActionMap.get( deleteAllValuesAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) entryEditorActionMap.get( refreshAttributesAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( expandAllAction );
+ toolBarManager.add( collapseAllAction );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( showQuickFilterAction );
+ toolBarManager.update( true );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void fillMenu( IMenuManager menuManager )
+ {
+ menuManager.add( openSortDialogAction );
+ menuManager.add( new Separator() );
+ menuManager.add( showOperationalAttributesAction );
+ menuManager.add( showRawValuesAction );
+ menuManager.add( new Separator() );
+ menuManager.add( openEntryEditorPreferencePage );
+ menuManager.addMenuListener( new IMenuListener()
+ {
+ public void menuAboutToShow( IMenuManager manager )
+ {
+ showRawValuesAction.setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean(
+ BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+ showOperationalAttributesAction.setChecked( BrowserCommonActivator.getDefault().getPreferenceStore()
+ .getBoolean( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_SHOW_OPERATIONAL_ATTRIBUTES ) );
+ }
+ } );
+ menuManager.update( true );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void contextMenuAboutToShow( IMenuManager menuManager )
+ {
+ // new
+ menuManager.add( ( IAction ) entryEditorActionMap.get( newAttributeAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( newValueAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( newSearchAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( newBatchOperationAction ) );
+ menuManager.add( new Separator() );
+
+ // navigation
+ menuManager.add( ( IAction ) entryEditorActionMap.get( locateDnInDitAction ) );
+ MenuManager schemaMenuManager = new MenuManager( "Open Schema Browser" );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showOcdAction ) );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showAtdAction ) );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showEqualityMrdAction ) );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showSubstringMrdAction ) );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showOrderingMrdAction ) );
+ schemaMenuManager.add( ( IAction ) entryEditorActionMap.get( showLsdAction ) );
+ menuManager.add( schemaMenuManager );
+ MenuManager showInSubMenu = new MenuManager( "Show In" );
+ showInSubMenu.add( ContributionItemFactory.VIEWS_SHOW_IN.create( PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow() ) );
+ menuManager.add( showInSubMenu );
+
+ menuManager.add( new Separator() );
+
+ // copy, paste, delete
+ menuManager.add( ( IAction ) entryEditorActionMap.get( copyAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( pasteAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( deleteAction ) );
+ menuManager.add( ( IAction ) entryEditorActionMap.get( selectAllAction ) );
+ MenuManager advancedMenuManager = new MenuManager( "Advanced" );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyDnAction ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyUrlAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyAttriuteDescriptionAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyValueUtf8Action ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyValueBase64Action ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyValueHexAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyValueAsLdifAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copySearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyNotSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyAndSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( copyOrSearchFilterAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) entryEditorActionMap.get( deleteAllValuesAction ) );
+ menuManager.add( advancedMenuManager );
+ menuManager.add( new Separator() );
+
+ // edit
+ menuManager.add( ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction ) );
+ super.addEditMenu( menuManager );
+ menuManager.add( new Separator() );
+
+ // refresh
+ menuManager.add( ( IAction ) entryEditorActionMap.get( refreshAttributesAction ) );
+ menuManager.add( new Separator() );
+
+ // additions
+ menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+ // properties
+ menuManager.add( ( IAction ) entryEditorActionMap.get( propertyDialogAction ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void activateGlobalActionHandlers()
+ {
+ if ( actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), ( IAction ) entryEditorActionMap
+ .get( refreshAttributesAction ) );
+ }
+
+ super.activateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction );
+ commandService.getCommand( naa.getActionDefinitionId() ).setHandler( new ActionHandler( naa ) );
+ IAction lid = ( IAction ) entryEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( new ActionHandler( lid ) );
+ IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction );
+ commandService.getCommand( eada.getActionDefinitionId() ).setHandler( new ActionHandler( eada ) );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void deactivateGlobalActionHandlers()
+ {
+ if ( actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null );
+ }
+
+ super.deactivateGlobalActionHandlers();
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction naa = ( IAction ) entryEditorActionMap.get( newAttributeAction );
+ commandService.getCommand( naa.getActionDefinitionId() ).setHandler( null );
+ IAction lid = ( IAction ) entryEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( null );
+ IAction eada = ( IAction ) entryEditorActionMap.get( editAttributeDescriptionAction );
+ commandService.getCommand( eada.getActionDefinitionId() ).setHandler( null );
+ }
+ }
+
+
+ /**
+ * Sets the input.
+ *
+ * @param entry the input
+ */
+ public void setInput( IEntry entry )
+ {
+ for ( Iterator it = entryEditorActionMap.values().iterator(); it.hasNext(); )
+ {
+ EntryEditorActionProxy action = ( EntryEditorActionProxy ) it.next();
+ action.inputChanged( entry );
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetConfiguration;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetFilter;
+
+
+/**
+ * The BrowserConfiguration contains the content provider,
+ * label provider, sorter, filter the context menu manager and the
+ * preferences for the entry editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorConfiguration extends EntryEditorWidgetConfiguration
+{
+
+ /**
+ * Creates a new instance of EntryEditorConfiguration.
+ */
+ public EntryEditorConfiguration()
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public EntryEditorWidgetFilter getFilter()
+ {
+ if ( filter == null )
+ {
+ filter = new EntryEditorFilter( getPreferences() );
+ }
+
+ return filter;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorFilter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorFilter.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorFilter.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorFilter.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetFilter;
+import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetPreferences;
+
+
+/**
+ * The EntryEditorFilter implements the filter for
+ * the entry editor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorFilter extends EntryEditorWidgetFilter
+{
+
+ /** The preferences. */
+ private EntryEditorWidgetPreferences preferences;
+
+
+ /**
+ * Creates a new instance of EntryEditorFilter.
+ *
+ * @param preferences the preferences
+ */
+ public EntryEditorFilter( EntryEditorWidgetPreferences preferences )
+ {
+ this.preferences = preferences;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isShowMayAttributes()
+ {
+ return preferences.isShowMayAttributes();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isShowMustAttributes()
+ {
+ return preferences.isShowMustAttributes();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isShowObjectClassAttribute()
+ {
+ return preferences.isShowObjectClassAttribute();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isShowOperationalAttributes()
+ {
+ return preferences.isShowOperationalAttributes();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorInput.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorInput.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorInput.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,319 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+/**
+ * The input for the entry editor.
+ *
+ * There is a trick to provide a single instance of the entry editor:
+ * <ul>
+ * <li>If oneInstanceHackEnabled is true the equals method returns always
+ * true as long as the compared object is also of type EntryEditorInput.
+ * With this trick only one instance of the entry editor is opened
+ * by the eclipse editor framework.
+ * <li>If oneInstanceHackEnabled is false the equals method returns
+ * true only if the wrapped objects (IEntry, ISearchResult or
+ * IBookmark) are equal. This is necessary for the history navigation
+ * because it must be able to distinguish the different
+ * input objects.
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorInput implements IEditorInput
+{
+
+ /** The entry input */
+ private IEntry entry;
+
+ /** The search result input */
+ private ISearchResult searchResult;
+
+ /** The bookmark input */
+ private IBookmark bookmark;
+
+ /** One instance hack flag */
+ private static boolean oneInstanceHackEnabled = true;
+
+
+ /**
+ * Creates a new instance of EntryEditorInput with an IEntry as
+ * domain object.
+ *
+ * @param entry the entry input
+ */
+ public EntryEditorInput( IEntry entry )
+ {
+ this.entry = entry;
+ this.searchResult = null;
+ this.bookmark = null;
+ }
+
+
+ /**
+ * Creates a new instance of EntryEditorInput with an ISearchResult as
+ * domain object.
+ *
+ * @param searchResult the search result input
+ */
+ public EntryEditorInput( ISearchResult searchResult )
+ {
+ this.entry = null;
+ this.searchResult = searchResult;
+ this.bookmark = null;
+ }
+
+
+ /**
+ * Creates a new instance of EntryEditorInput with an IBookmark as
+ * domain object.
+ *
+ * @param bookmark the bookmark input
+ */
+ public EntryEditorInput( IBookmark bookmark )
+ {
+ this.entry = null;
+ this.searchResult = null;
+ this.bookmark = bookmark;
+ }
+
+
+ /**
+ * This implementation always return false because
+ * an entry should not be visible in the
+ * "File Most Recently Used" menu.
+ *
+ * {@inheritDoc}
+ */
+ public boolean exists()
+ {
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ATTRIBUTE );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return "Entry Editor";
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getToolTipText()
+ {
+ return "";
+ }
+
+ /**
+ * This implementation always return null.
+ *
+ * {@inheritDoc}
+ */
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ /**
+ * Gets the resolved entry, either the entry input itself
+ * or the entry behind the search result intput or the entry behind
+ * the bookmark input.
+ *
+ * @return the resolved entry
+ */
+ public IEntry getResolvedEntry()
+ {
+ if ( entry != null )
+ {
+ return entry;
+ }
+ else if ( searchResult != null )
+ {
+ return searchResult.getEntry();
+ }
+ else if ( bookmark != null )
+ {
+ return bookmark.getEntry();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets the entry input, may be null.
+ *
+ * @return the entry input or null
+ */
+ public IEntry getEntryInput()
+ {
+ return entry;
+ }
+
+
+ /**
+ * Gets the search result input, may be null.
+ *
+ * @return the search result input or null
+ */
+ public ISearchResult getSearchResultInput()
+ {
+ return searchResult;
+ }
+
+
+ /**
+ * Gets the bookmark input, may be null.
+ *
+ * @return the bookmark input or null
+ */
+ public IBookmark getBookmarkInput()
+ {
+ return bookmark;
+ }
+
+
+ /**
+ * Gets the input, may be null.
+ *
+ * @return the input or null
+ */
+ public Object getInput()
+ {
+ if ( entry != null )
+ {
+ return entry;
+ }
+ else if ( searchResult != null )
+ {
+ return searchResult;
+ }
+ else if ( bookmark != null )
+ {
+ return bookmark;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode()
+ {
+ return getToolTipText().hashCode();
+ }
+
+
+ /**
+ * The result depends
+ *
+ * {@inheritDoc}
+ */
+ public boolean equals( Object obj )
+ {
+ boolean equal;
+
+ if ( oneInstanceHackEnabled )
+ {
+ equal = ( obj instanceof EntryEditorInput );
+ }
+ else
+ {
+ if ( obj instanceof EntryEditorInput )
+ {
+ EntryEditorInput other = ( EntryEditorInput ) obj;
+ if ( this.getInput() == null && other.getInput() == null )
+ {
+ return true;
+ }
+ else if ( this.getInput() == null || other.getInput() == null )
+ {
+ return false;
+ }
+ else
+ {
+ equal = other.getInput().equals( this.getInput() );
+ }
+ }
+ else
+ {
+ equal = false;
+ }
+ }
+
+ return equal;
+ }
+
+
+ /**
+ * Enables or disabled the one instance hack.
+ *
+ * @param b
+ * true to enable the one instance hack,
+ * false to disable the one instance hack
+ */
+ public static void enableOneInstanceHack( boolean b )
+ {
+ oneInstanceHackEnabled = b;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,272 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBookmark;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.INavigationLocation;
+import org.eclipse.ui.NavigationLocation;
+
+
+/**
+ * This class is used to mark the entry editor input to the navigation history.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorNavigationLocation extends NavigationLocation
+{
+
+ /**
+ * Creates a new instance of EntryEditorNavigationLocation.
+ *
+ * @param editor the entry editor
+ */
+ EntryEditorNavigationLocation( EntryEditor editor )
+ {
+ super( editor );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getText()
+ {
+ EntryEditorInput eei = getEntryEditorInput();
+ if ( eei != null )
+ {
+ if ( eei.getEntryInput() != null )
+ {
+ if ( eei.getEntryInput() instanceof IRootDSE )
+ {
+ return "Root DSE";
+ }
+ else
+ {
+ return "Entry " + eei.getEntryInput().getDn().getUpName();
+ }
+ }
+ else if ( eei.getSearchResultInput() != null )
+ {
+ if ( eei.getSearchResultInput() instanceof IRootDSE )
+ {
+ return "Root DSE";
+ }
+ else
+ {
+ return "Search Result " + eei.getSearchResultInput().getDn().getUpName();
+ }
+ }
+ else if ( eei.getBookmarkInput() != null )
+ {
+ if ( eei.getBookmarkInput() instanceof IRootDSE )
+ {
+ return "Root DSE";
+ }
+ else
+ {
+ return "Bookmark " + eei.getBookmarkInput().getDn().getUpName();
+ }
+ }
+ }
+ return super.getText();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void saveState( IMemento memento )
+ {
+ EntryEditorInput eei = getEntryEditorInput();
+ if ( eei != null )
+ {
+ if ( eei.getEntryInput() != null )
+ {
+ IEntry entry = eei.getEntryInput();
+ memento.putString( "TYPE", "IEntry" );
+ memento.putString( "DN", entry.getDn().getUpName() );
+ memento.putString( "CONNECTION", entry.getBrowserConnection().getConnection().getId() );
+ }
+ else if ( eei.getSearchResultInput() != null )
+ {
+ ISearchResult searchResult = eei.getSearchResultInput();
+ memento.putString( "TYPE", "ISearchResult" );
+ memento.putString( "DN", searchResult.getDn().getUpName() );
+ memento.putString( "SEARCH", searchResult.getSearch().getName() );
+ memento.putString( "CONNECTION", searchResult.getSearch().getBrowserConnection().getConnection().getId() );
+ }
+ else if ( eei.getBookmarkInput() != null )
+ {
+ IBookmark bookmark = eei.getBookmarkInput();
+ memento.putString( "TYPE", "IBookmark" );
+ memento.putString( "BOOKMARK", bookmark.getName() );
+ memento.putString( "CONNECTION", bookmark.getBrowserConnection().getConnection().getId() );
+ }
+ }
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreState( IMemento memento )
+ {
+ try
+ {
+ String type = memento.getString( "TYPE" );
+ if ( "IEntry".equals( type ) )
+ {
+ IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById(
+ memento.getString( "CONNECTION" ) );
+ LdapDN dn = new LdapDN( memento.getString( "DN" ) );
+ IEntry entry = connection.getEntryFromCache( dn );
+ super.setInput( new EntryEditorInput( entry ) );
+ }
+ else if ( "ISearchResult".equals( type ) )
+ {
+ IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById(
+ memento.getString( "CONNECTION" ) );
+ ISearch search = connection.getSearchManager().getSearch( memento.getString( "SEARCH" ) );
+ ISearchResult[] searchResults = search.getSearchResults();
+ LdapDN dn = new LdapDN( memento.getString( "DN" ) );
+ for ( int i = 0; i < searchResults.length; i++ )
+ {
+ if ( dn.equals( searchResults[i].getDn() ) )
+ {
+ super.setInput( new EntryEditorInput( searchResults[i] ) );
+ break;
+ }
+ }
+ }
+ else if ( "IBookmark".equals( type ) )
+ {
+ IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById(
+ memento.getString( "CONNECTION" ) );
+ IBookmark bookmark = connection.getBookmarkManager().getBookmark( memento.getString( "BOOKMARK" ) );
+ super.setInput( new EntryEditorInput( bookmark ) );
+ }
+ }
+ catch ( InvalidNameException e )
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreLocation()
+ {
+ IEditorPart editorPart = getEditorPart();
+ if ( editorPart != null && editorPart instanceof EntryEditor )
+ {
+ EntryEditor entryEditor = ( EntryEditor ) editorPart;
+ entryEditor.setInput( ( EntryEditorInput ) getInput() );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean mergeInto( INavigationLocation currentLocation )
+ {
+ if ( currentLocation == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != currentLocation.getClass() )
+ {
+ return false;
+ }
+
+ EntryEditorNavigationLocation location = ( EntryEditorNavigationLocation ) currentLocation;
+ Object other = location.getEntryEditorInput().getInput();
+ Object entry = getEntryEditorInput().getInput();
+
+ if ( other == null && entry == null )
+ {
+ return true;
+ }
+ else if ( other == null || entry == null )
+ {
+ return false;
+ }
+ else
+ {
+ return entry.equals( other );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update()
+ {
+ }
+
+
+ /**
+ * Gets the input.
+ *
+ * @return the input
+ */
+ private EntryEditorInput getEntryEditorInput()
+ {
+
+ Object editorInput = getInput();
+ if ( editorInput != null && editorInput instanceof EntryEditorInput )
+ {
+ EntryEditorInput entryEditorInput = ( EntryEditorInput ) editorInput;
+ return entryEditorInput;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "" + getEntryEditorInput().getInput();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,509 @@
+/*
+ * 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.studio.ldapbrowser.ui.editors.entry;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.LdifFile;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifChangeAddRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifChangeDeleteRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifChangeModDnRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifChangeModifyRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContentRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifModSpec;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifRecord;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldapbrowser.core.model.ldif.parser.LdifParser;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
+import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsLdifAction;
+import org.apache.directory.studio.ldifeditor.LdifEditorActivator;
+import org.apache.directory.studio.ldifeditor.LdifEditorConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+
+/**
+ * This class implements the Outline Page for the Entry Editor.
+ * It used to display LDAP entries.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryEditorOutlinePage extends ContentOutlinePage
+{
+ /** The editor it is attached to */
+ private EntryEditor entryEditor;
+
+
+ /**
+ * Creates a new instance of EntryEditorOutlinePage.
+ *
+ * @param entryEditor
+ * the editor the Outline page is attached to
+ */
+ public EntryEditorOutlinePage( EntryEditor entryEditor )
+ {
+ this.entryEditor = entryEditor;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.contentoutline.ContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ super.createControl( parent );
+
+ final TreeViewer treeViewer = getTreeViewer();
+ treeViewer.setLabelProvider( new LdifLabelProvider() );
+ treeViewer.setContentProvider( new LdifContentProvider() );
+ // treeViewer.setAutoExpandLevel(1);
+
+ treeViewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( !event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection )
+ {
+
+ Object o = entryEditor.getMainWidget().getViewer().getInput();
+ if ( o != null && o instanceof IEntry )
+ {
+ IEntry entry = ( IEntry ) o;
+ IAttribute[] attributes = entry.getAttributes();
+
+ List selectionList = new ArrayList();
+
+ Iterator it = ( ( IStructuredSelection ) event.getSelection() ).iterator();
+ while ( it.hasNext() )
+ {
+ Object element = it.next();
+
+ if ( element instanceof LdifAttrValLine )
+ {
+ // select the value
+ LdifAttrValLine line = ( LdifAttrValLine ) element;
+ for ( int a = 0; a < attributes.length; a++ )
+ {
+ IAttribute attribute = attributes[a];
+ if ( attribute.getDescription().equals( line.getUnfoldedAttributeDescription() ) )
+ {
+ IValue[] values = attribute.getValues();
+ for ( int v = 0; v < values.length; v++ )
+ {
+ IValue value = values[v];
+ if ( value.getStringValue().equals( line.getValueAsString() ) )
+ {
+ selectionList.add( value );
+ }
+ }
+ }
+ }
+ }
+ else if ( element instanceof List )
+ {
+ // select attribute and all values
+ List list = ( List ) element;
+ if ( !list.isEmpty() && list.get( 0 ) instanceof LdifAttrValLine )
+ {
+ LdifAttrValLine line = ( LdifAttrValLine ) list.get( 0 );
+ for ( int a = 0; a < attributes.length; a++ )
+ {
+ IAttribute attribute = attributes[a];
+ if ( attribute.getDescription().equals(
+ line.getUnfoldedAttributeDescription() ) )
+ {
+ selectionList.add( attribute );
+ selectionList.addAll( Arrays.asList( attribute.getValues() ) );
+ }
+ }
+ }
+ }
+ else if ( element instanceof LdifRecord )
+ {
+ for ( int a = 0; a < attributes.length; a++ )
+ {
+ IAttribute attribute = attributes[a];
+ selectionList.add( attribute );
+ selectionList.addAll( Arrays.asList( attribute.getValues() ) );
+ }
+ }
+ }
+
+ IStructuredSelection selection = new StructuredSelection( selectionList );
+ entryEditor.getMainWidget().getViewer().setSelection( selection );
+ }
+ }
+ }
+ } );
+
+ treeViewer.addDoubleClickListener( new IDoubleClickListener()
+ {
+ public void doubleClick( DoubleClickEvent event )
+ {
+ if ( event.getSelection() instanceof IStructuredSelection )
+ {
+ Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
+ if ( treeViewer.getExpandedState( obj ) )
+ treeViewer.collapseToLevel( obj, 1 );
+ else if ( ( ( ITreeContentProvider ) treeViewer.getContentProvider() ).hasChildren( obj ) )
+ treeViewer.expandToLevel( obj, 1 );
+ }
+ }
+ } );
+
+ this.refresh();
+ }
+
+
+ /**
+ * Refreshes this viewer starting with the given element.
+ *
+ * @param element
+ * the element
+ */
+ public void refresh( Object element )
+ {
+ final TreeViewer treeViewer = getTreeViewer();
+ if ( treeViewer != null && treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() )
+ {
+ treeViewer.refresh( element );
+ }
+ }
+
+
+ /**
+ * Refreshes this viewer completely with information freshly obtained from this viewer's model.
+ */
+ public void refresh()
+ {
+ final TreeViewer treeViewer = getTreeViewer();
+
+ if ( treeViewer != null && treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() )
+ {
+ // ISelection selection = treeViewer.getSelection();
+ // Object[] expandedElements = treeViewer.getExpandedElements();
+
+ if ( !treeViewer.getTree().isEnabled() )
+ {
+ treeViewer.getTree().setEnabled( true );
+ }
+
+ if ( entryEditor != null )
+ {
+ Object o = entryEditor.getMainWidget().getViewer().getInput();
+
+ if ( o == null )
+ {
+ treeViewer.setInput( null );
+ treeViewer.getTree().setEnabled( false );
+ }
+ else
+ {
+ if ( o instanceof IEntry )
+ {
+ StringBuffer sb = new StringBuffer();
+ new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES )
+ .serialializeEntries( new IEntry[]
+ { ( IEntry ) o }, sb );
+ LdifFile model = new LdifParser().parse( sb.toString() );
+ treeViewer.setInput( model );
+ treeViewer.expandToLevel( 2 );
+ }
+ }
+ }
+
+ treeViewer.refresh();
+
+ // treeViewer.setSelection(selection);
+ // treeViewer.setExpandedElements(expandedElements);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.Page#dispose()
+ */
+ public void dispose()
+ {
+ super.dispose();
+ if ( entryEditor != null )
+ {
+ entryEditor = null;
+ }
+ }
+
+ /**
+ * This class implements the ContentProvider used for the LDIF Outline View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private static class LdifContentProvider implements ITreeContentProvider
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren( Object element )
+ {
+ // file --> records
+ if ( element instanceof LdifFile )
+ {
+ LdifFile ldifFile = ( LdifFile ) element;
+ return ldifFile.getRecords();
+ }
+
+ // record --> Array of List of AttrValLine
+ else if ( element instanceof LdifContentRecord )
+ {
+ LdifContentRecord record = ( LdifContentRecord ) element;
+ return getUniqueAttrValLineArray( record.getAttrVals() );
+ }
+ else if ( element instanceof LdifChangeAddRecord )
+ {
+ LdifChangeAddRecord record = ( LdifChangeAddRecord ) element;
+ return getUniqueAttrValLineArray( record.getAttrVals() );
+ }
+ else if ( element instanceof LdifChangeModifyRecord )
+ {
+ LdifChangeModifyRecord record = ( LdifChangeModifyRecord ) element;
+ return record.getModSpecs();
+ }
+ else if ( element instanceof LdifChangeModDnRecord )
+ {
+ return new Object[0];
+ }
+ else if ( element instanceof LdifChangeDeleteRecord )
+ {
+ return new Object[0];
+ }
+
+ // List of AttrValLine --> Array of AttrValLine
+ else if ( element instanceof List && ( ( List ) element ).get( 0 ) instanceof LdifAttrValLine )
+ {
+ List list = ( List ) element;
+ return list.toArray();
+ }
+ else if ( element instanceof LdifModSpec )
+ {
+ LdifModSpec modSpec = ( LdifModSpec ) element;
+ return modSpec.getAttrVals();
+ }
+
+ else
+ {
+ return new Object[0];
+ }
+ }
+
+
+ /**
+ * Returns a unique line of attribute values from an array of attribute value lines
+ *
+ * @param lines
+ * the attribute value lines
+ * @return
+ * a unique line of attribute values from an array of attribute values lines
+ */
+ private Object[] getUniqueAttrValLineArray( LdifAttrValLine[] lines )
+ {
+ Map uniqueAttrMap = new LinkedHashMap();
+ for ( int i = 0; i < lines.length; i++ )
+ {
+ if ( !uniqueAttrMap.containsKey( lines[i].getUnfoldedAttributeDescription() ) )
+ {
+ uniqueAttrMap.put( lines[i].getUnfoldedAttributeDescription(), new ArrayList() );
+ }
+ ( ( List ) uniqueAttrMap.get( lines[i].getUnfoldedAttributeDescription() ) ).add( lines[i] );
+ }
+ return uniqueAttrMap.values().toArray();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent( Object element )
+ {
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren( Object element )
+ {
+ return getChildren( element ) != null && getChildren( element ).length > 0;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements( Object inputElement )
+ {
+ return getChildren( inputElement );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ }
+ }
+
+ /**
+ * This class implements the LabelProvider used for the LDIF Outline View
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private static class LdifLabelProvider extends LabelProvider
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getText( Object element )
+ {
+ // Record
+ if ( element instanceof LdifRecord )
+ {
+ LdifRecord ldifRecord = ( LdifRecord ) element;
+ return ldifRecord.getDnLine().getValueAsString();
+ }
+
+ // List of AttrValLine
+ else if ( element instanceof List && ( ( List ) element ).get( 0 ) instanceof LdifAttrValLine )
+ {
+ List list = ( List ) element;
+ return ( ( LdifAttrValLine ) list.get( 0 ) ).getUnfoldedAttributeDescription() + " (" + list.size()
+ + ")";
+ }
+ else if ( element instanceof LdifModSpec )
+ {
+ LdifModSpec modSpec = ( LdifModSpec ) element;
+ return modSpec.getModSpecType().getUnfoldedAttributeDescription() + " (" + modSpec.getAttrVals().length
+ + ")";
+ }
+
+ // AttrValLine
+ else if ( element instanceof LdifAttrValLine )
+ {
+ LdifAttrValLine line = ( LdifAttrValLine ) element;
+ return Utils.getShortenedString( line.getValueAsString(), 20 );
+ }
+
+ else
+ {
+ return "";
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage( Object element )
+ {
+ // Record
+ if ( element instanceof LdifContentRecord )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_ENTRY );
+ }
+ else if ( element instanceof LdifChangeAddRecord )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ADD );
+ }
+ else if ( element instanceof LdifChangeModifyRecord )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MODIFY );
+ }
+ else if ( element instanceof LdifChangeDeleteRecord )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_DELETE );
+ }
+ else if ( element instanceof LdifChangeModDnRecord )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_RENAME );
+ }
+
+ // List of AttrValLine
+ else if ( element instanceof List && ( ( List ) element ).get( 0 ) instanceof LdifAttrValLine )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ATTRIBUTE );
+ }
+ else if ( element instanceof LdifModSpec )
+ {
+ LdifModSpec modSpec = ( LdifModSpec ) element;
+ if ( modSpec.isAdd() )
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_ADD );
+ else if ( modSpec.isReplace() )
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_REPLACE );
+ else if ( modSpec.isDelete() )
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_MOD_DELETE );
+ else
+ return null;
+ }
+
+ // AttrValLine
+ else if ( element instanceof LdifAttrValLine )
+ {
+ return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_VALUE );
+ }
+
+ else
+ {
+ return null;
+ }
+ }
+ }
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java
------------------------------------------------------------------------------
svn:eol-style = native