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:53:22 UTC
svn commit: r488368 [20/23] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/ ldapstudio-browser-ui/META-INF/
ldapstudio-browser-ui/about_files/ ldapstudio-browser-ui/icons/
ldapstudio-browser-ui/icons/ovr16/ ldapstudio-browser-ui/s...
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenMultiValuedEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenMultiValuedEditorAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenMultiValuedEditorAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenMultiValuedEditorAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,58 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+public class OpenMultiValuedEditorAction extends AbstractOpenEditorAction
+{
+
+ public OpenMultiValuedEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
+ SearchResultEditorActionGroup actionGroup, ValueProviderManager valueProviderManager )
+ {
+ super( viewer, cursor, actionGroup, valueProviderManager );
+ this.cellEditor = this.valueProviderManager.getMultiValuedValueProvider();
+ this.setText( "Multivalued Editor" );
+ this.setToolTipText( "Multivalued Editor" );
+ this.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_MULTIVALUEDEDITOR ) );
+ }
+
+
+ protected void updateEnabledState()
+ {
+
+ if ( viewer.getCellModifier().canModify( this.selectedSearchResult, this.selectedProperty ) )
+ {
+ this.setEnabled( true );
+ }
+ else
+ {
+ this.setEnabled( false );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,56 @@
+/*
+ * 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.editors.searchresult;
+
+
+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 OpenSearchResultEditorPreferencePage extends Action
+{
+
+ public OpenSearchResultEditorPreferencePage()
+ {
+ super.setText( "Preferences..." );
+ super.setToolTipText( "Preferences..." );
+ super.setEnabled( true );
+ }
+
+
+ public void run()
+ {
+ Shell shell = Display.getCurrent().getActiveShell();
+ String srePageId = BrowserUIConstants.PREFERENCEPAGEID_SEARCHRESULTEDITOR;
+ String attPageId = BrowserUIConstants.PREFERENCEPAGEID_ATTRIBUTES;
+ PreferencesUtil.createPreferenceDialogOn( shell, srePageId, new String[]
+ { srePageId, attPageId }, null ).open();
+ }
+
+
+ public void dispose()
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultDeleteAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultDeleteAction.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultDeleteAction.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultDeleteAction.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.IEntry;
+import org.apache.directory.ldapstudio.browser.ui.actions.DeleteAction;
+
+
+public class SearchResultDeleteAction extends DeleteAction
+{
+
+ public SearchResultDeleteAction()
+ {
+ super();
+ }
+
+
+ protected IEntry[] getEntries() throws Exception
+ {
+ return new IEntry[0];
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditor.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditor.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditor.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,276 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.views.browser.BrowserView;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+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.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;
+
+
+public class SearchResultEditor extends EditorPart implements INavigationLocationProvider, IReusableEditor,
+ IPropertyChangeListener
+{
+
+ private SearchResultEditorConfiguration configuration;
+
+ private SearchResultEditorActionGroup actionGroup;
+
+ private SearchResultEditorWidget mainWidget;
+
+ private SearchResultEditorUniversalListener universalListener;
+
+
+ public static String getId()
+ {
+ return SearchResultEditor.class.getName();
+ }
+
+
+ public void setInput( IEditorInput input )
+ {
+ super.setInput( input );
+ if ( input instanceof SearchResultEditorInput && this.universalListener != null )
+ {
+ SearchResultEditorInput srei = ( SearchResultEditorInput ) input;
+ ISearch search = srei.getSearch();
+ this.universalListener.setInput( search );
+
+ if ( search != null )
+ {
+ // INavigationLocation[] locations =
+ // getSite().getPage().getNavigationHistory().getLocations();
+ // if(locations != null && locations.length > 0) {
+ // if(locations[locations.length-1].getInput() instanceof
+ // SearchResultEditorInput &&
+ // ((SearchResultEditorInput)locations[locations.length-1].getInput()).getSearch()
+ // == search) {
+ // return;
+ // }
+ // }
+ getSite().getPage().getNavigationHistory().markLocation( this );
+ }
+ }
+ }
+
+
+ public void refresh()
+ {
+ if ( this.universalListener != null )
+ {
+ this.universalListener.refreshInput();
+ }
+ }
+
+
+ public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+ {
+ setInput( input );
+ super.setSite( site );
+ }
+
+
+ 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.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ composite.setLayout( layout );
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite,
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_search_result_editor" );
+
+ // create configuration
+ this.configuration = new SearchResultEditorConfiguration( this );
+
+ // create main widget
+ this.mainWidget = new SearchResultEditorWidget( this.configuration );
+ this.mainWidget.createWidget( composite );
+
+ // create actions and context menu (and register global actions)
+ this.actionGroup = new SearchResultEditorActionGroup( this );
+ this.actionGroup.fillToolBar( this.mainWidget.getToolBarManager() );
+ this.actionGroup.fillMenu( this.mainWidget.getMenuManager() );
+ this.actionGroup.enableGlobalActionHandlers( getEditorSite().getActionBars() );
+ this.actionGroup.fillContextMenu( this.configuration.getContextMenuManager( this.mainWidget.getViewer() ) );
+
+ // create the listener
+ this.universalListener = new SearchResultEditorUniversalListener( this );
+ getSite().setSelectionProvider( this.configuration.getCursor( this.mainWidget.getViewer() ) );
+ this.setInput( getEditorInput() );
+
+ BrowserUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+ }
+
+
+ public void setFocus()
+ {
+ this.mainWidget.setFocus();
+ }
+
+
+ public void dispose()
+ {
+
+ SearchResultEditorManager.editorClosed();
+
+ if ( this.configuration != null )
+ {
+ this.actionGroup.dispose();
+ this.actionGroup = null;
+ this.universalListener.dispose();
+ this.universalListener = null;
+ this.mainWidget.dispose();
+ this.mainWidget = null;
+ this.configuration.dispose();
+ this.configuration = null;
+ getSite().setSelectionProvider( null );
+ BrowserUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
+ }
+
+ super.dispose();
+ }
+
+
+ public void doSave( IProgressMonitor monitor )
+ {
+ }
+
+
+ public void doSaveAs()
+ {
+ }
+
+
+ public boolean isDirty()
+ {
+ return false;
+ }
+
+
+ public boolean isSaveAsAllowed()
+ {
+ return false;
+ }
+
+
+ public INavigationLocation createEmptyNavigationLocation()
+ {
+ System.out.println( "SearchResultEditor#createEmptyNavigationLocation()" );
+ return null;
+ }
+
+
+ public INavigationLocation createNavigationLocation()
+ {
+ return new SearchResultEditorNavigationLocation( this );
+ }
+
+
+ public Object getAdapter( Class required )
+ {
+
+ 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()
+ {
+ ISelection selection = getConfiguration().getCursor( getMainWidget().getViewer() ).getSelection();
+ return new ShowInContext( getMainWidget().getViewer().getInput(), selection );
+ }
+ };
+ }
+
+ return super.getAdapter( required );
+ }
+
+
+ public SearchResultEditorActionGroup getActionGroup()
+ {
+ return actionGroup;
+ }
+
+
+ public SearchResultEditorConfiguration getConfiguration()
+ {
+ return configuration;
+ }
+
+
+ public SearchResultEditorWidget getMainWidget()
+ {
+ return mainWidget;
+ }
+
+
+ public SearchResultEditorUniversalListener getUniversalListener()
+ {
+ return universalListener;
+ }
+
+
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ // if(this.mainWidget.getViewer() != null) {
+ // this.mainWidget.getViewer().refresh();
+ // }
+ this.refresh();
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorActionGroup.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,530 @@
+/*
+ * 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.editors.searchresult;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyAttributeDescriptionAction;
+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.CopySearchFilterAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyUrlAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.CopyValueAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.LocateDnInDitAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewBatchOperationAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewSearchAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.NewValueAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.OpenSchemaBrowserAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.OpenSearchResultAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.PropertiesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.RefreshAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.ShowRawValuesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.ValueEditorPreferencesAction;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.BrowserActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.actions.proxy.SearchResultEditorActionProxy;
+import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProvider;
+
+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.TableViewer;
+import org.eclipse.ui.IActionBars;
+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;
+
+
+public class SearchResultEditorActionGroup implements IMenuListener
+{
+
+ private ShowDNAction showDNAction;
+
+ private ShowLinksAction showLinksAction;
+
+ private ShowRawValuesAction showRawValuesAction;
+
+ private OpenSearchResultEditorPreferencePage openSearchResultEditorPreferencePage;
+
+ private ShowQuickFilterAction showQuickFilterAction;
+
+ private OpenDefaultEditorAction openDefaultEditorAction;
+
+ private OpenBestEditorAction openBestEditorAction;
+
+ private OpenEditorAction[] openEditorActions;
+
+ private ValueEditorPreferencesAction openValueEditorPreferencesAction;
+
+ private static final String copyTableAction = "copyTableAction";
+
+ private static final String refreshSearchAction = "refreshSearchAction";
+
+ private final static String newValueAction = "newValueAction";
+
+ private final static String newSearchAction = "newSearchAction";
+
+ private static final String newBatchOperationAction = "newBatchOperationAction";
+
+ private final static String copyAction = "copyAction";
+
+ private final static String pasteAction = "pasteAction";
+
+ private final static String deleteAction = "deleteAction";
+
+ private static final String copyDnAction = "copyDnAction";
+
+ private static final String copyUrlAction = "copyUrlAction";
+
+ private static final String copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction";
+
+ private static final String copyValueUtf8Action = "copyValueUtf8Action";
+
+ private static final String copyValueBase64Action = "copyValueBase64Action";
+
+ private static final String copyValueHexAction = "copyValueHexAction";
+
+ private static final String copyValueAsLdifAction = "copyValueAsLdifAction";
+
+ private static final String copySearchFilterAction = "copySearchFilterAction";
+
+ private static final String copyNotSearchFilterAction = "copyNotSearchFilterAction";
+
+ private static final String copyAndSearchFilterAction = "copyAndSearchFilterAction";
+
+ private static final String copyOrSearchFilterAction = "copyOrSearchFilterAction";
+
+ private static final String openSearchResultAction = "showEntryInSearchResultsAction";
+
+ private static final String locateDnInDitAction = "locateDnInDitAction";
+
+ private static final String showOcdAction = "showOcdAction";
+
+ private static final String showAtdAction = "showAtdAction";
+
+ private static final String showEqualityMrdAction = "showEqualityMrdAction";
+
+ private static final String showSubstringMrdAction = "showSubstringMrdAction";
+
+ private static final String showOrderingMrdAction = "showOrderingMrdAction";
+
+ private static final String showLsdAction = "showLsdAction";
+
+ private final static String propertyDialogAction = "propertyDialogAction";
+
+ private Map searchResultEditorActionMap;
+
+ private IActionBars actionBars;
+
+ private SearchResultEditor searchResultEditor;
+
+
+ public SearchResultEditorActionGroup( SearchResultEditor searchResultEditor )
+ {
+ this.searchResultEditor = searchResultEditor;
+ this.searchResultEditorActionMap = new HashMap();
+
+ TableViewer viewer = searchResultEditor.getMainWidget().getViewer();
+ SearchResultEditorCursor cursor = searchResultEditor.getConfiguration().getCursor( viewer );
+
+ this.showDNAction = new ShowDNAction();
+ this.showLinksAction = new ShowLinksAction();
+ this.showRawValuesAction = new ShowRawValuesAction();
+ this.openSearchResultEditorPreferencePage = new OpenSearchResultEditorPreferencePage();
+ this.showQuickFilterAction = new ShowQuickFilterAction( searchResultEditor.getMainWidget()
+ .getQuickFilterWidget() );
+
+ this.openBestEditorAction = new OpenBestEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
+ viewer ), this, searchResultEditor.getConfiguration().getValueProviderManager( viewer ) );
+ this.openDefaultEditorAction = new OpenDefaultEditorAction( this.openBestEditorAction );
+ ValueProvider[] valueProviders = searchResultEditor.getConfiguration().getValueProviderManager( viewer )
+ .getAllValueProviders();
+ this.openEditorActions = new OpenEditorAction[valueProviders.length];
+ for ( int i = 0; i < this.openEditorActions.length; i++ )
+ {
+ this.openEditorActions[i] = new OpenEditorAction( viewer, searchResultEditor.getConfiguration().getCursor(
+ viewer ), this, searchResultEditor.getConfiguration().getValueProviderManager( viewer ),
+ valueProviders[i] );
+ }
+ this.openValueEditorPreferencesAction = new ValueEditorPreferencesAction();
+
+ this.searchResultEditorActionMap.put( copyTableAction, new SearchResultEditorActionProxy( cursor,
+ new CopyEntryAsCsvAction( CopyEntryAsCsvAction.MODE_TABLE ) ) );
+ this.searchResultEditorActionMap.put( refreshSearchAction, new SearchResultEditorActionProxy( cursor,
+ new RefreshAction() ) );
+
+ this.searchResultEditorActionMap.put( newValueAction, new SearchResultEditorActionProxy( cursor,
+ new NewValueAction() ) );
+ this.searchResultEditorActionMap.put( newSearchAction, new SearchResultEditorActionProxy( cursor,
+ new NewSearchAction() ) );
+ this.searchResultEditorActionMap.put( newBatchOperationAction, new SearchResultEditorActionProxy( cursor,
+ new NewBatchOperationAction() ) );
+
+ this.searchResultEditorActionMap.put( locateDnInDitAction, new SearchResultEditorActionProxy( cursor,
+ new LocateDnInDitAction() ) );
+ this.searchResultEditorActionMap.put( openSearchResultAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSearchResultAction() ) );
+
+ this.searchResultEditorActionMap.put( showOcdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) );
+ this.searchResultEditorActionMap.put( showAtdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) );
+ this.searchResultEditorActionMap.put( showEqualityMrdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) );
+ this.searchResultEditorActionMap.put( showSubstringMrdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) );
+ this.searchResultEditorActionMap.put( showOrderingMrdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) );
+ this.searchResultEditorActionMap.put( showLsdAction, new SearchResultEditorActionProxy( cursor,
+ new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SYNTAX ) ) );
+
+ this.searchResultEditorActionMap.put( pasteAction, new SearchResultEditorActionProxy( cursor,
+ new SearchResultEditorPasteAction() ) );
+ this.searchResultEditorActionMap.put( copyAction, new SearchResultEditorActionProxy( cursor, new CopyAction(
+ ( BrowserActionProxy ) this.searchResultEditorActionMap.get( pasteAction ) ) ) );
+ this.searchResultEditorActionMap.put( deleteAction, new SearchResultEditorActionProxy( cursor,
+ new SearchResultDeleteAction() ) );
+
+ this.searchResultEditorActionMap.put( copyDnAction, new SearchResultEditorActionProxy( cursor,
+ new CopyDnAction() ) );
+ this.searchResultEditorActionMap.put( copyUrlAction, new SearchResultEditorActionProxy( cursor,
+ new CopyUrlAction() ) );
+ this.searchResultEditorActionMap.put( copyAttriuteDescriptionAction, new SearchResultEditorActionProxy( cursor,
+ new CopyAttributeDescriptionAction() ) );
+ this.searchResultEditorActionMap.put( copyValueUtf8Action, new SearchResultEditorActionProxy( cursor,
+ new CopyValueAction( CopyValueAction.MODE_UTF8 ) ) );
+ this.searchResultEditorActionMap.put( copyValueBase64Action, new SearchResultEditorActionProxy( cursor,
+ new CopyValueAction( CopyValueAction.MODE_BASE64 ) ) );
+ this.searchResultEditorActionMap.put( copyValueHexAction, new SearchResultEditorActionProxy( cursor,
+ new CopyValueAction( CopyValueAction.MODE_HEX ) ) );
+ this.searchResultEditorActionMap.put( copyValueAsLdifAction, new SearchResultEditorActionProxy( cursor,
+ new CopyValueAction( CopyValueAction.MODE_LDIF ) ) );
+
+ this.searchResultEditorActionMap.put( copySearchFilterAction, new SearchResultEditorActionProxy( cursor,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) );
+ this.searchResultEditorActionMap.put( copyNotSearchFilterAction, new SearchResultEditorActionProxy( cursor,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) );
+ this.searchResultEditorActionMap.put( copyAndSearchFilterAction, new SearchResultEditorActionProxy( cursor,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) );
+ this.searchResultEditorActionMap.put( copyOrSearchFilterAction, new SearchResultEditorActionProxy( cursor,
+ new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) );
+
+ this.searchResultEditorActionMap.put( propertyDialogAction, new SearchResultEditorActionProxy( cursor,
+ new PropertiesAction() ) );
+
+ }
+
+
+ public void dispose()
+ {
+
+ if ( this.searchResultEditor != null )
+ {
+
+ this.showRawValuesAction.dispose();
+ this.showRawValuesAction = null;
+ this.showDNAction.dispose();
+ this.showDNAction = null;
+ this.showLinksAction.dispose();
+ this.showLinksAction = null;
+ this.openSearchResultEditorPreferencePage = null;
+ this.showQuickFilterAction.dispose();
+ this.showQuickFilterAction = null;
+
+ this.openDefaultEditorAction.dispose();
+ this.openDefaultEditorAction = null;
+ this.openBestEditorAction.dispose();
+ this.openBestEditorAction = null;
+ for ( int i = 0; i < this.openEditorActions.length; i++ )
+ {
+ this.openEditorActions[i].dispose();
+ this.openEditorActions[i] = null;
+ }
+ this.openValueEditorPreferencesAction.dispose();
+ this.openValueEditorPreferencesAction = null;
+
+ for ( Iterator it = this.searchResultEditorActionMap.keySet().iterator(); it.hasNext(); )
+ {
+ String key = ( String ) it.next();
+ SearchResultEditorActionProxy action = ( SearchResultEditorActionProxy ) this.searchResultEditorActionMap
+ .get( key );
+ action.dispose();
+ action = null;
+ it.remove();
+ }
+ this.searchResultEditorActionMap.clear();
+ this.searchResultEditorActionMap = null;
+
+ this.actionBars = null;
+ this.searchResultEditor = null;
+ }
+ }
+
+
+ public void fillToolBar( IToolBarManager toolBarManager )
+ {
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( newValueAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyTableAction ) );
+ toolBarManager.add( new Separator() );
+ toolBarManager.add( this.showQuickFilterAction );
+ toolBarManager.update( true );
+ }
+
+
+ public void fillMenu( IMenuManager menuManager )
+ {
+ menuManager.add( this.showDNAction );
+ menuManager.add( this.showLinksAction );
+ menuManager.add( this.showRawValuesAction );
+ menuManager.add( new Separator() );
+ menuManager.add( this.openSearchResultEditorPreferencePage );
+ menuManager.addMenuListener( new IMenuListener()
+ {
+ public void menuAboutToShow( IMenuManager manager )
+ {
+ showRawValuesAction.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_SHOW_RAW_VALUES ) );
+ }
+ } );
+ menuManager.update( true );
+ }
+
+
+ public void enableGlobalActionHandlers( IActionBars actionBars )
+ {
+ this.actionBars = actionBars;
+ this.activateGlobalActionHandlers();
+ }
+
+
+ public void fillContextMenu( IMenuManager menuManager )
+ {
+ menuManager.setRemoveAllWhenShown( true );
+ menuManager.addMenuListener( this );
+ }
+
+
+ public void menuAboutToShow( IMenuManager menuManager )
+ {
+
+ // new
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newValueAction ) );
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newSearchAction ) );
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( newBatchOperationAction ) );
+ menuManager.add( new Separator() );
+
+ // navigation
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction ) );
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction ) );
+ MenuManager schemaMenuManager = new MenuManager( "Open Schema Browser" );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showOcdAction ) );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showAtdAction ) );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showEqualityMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showSubstringMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( showOrderingMrdAction ) );
+ schemaMenuManager.add( ( IAction ) this.searchResultEditorActionMap.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 ) this.searchResultEditorActionMap.get( copyAction ) );
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( pasteAction ) );
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
+ MenuManager advancedMenuManager = new MenuManager( "Advanced" );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyDnAction ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyUrlAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyAttriuteDescriptionAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueUtf8Action ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueBase64Action ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueHexAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyValueAsLdifAction ) );
+ advancedMenuManager.add( new Separator() );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copySearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyNotSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyAndSearchFilterAction ) );
+ advancedMenuManager.add( ( IAction ) this.searchResultEditorActionMap.get( copyOrSearchFilterAction ) );
+ menuManager.add( advancedMenuManager );
+ menuManager.add( new Separator() );
+
+ // edit
+ menuManager.add( this.openDefaultEditorAction );
+ MenuManager editorMenuManager = new MenuManager( "Edit Value With" );
+ if ( this.openBestEditorAction.isEnabled() )
+ {
+ editorMenuManager.add( this.openBestEditorAction );
+ editorMenuManager.add( new Separator() );
+ }
+ for ( int i = 0; i < this.openEditorActions.length; i++ )
+ {
+ if ( this.openEditorActions[i].isEnabled()
+ && this.openEditorActions[i].getValueProvider().getClass() != this.openBestEditorAction
+ .getBestValueProvider().getClass() )
+ {
+ editorMenuManager.add( this.openEditorActions[i] );
+ }
+ }
+ editorMenuManager.add( new Separator() );
+ editorMenuManager.add( this.openValueEditorPreferencesAction );
+ menuManager.add( editorMenuManager );
+ menuManager.add( new Separator() );
+
+ // refresh
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
+ menuManager.add( new Separator() );
+
+ // additions
+ menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
+
+ // / properties
+ menuManager.add( ( IAction ) this.searchResultEditorActionMap.get( propertyDialogAction ) );
+
+ }
+
+
+ public void activateGlobalActionHandlers()
+ {
+
+ if ( this.actionBars != null )
+ {
+ actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), ( IAction ) this.searchResultEditorActionMap
+ .get( copyAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(),
+ ( IAction ) this.searchResultEditorActionMap.get( pasteAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(),
+ ( IAction ) this.searchResultEditorActionMap.get( deleteAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(),
+ ( IAction ) this.searchResultEditorActionMap.get( refreshSearchAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(),
+ ( IAction ) this.searchResultEditorActionMap.get( propertyDialogAction ) );
+ actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), this.showQuickFilterAction );
+ actionBars.updateActionBars();
+ }
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction nva = ( IAction ) this.searchResultEditorActionMap.get( newValueAction );
+ commandService.getCommand( nva.getActionDefinitionId() ).setHandler( new ActionHandler( nva ) );
+ IAction lid = ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( new ActionHandler( lid ) );
+ IAction osr = ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction );
+ commandService.getCommand( osr.getActionDefinitionId() ).setHandler( new ActionHandler( osr ) );
+ commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler(
+ new ActionHandler( openDefaultEditorAction ) );
+ }
+
+ }
+
+
+ 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.REFRESH.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), null );
+ actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), null );
+ actionBars.updateActionBars();
+ }
+
+ ICommandService commandService = ( ICommandService ) PlatformUI.getWorkbench().getAdapter(
+ ICommandService.class );
+ if ( commandService != null )
+ {
+ IAction nva = ( IAction ) this.searchResultEditorActionMap.get( newValueAction );
+ commandService.getCommand( nva.getActionDefinitionId() ).setHandler( null );
+ IAction lid = ( IAction ) this.searchResultEditorActionMap.get( locateDnInDitAction );
+ commandService.getCommand( lid.getActionDefinitionId() ).setHandler( null );
+ IAction osr = ( IAction ) this.searchResultEditorActionMap.get( openSearchResultAction );
+ commandService.getCommand( osr.getActionDefinitionId() ).setHandler( null );
+ commandService.getCommand( openDefaultEditorAction.getActionDefinitionId() ).setHandler( null );
+ }
+
+ }
+
+
+ public OpenBestEditorAction getOpenBestEditorAction()
+ {
+ return openBestEditorAction;
+ }
+
+
+ public void setInput( ISearch search )
+ {
+ for ( Iterator it = this.searchResultEditorActionMap.values().iterator(); it.hasNext(); )
+ {
+ SearchResultEditorActionProxy action = ( SearchResultEditorActionProxy ) it.next();
+ action.inputChanged( search );
+ }
+ }
+
+
+ public boolean isEditorActive()
+ {
+ if ( this.openDefaultEditorAction.isActive() )
+ {
+ return true;
+ }
+ if ( this.openBestEditorAction.isActive() )
+ {
+ return true;
+ }
+ for ( int i = 0; i < this.openEditorActions.length; i++ )
+ {
+ if ( this.openEditorActions[i].isActive() )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCellModifier.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,210 @@
+/*
+ * 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.editors.searchresult;
+
+
+import java.util.Iterator;
+
+import org.apache.directory.ldapstudio.browser.core.events.ModelModifier;
+import org.apache.directory.ldapstudio.browser.core.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Item;
+
+
+public class SearchResultEditorCellModifier implements ICellModifier, ModelModifier
+{
+
+ private TableViewer viewer;
+
+ private ValueProviderManager valueProviderManager;
+
+
+ public SearchResultEditorCellModifier( TableViewer viewer, ValueProviderManager valueProviderManager )
+ {
+ this.viewer = viewer;
+ this.valueProviderManager = valueProviderManager;
+ }
+
+
+ public void dispose()
+ {
+ this.viewer = null;
+ this.valueProviderManager = null;
+ }
+
+
+ public boolean canModify( Object element, String property )
+ {
+
+ if ( element != null && element instanceof ISearchResult && property != null )
+ {
+ ISearchResult result = ( ISearchResult ) element;
+ AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+
+ // check DN
+ if ( BrowserUIConstants.DN.equals( property ) )
+ {
+ return false;
+ }
+
+ // attribute dummy
+ if ( ah == null )
+ {
+ try
+ {
+ ah = new AttributeHierachie( result.getEntry(), property, new IAttribute[]
+ { new Attribute( result.getEntry(), property ) } );
+ }
+ catch ( ModelModificationException e )
+ {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ // check schema modifyable
+ boolean isOneModifyable = false;
+ for ( Iterator it = ah.iterator(); it.hasNext(); )
+ {
+ IAttribute attribute = ( IAttribute ) it.next();
+ if ( SchemaUtils.isModifyable( attribute.getAttributeTypeDescription() ) )
+ {
+ isOneModifyable = true;
+ break;
+ }
+ }
+ if ( !isOneModifyable )
+ {
+ return false;
+ }
+
+ // check if property is valid for the entry
+ boolean isOneValid = false;
+ for ( Iterator it = ah.iterator(); it.hasNext(); )
+ {
+ IAttribute attribute = ( IAttribute ) it.next();
+ if ( attribute.isObjectClassAttribute() || attribute.isMustAttribute() || attribute.isMayAttribute() )
+ {
+ isOneValid = true;
+ break;
+ }
+ }
+ if ( !isOneValid )
+ {
+ return false;
+ }
+
+ // call value provider
+ return this.valueProviderManager.getCurrentValueProvider( ah ).getRawValue( ah ) != null;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ public Object getValue( Object element, String property )
+ {
+
+ if ( element != null && element instanceof ISearchResult && property != null )
+ {
+ ISearchResult result = ( ISearchResult ) element;
+ AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+
+ if ( !this.canModify( element, property ) )
+ {
+ return null;
+ }
+
+ if ( ah == null )
+ {
+ try
+ {
+ ah = new AttributeHierachie( result.getEntry(), property, new IAttribute[]
+ { new Attribute( result.getEntry(), property ) } );
+ }
+ catch ( ModelModificationException e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ return this.valueProviderManager.getCurrentValueProvider( ah ).getRawValue( ah );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public void modify( Object element, String property, Object newRawValue )
+ {
+
+ if ( element != null && element instanceof Item )
+ {
+ element = ( ( Item ) element ).getData();
+ }
+
+ if ( element != null && element instanceof ISearchResult && property != null )
+ {
+ ISearchResult result = ( ISearchResult ) element;
+ AttributeHierachie ah = result.getAttributeWithSubtypes( property );
+
+ try
+ {
+ // switch operation:
+ if ( ah == null && newRawValue != null )
+ {
+ this.valueProviderManager.getCurrentValueProvider( result.getEntry(), property ).create(
+ result.getEntry(), property, newRawValue );
+ }
+ else if ( ah != null && newRawValue == null )
+ {
+ this.valueProviderManager.getCurrentValueProvider( ah ).delete( ah );
+ }
+ else if ( ah != null && ah.size() == 1 && ah.getAttribute().getValueSize() == 1 && newRawValue != null )
+ {
+ this.valueProviderManager.getCurrentValueProvider( ah ).modify( ah.getAttribute().getValues()[0],
+ newRawValue );
+ }
+ }
+ catch ( ModelModificationException mme )
+ {
+ MessageDialog.openError( this.viewer.getTable().getShell(), "Error While Modifying Value", mme
+ .getMessage() );
+ }
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorConfiguration.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,168 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.ui.valueproviders.ValueProviderManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class SearchResultEditorConfiguration
+{
+
+ private boolean disposed = false;
+
+ protected SearchResultEditorCursor cursor;
+
+ protected SearchResultEditorSorter sorter;
+
+ protected SearchResultEditorFilter filter;
+
+ protected SearchResultEditorContentProvider contentProvider;
+
+ protected SearchResultEditorLabelProvider labelProvider;
+
+ protected SearchResultEditorCellModifier cellModifier;
+
+ protected ValueProviderManager valueProviderManager;
+
+ protected MenuManager contextMenuManager;
+
+
+ public SearchResultEditorConfiguration( IWorkbenchPart part )
+ {
+ super();
+ }
+
+
+ public void dispose()
+ {
+ if ( !this.disposed )
+ {
+
+ if ( this.contentProvider != null )
+ this.contentProvider.dispose();
+ this.contentProvider = null;
+
+ if ( this.labelProvider != null )
+ this.labelProvider.dispose();
+ this.labelProvider = null;
+
+ if ( this.cellModifier != null )
+ this.cellModifier.dispose();
+ this.cellModifier = null;
+
+ if ( this.valueProviderManager != null )
+ this.valueProviderManager.dispose();
+ this.valueProviderManager = null;
+
+ if ( this.contextMenuManager != null )
+ this.contextMenuManager.dispose();
+ this.contextMenuManager = null;
+
+ if ( this.cursor != null )
+ this.cursor.dispose();
+ this.cursor = null;
+
+ this.disposed = true;
+ }
+ }
+
+
+ public SearchResultEditorSorter getSorter()
+ {
+ if ( this.sorter == null )
+ this.sorter = new SearchResultEditorSorter();
+
+ return sorter;
+ }
+
+
+ public SearchResultEditorFilter getFilter()
+ {
+ if ( this.filter == null )
+ this.filter = new SearchResultEditorFilter();
+
+ return filter;
+ }
+
+
+ public IMenuManager getContextMenuManager( TableViewer viewer )
+ {
+ if ( this.contextMenuManager == null )
+ {
+ this.contextMenuManager = new MenuManager();
+ Menu menu = this.contextMenuManager.createContextMenu( viewer.getControl() );
+ getCursor( viewer ).setMenu( menu );
+ }
+ return this.contextMenuManager;
+ }
+
+
+ public SearchResultEditorContentProvider getContentProvider( SearchResultEditorWidget mainWidget )
+ {
+ if ( this.contentProvider == null )
+ this.contentProvider = new SearchResultEditorContentProvider( mainWidget, this );
+
+ return contentProvider;
+ }
+
+
+ public SearchResultEditorLabelProvider getLabelProvider( TableViewer viewer )
+ {
+ if ( this.labelProvider == null )
+ this.labelProvider = new SearchResultEditorLabelProvider( viewer, this.getValueProviderManager( viewer ) );
+
+ return labelProvider;
+ }
+
+
+ public SearchResultEditorCellModifier getCellModifier( TableViewer viewer )
+ {
+ if ( this.cellModifier == null )
+ this.cellModifier = new SearchResultEditorCellModifier( viewer, this.getValueProviderManager( viewer ) );
+
+ return cellModifier;
+ }
+
+
+ public SearchResultEditorCursor getCursor( TableViewer viewer )
+ {
+ if ( this.cursor == null )
+ this.cursor = new SearchResultEditorCursor( viewer );
+
+ return cursor;
+ }
+
+
+ public ValueProviderManager getValueProviderManager( TableViewer viewer )
+ {
+ if ( this.valueProviderManager == null )
+ this.valueProviderManager = new ValueProviderManager( viewer.getTable() );
+
+ return valueProviderManager;
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorContentProvider.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorContentProvider.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorContentProvider.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorContentProvider.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,205 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+import org.apache.directory.ldapstudio.browser.ui.jobs.FilterAndSortJob;
+import org.apache.directory.ldapstudio.browser.ui.jobs.RunnableContextJobAdapter;
+import org.apache.directory.ldapstudio.browser.ui.jobs.TimeTriggeredProgressMonitorDialog;
+
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+
+
+public class SearchResultEditorContentProvider implements ILazyContentProvider
+{
+
+ private SearchResultEditorWidget mainWidget;
+
+ private SearchResultEditorConfiguration configuration;
+
+ private Object input;
+
+ private Object[] elements;
+
+ private Object[] filteredAndSortedElements;
+
+
+ public SearchResultEditorContentProvider( SearchResultEditorWidget mainWidget,
+ SearchResultEditorConfiguration configuration )
+ {
+ this.mainWidget = mainWidget;
+ this.configuration = configuration;
+
+ this.configuration.getFilter().connect( this );
+ this.configuration.getSorter().connect( this );
+ }
+
+
+ public void dispose()
+ {
+ this.mainWidget = null;
+ this.configuration = null;
+ this.elements = null;
+ this.filteredAndSortedElements = null;
+ }
+
+
+ public void refresh()
+ {
+ this.filterAndSort();
+ this.mainWidget.getViewer().refresh();
+ }
+
+
+ private void filterAndSort()
+ {
+
+ this.filteredAndSortedElements = elements;
+
+ // filter and sort, use Job if too much elements
+ if ( this.configuration.getFilter().isFiltered() || this.configuration.getSorter().isSorted() )
+ {
+ if ( elements.length > 1000 && this.mainWidget.getViewer() != null
+ && !this.mainWidget.getViewer().getTable().isDisposed() )
+ {
+ FilterAndSortJob job = new FilterAndSortJob( this.configuration, this.mainWidget, this.elements );
+ RunnableContextJobAdapter.execute( job, new TimeTriggeredProgressMonitorDialog( Display.getCurrent()
+ .getActiveShell(), 5000 ) );
+ this.filteredAndSortedElements = job.getFilteredAndSortedElements();
+ }
+ else if ( elements.length > 0 && this.mainWidget.getViewer() != null
+ && !this.mainWidget.getViewer().getTable().isDisposed() )
+ {
+ this.filteredAndSortedElements = this.configuration.getFilter().filter( this.mainWidget.getViewer(),
+ "", elements );
+ this.configuration.getSorter().sort( this.mainWidget.getViewer(), this.filteredAndSortedElements );
+ }
+ }
+
+ // update virtual table
+ this.mainWidget.getViewer().setItemCount( this.filteredAndSortedElements.length );
+
+ // update state
+ String url = "";
+ boolean enabled = true;
+ if ( input != null && input instanceof ISearch )
+ {
+ ISearch search = ( ISearch ) input;
+
+ if ( filteredAndSortedElements.length < elements.length )
+ {
+ url += filteredAndSortedElements.length + " of ";
+ }
+
+ if ( search.getSearchResults() == null )
+ {
+ url += "Search not performed - ";
+ enabled = false;
+ }
+ else if ( search.getSearchResults().length == 1 )
+ {
+ url += search.getSearchResults().length + " Result - ";
+ }
+ else
+ {
+ url += search.getSearchResults().length + " Results - ";
+ }
+
+ // url += search.getURL();
+ url += "Search Base: " + search.getSearchBase().toString() + " - ";
+ url += "Filter: " + search.getFilter();
+
+ boolean showDn = BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean(
+ BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN )
+ || search.getReturningAttributes().length == 0;
+ this.configuration.getFilter().inputChanged( search, showDn );
+ this.configuration.getSorter().inputChanged( search, showDn );
+ }
+ else
+ {
+ url = "No search selected";;
+ enabled = false;
+ }
+
+ if ( this.mainWidget.getInfoText() != null && !this.mainWidget.getInfoText().isDisposed() )
+ {
+ this.mainWidget.getInfoText().setText( url );
+ }
+ if ( this.mainWidget.getQuickFilterWidget() != null )
+ {
+ this.mainWidget.getQuickFilterWidget().setEnabled( enabled );
+ }
+ if ( this.mainWidget.getViewer() != null && !this.mainWidget.getViewer().getTable().isDisposed() )
+ {
+ this.mainWidget.getViewer().getTable().setEnabled( enabled );
+ }
+
+ }
+
+
+ public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ {
+ this.input = newInput;
+ this.elements = getElements( newInput );
+ // this.filterAndSort();
+ }
+
+
+ public Object[] getElements( Object inputElement )
+ {
+ if ( inputElement != null && inputElement instanceof ISearch )
+ {
+ ISearch search = ( ISearch ) inputElement;
+ return search.getSearchResults() != null ? search.getSearchResults() : new Object[0];
+ }
+ else
+ {
+ return new Object[]
+ {};
+ // return new Object[]{inputElement};
+ }
+ }
+
+
+ public TableViewer getViewer()
+ {
+ return this.mainWidget.getViewer();
+ }
+
+
+ public void updateElement( int index )
+ {
+ // if(sortedAndSortedElements instanceof ISearchResult[]) {
+ if ( filteredAndSortedElements != null && filteredAndSortedElements.length > 0
+ && index < filteredAndSortedElements.length )
+ {
+ // System.out.println(index);
+ mainWidget.getViewer().replace( filteredAndSortedElements[index], index );
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorCursor.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,246 @@
+/*
+ * 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.editors.searchresult;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent;
+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.internal.model.Attribute;
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableCursor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Display;
+
+
+public class SearchResultEditorCursor extends TableCursor implements ISelectionProvider, EntryUpdateListener
+{
+
+ private TableViewer viewer;
+
+
+ public SearchResultEditorCursor( TableViewer viewer )
+ {
+ super( viewer.getTable(), SWT.NONE );
+ this.viewer = viewer;
+
+ setBackground( Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION ) );
+ setForeground( Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION_TEXT ) );
+
+ EventRegistry.addEntryUpdateListener( this );
+
+ initSelectionChecker();
+ initSelectionProvider();
+ }
+
+
+ private void initSelectionChecker()
+ {
+ this.addSelectionListener( new SelectionListener()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ checkSelection();
+ }
+
+
+ public void widgetDefaultSelected( SelectionEvent e )
+ {
+ checkSelection();
+ }
+
+
+ private void checkSelection()
+ {
+ if ( viewer != null && viewer.getColumnProperties() != null
+ && viewer.getColumnProperties().length - 1 < getColumn() )
+ {
+ setSelection( getRow(), viewer.getColumnProperties().length - 1 );
+ }
+ }
+ } );
+ }
+
+
+ public boolean setFocus()
+ {
+ return super.setFocus();
+ }
+
+
+ private void initSelectionProvider()
+ {
+ this.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ for ( Iterator it = selectionChangesListenerList.iterator(); it.hasNext(); )
+ {
+ ( ( ISelectionChangedListener ) it.next() ).selectionChanged( new SelectionChangedEvent(
+ SearchResultEditorCursor.this, getSelection() ) );
+ }
+ }
+ } );
+ }
+
+
+ public void dispose()
+ {
+ EventRegistry.removeEntryUpdateListener( this );
+ this.viewer = null;
+ super.dispose();
+ }
+
+
+ public void entryUpdated( EntryModificationEvent event )
+ {
+ this.viewer.refresh();
+ this.redraw();
+ }
+
+
+ public String getSelectedProperty()
+ {
+ if ( !this.isDisposed() && this.getRow() != null && this.viewer != null
+ && this.viewer.getColumnProperties() != null
+ && this.viewer.getColumnProperties().length >= this.getColumn() + 1 )
+ {
+ String property = ( String ) this.viewer.getColumnProperties()[this.getColumn()];
+ return property;
+ }
+ return null;
+ }
+
+
+ public AttributeHierachie getSelectedAttributeHierarchie()
+ {
+ if ( !this.isDisposed() && this.getRow() != null && this.viewer != null
+ && this.viewer.getColumnProperties() != null
+ && this.viewer.getColumnProperties().length >= this.getColumn() + 1 )
+ {
+ Object o = this.getRow().getData();
+ String property = ( String ) this.viewer.getColumnProperties()[this.getColumn()];
+ if ( o instanceof ISearchResult && !BrowserUIConstants.DN.equals( property ) )
+ {
+ ISearchResult sr = ( ISearchResult ) o;
+ AttributeHierachie ah = sr.getAttributeWithSubtypes( property );
+
+ if ( ah == null )
+ {
+ try
+ {
+ ah = new AttributeHierachie( sr.getEntry(), property, new IAttribute[]
+ { new Attribute( sr.getEntry(), property ) } );
+ }
+ catch ( ModelModificationException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return ah;
+ }
+ }
+ return null;
+ }
+
+
+ public ISearchResult getSelectedSearchResult()
+ {
+ if ( !this.isDisposed() && this.getRow() != null )
+ {
+ Object o = this.getRow().getData();
+ if ( o instanceof ISearchResult )
+ {
+ return ( ISearchResult ) o;
+ }
+ }
+ return null;
+ }
+
+ private List selectionChangesListenerList = new ArrayList();
+
+
+ public void addSelectionChangedListener( ISelectionChangedListener listener )
+ {
+ if ( !this.selectionChangesListenerList.contains( listener ) )
+ {
+ this.selectionChangesListenerList.add( listener );
+ }
+ }
+
+
+ public ISelection getSelection()
+ {
+ ISearchResult searchResult = this.getSelectedSearchResult();
+ AttributeHierachie ah = this.getSelectedAttributeHierarchie();
+ String property = this.getSelectedProperty();
+ // String attributeName = this.getSelectedAttributeName();
+
+ // System.out.println(attributes.length);
+
+ List list = new ArrayList();
+ if ( searchResult != null )
+ list.add( searchResult );
+ if ( ah != null )
+ list.add( ah );
+ if ( property != null )
+ {
+ list.add( property );
+ }
+ // if(attributeName != null) list.add(attributeName);
+
+ return new StructuredSelection( list );
+ }
+
+
+ public void removeSelectionChangedListener( ISelectionChangedListener listener )
+ {
+ if ( this.selectionChangesListenerList.contains( listener ) )
+ {
+ this.selectionChangesListenerList.remove( listener );
+ }
+ }
+
+
+ public void setSelection( ISelection selection )
+ {
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorFilter.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,190 @@
+/*
+ * 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.editors.searchresult;
+
+
+import java.util.ArrayList;
+
+import org.apache.directory.ldapstudio.browser.core.model.AttributeHierachie;
+import org.apache.directory.ldapstudio.browser.core.model.IAttribute;
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
+import org.apache.directory.ldapstudio.browser.core.model.IValue;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+public class SearchResultEditorFilter extends ViewerFilter
+{
+
+ protected SearchResultEditorContentProvider contentProvider;
+
+ protected String quickFilterValue;
+
+ private boolean showDn;
+
+
+ public SearchResultEditorFilter()
+ {
+ this.quickFilterValue = "";
+ }
+
+
+ public void connect( SearchResultEditorContentProvider contentProvider )
+ {
+ this.contentProvider = contentProvider;
+ }
+
+
+ public void inputChanged( ISearch newSearch, boolean showDn )
+ {
+ this.showDn = showDn;
+ }
+
+
+ public boolean isFiltered()
+ {
+ return this.quickFilterValue != null && !"".equals( quickFilterValue );
+ }
+
+
+ public Object[] filter( Viewer viewer, Object parent, Object[] elements )
+ {
+
+ if ( isFiltered() )
+ {
+ int size = elements.length;
+ ArrayList out = new ArrayList( size );
+ for ( int i = 0; i < size; ++i )
+ {
+ Object element = elements[i];
+ if ( select( viewer, parent, element ) )
+ out.add( element );
+ }
+
+ return out.toArray();
+ }
+ else
+ {
+ return elements;
+ }
+
+ }
+
+
+ public boolean select( Viewer viewer, Object parentElement, Object element )
+ {
+
+ if ( element instanceof ISearchResult )
+ {
+ ISearchResult searchResult = ( ISearchResult ) element;
+
+ String[] returningAttributes = searchResult.getSearch().getReturningAttributes();
+ for ( int r = 0; r < returningAttributes.length; r++ )
+ {
+ String ra = returningAttributes[r];
+ AttributeHierachie ah = searchResult.getAttributeWithSubtypes( ra );
+ if ( ah != null )
+ {
+ IAttribute[] attributes = ah.getAttributes();
+ for ( int i = 0; i < attributes.length; i++ )
+ {
+ IValue[] values = attributes[i].getValues();
+ for ( int k = 0; k < values.length; k++ )
+ {
+ if ( this.goesThroughQuickFilter( values[k] ) )
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ // IAttribute[] attributes = searchResult.getAttributes();
+ // for (int i = 0; i < attributes.length; i++) {
+ // IValue[] values = attributes[i].getValues();
+ // for (int k = 0; k < values.length; k++) {
+ // if (this.goesThroughQuickFilter(values[k])) {
+ // return true;
+ // }
+ // }
+ // }
+ if ( this.showDn
+ && searchResult.getDn().toString().toUpperCase().indexOf( this.quickFilterValue.toUpperCase() ) > -1 )
+ {
+ return true;
+ }
+
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ private boolean goesThroughQuickFilter( IValue value )
+ {
+
+ // fitler value
+ // if(this.quickFilterValue != null &&
+ // !"".equals(this.quickFilterValue)) {
+ if ( value.isString()
+ && value.getStringValue().toUpperCase().indexOf( this.quickFilterValue.toUpperCase() ) == -1 )
+ {
+ return false;
+ }
+ else if ( value.isBinary() )
+ {
+ return false;
+ }
+ // }
+
+ return true;
+ }
+
+
+ public void dispose()
+ {
+ this.contentProvider = null;
+ }
+
+
+ public String getQuickFilterValue()
+ {
+ return quickFilterValue;
+ }
+
+
+ public void setQuickFilterValue( String quickFilterValue )
+ {
+ if ( !this.quickFilterValue.equals( quickFilterValue ) )
+ {
+ this.quickFilterValue = quickFilterValue;
+ if ( this.contentProvider != null )
+ this.contentProvider.refresh();
+ }
+ }
+
+}
Added: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorInput.java?view=auto&rev=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorInput.java (added)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-browser-ui/src/org/apache/directory/ldapstudio/browser/ui/editors/searchresult/SearchResultEditorInput.java Mon Dec 18 09:52:58 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.editors.searchresult;
+
+
+import org.apache.directory.ldapstudio.browser.core.model.ISearch;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
+import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+
+public class SearchResultEditorInput implements IEditorInput
+{
+
+ private ISearch search;
+
+
+ public SearchResultEditorInput( ISearch search )
+ {
+ this.search = search;
+ }
+
+
+ public boolean exists()
+ {
+ return false;
+ }
+
+
+ public ImageDescriptor getImageDescriptor()
+ {
+ return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SEARCHRESULTEDITOR );
+ }
+
+
+ public String getName()
+ {
+ return "Search Result Editor";
+ }
+
+
+ public String getToolTipText()
+ {
+ return this.search != null ? this.search.getName() : "";
+ }
+
+
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ public ISearch getSearch()
+ {
+ return search;
+ }
+
+
+ public boolean equals( Object obj )
+ {
+ return obj instanceof SearchResultEditorInput;
+ }
+
+}