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 [8/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/schemabrowser/SchemaBrowserInput.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserInput.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserInput.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserInput.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,248 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaPart;
+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 schema browser.
+ *
+ * There is a trick to provide a single instance of the schema browser:
+ * <ul>
+ * <li>If oneInstanceHackEnabled is true the equals method returns always
+ * true as long as the compared object is also of type SchemaBrowserInput.
+ * With this trick only one instance of the schema browser is opened
+ * by the eclipse editor framework.
+ * <li>If oneInstanceHackEnabled is false the equals method returns
+ * true only if the wrapped objects (IConnection and SchemaPart) 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 SchemaBrowserInput implements IEditorInput
+{
+
+ /** The connection */
+ private IBrowserConnection connection;
+
+ /** The schema element */
+ private SchemaPart schemaElement;
+
+ /** One instance hack flag */
+ private static boolean oneInstanceHackEnabled = true;
+
+
+ /**
+ * Creates a new instance of SchemaBrowserInput.
+ *
+ *@param connection the connection
+ * @param schemaElement the schema element input
+ */
+ public SchemaBrowserInput( IBrowserConnection connection, SchemaPart schemaElement )
+ {
+ this.connection = connection;
+ this.schemaElement = schemaElement;
+ }
+
+
+// /**
+// * Creates a new instance of SchemaBrowserInput.
+// *
+// *@param connection the connection
+// * @param schemaElement the schema element input
+// */
+// public SchemaBrowserInput( Connection connection, SchemaPart schemaElement )
+// {
+// this.connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection( connection );
+// this.schemaElement = schemaElement;
+// }
+
+
+ /**
+ * This implementation always return false because
+ * a schema element 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_BROWSER_SCHEMABROWSEREDITOR );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return "Schema Browser";
+ }
+
+
+ /**
+ * This implementation always return null.
+ *
+ * {@inheritDoc}
+ */
+ public IPersistableElement getPersistable()
+ {
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getToolTipText()
+ {
+ return "";
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter( Class adapter )
+ {
+ return null;
+ }
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ public IBrowserConnection getConnection()
+ {
+ return connection;
+ }
+
+
+ /**
+ /**
+ * Gets the schema element, may be null.
+ *
+ * @return the schema element or null
+ */
+ public SchemaPart getSchemaElement()
+ {
+ return schemaElement;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode()
+ {
+ return getToolTipText().hashCode();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals( Object obj )
+ {
+
+ boolean equal;
+
+ if ( oneInstanceHackEnabled )
+ {
+ equal = ( obj instanceof SchemaBrowserInput );
+ }
+ else
+ {
+ if ( obj instanceof SchemaBrowserInput )
+ {
+ SchemaBrowserInput other = ( SchemaBrowserInput ) obj;
+ if ( this.connection == null && other.connection == null)
+ {
+ return true;
+ }
+ else if ( this.connection == null || other.connection == null)
+ {
+ return false;
+ }
+ else if ( !this.connection.equals( other.connection ))
+ {
+ return false;
+ }
+ else if ( this.schemaElement == null && other.schemaElement == null )
+ {
+ return true;
+ }
+ else if ( this.schemaElement == null || other.schemaElement == null )
+ {
+ return false;
+ }
+ else
+ {
+ equal = other.schemaElement.equals( this.schemaElement );
+ }
+ }
+ 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/schemabrowser/SchemaBrowserInput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+
+/**
+ * The SchemaBrowserManager is used to set and get the the input
+ * of the single schema browser instance.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaBrowserManager
+{
+
+ /** The dummy input, to find the single schema browser instance */
+ private static SchemaBrowserInput DUMMY_INPUT = new SchemaBrowserInput( null, null );
+
+
+ /**
+ * Sets the input to the schema browser.
+ *
+ * @param connection the connection
+ * @param schemaElement the schema element
+ */
+ public static void setInput( IBrowserConnection connection, SchemaPart schemaElement )
+ {
+ SchemaBrowserInput input = new SchemaBrowserInput( connection, schemaElement );
+ setInput( input );
+ }
+
+
+ /**
+ * Sets the input to the schema browser.
+ *
+ * @param input the input
+ */
+ private static void setInput( SchemaBrowserInput input )
+ {
+ SchemaBrowser editor = ( SchemaBrowser ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .findEditor( DUMMY_INPUT );
+ if ( editor == null && input != null )
+ {
+ // open new schema browser
+ try
+ {
+ editor = ( SchemaBrowser ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .openEditor( input, SchemaBrowser.getId(), false );
+ editor.setInput( input );
+ }
+ catch ( PartInitException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ else if ( editor != null )
+ {
+ // set the input to already opened schema browser
+ editor.setInput( input );
+
+ // bring schema browser to top only if a schema element should be displayed.
+ if ( input.getSchemaElement() != null )
+ {
+ if ( !PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().isPartVisible( editor ) )
+ {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( editor );
+ }
+ }
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,260 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.AttributeTypeDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.LdapSyntaxDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.MatchingRuleDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.MatchingRuleUseDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.ObjectClassDescription;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaPart;
+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 schema browser input to the navigation history.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaBrowserNavigationLocation extends NavigationLocation
+{
+
+ /**
+ * Creates a new instance of SchemaBrowserNavigationLocation.
+ *
+ * @param schemaBrowser the schema browser
+ */
+ SchemaBrowserNavigationLocation( SchemaBrowser schemaBrowser )
+ {
+ super( schemaBrowser );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getText()
+ {
+ SchemaPart schemaElement = getSchemElement();
+ if ( schemaElement != null )
+ {
+ if(schemaElement instanceof ObjectClassDescription)
+ {
+ return "Object Class " + schemaElement.toString();
+ }
+ else if(schemaElement instanceof AttributeTypeDescription )
+ {
+ return "Attribute Type " + schemaElement.toString();
+ }
+ else if(schemaElement instanceof LdapSyntaxDescription )
+ {
+ return "Syntax " + schemaElement.toString();
+ }
+ else if(schemaElement instanceof MatchingRuleDescription)
+ {
+ return "Matching Rule " + schemaElement.toString();
+ }
+ else if(schemaElement instanceof MatchingRuleUseDescription )
+ {
+ return "Matching Rule Use " + schemaElement.toString();
+ }
+ else
+ {
+ return schemaElement.getNumericOID();
+ }
+ }
+ else
+ {
+ return super.getText();
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void saveState( IMemento memento )
+ {
+ IBrowserConnection connection = getConnection();
+ SchemaPart schemaElement = getSchemElement();
+ memento.putString( "CONNECTION", connection.getConnection().getId() );
+ memento.putString( "SCHEMAELEMENTYPE", schemaElement.getClass().getName() );
+ memento.putString( "SCHEMAELEMENTOID", schemaElement.getNumericOID() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreState( IMemento memento )
+ {
+ IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById(
+ memento.getString( "CONNECTION" ) );
+ String schemaElementType = memento.getString( "SCHEMAELEMENTYPE" );
+ String schemaElementOid = memento.getString( "SCHEMAELEMENTOID" );
+ SchemaPart schemaElement = null;
+ if(ObjectClassDescription.class.getName().equals( schemaElementType ) )
+ {
+ schemaElement = connection.getSchema().getObjectClassDescription( schemaElementOid );
+ }
+ else if(AttributeTypeDescription.class.getName().equals( schemaElementType ) )
+ {
+ schemaElement = connection.getSchema().getAttributeTypeDescription( schemaElementOid );
+ }
+ else if(LdapSyntaxDescription.class.getName().equals( schemaElementType ) )
+ {
+ schemaElement = connection.getSchema().getLdapSyntaxDescription( schemaElementOid );
+ }
+ else if(MatchingRuleDescription.class.getName().equals( schemaElementType ) )
+ {
+ schemaElement = connection.getSchema().getMatchingRuleDescription( schemaElementOid );
+ }
+ else if(MatchingRuleUseDescription.class.getName().equals( schemaElementType ) )
+ {
+ schemaElement = connection.getSchema().getMatchingRuleUseDescription( schemaElementOid );
+ }
+
+ super.setInput( new SchemaBrowserInput( connection, schemaElement ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreLocation()
+ {
+ IEditorPart editorPart = getEditorPart();
+ if ( editorPart != null && editorPart instanceof SchemaBrowser )
+ {
+ SchemaBrowser schemaBrowser = ( SchemaBrowser ) editorPart;
+ Object input = getInput();
+ if(input != null && input instanceof SchemaBrowserInput)
+ {
+ SchemaBrowserInput sbi = (SchemaBrowserInput)input;
+ if(sbi.getConnection() != null && sbi.getSchemaElement() != null)
+ {
+ schemaBrowser.setInput( sbi );
+ }
+ }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean mergeInto( INavigationLocation currentLocation )
+ {
+ if ( currentLocation == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != currentLocation.getClass() )
+ {
+ return false;
+ }
+
+ SchemaBrowserNavigationLocation location = ( SchemaBrowserNavigationLocation ) currentLocation;
+ SchemaPart other = location.getSchemElement();
+ SchemaPart element = getSchemElement();
+
+ if ( other == null && element == null )
+ {
+ return true;
+ }
+ else if ( other == null || element == null )
+ {
+ return false;
+ }
+ else
+ {
+ return element.equals( other );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update()
+ {
+ }
+
+
+ /**
+ * Gets the schema element.
+ *
+ * @return the schema element
+ */
+ private SchemaPart getSchemElement()
+ {
+
+ Object editorInput = getInput();
+ if ( editorInput != null && editorInput instanceof SchemaBrowserInput )
+ {
+ SchemaBrowserInput schemaBrowserInput = ( SchemaBrowserInput ) editorInput;
+ SchemaPart schemaElement = schemaBrowserInput.getSchemaElement();
+ if ( schemaElement != null )
+ {
+ return schemaElement;
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ private IBrowserConnection getConnection()
+ {
+
+ Object editorInput = getInput();
+ if ( editorInput != null && editorInput instanceof SchemaBrowserInput )
+ {
+ SchemaBrowserInput schemaBrowserInput = ( SchemaBrowserInput ) editorInput;
+ return schemaBrowserInput.getConnection();
+ }
+
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "" + getSchemElement();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,197 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaPart;
+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.swt.widgets.Text;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+
+/**
+ * A base implementation used from all schema detail pages.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class SchemaDetailsPage implements IHyperlinkListener
+{
+
+ /** The raw section, displays the schema attibute value */
+ protected Section rawSection;
+
+ /** The text with the schema attribute value */
+ protected Text rawText;
+
+ /** The toolkit used to create controls */
+ protected FormToolkit toolkit;
+
+ /** The master schema page */
+ protected SchemaPage schemaPage;
+
+ /** The detail page form */
+ protected ScrolledForm detailForm;
+
+
+ /**
+ * Creates a new instance of SchemaDetailsPage.
+ *
+ * @param schemaPage the master schema page
+ * @param toolkit the toolkit used to create controls
+ */
+ protected SchemaDetailsPage( SchemaPage schemaPage, FormToolkit toolkit )
+ {
+ this.schemaPage = schemaPage;
+ this.toolkit = toolkit;
+ }
+
+
+ /**
+ * Disposes this details page.
+ */
+ public void dispose()
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void linkActivated( HyperlinkEvent e )
+ {
+ Object obj = e.getHref();
+ if ( obj instanceof SchemaPart )
+ {
+ schemaPage.getSchemaBrowser().setInput(
+ new SchemaBrowserInput( schemaPage.getConnection(), ( SchemaPart ) obj ) );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void linkEntered( HyperlinkEvent e )
+ {
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void linkExited( HyperlinkEvent e )
+ {
+ }
+
+
+ /**
+ * Sets the input of this details page.
+ *
+ * @param input the input
+ */
+ public abstract void setInput( Object input );
+
+
+ /**
+ * Creates the contents of the details page.
+ *
+ * @param detailForm the parent
+ */
+ protected abstract void createContents( final ScrolledForm detailForm );
+
+
+ /**
+ * Creates the raw content section.
+ */
+ protected void createRawSection()
+ {
+ rawSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE );
+ rawSection.setText( "Raw Schema Definition" );
+ rawSection.marginWidth = 0;
+ rawSection.marginHeight = 0;
+ rawSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ toolkit.createCompositeSeparator( rawSection );
+ rawSection.addExpansionListener( new ExpansionAdapter()
+ {
+ public void expansionStateChanged( ExpansionEvent e )
+ {
+ detailForm.reflow( true );
+ }
+ } );
+ }
+
+
+ /**
+ * Creates the contents of the raw section.
+ *
+ * @param schemaPart the schema part to display
+ */
+ protected void createRawContents( SchemaPart schemaPart )
+ {
+
+ if ( rawSection.getClient() != null && !rawSection.getClient().isDisposed() )
+ {
+ rawSection.getClient().dispose();
+ }
+
+ Composite client = toolkit.createComposite( rawSection, SWT.WRAP );
+ client.setLayout( new GridLayout() );
+ rawSection.setClient( client );
+
+ if ( schemaPart != null )
+ {
+ rawText = toolkit.createText( client, getNonNullString( schemaPart.getLine().getValueAsString() ), SWT.WRAP
+ | SWT.MULTI );
+ GridData gd2 = new GridData( GridData.FILL_HORIZONTAL );
+ gd2.widthHint = detailForm.getForm().getSize().x - 100 - 60;
+ // detailForm.getForm().getVerticalBar().getSize().x
+ // gd2.widthHint = 10;
+ rawText.setLayoutData( gd2 );
+ rawText.setEditable( false );
+ }
+
+ rawSection.layout();
+
+ }
+
+
+ /**
+ * Helper method, return a dash "-" if the given string is null.
+ *
+ * @param s the string
+ * @return the given string or a dash "-" if the given string is null.
+ */
+ protected String getNonNullString( String s )
+ {
+ return s == null ? "-" : s;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,435 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaPart;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+
+/**
+ * A base implementation used from all schema master pages.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class SchemaPage
+{
+
+ /** The connection widget */
+ protected BrowserConnectionWidgetContributionItem connectionCombo;
+
+ /** The show default schema action */
+ protected ShowDefaultSchemaAction showDefaultSchemaAction;
+
+ /** The reload schema action */
+ protected ReloadSchemaAction reloadSchemaAction;
+
+ /** The schema browser */
+ protected SchemaBrowser schemaBrowser;
+
+ /** The toolkit used to create controls */
+ protected FormToolkit toolkit;
+
+ /** The outer form */
+ protected Form form;
+
+ /** The sash form, used to split the master and detail form */
+ protected SashForm sashForm;
+
+ /** The master form, contains the schema element list */
+ protected ScrolledForm masterForm;
+
+ /** The detail form, contains the schema details */
+ protected ScrolledForm detailForm;
+
+ /** The schema details page */
+ protected SchemaDetailsPage detailsPage;
+
+ /** The section of the master form */
+ protected Section section;
+
+ /** The filter field of the master form */
+ protected Text filterText;
+
+ /** The list with all schema elements */
+ protected TableViewer viewer;
+
+ /** Flag indicating if the viewer's selection is changed programatically */
+ protected boolean inChange;
+
+
+ /**
+ * Creates a new instance of SchemaPage.
+ *
+ * @param schemaBrowser the schema browser
+ */
+ public SchemaPage( SchemaBrowser schemaBrowser )
+ {
+ this.schemaBrowser = schemaBrowser;
+ this.inChange = false;
+ }
+
+
+ /**
+ * Refreshes this schema page.
+ */
+ public void refresh()
+ {
+ Schema schema = null;
+ if ( showDefaultSchemaAction.isChecked() )
+ {
+ schema = Schema.DEFAULT_SCHEMA;
+ }
+ else if ( getConnection() != null )
+ {
+ schema = getConnection().getSchema();
+ }
+
+ if ( viewer.getInput() != schema )
+ {
+ viewer.setInput( schema );
+ viewer.setSelection( StructuredSelection.EMPTY );
+ }
+
+ form.setText( getTitle() );
+ viewer.refresh();
+ }
+
+
+ /**
+ * Gets the title of this schema page.
+ *
+ * @return the title
+ */
+ protected abstract String getTitle();
+
+
+ /**
+ * Gets the filter description.
+ *
+ * @return the filter description
+ */
+ protected abstract String getFilterDescription();
+
+
+ /**
+ * Gets the content provider.
+ *
+ * @return the content provider
+ */
+ protected abstract IStructuredContentProvider getContentProvider();
+
+
+ /**
+ * Gets the label provider.
+ *
+ * @return the label provider
+ */
+ protected abstract ITableLabelProvider getLabelProvider();
+
+
+ /**
+ * Gets the sorter.
+ *
+ * @return the sorter
+ */
+ protected abstract ViewerSorter getSorter();
+
+
+ /**
+ * Gets the filter.
+ *
+ * @return the filter
+ */
+ protected abstract ViewerFilter getFilter();
+
+
+ /**
+ * Gets the details page.
+ *
+ * @return the details page
+ */
+ protected abstract SchemaDetailsPage getDetailsPage();
+
+
+ /**
+ * Creates the master page.
+ *
+ * @param body the parent composite
+ */
+ //protected abstract void createMaster( Composite body );
+ private void createMaster( Composite parent )
+ {
+ // create section
+ section = toolkit.createSection( parent, Section.DESCRIPTION );
+ section.marginWidth = 10;
+ section.marginHeight = 12;
+ section.setText( getTitle() );
+ section.setDescription( getFilterDescription() );
+ toolkit.createCompositeSeparator( section );
+
+ // create client
+ Composite client = toolkit.createComposite( section, SWT.WRAP );
+ GridLayout layout = new GridLayout( 2, false );
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ client.setLayout( layout );
+ section.setClient( client );
+
+ // create filter field
+ toolkit.createLabel( client, "Filter:" );
+ this.filterText = toolkit.createText( client, "", SWT.NONE );
+ this.filterText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ this.filterText.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER );
+ this.filterText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ viewer.refresh();
+ }
+ } );
+
+ // create table
+ Table t = toolkit.createTable( client, SWT.NONE );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.horizontalSpan = 2;
+ gd.heightHint = 20;
+ gd.widthHint = 100;
+ t.setLayoutData( gd );
+ toolkit.paintBordersFor( client );
+
+ // setup viewer
+ viewer = new TableViewer( t );
+ viewer.setContentProvider( getContentProvider() );
+ viewer.setLabelProvider( getLabelProvider() );
+ viewer.setSorter( getSorter() );
+ viewer.addFilter( getFilter() );
+ }
+
+
+ /**
+ * Creates the detail page.
+ *
+ * @param body the parent composite
+ */
+ private void createDetail( Composite body )
+ {
+ detailsPage = getDetailsPage();
+ detailsPage.createContents( this.detailForm );
+ }
+
+
+ /**
+ * Selects the given object in the list. Causes also an input
+ * change of the details page.
+ *
+ * @param obj the object to select
+ */
+ public void select( Object obj )
+ {
+ ISelection newSelection = new StructuredSelection( obj );
+ ISelection oldSelection = this.viewer.getSelection();
+
+ if ( !newSelection.equals( oldSelection ) )
+ {
+ inChange = true;
+ this.viewer.setSelection( newSelection, true );
+ if ( this.viewer.getSelection().isEmpty() )
+ {
+ this.filterText.setText( "" );
+ this.viewer.setSelection( newSelection, true );
+ }
+ inChange = false;
+ }
+ }
+
+
+ /**
+ * Disposed this page and the details page.
+ */
+ public void dispose()
+ {
+ this.detailsPage.dispose();
+
+ this.schemaBrowser = null;
+ this.toolkit.dispose();
+ this.toolkit = null;
+ }
+
+
+ /**
+ * Creates this schema page and details page.
+ *
+ * @param parent the parent composite
+ * @return the created composite.
+ */
+ Control createControl( Composite parent )
+ {
+ this.toolkit = new FormToolkit( parent.getDisplay() );
+ this.form = this.toolkit.createForm( parent );
+ this.form.getBody().setLayout( new FillLayout() );
+
+ this.sashForm = new SashForm( this.form.getBody(), SWT.HORIZONTAL );
+ this.sashForm.setLayout( new FillLayout() );
+
+ this.masterForm = this.toolkit.createScrolledForm( this.sashForm );
+ this.detailForm = new ScrolledForm( this.sashForm, SWT.V_SCROLL | this.toolkit.getOrientation() );
+ this.detailForm.setExpandHorizontal( true );
+ this.detailForm.setExpandVertical( true );
+ this.detailForm.setBackground( this.toolkit.getColors().getBackground() );
+ this.detailForm.setForeground( this.toolkit.getColors().getColor( FormColors.TITLE ) );
+ this.detailForm.setFont( JFaceResources.getHeaderFont() );
+ this.sashForm.setWeights( new int[]
+ { 50, 50 } );
+
+ this.masterForm.getBody().setLayout( new FillLayout() );
+ this.createMaster( this.masterForm.getBody() );
+
+ this.detailForm.getBody().setLayout( new FillLayout() );
+ this.createDetail( this.detailForm.getBody() );
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ ISelection selection = event.getSelection();
+ if ( selection.isEmpty() )
+ {
+ detailsPage.setInput( null );
+ }
+ else
+ {
+ Object obj = ( ( StructuredSelection ) selection ).getFirstElement();
+ detailsPage.setInput( obj );
+
+ // Do not set the input of the schema browser if
+ // the selection was changed programatically.
+ if ( !inChange && obj instanceof SchemaPart )
+ {
+ schemaBrowser.setInput( new SchemaBrowserInput( getConnection(), ( SchemaPart ) obj ) );
+ }
+ }
+ }
+ } );
+
+ connectionCombo = new BrowserConnectionWidgetContributionItem( this );
+ this.form.getToolBarManager().add( connectionCombo );
+ this.form.getToolBarManager().add( new Separator() );
+ showDefaultSchemaAction = new ShowDefaultSchemaAction( schemaBrowser );
+ this.form.getToolBarManager().add( showDefaultSchemaAction );
+ this.form.getToolBarManager().add( new Separator() );
+ reloadSchemaAction = new ReloadSchemaAction( this );
+ this.form.getToolBarManager().add( reloadSchemaAction );
+ this.form.updateToolBar();
+
+ this.refresh();
+
+ return this.form;
+ }
+
+
+ /**
+ * Gets the schema browser.
+ *
+ * @return the schema browser
+ */
+ public SchemaBrowser getSchemaBrowser()
+ {
+ return schemaBrowser;
+ }
+
+
+ /**
+ * Gets the connection.
+ *
+ * @return the connection
+ */
+ public IBrowserConnection getConnection()
+ {
+ return connectionCombo.getConnection();
+ }
+
+
+ /**
+ * Sets the connection.
+ *
+ * @param connection the connection
+ */
+ public void setConnection( IBrowserConnection connection )
+ {
+ connectionCombo.setConnection( connection );
+ reloadSchemaAction.updateEnabledState();
+ refresh();
+ }
+
+
+ /**
+ * Checks if is show default schema.
+ *
+ * @return true, if is show default schema
+ */
+ public boolean isShowDefaultSchema()
+ {
+ return showDefaultSchemaAction.isChecked();
+ }
+
+
+ /**
+ * Sets the show default schema flag.
+ *
+ * @param b the show default schema flag
+ */
+ public void setShowDefaultSchema( boolean b )
+ {
+ showDefaultSchemaAction.setChecked( b );
+ connectionCombo.updateEnabledState();
+ reloadSchemaAction.updateEnabledState();
+ refresh();
+ }
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.schemabrowser;
+
+
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.jface.action.Action;
+
+
+/**
+ * This action toggles between connection specific schemas and the default schema.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ShowDefaultSchemaAction extends Action
+{
+ /** The schema browser */
+ private SchemaBrowser schemaBrowser;
+
+
+ /**
+ * Creates a new instance of ShowDefaultSchemaAction.
+ *
+ * @param schemaBrowser the schema browser
+ */
+ public ShowDefaultSchemaAction( SchemaBrowser schemaBrowser )
+ {
+ super( "Show Default Schema", Action.AS_CHECK_BOX );
+ super.setToolTipText( "Show Default Schema" );
+ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor(
+ BrowserUIConstants.IMG_DEFAULT_SCHEMA ) );
+ super.setEnabled( true );
+
+ this.schemaBrowser = schemaBrowser;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run()
+ {
+ this.schemaBrowser.setShowDefaultSchema( isChecked() );
+ }
+
+
+ /**
+ * Disposes this action.
+ */
+ public void dispose()
+ {
+ this.schemaBrowser = null;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,209 @@
+/*
+ * 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.searchresult;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction;
+import org.apache.directory.studio.valueeditors.ValueEditorManager;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.widgets.TableItem;
+
+
+public abstract class AbstractOpenEditorAction extends BrowserAction implements FocusListener, KeyListener
+{
+
+ protected ValueEditorManager valueEditorManager;
+
+ protected TableViewer viewer;
+
+ protected SearchResultEditorCursor cursor;
+
+ protected CellEditor cellEditor;
+
+ private boolean isActive;
+
+
+ protected AbstractOpenEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
+ ValueEditorManager valueEditorManager )
+ {
+ this.viewer = viewer;
+ this.cursor = cursor;
+ this.valueEditorManager = valueEditorManager;
+ this.isActive = false;
+ }
+
+
+ public CellEditor getCellEditor()
+ {
+ return this.cellEditor;
+ }
+
+
+ public void run()
+ {
+ this.activateEditor();
+ }
+
+
+ private void activateEditor()
+ {
+
+ Object element = cursor.getRow().getData();
+ String property = ( String ) this.viewer.getColumnProperties()[cursor.getColumn()];
+
+ if ( !this.viewer.isCellEditorActive() && viewer.getCellModifier().canModify( element, property ) )
+ {
+
+ // check if attribute exists
+ /*
+ * if(element instanceof ISearchResult) { ISearchResult result =
+ * (ISearchResult)element; IAttribute attribute =
+ * result.getAttribute(property); if(attribute == null) {
+ * EventRegistry.suspendEventFireingInCurrentThread(); try {
+ * attribute = result.getEntry().createAttribute(property,
+ * this); System.out.println("activateEditor(): created
+ * attribute " + attribute); } catch (ModelModificationException
+ * e) { } EventRegistry.resumeEventFireingInCurrentThread(); } }
+ */
+
+ // set cell editor to viewer
+ for ( int i = 0; i < this.viewer.getCellEditors().length; i++ )
+ {
+ this.viewer.getCellEditors()[i] = this.cellEditor;
+ }
+
+ // add listener for end of editing
+ if ( this.cellEditor.getControl() != null )
+ {
+ this.cellEditor.getControl().addFocusListener( this );
+ this.cellEditor.getControl().addKeyListener( this );
+ }
+
+ // deactivate cursor
+ this.cursor.setVisible( false );
+
+ // start editing
+ this.isActive = true;
+ this.viewer.editElement( element, cursor.getColumn() );
+
+ viewer.setSelection( null, true );
+ viewer.getTable().setSelection( new TableItem[0] );
+
+ if ( !this.viewer.isCellEditorActive() )
+ {
+ this.editorClosed();
+ }
+ }
+ else
+ {
+ this.valueEditorManager.setUserSelectedValueEditor( null );
+ }
+ }
+
+
+ private void editorClosed()
+ {
+
+ // check empty attribute
+ /*
+ * Object element = cursor.getRow().getData(); String property =
+ * (String)this.viewer.getColumnProperties()[cursor.getColumn()];
+ * if(element instanceof ISearchResult) { ISearchResult result =
+ * (ISearchResult)element; IAttribute attribute =
+ * result.getAttribute(property); if(attribute != null &&
+ * attribute.getValueSize() == 0) {
+ * EventRegistry.suspendEventFireingInCurrentThread(); try {
+ * result.getEntry().deleteAttribute(attribute, this);
+ * System.out.println("activateEditor(): deleted attribute " +
+ * attribute); } catch (ModelModificationException e) { }
+ * EventRegistry.resumeEventFireingInCurrentThread(); } }
+ */
+
+ // clear active flag
+ this.isActive = false;
+
+ // remove cell editors from viewer to prevend auto-editing
+ for ( int i = 0; i < this.viewer.getCellEditors().length; i++ )
+ {
+ this.viewer.getCellEditors()[i] = null;
+ }
+
+ // remove listener
+ if ( this.cellEditor.getControl() != null )
+ {
+ this.cellEditor.getControl().removeFocusListener( this );
+ this.cellEditor.getControl().removeKeyListener( this );
+ }
+
+ this.valueEditorManager.setUserSelectedValueEditor( null );
+
+ // activate cursor
+ cursor.setVisible( true );
+ viewer.refresh();
+ cursor.redraw();
+ cursor.getDisplay().asyncExec( new Runnable()
+ {
+ public void run()
+ {
+ cursor.setFocus();
+ }
+ } );
+
+ }
+
+
+ public void focusGained( FocusEvent e )
+ {
+ }
+
+
+ public void focusLost( FocusEvent e )
+ {
+ this.editorClosed();
+ }
+
+
+ public void keyPressed( KeyEvent e )
+ {
+ if ( e.character == SWT.ESC && e.stateMask == SWT.NONE )
+ {
+ e.doit = false;
+ }
+ }
+
+
+ public void keyReleased( KeyEvent e )
+ {
+ }
+
+
+ public boolean isActive()
+ {
+ return isActive;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortJob.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortJob.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortJob.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortJob.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,117 @@
+/*
+ * 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.searchresult;
+
+
+import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.connection.core.StudioProgressMonitor;
+import org.apache.directory.studio.ldapbrowser.core.jobs.AbstractEclipseJob;
+
+
+/**
+ * This job to filter and sort the search result editor asynchrously to avoid
+ * freezing the GUI.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class FilterAndSortJob extends AbstractEclipseJob
+{
+
+ /** The configuration. */
+ private SearchResultEditorConfiguration configuration;
+
+ /** The main widget. */
+ private SearchResultEditorWidget mainWidget;
+
+ /** All elements, unfiltered and unsorted. */
+ private Object[] elements;
+
+ /** The filtered and sorted elements. */
+ private Object[] filteredAndSortedElements;
+
+
+ /**
+ * Creates a new instance of FilterAndSortJob.
+ *
+ * @param configuration the configuration
+ * @param mainWidget the main widget
+ * @param elements the elements, unfiltered and unsorted
+ */
+ public FilterAndSortJob( SearchResultEditorConfiguration configuration, SearchResultEditorWidget mainWidget,
+ Object[] elements )
+ {
+ this.configuration = configuration;
+ this.mainWidget = mainWidget;
+ this.elements = elements;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Object[] getLockedObjects()
+ {
+ return new Object[0];
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void executeAsyncJob( StudioProgressMonitor monitor ) throws Exception
+ {
+ monitor.beginTask( "Filter and Sort", 3 );
+ monitor.worked( 1 );
+
+ monitor.setTaskName( "Filter and Sort" );
+
+ monitor.reportProgress( "Filtering..." );
+ this.filteredAndSortedElements = this.configuration.getFilter().filter( this.mainWidget.getViewer(), "",
+ elements );
+ monitor.worked( 1 );
+
+ monitor.reportProgress( "Sorting..." );
+ this.configuration.getSorter().sort( this.mainWidget.getViewer(), this.filteredAndSortedElements );
+ monitor.worked( 1 );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Connection[] getConnections()
+ {
+ return new Connection[0];
+ }
+
+
+ /**
+ * Gets the filtered and sorted elements.
+ *
+ * @return the filtered and sorted elements
+ */
+ public Object[] getFilteredAndSortedElements()
+ {
+ return filteredAndSortedElements;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortJob.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,119 @@
+/*
+ * 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.searchresult;
+
+
+import org.apache.directory.studio.valueeditors.IValueEditor;
+import org.apache.directory.studio.valueeditors.ValueEditorManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+public class OpenBestEditorAction extends AbstractOpenEditorAction
+{
+
+ private IValueEditor bestValueEditor;
+
+
+ public OpenBestEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
+ ValueEditorManager valueEditorManager )
+ {
+ super( viewer, cursor, valueEditorManager );
+ }
+
+
+ /**
+ * Gets the best value editor.
+ *
+ * @return the best value editor
+ */
+ public IValueEditor getBestValueEditor()
+ {
+ return this.bestValueEditor;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#dispose()
+ */
+ public void dispose()
+ {
+ bestValueEditor = null;
+ super.dispose();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getCommandId()
+ */
+ public String getCommandId()
+ {
+ return null;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return isEnabled() ? bestValueEditor.getValueEditorImageDescriptor() : null;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getText()
+ */
+ public String getText()
+ {
+ return isEnabled() ? bestValueEditor.getValueEditorName() : null;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#isEnabled()
+ */
+ public boolean isEnabled()
+ {
+ if ( getSelectedSearchResults().length == 1 && getSelectedProperties().length == 1
+ && viewer.getCellModifier().canModify( getSelectedSearchResults()[0], getSelectedProperties()[0] ) )
+ {
+ if ( getSelectedAttributeHierarchies().length == 0 )
+ {
+ bestValueEditor = valueEditorManager.getCurrentValueEditor( getSelectedSearchResults()[0].getEntry(),
+ getSelectedProperties()[0] );
+ }
+ else
+ {
+ bestValueEditor = valueEditorManager.getCurrentValueEditor( getSelectedAttributeHierarchies()[0] );
+ }
+
+ super.cellEditor = bestValueEditor.getCellEditor();
+ return true;
+ }
+ else
+ {
+ super.cellEditor = null;
+ return false;
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,110 @@
+/*
+ * 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.searchresult;
+
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
+import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.SearchResultEditorActionProxy;
+import org.apache.directory.studio.valueeditors.ValueEditorManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+public class OpenDefaultEditorAction extends AbstractOpenEditorAction
+{
+
+ private SearchResultEditorActionProxy bestValueEditorProxy;
+
+
+ public OpenDefaultEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
+ ValueEditorManager valueEditorManager, SearchResultEditorActionProxy bestValueEditorProxy )
+ {
+ super( viewer, cursor, valueEditorManager );
+ this.bestValueEditorProxy = bestValueEditorProxy;
+ }
+
+
+ public void run()
+ {
+ this.bestValueEditorProxy.run();
+ }
+
+
+ public void dispose()
+ {
+ this.bestValueEditorProxy = null;
+
+ super.dispose();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getCommandId()
+ */
+ public String getCommandId()
+ {
+ return BrowserCommonConstants.ACTION_ID_EDIT_VALUE;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ if ( bestValueEditorProxy != null )
+ {
+ return bestValueEditorProxy.getImageDescriptor();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getText()
+ */
+ public String getText()
+ {
+ return "Edit Value";
+ }
+
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#isEnabled()
+ */
+ public boolean isEnabled()
+ {
+ if ( bestValueEditorProxy != null )
+ {
+ return bestValueEditorProxy.isEnabled();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.searchresult;
+
+
+import java.util.Arrays;
+
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.valueeditors.IValueEditor;
+import org.apache.directory.studio.valueeditors.ValueEditorManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+public class OpenEditorAction extends AbstractOpenEditorAction
+{
+
+ private IValueEditor valueEditor;
+
+
+ public OpenEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
+ ValueEditorManager valueEditorManager,
+ IValueEditor valueEditor )
+ {
+ super( viewer, cursor, valueEditorManager );
+ super.cellEditor = valueEditor.getCellEditor();
+ this.valueEditor = valueEditor;
+ }
+
+
+ public IValueEditor getValueEditor()
+ {
+ return this.valueEditor;
+ }
+
+
+ public void run()
+ {
+ this.valueEditorManager.setUserSelectedValueEditor( this.valueEditor );
+ super.run();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#dispose()
+ */
+ public void dispose()
+ {
+ this.valueEditor = null;
+ super.dispose();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getCommandId()
+ */
+ public String getCommandId()
+ {
+ return null;
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor()
+ {
+ return valueEditor.getValueEditorImageDescriptor();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#getText()
+ */
+ public String getText()
+ {
+ return valueEditor.getValueEditorName();
+ }
+
+
+ /**
+ * @see org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction#isEnabled()
+ */
+ public boolean isEnabled()
+ {
+ if ( getSelectedSearchResults().length == 1 && getSelectedProperties().length == 1
+ && viewer.getCellModifier().canModify( getSelectedSearchResults()[0], getSelectedProperties()[0] ) )
+ {
+ IValueEditor[] alternativeVps;
+ if ( getSelectedAttributeHierarchies().length == 0 )
+ {
+ return false;
+ }
+ else
+ {
+ AttributeHierarchy ah = getSelectedAttributeHierarchies()[0];
+ alternativeVps = valueEditorManager.getAlternativeValueEditors( ah );
+ return Arrays.asList( alternativeVps ).contains( this.valueEditor )
+ && valueEditor.getRawValue( ah ) != null;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java Mon Nov 5 09:01:21 2007
@@ -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.studio.ldapbrowser.ui.editors.searchresult;
+
+
+import org.apache.directory.studio.ldapbrowser.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()
+ {
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.java Mon Nov 5 09:01:21 2007
@@ -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.studio.ldapbrowser.ui.editors.searchresult;
+
+
+import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAction;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+
+
+public class SearchResultDeleteAction extends DeleteAction
+{
+
+ public SearchResultDeleteAction()
+ {
+ super();
+ }
+
+
+ protected IEntry[] getEntries() throws Exception
+ {
+ return new IEntry[0];
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,280 @@
+/*
+ * 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.searchresult;
+
+
+import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
+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.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.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;
+
+
+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 )
+ {
+ // enable one instance hack before fireing the input change event
+ // otherwise the navigation history is cleared.
+ SearchResultEditorInput.enableOneInstanceHack( true );
+ firePropertyChange( IEditorPart.PROP_INPUT );
+
+ // disable one instance hack for marking the location
+ SearchResultEditorInput.enableOneInstanceHack( false );
+ getSite().getPage().getNavigationHistory().markLocation( this );
+ }
+ }
+
+ // finally enable the one instance hack
+ SearchResultEditorInput.enableOneInstanceHack( true );
+ }
+
+
+ public void refresh()
+ {
+ if ( this.universalListener != null )
+ {
+ this.universalListener.refreshInput();
+ }
+ }
+
+
+ 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
+ this.setInput( new SearchResultEditorInput( null ) );
+ getSite().getPage().getNavigationHistory().markLocation( this );
+
+ this.setInput( input );
+ }
+
+
+ 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()
+ {
+ 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()
+ {
+ 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();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
------------------------------------------------------------------------------
svn:eol-style = native