repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyAttributeDescriptionAction.java
/* * 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.actions; import java.util.LinkedHashSet; import java.util.Set; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IValue; 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.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; /** * This class implements the Copy Attribute Description Action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyAttributeDescriptionAction extends BrowserAction { /** * Creates a new instance of CopyAttributeDescriptionAction. */ public CopyAttributeDescriptionAction() { } /** * {@inheritDoc} */ public void run() { StringBuffer text = new StringBuffer(); boolean isFirst = true; for ( String attributeName : getAttributeNameSet() ) { if ( isFirst ) { isFirst = false; } else { text.append( BrowserCoreConstants.LINE_SEPARATOR ); } text.append( attributeName ); } if ( text.length() > 0 ) { CopyAction.copyToClipboard( new Object[] { text.toString() }, new Transfer[] { TextTransfer.getInstance() } ); } } /** * Gets a Set containing all the Attribute Names. * * @return a Set containing all the Attribute Names */ private Set<String> getAttributeNameSet() { Set<String> attributeNameSet = new LinkedHashSet<String>(); for ( AttributeHierarchy attributeHierarchy : getSelectedAttributeHierarchies() ) { for ( IAttribute attribute : attributeHierarchy ) { attributeNameSet.add( attribute.getDescription() ); } } for ( IAttribute attribute : getSelectedAttributes() ) { attributeNameSet.add( attribute.getDescription() ); } for ( IValue value : getSelectedValues() ) { attributeNameSet.add( value.getAttribute().getDescription() ); } return attributeNameSet; } /** * {@inheritDoc} */ public String getText() { if ( getAttributeNameSet().size() > 1 ) { return Messages.getString( "CopyAttributeDescriptionAction.CopyAttributeDescriptions" ); //$NON-NLS-1$ } else { return Messages.getString( "CopyAttributeDescriptionAction.CopyAttributeDescription" ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_ATT ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getAttributeNameSet().size() > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewLdifFileAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewLdifFileAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldifeditor.LdifEditorActivator; import org.apache.directory.studio.ldifeditor.LdifEditorConstants; import org.apache.directory.studio.ldifeditor.editor.LdifEditor; import org.apache.directory.studio.ldifeditor.editor.NonExistingLdifEditorInput; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * This Action launches a new empty LDIF Editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewLdifFileAction extends BrowserAction { /** * Creates a new instance of NewLdifFileAction. * */ public NewLdifFileAction() { super(); } /** * {@inheritDoc} */ public void run() { IEditorInput input = new NonExistingLdifEditorInput(); String editorId = LdifEditor.getId(); try { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); page.openEditor( input, editorId ); } catch ( PartInitException e ) { } } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewLdifFileAction.NewLDIF" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return LdifEditorActivator.getDefault().getImageDescriptor( LdifEditorConstants.IMG_LDIFEDITOR_NEW ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateDnInDitAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * This action is used within the entry editor and search result editor * to locate and open the entry identified by the Dn under the cursor. * * Example: Attribute "seeAlso" with value "ou=test" is selected in entry edtor. * Then this action is enabled and opens entry "ou=test" in DIT. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LocateDnInDitAction extends LocateInDitAction { /** * Creates a new instance of LocateDnInDitAction. */ public LocateDnInDitAction() { } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "LocateDnInDitAction.LocateDN" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_DN_IN_DIT ); } /** * This implementation returns a connection and Dn if the selected attribute or value * contains a valid Dn. */ protected ConnectionAndDn getConnectionAndDn() { if ( getSelectedAttributeHierarchies().length == 1 && getSelectedAttributeHierarchies()[0].getAttribute().getValueSize() == 1 && getSelectedSearchResults().length == 1 ) { try { IValue value = getSelectedAttributeHierarchies()[0].getAttribute().getValues()[0]; if ( value.isString() && Dn.isValid( value.getStringValue() ) ) { return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new Dn( value.getStringValue() ) ); } } catch ( LdapInvalidDnException e ) { // no valid Dn } } if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 ) { try { IValue value = getSelectedValues()[0]; if ( value.isString() && Dn.isValid( value.getStringValue() ) ) { return new ConnectionAndDn( value.getAttribute().getEntry().getBrowserConnection(), new Dn( value.getStringValue() ) ); } } catch ( LdapInvalidDnException e ) { // no valid Dn } } if ( getSelectedSearchResults().length == 1 && getSelectedAttributeHierarchies().length == 0 ) { ISearchResult result = getSelectedSearchResults()[0]; return new ConnectionAndDn( result.getEntry().getBrowserConnection(), result.getEntry().getDn() ); } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/PasswordModifyExtendedOperationAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/PasswordModifyExtendedOperationAction.java
/* * 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.actions; import org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyRequest; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; 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.IEntry; import org.apache.directory.studio.ldapbrowser.ui.dialogs.PasswordModifyExtendedOperationDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.PlatformUI; /** * This Action opens the password modify extended operation dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class PasswordModifyExtendedOperationAction extends BrowserAction { public PasswordModifyExtendedOperationAction() { super(); } public void run() { ConnectionAndEntry connectionAndDn = getConnectionAndEntry(); PasswordModifyExtendedOperationDialog passwordDialog = new PasswordModifyExtendedOperationDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(), connectionAndDn.connection, connectionAndDn.entry ); passwordDialog.open(); } private ConnectionAndEntry getConnectionAndEntry() { if ( getSelectedEntries().length > 0 ) { return new ConnectionAndEntry( getSelectedEntries()[0].getBrowserConnection(), getSelectedEntries()[0] ); } else if ( getSelectedSearchResults().length > 0 ) { return new ConnectionAndEntry( getSelectedSearchResults()[0].getEntry().getBrowserConnection(), getSelectedSearchResults()[0].getEntry() ); } else if ( getSelectedBookmarks().length > 0 ) { return new ConnectionAndEntry( getSelectedBookmarks()[0].getEntry().getBrowserConnection(), getSelectedBookmarks()[0].getEntry() ); } else if ( getSelectedConnections().length > 0 ) { Connection connection = getSelectedConnections()[0]; IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); return new ConnectionAndEntry( browserConnection, null ); } else if ( getInput() instanceof IBrowserConnection ) { return new ConnectionAndEntry( ( IBrowserConnection ) getInput(), null ); } return null; } protected class ConnectionAndEntry { private IBrowserConnection connection; private IEntry entry; protected ConnectionAndEntry( IBrowserConnection connection, IEntry entry ) { this.connection = connection; this.entry = entry; } } public String getText() { return Messages.getString( "PasswordModifyExtendedOperationAction.Text" ); //$NON-NLS-1$ } public ImageDescriptor getImageDescriptor() { return null; } public String getCommandId() { return null; } public boolean isEnabled() { return getConnectionAndEntry() != null && getConnectionAndEntry().connection != null && getConnectionAndEntry().connection.getRootDSE() != null && getConnectionAndEntry().connection.getRootDSE() .isExtensionSupported( PasswordModifyRequest.EXTENSION_OID ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorPropertiesAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorPropertiesAction.java
/* * 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.actions; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.common.actions.PropertiesAction; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor; import org.eclipse.ui.IEditorInput; /** * This Action opens the Property Dialog for a given object. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorPropertiesAction extends PropertiesAction { private EntryEditor entryEditor; /** * Creates a new instance of EntryEditorPropertiesAction. * * @param entryEditor * the associated Entry Editor */ public EntryEditorPropertiesAction( EntryEditor entryEditor ) { super(); this.entryEditor = entryEditor; } /** * {@inheritDoc} */ public IEntry[] getSelectedEntries() { // We're only returning the entry when no value is selected if ( getSelectedValues().length == 0 ) { if ( entryEditor != null ) { IEditorInput input = entryEditor.getEditorInput(); if ( input instanceof EntryEditorInput ) { IEntry entry = ( ( EntryEditorInput ) input ).getResolvedEntry(); if ( entry != null ) { return new IEntry[] { entry }; } } } } return new IEntry[0]; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsCsvAction.java
/* * 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.actions; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.AttributeComparator; import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * This Action copies entry(ies) as CSV. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyEntryAsCsvAction extends CopyEntryAsAction { /** * Table Mode. */ public static final int MODE_TABLE = 5; /** * Creates a new instance of CopyEntryAsCsvAction. * * @param mode * the copy Mode */ public CopyEntryAsCsvAction( int mode ) { super( Messages.getString( "CopyEntryAsCsvAction.CSV" ), mode ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { if ( this.mode == MODE_DN_ONLY ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV ); } else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_SEARCHRESULT ); } else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_OPERATIONAL ); } else if ( this.mode == MODE_NORMAL ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV_USER ); } else if ( this.mode == MODE_TABLE ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_TABLE ); } else { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_CSV ); } } /** * {@inheritDoc} */ public String getText() { if ( this.mode == MODE_TABLE ) { return Messages.getString( "CopyEntryAsCsvAction.CopyTable" ); //$NON-NLS-1$ } return super.getText(); } /** * {@inheritDoc} */ public boolean isEnabled() { if ( this.mode == MODE_TABLE ) { return getInput() instanceof ISearch && ( ( ISearch ) getInput() ).getSearchResults() != null && ( ( ISearch ) getInput() ).getSearchResults().length > 0; } return super.isEnabled(); } /** * {@inheritDoc} */ public void run() { if ( this.mode == MODE_TABLE ) { if ( getInput() instanceof ISearch && ( ( ISearch ) getInput() ).getSearchResults() != null && ( ( ISearch ) getInput() ).getSearchResults().length > 0 ) { List<IEntry> entryList = new ArrayList<IEntry>(); ISearchResult[] results = ( ( ISearch ) getInput() ).getSearchResults(); for ( int k = 0; k < results.length; k++ ) { entryList.add( results[k].getEntry() ); } IEntry[] entries = ( IEntry[] ) entryList.toArray( new IEntry[entryList.size()] ); StringBuffer text = new StringBuffer(); serialializeEntries( entries, text ); copyToClipboard( text.toString() ); } } else { super.run(); } } /** * {@inheritDoc} */ public void serialializeEntries( IEntry[] entries, StringBuffer text ) { String attributeDelimiter = BrowserCommonActivator.getDefault().getPreferenceStore().getString( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_ATTRIBUTEDELIMITER ); String valueDelimiter = BrowserCommonActivator.getDefault().getPreferenceStore().getString( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_VALUEDELIMITER ); String quoteCharacter = BrowserCommonActivator.getDefault().getPreferenceStore().getString( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_QUOTECHARACTER ); String lineSeparator = BrowserCommonActivator.getDefault().getPreferenceStore().getString( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_LINESEPARATOR ); int binaryEncoding = BrowserCommonActivator.getDefault().getPreferenceStore().getInt( BrowserCommonConstants.PREFERENCE_FORMAT_TABLE_BINARYENCODING ); String[] returningAttributes = null; if ( this.mode == MODE_DN_ONLY ) { returningAttributes = new String[0]; } else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearchResults().length > 0 && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 ) { returningAttributes = getSelectedSearchResults()[0].getSearch().getReturningAttributes(); } else if ( ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_TABLE ) && getSelectedSearches().length == 1 ) { returningAttributes = getSelectedSearches()[0].getReturningAttributes(); } else if ( ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_TABLE ) && ( getInput() instanceof ISearch ) ) { returningAttributes = ( ( ISearch ) ( getInput() ) ).getReturningAttributes(); } else { Map<String, IAttribute> attributeMap = new HashMap<String, IAttribute>(); for ( int e = 0; entries != null && e < entries.length; e++ ) { IAttribute[] attributes = entries[e].getAttributes(); for ( int a = 0; attributes != null && a < attributes.length; a++ ) { if ( attributes[a].isOperationalAttribute() && this.mode != MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) continue; if ( !attributeMap.containsKey( attributes[a].getDescription() ) ) { attributeMap.put( attributes[a].getDescription(), attributes[a] ); } } } IAttribute[] attributes = ( IAttribute[] ) attributeMap.values().toArray( new IAttribute[attributeMap.size()] ); if ( attributes.length > 0 ) { AttributeComparator comparator = new AttributeComparator(); Arrays.sort( attributes, comparator ); } returningAttributes = new String[attributes.length]; for ( int i = 0; i < attributes.length; i++ ) { returningAttributes[i] = attributes[i].getDescription(); } } // header if ( this.mode != MODE_TABLE || BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) ) { text.append( quoteCharacter ); text.append( "Dn" ); //$NON-NLS-1$ text.append( quoteCharacter ); text.append( attributeDelimiter ); } for ( int a = 0; returningAttributes != null && a < returningAttributes.length; a++ ) { text.append( quoteCharacter ); text.append( returningAttributes[a] ); text.append( quoteCharacter ); if ( a + 1 < returningAttributes.length ) { text.append( attributeDelimiter ); } } text.append( lineSeparator ); for ( int e = 0; entries != null && e < entries.length; e++ ) { if ( this.mode != MODE_TABLE || BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) ) { text.append( quoteCharacter ); text.append( entries[e].getDn().getName() ); text.append( quoteCharacter ); text.append( attributeDelimiter ); } for ( int a = 0; returningAttributes != null && a < returningAttributes.length; a++ ) { AttributeComparator comparator = new AttributeComparator(); AttributeHierarchy ah = entries[e].getAttributeWithSubtypes( returningAttributes[a] ); if ( ah != null ) { StringBuffer valueSB = new StringBuffer(); for ( Iterator it = ah.iterator(); it.hasNext(); ) { IAttribute attribute = ( IAttribute ) it.next(); if ( attribute != null ) { IValue[] values = attribute.getValues(); Arrays.sort( values, comparator ); for ( int v = 0; v < values.length; v++ ) { String val = ModelConverter.getStringValue( values[v], binaryEncoding ); valueSB.append( val ); if ( v + 1 < values.length ) { valueSB.append( valueDelimiter ); } } } if ( it.hasNext() ) { valueSB.append( valueDelimiter ); } } String value = valueSB.toString().replaceAll( quoteCharacter, quoteCharacter + quoteCharacter ); text.append( quoteCharacter ); text.append( value ); text.append( quoteCharacter ); } // IAttribute attribute = // entries[e].getAttribute(returningAttributes[a]); // if (attribute != null) { // // IValue[] values = attribute.getValues(); // Arrays.sort(values, comparator); // // StringBuffer valueSB = new StringBuffer(); // for (int v = 0; v < values.length; v++) { // String val = LdifUtils.getStringValue(values[v], // binaryEncoding); // valueSB.append(val); // if (v + 1 < values.length) { // valueSB.append(valueDelimiter); // ; // } // } // // String value = valueSB.toString().replaceAll(quoteCharacter, // quoteCharacter + quoteCharacter); // text.append(quoteCharacter); // text.append(value); // text.append(quoteCharacter); // // } if ( a + 1 < returningAttributes.length ) { text.append( attributeDelimiter ); } } if ( e < entries.length ) { text.append( lineSeparator ); } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/GotoDnNavigateMenuAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/GotoDnNavigateMenuAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.ClipboardUtils; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.common.dialogs.DnDialog; import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.ui.PlatformUI; /** * This action locates a Dn that the user entered into a dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class GotoDnNavigateMenuAction extends LocateInDitAction { /** * {@inheritDoc} */ public String getText() { return Messages.getString( "GotoDnAction.GotoDN" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_DN_IN_DIT ); } /** * {@inheritDoc} */ public boolean isEnabled() { return ( getSelectedConnection() != null ); } /** * {@inheritDoc} */ protected ConnectionAndDn getConnectionAndDn() { Connection selectedConnection = getSelectedConnection(); if ( selectedConnection != null ) { // Getting the browser connection associated with the connection IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( selectedConnection ); // Getting the DN from the clipboard (if any) Dn dn = Utils.getLdapDn( ClipboardUtils.getFromClipboard( TextTransfer.getInstance(), String.class ) ); // Displaying the DN dialog DnDialog dialog = new DnDialog( getShell(), Messages.getString( "GotoDnAction.GotoDNAction" ), Messages.getString( "GotoDnAction.EnterDNAction" ), connection, dn ); //$NON-NLS-1$ //$NON-NLS-2$ if ( dialog.open() == TextDialog.OK && dialog.getDn() != null ) { dn = dialog.getDn(); return new ConnectionAndDn( connection, dn ); } } return null; } /** * Gets the currently selected connection. * * @return the currently selected connection */ private Connection getSelectedConnection() { // Getting the connections view ConnectionView connectionView = ( ConnectionView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().findView( ConnectionView.getId() ); if ( connectionView != null ) { // Getting the selection of the connections view StructuredSelection selection = ( StructuredSelection ) connectionView.getMainWidget().getViewer() .getSelection(); // Checking if only one object is selected if ( selection.size() == 1 ) { Object selectedObject = selection.getFirstElement(); // Checking if the selected object is a connection if ( selectedObject instanceof Connection ) { return ( Connection ) selectedObject; } } } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyValueAction.java
/* * 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.actions; import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldifparser.LdifUtils; import org.apache.directory.studio.valueeditors.IValueEditor; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; /** * This Action copies values of the seleced Entry to the Clipboard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyValueAction extends BrowserAction { public enum Mode { /** * UTF8 Mode. */ UTF8, /** * Base64 Mode. */ BASE64, /** * Hexadecimal Mode. */ HEX, /** * LDIF Mode. */ LDIF, /** * Display mode, copies the display value. */ DISPLAY, } private Mode mode; private ValueEditorManager valueEditorManager; /** * Creates a new instance of CopyValueAction. * * @param mode * the copy Mode */ public CopyValueAction( Mode mode, ValueEditorManager valueEditorManager ) { this.mode = mode; this.valueEditorManager = valueEditorManager; } /** * {@inheritDoc} */ public String getText() { switch ( mode ) { case UTF8: return getValueSet().size() > 1 ? Messages.getString( "CopyValueAction.CopyValuesUTF" ) : Messages.getString( "CopyValueAction.CopyValueUTF" ); //$NON-NLS-1$ //$NON-NLS-2$ case BASE64: return getValueSet().size() > 1 ? Messages.getString( "CopyValueAction.CopyValuesBase" ) : Messages.getString( "CopyValueAction.CopyValueBase" ); //$NON-NLS-1$ //$NON-NLS-2$ case HEX: return getValueSet().size() > 1 ? Messages.getString( "CopyValueAction.VopyValuesHex" ) : Messages.getString( "CopyValueAction.CopyValueHex" ); //$NON-NLS-1$ //$NON-NLS-2$ case LDIF: return getValueSet().size() > 1 ? Messages.getString( "CopyValueAction.CopyValuePairs" ) : Messages.getString( "CopyValueAction.CopyValuePair" ); //$NON-NLS-1$ //$NON-NLS-2$ case DISPLAY: return getValueSet().size() > 1 ? Messages.getString( "CopyValueAction.CopyDisplayValues" ) : Messages.getString( "CopyValueAction.CopyDisplayValue" ); //$NON-NLS-1$ //$NON-NLS-2$ default: return Messages.getString( "CopyValueAction.CopyValue" ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { switch ( mode ) { case UTF8: return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_UTF8 ); case BASE64: return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_BASE64 ); case HEX: return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_HEX ); case LDIF: return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF ); case DISPLAY: return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_DISPLAY ); default: return null; } } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getValueSet().size() > 0 || getSelectedSearchResults().length > 0; } /** * {@inheritDoc} */ public void run() { StringBuffer text = new StringBuffer(); Set<IValue> valueSet = getValueSet(); if ( !valueSet.isEmpty() ) { for ( Iterator<IValue> iterator = valueSet.iterator(); iterator.hasNext(); ) { IValue value = iterator.next(); switch ( mode ) { case UTF8: text.append( LdifUtils.utf8decode( value.getBinaryValue() ) ); if ( iterator.hasNext() ) { text.append( BrowserCoreConstants.LINE_SEPARATOR ); } break; case BASE64: text.append( LdifUtils.base64encode( value.getBinaryValue() ) ); if ( iterator.hasNext() ) { text.append( BrowserCoreConstants.LINE_SEPARATOR ); } break; case HEX: text.append( LdifUtils.hexEncode( value.getBinaryValue() ) ); if ( iterator.hasNext() ) { text.append( BrowserCoreConstants.LINE_SEPARATOR ); } break; case LDIF: text.append( ModelConverter.valueToLdifAttrValLine( value ).toFormattedString( Utils.getLdifFormatParameters() ) ); break; case DISPLAY: IValueEditor ve = valueEditorManager.getCurrentValueEditor( value ); String displayValue = ve.getDisplayValue( value ); text.append( displayValue ); if ( iterator.hasNext() ) { text.append( BrowserCoreConstants.LINE_SEPARATOR ); } break; } } } else if ( getSelectedSearchResults().length > 0 ) { Dn dn = getSelectedSearchResults()[0].getDn(); switch ( mode ) { case UTF8: case DISPLAY: text.append( dn.getName() ); break; case BASE64: text.append( LdifUtils.base64encode( LdifUtils.utf8encode( dn.getName() ) ) ); break; case HEX: text.append( LdifUtils.hexEncode( LdifUtils.utf8encode( dn.getName() ) ) ); break; case LDIF: text.append( ModelConverter.dnToLdifDnLine( dn ) .toFormattedString( Utils.getLdifFormatParameters() ) ); break; } } if ( text.length() > 0 ) { CopyAction.copyToClipboard( new Object[] { text.toString() }, new Transfer[] { TextTransfer.getInstance() } ); } } /** * Gets a Set containing all the Values * * @return * a Set containing all the Values */ protected Set<IValue> getValueSet() { Set<IValue> valueSet = new LinkedHashSet<IValue>(); for ( AttributeHierarchy ah : getSelectedAttributeHierarchies() ) { for ( IAttribute att : ah ) { valueSet.addAll( Arrays.asList( att.getValues() ) ); } } for ( IAttribute att : getSelectedAttributes() ) { valueSet.addAll( Arrays.asList( att.getValues() ) ); } valueSet.addAll( Arrays.asList( getSelectedValues() ) ); return valueSet; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/GotoDnAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/GotoDnAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.ClipboardUtils; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.common.dialogs.DnDialog; import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; 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.swt.dnd.TextTransfer; /** * This action locates a Dn that the user entered into a dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class GotoDnAction extends LocateInDitAction { /** * Creates a new instance of LocateDnInDitAction. */ public GotoDnAction() { } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "GotoDnAction.GotoDN" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_DN_IN_DIT ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getInput() instanceof IBrowserConnection; } /** * This implementation returns a connection and Dn if th user put * a valid Dn into the dialog */ protected ConnectionAndDn getConnectionAndDn() { if ( getInput() instanceof IBrowserConnection ) { IBrowserConnection conn = ( IBrowserConnection ) getInput(); Dn dn = Utils.getLdapDn( ClipboardUtils.getFromClipboard( TextTransfer.getInstance(), String.class ) ); DnDialog dialog = new DnDialog( getShell(), Messages.getString( "GotoDnAction.GotoDNAction" ), Messages.getString( "GotoDnAction.EnterDNAction" ), conn, dn ); //$NON-NLS-1$ //$NON-NLS-2$ if ( dialog.open() == TextDialog.OK && dialog.getDn() != null ) { dn = dialog.getDn(); return new ConnectionAndDn( conn, dn ); } } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/Messages.java
/* * 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.actions; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/EntryEditorMenuManager.java
/* * 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.actions; import java.util.Collection; import org.apache.directory.studio.entryeditors.EntryEditorExtension; import org.apache.directory.studio.entryeditors.EntryEditorManager; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; public class EntryEditorMenuManager extends MenuManager implements IMenuListener { /** The selection provider */ private ISelectionProvider selectionProvider; /** The OpenEntryEditorsPreferencePageAction */ private OpenEntryEditorsPreferencePageAction openEntryEditorsPreferencePageAction; /** * Creates a menu manager. The text and id are <code>null</code>. * Typically used for creating a context menu, where it doesn't need to be referred to by id. */ public EntryEditorMenuManager( ISelectionProvider selectionProvider ) { super( Messages.getString( "EntryEditorMenuManager.OpenWith" ) ); //$NON-NLS-1$ this.selectionProvider = selectionProvider; openEntryEditorsPreferencePageAction = new OpenEntryEditorsPreferencePageAction(); addMenuListener( this ); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager manager ) { // As the Menu Manager is dynamic, we need to // remove all the previously added actions removeAll(); // Getting the currently selected entry IEntry selectedEntry = getCurrentSelection(); if ( selectedEntry != null ) { // Getting the entry editors and creating an action for each one // that can handle the entry Collection<EntryEditorExtension> entryEditors = BrowserUIPlugin.getDefault().getEntryEditorManager() .getSortedEntryEditorExtensions(); for ( EntryEditorExtension entryEditor : entryEditors ) { // Verifying that the editor can handle the entry if ( entryEditor.getEditorInstance().canHandle( selectedEntry ) ) { // Creating the action associated with the entry editor add( createAction( entryEditor ) ); } } } // Separator add( new Separator() ); // Preferences Action add( openEntryEditorsPreferencePageAction ); } /** * Gets the currently selected entry. * * @return * the currently selected entry */ private IEntry getCurrentSelection() { StructuredSelection structuredSelection = ( StructuredSelection ) selectionProvider.getSelection(); if ( !structuredSelection.isEmpty() ) { Object selection = structuredSelection.getFirstElement(); if ( selection instanceof IEntry ) { return ( IEntry ) selection; } else if ( selection instanceof ISearchResult ) { return ( ( ISearchResult ) selection ).getEntry(); } else if ( selection instanceof IBookmark ) { return ( ( IBookmark ) selection ).getEntry(); } } return null; } /** * Creates an action for the given entry editor. * * @param entryEditorExtension * the entry editor * @return * an action associated with the entry editor */ private IAction createAction( final EntryEditorExtension entryEditorExtension ) { Action action = new Action( entryEditorExtension.getName(), entryEditorExtension.getIcon() ) { public void run() { EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager(); ISelection selection = selectionProvider.getSelection(); IEntry[] selectedEntries = BrowserSelectionUtils.getEntries( selection ); ISearchResult[] selectedSearchResults = BrowserSelectionUtils.getSearchResults( selection ); IBookmark[] selectedBookMarks = BrowserSelectionUtils.getBookmarks( selection ); entryEditorManager.openEntryEditor( entryEditorExtension, selectedEntries, selectedSearchResults, selectedBookMarks ); } }; return action; } /** * {@inheritDoc} */ public boolean isVisible() { ISelection selection = selectionProvider.getSelection(); IBookmark[] selectedBookMarks = BrowserSelectionUtils.getBookmarks( selection ); IEntry[] selectedEntries = BrowserSelectionUtils.getEntries( selection ); ISearchResult[] selectedSearchResults = BrowserSelectionUtils.getSearchResults( selection ); return ( selectedSearchResults.length + selectedBookMarks.length + selectedEntries.length == 1 ); } /** * {@inheritDoc} */ public boolean isDynamic() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewBatchOperationAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewBatchOperationAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.BatchOperationWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardDialog; /** * This Action opens the New Batch Operation Dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewBatchOperationAction extends BrowserAction { /** * Creates a new instance of NewBatchOperationAction. */ public NewBatchOperationAction() { } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewBatchOperationAction.NewBatch" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BATCH ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getSelectedSearches().length == 1 && getSelectedSearches()[0].getSearchResults() != null || getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length + getSelectedAttributes().length + getSelectedValues().length > 0; } /** * {@inheritDoc} */ public void run() { BatchOperationWizard wizard = new BatchOperationWizard(); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ImportExportAction.java
/* * 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.actions; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; 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.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportCsvWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportDsmlWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportExcelWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportLdifWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportOdfWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ImportDsmlWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.ImportLdifWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.WizardDialog; /** * This class implements Import/Export Actions for LDIF, CSV, EXCEL, ODF and DSML. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportExportAction extends BrowserAction { /** * LDIF Import Type */ public static final int TYPE_IMPORT_LDIF = 0; /** * LDIF Export Type */ public static final int TYPE_EXPORT_LDIF = 1; /** * CSV Export Type */ public static final int TYPE_EXPORT_CSV = 2; /** * EXCEL Export Type */ public static final int TYPE_EXPORT_EXCEL = 3; /** * DSML Import Type */ public static final int TYPE_IMPORT_DSML = 4; /** * DSML Export Type */ public static final int TYPE_EXPORT_DSML = 5; /** * ODF Export Type */ public static final int TYPE_EXPORT_ODF = 6; private int type; /** * Creates a new instance of ImportExportAction. * * @param type * the type of Import/Export */ public ImportExportAction( int type ) { super(); this.type = type; } /** * {@inheritDoc} */ public String getText() { if ( this.type == TYPE_IMPORT_LDIF ) { return Messages.getString( "ImportExportAction.LDIFImport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_EXPORT_LDIF ) { return Messages.getString( "ImportExportAction.LDIFExport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_EXPORT_CSV ) { return Messages.getString( "ImportExportAction.CVSExport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_EXPORT_EXCEL ) { return Messages.getString( "ImportExportAction.ExcelExport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_EXPORT_ODF ) { return Messages.getString( "ImportExportAction.OdfExport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_IMPORT_DSML ) { return Messages.getString( "ImportExportAction.DSMLImport" ); //$NON-NLS-1$ } else if ( this.type == TYPE_EXPORT_DSML ) { return Messages.getString( "ImportExportAction.DSMLExport" ); //$NON-NLS-1$ } else { return Messages.getString( "ImportExportAction.Export" ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { if ( this.type == TYPE_IMPORT_LDIF ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_LDIF ); } else if ( this.type == TYPE_EXPORT_LDIF ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_LDIF ); } else if ( this.type == TYPE_EXPORT_CSV ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CSV ); } else if ( this.type == TYPE_EXPORT_EXCEL ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_XLS ); } else if ( this.type == TYPE_EXPORT_ODF ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_ODF ); } else if ( this.type == TYPE_IMPORT_DSML ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_DSML ); } else if ( this.type == TYPE_EXPORT_DSML ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_DSML ); } else { return null; } } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getEntry() != null || getConnection() != null || getSearch() != null || getConnectionInput() != null; } /** * {@inheritDoc} */ public void run() { IWizard wizard = null; if ( this.type == TYPE_IMPORT_LDIF ) { if ( getEntry() != null ) { wizard = new ImportLdifWizard( getEntry().getBrowserConnection() ); } else if ( getSearch() != null ) { wizard = new ImportLdifWizard( getSearch().getBrowserConnection() ); } else if ( getConnectionInput() != null ) { wizard = new ImportLdifWizard( getConnectionInput() ); } else if ( getConnection() != null ) { wizard = new ImportLdifWizard( getConnection() ); } } else if ( this.type == TYPE_IMPORT_DSML ) { if ( getEntry() != null ) { wizard = new ImportDsmlWizard( getEntry().getBrowserConnection() ); } else if ( getSearch() != null ) { wizard = new ImportDsmlWizard( getSearch().getBrowserConnection() ); } else if ( getConnectionInput() != null ) { wizard = new ImportDsmlWizard( getConnectionInput() ); } else if ( getConnection() != null ) { wizard = new ImportDsmlWizard( getConnection() ); } } else if ( this.type == TYPE_EXPORT_LDIF ) { wizard = new ExportLdifWizard(); } else if ( this.type == TYPE_EXPORT_CSV ) { wizard = new ExportCsvWizard(); } else if ( this.type == TYPE_EXPORT_EXCEL ) { wizard = new ExportExcelWizard(); } else if ( this.type == TYPE_EXPORT_ODF ) { wizard = new ExportOdfWizard(); } else if ( this.type == TYPE_EXPORT_DSML ) { wizard = new ExportDsmlWizard(); } if ( wizard != null ) { WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } } /** * Gets the selected Entry. * * @return * the selected Entry */ protected IEntry getEntry() { IEntry entry = null; if ( getSelectedEntries().length > 0 ) { entry = getSelectedEntries()[0]; } else if ( getSelectedSearchResults().length > 0 ) { entry = getSelectedSearchResults()[0].getEntry(); } else if ( getSelectedBookmarks().length > 0 ) { entry = getSelectedBookmarks()[0].getEntry(); } return entry != null ? entry : null; } /** * Gets the Connection. * * @return * the Connection */ protected IBrowserConnection getConnection() { if ( getSelectedConnections().length > 0 && getSelectedConnections()[0].getConnectionWrapper().isConnected() ) { Connection connection = getSelectedConnections()[0]; IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); return browserConnection; } else { return null; } } /** * Gets the Search. * * @return * the Search */ protected ISearch getSearch() { return getSelectedSearches().length > 0 ? getSelectedSearches()[0] : null; } /** * Gets the Connection Input. * * @return * the Connection Input */ protected IBrowserConnection getConnectionInput() { if ( getInput() instanceof IBrowserConnection ) { return ( IBrowserConnection ) getInput(); } else { return null; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateInDitAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/LocateInDitAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * This action is used to locate and open an entry by its Dn in DIT. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class LocateInDitAction extends BrowserAction { /** * {@inheritDoc} */ public final void run() { ConnectionAndDn connectionAndDn = getConnectionAndDn(); if ( connectionAndDn != null ) { IBrowserConnection connection = connectionAndDn.connection; Dn dn = connectionAndDn.dn; IEntry entry = connection.getEntryFromCache( dn ); if ( entry == null ) { ReadEntryRunnable runnable = new ReadEntryRunnable( connection, dn ); RunnableContextRunner.execute( runnable, null, true ); entry = runnable.getReadEntry(); } if ( entry != null ) { String targetId = BrowserView.getId(); IViewPart targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView( targetId ); if ( targetView == null ) { try { targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( targetId, null, IWorkbenchPage.VIEW_ACTIVATE ); } catch ( PartInitException e ) { } } if ( targetView instanceof BrowserView ) { ( ( BrowserView ) targetView ).select( entry ); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate( targetView ); } } } } /** * {@inheritDoc} */ public String getCommandId() { return BrowserUIConstants.CMD_LOCATE_IN_DIT; } /** * {@inheritDoc} */ public boolean isEnabled() { return getConnectionAndDn() != null; } /** * Get the connection and Dn to open. * * @return a ConnectionAndDn bean, or null. */ protected abstract ConnectionAndDn getConnectionAndDn(); /** * Inner class to get connection and Dn of the entry to locate. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ protected class ConnectionAndDn { /** The connection */ private IBrowserConnection connection; /** The Dn */ private Dn dn; /** * Creates a new instance of ConnectionAndDn. * * @param connection the connection * @param dn the Dn */ protected ConnectionAndDn( IBrowserConnection connection, Dn dn ) { this.connection = connection; this.dn = dn; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorAction.java
/* * 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.actions; import org.apache.directory.studio.entryeditors.EntryEditorManager; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * This class implements the Open Entry Editor Action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEntryEditorAction extends BrowserAction { /** * Creates a new instance of OpenEntryEditorAction. */ public OpenEntryEditorAction() { } /** * {@inheritDoc} */ public void run() { EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager(); entryEditorManager.openEntryEditor( getSelectedEntries(), getSelectedSearchResults(), getSelectedBookmarks() ); } /** * {@inheritDoc} */ public String getText() { if ( getSelectedSearchResults().length == 1 && getSelectedBookmarks().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length == 0 ) { return Messages.getString( "OpenEntryEditorAction.OpenSearchResult" ); //$NON-NLS-1$ } else if ( getSelectedBookmarks().length == 1 && getSelectedSearchResults().length + getSelectedEntries().length + getSelectedBrowserViewCategories().length == 0 ) { return Messages.getString( "OpenEntryEditorAction.OpenBookmark" ); //$NON-NLS-1$ } else { return Messages.getString( "OpenEntryEditorAction.OpenEntry" ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return null; } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 1 || getSelectedAttributes().length + getSelectedValues().length > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/MoveAction.java
/* * 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.actions; import java.util.LinkedHashSet; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.dialogs.MoveEntriesDialog; import org.apache.directory.studio.ldapbrowser.common.dialogs.SimulateRenameDialogImpl; import org.apache.directory.studio.ldapbrowser.core.jobs.MoveEntriesRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.impl.RootDSE; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; /** * This Action moves entries from one node of the tree to another. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MoveAction extends BrowserAction { /** * Creates a new instance of MoveAction. */ public MoveAction() { super(); } /** * {@inheritDoc} */ public String getText() { IEntry[] entries = getEntries(); ISearch[] searches = getSearches(); IBookmark[] bookmarks = getBookmarks(); if ( entries.length > 0 && searches.length == 0 && bookmarks.length == 0 ) { return entries.length == 1 ? Messages.getString( "MoveAction.MoveEntry" ) : Messages.getString( "MoveAction.MoveEntries" ); //$NON-NLS-1$ //$NON-NLS-2$ } else { return Messages.getString( "MoveAction.Move" ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return null; } /** * {@inheritDoc} */ public String getCommandId() { return IWorkbenchActionDefinitionIds.MOVE; } /** * {@inheritDoc} */ public void run() { IEntry[] entries = getEntries(); ISearch[] searches = getSearches(); IBookmark[] bookmarks = getBookmarks(); if ( entries.length > 0 && searches.length == 0 && bookmarks.length == 0 ) { moveEntries( entries ); } } /** * {@inheritDoc} */ public boolean isEnabled() { try { IEntry[] entries = getEntries(); ISearch[] searches = getSearches(); IBookmark[] bookmarks = getBookmarks(); return entries.length > 0 && searches.length == 0 && bookmarks.length == 0; } catch ( Exception e ) { return false; } } /** * Gets the Entries. * * @return * the Entries */ protected IEntry[] getEntries() { if ( getSelectedBookmarks().length + getSelectedSearches().length + getSelectedAttributes().length + getSelectedValues().length == 0 && getSelectedEntries().length + getSelectedSearchResults().length > 0 ) { LinkedHashSet<IEntry> entriesSet = new LinkedHashSet<IEntry>(); for ( int i = 0; i < getSelectedEntries().length; i++ ) { entriesSet.add( getSelectedEntries()[i] ); } for ( int i = 0; i < this.getSelectedSearchResults().length; i++ ) { entriesSet.add( this.getSelectedSearchResults()[i].getEntry() ); } IEntry[] entries = ( IEntry[] ) entriesSet.toArray( new IEntry[entriesSet.size()] ); for ( int i = 0; i < entries.length; i++ ) { if ( entries[i] == null || entries[i] instanceof RootDSE ) { return new IEntry[0]; } } return entries; } else { return new IEntry[0]; } } /** * Opens a Move Entries Dialog and launches the Move Entries Jobs. * * @param entries * the entries to move */ protected void moveEntries( final IEntry[] entries ) { MoveEntriesDialog moveDialog = new MoveEntriesDialog( getShell(), entries ); if ( moveDialog.open() == Dialog.OK ) { Dn newParentDn = moveDialog.getParentDn(); if ( newParentDn != null /* && !newRdn.equals(entry.getRdn()) */) { IEntry newParentEntry = entries[0].getBrowserConnection().getEntryFromCache( newParentDn ); if ( newParentEntry == null ) { ReadEntryRunnable runnable = new ReadEntryRunnable( entries[0].getBrowserConnection(), newParentDn ); RunnableContextRunner.execute( runnable, null, true ); newParentEntry = runnable.getReadEntry(); } if ( newParentEntry != null ) { new StudioBrowserJob( new MoveEntriesRunnable( entries, newParentEntry, new SimulateRenameDialogImpl( getShell() ) ) ).execute(); } } } } /** * Gets the searches. * * @return * the searches */ protected ISearch[] getSearches() { if ( getSelectedSearches().length == 1 ) { return getSelectedSearches(); } else { return new ISearch[0]; } } /** * Gets the Bookmarks * * @return * the Bookmarks */ protected IBookmark[] getBookmarks() { if ( getSelectedBookmarks().length == 1 ) { return getSelectedBookmarks(); } else { return new IBookmark[0]; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorsPreferencePageAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEntryEditorsPreferencePageAction.java
/* * 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.actions; 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; /** * The OpenEntryEditorsPreferencePageAction is used to open the * preference dialog with the entry editors preference page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEntryEditorsPreferencePageAction extends Action { /** * Creates a new instance of OpenBrowserPreferencePageAction. */ public OpenEntryEditorsPreferencePageAction() { super.setText( Messages.getString( "OpenEntryEditorsPageAction.Preferences" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenEntryEditorsPageAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String pageId = BrowserUIConstants.PREFERENCEPAGEID_ENTRYEDITORS; PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[] { pageId }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExportConnectionsAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/ExportConnectionsAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportConnectionsWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; /** * This Action launches the Export Connections Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportConnectionsAction extends BrowserAction { /** * Creates a new instance of ExportConnectionsAction. */ public ExportConnectionsAction() { super(); } /** * {@inheritDoc} */ public void run() { ExportConnectionsWizard wizard = new ExportConnectionsWizard(); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); wizard.init( window.getWorkbench(), ( IStructuredSelection ) window.getSelectionService().getSelection() ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "ExportConnectionsAction.ExportConnections" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CONNECTIONS ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewContextEntryAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewContextEntryAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.wizards.NewContextEntryWizard; 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.INewWizard; import org.eclipse.ui.IWorkbenchWindow; /** * This action launches the New Context Entry Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewContextEntryAction extends NewEntryAction { /** * Creates a new instance of NewContextEntryAction. */ public NewContextEntryAction() { } /** * Creates a new instance of NewContextEntryAction. * * @param window * the associated Window */ public NewContextEntryAction( IWorkbenchWindow window ) { super( window ); } /** * {@inheritDoc} */ protected INewWizard getWizard() { return new NewContextEntryWizard(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewEntryAction.NewContextEntry" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_ADD ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyUrlAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.url.LdapUrl; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; 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.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; /** * This Action copies the URL of the selected Entry to the Clipboard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyUrlAction extends BrowserAction { /** * Creates a new instance of CopyUrlAction. */ public CopyUrlAction() { } /** * {@inheritDoc} */ public void run() { LdapUrl url = null; if ( getSelectedSearches().length > 0 ) { url = getSelectedSearches()[0].getUrl(); } else if ( getSelectedEntries().length > 0 ) { url = getSelectedEntries()[0].getUrl(); } else if ( getSelectedAttributes().length > 0 ) { url = getSelectedAttributes()[0].getEntry().getUrl(); } else if ( getSelectedAttributeHierarchies().length > 0 ) { url = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getUrl(); } else if ( getSelectedValues().length > 0 ) { url = getSelectedValues()[0].getAttribute().getEntry().getUrl(); } else if ( getSelectedSearchResults().length > 0 ) { url = getSelectedSearchResults()[0].getEntry().getUrl(); } else if ( getSelectedBookmarks().length > 0 ) { url = getSelectedBookmarks()[0].getEntry().getUrl(); } if ( url != null ) { CopyAction.copyToClipboard( new Object[] { url.toString() }, new Transfer[] { TextTransfer.getInstance() } ); } } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "CopyUrlAction.CopyURL" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_URL ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getSelectedSearches().length + getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 1 || getSelectedAttributes().length + getSelectedValues().length > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEncoderDecoderDialogAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/OpenEncoderDecoderDialogAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.dialogs.EncoderDecoderDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.PlatformUI; /** * This Action opens the Encoder/Decoder Dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEncoderDecoderDialogAction extends BrowserAction { /** * Creates a new instance of OpenEncoderDecoderDialogAction. */ public OpenEncoderDecoderDialogAction() { super(); } /** * {@inheritDoc} */ public void run() { EncoderDecoderDialog dlg = new EncoderDecoderDialog( PlatformUI.getWorkbench().getDisplay().getActiveShell() ); dlg.open(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "OpenEncoderDecoderDialogAction.OpenEndoderDecoder" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return null; } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewBookmarkAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewBookmarkAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.NewBookmarkWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; /** * This Action creates a new Bookmark. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewBookmarkAction extends BrowserAction { /** * Creates a new instance of NewBookmarkAction. */ public NewBookmarkAction() { } /** * {@inheritDoc} */ public void run() { NewBookmarkWizard wizard = new NewBookmarkWizard(); IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); wizard.init( window.getWorkbench(), ( IStructuredSelection ) window.getSelectionService().getSelection() ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewBookmarkAction.NewBookmark" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BOOKMARK_ADD ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewSearchAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewSearchAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.search.SearchPage; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.PlatformUI; /** * This Action opens a new Search Dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewSearchAction extends BrowserAction { /** * Creates a new instance of NewSearchAction. */ public NewSearchAction() { super(); } /** * {@inheritDoc} */ public void run() { NewSearchUI.openSearchDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), SearchPage.getId() ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewSearchAction.NewSearch" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_SEARCH_NEW ); } /** * {@inheritDoc} */ public String getCommandId() { return "org.eclipse.search.ui.openSearchDialog"; //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyDnAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; 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.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; /** * This class implements the Copy Drag'n'Drop Action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyDnAction extends BrowserAction { /** * Creates a new instance of CopyDnAction. */ public CopyDnAction() { } /** * {@inheritDoc} */ public void run() { String dn = null; if ( getSelectedEntries().length > 0 ) { dn = getSelectedEntries()[0].getDn().getName(); } else if ( getSelectedAttributes().length > 0 ) { dn = getSelectedAttributes()[0].getEntry().getDn().getName(); } else if ( getSelectedAttributeHierarchies().length > 0 ) { dn = getSelectedAttributeHierarchies()[0].getAttribute().getEntry().getDn().getName(); } else if ( getSelectedValues().length > 0 ) { dn = getSelectedValues()[0].getAttribute().getEntry().getDn().getName(); } else if ( getSelectedSearchResults().length > 0 ) { dn = getSelectedSearchResults()[0].getDn().getName(); } else if ( getSelectedBookmarks().length > 0 ) { dn = getSelectedBookmarks()[0].getDn().getName(); } if ( dn != null ) { CopyAction.copyToClipboard( new Object[] { dn }, new Transfer[] { TextTransfer.getInstance() } ); } } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "CopyDnAction.CopyDN" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_DN ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 1 || getSelectedAttributes().length + getSelectedValues().length > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsLdifAction.java
/* * 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.actions; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.AttributeComparator; import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * This Action copies entry(ies) as LDIF. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class CopyEntryAsLdifAction extends CopyEntryAsAction { /** * Creates a new instance of CopyEntryAsLdifAction. * * @param mode * the copy Mode */ public CopyEntryAsLdifAction( int mode ) { super( Messages.getString( "CopyEntryAsLdifAction.LDIF" ), mode ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { if ( this.mode == MODE_DN_ONLY ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF ); } else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_SEARCHRESULT ); } else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_OPERATIONAL ); } else { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_COPY_LDIF_USER ); } } /** * {@inheritDoc} */ public void serialializeEntries( IEntry[] entries, StringBuffer text ) { String lineSeparator = BrowserCorePlugin.getDefault().getPluginPreferences().getString( BrowserCoreConstants.PREFERENCE_LDIF_LINE_SEPARATOR ); Set<String> returningAttributesSet = null; if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearchResults().length > 0 && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 ) { returningAttributesSet = new HashSet<String>( Arrays.asList( getSelectedSearchResults()[0].getSearch() .getReturningAttributes() ) ); } else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY && getSelectedSearches().length == 1 ) { returningAttributesSet = new HashSet<String>( Arrays.asList( getSelectedSearches()[0].getReturningAttributes() ) ); } boolean isFirst = true; for ( IEntry entry : entries ) { if ( isFirst ) { isFirst = false; } else { text.append( lineSeparator ); } serializeDn( entry.getDn(), text ); if ( this.mode != MODE_DN_ONLY ) { List<IValue> valueList = new ArrayList<IValue>(); IAttribute[] attributes = entry.getAttributes(); if ( attributes != null ) { for ( IAttribute attribute : attributes ) { if ( ( returningAttributesSet != null ) && !returningAttributesSet.contains( attribute.getType() ) ) { continue; } if (( attribute.isOperationalAttribute() ) && ( this.mode != MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) { continue; } for ( IValue value : attribute.getValues() ) { valueList.add( value ); } } } IValue[] values = ( IValue[] ) valueList.toArray( new IValue[valueList.size()] ); AttributeComparator comparator = new AttributeComparator(); Arrays.sort( values, comparator ); for ( IValue value : values ) { serializeValue( value, text ); } } } } /** * Serializes a Value. * * @param value * the Value to serialize * @param text * the StringBuffer to serialize to */ protected void serializeValue( IValue value, StringBuffer text ) { text .append( ModelConverter.valueToLdifAttrValLine( value ).toFormattedString( Utils.getLdifFormatParameters() ) ); } /** * Serialize a Dn. * * @param dn * the Dn to serialize * @param text * the StringBuffer to serialize to */ protected void serializeDn( Dn dn, StringBuffer text ) { text.append( ModelConverter.dnToLdifDnLine( dn ).toFormattedString( Utils.getLdifFormatParameters() ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewEntryAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/NewEntryAction.java
/* * 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.actions; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.wizards.NewEntryWizard; 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.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbenchWindow; /** * This action launches the New Entry Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewEntryAction extends BrowserAction { protected IWorkbenchWindow window; /** * Creates a new instance of NewEntryAction. */ public NewEntryAction() { } /** * Creates a new instance of NewEntryAction. * * @param window * the associated Window */ public NewEntryAction( IWorkbenchWindow window ) { super(); this.window = window; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); this.window = null; } /** * {@inheritDoc} */ public void init( IWorkbenchWindow window ) { super.init( window ); this.window = window; } /** * {@inheritDoc} */ public void run() { INewWizard wizard = getWizard(); wizard.init( window.getWorkbench(), ( IStructuredSelection ) window.getSelectionService().getSelection() ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } /** * {@inheritDoc} */ protected INewWizard getWizard() { return new NewEntryWizard(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewEntryAction.NewEntry" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_ENTRY_ADD ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/CopyEntryAsAction.java
/* * 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.actions; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.widgets.Display; /** * This abstract class must be extended by each Action that <em>"Copies an Entry as..."</em>. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class CopyEntryAsAction extends BrowserAction { /** * Returns Dn only Mode. */ public static final int MODE_DN_ONLY = 1; /** * Returns Attributes only Mode. */ public static final int MODE_RETURNING_ATTRIBUTES_ONLY = 2; /** * Normal Mode */ public static final int MODE_NORMAL = 3; /** * Includes Operational Attributes Mode. */ public static final int MODE_INCLUDE_OPERATIONAL_ATTRIBUTES = 4; protected int mode; protected String type; protected String appendix; /** * Creates a new instance of CopyEntryAsAction. * * @param type * the type of the target * @param mode * the copy Mode */ public CopyEntryAsAction( String type, int mode ) { super(); this.type = type; this.mode = mode; if ( this.mode == MODE_DN_ONLY ) { this.appendix = Messages.getString( "CopyEntryAsAction.DNOnly" ); //$NON-NLS-1$ } else if ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY ) { this.appendix = Messages.getString( "CopyEntryAsAction.AttributesOnly" ); //$NON-NLS-1$ } else if ( this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) { this.appendix = Messages.getString( "CopyEntryAsAction.OperationalAttributes" ); //$NON-NLS-1$ } else if ( this.mode == MODE_NORMAL ) { this.appendix = Messages.getString( "CopyEntryAsAction.UserAttributes" ); //$NON-NLS-1$ } else { appendix = ""; //$NON-NLS-1$ } } /** * {@inheritDoc} */ public String getText() { if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length > 0 && getSelectedSearches().length == 0 ) { String text = ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length > 1 ? NLS.bind( Messages.getString( "CopyEntryAsAction.CopyEntries" ), new String[] { type } ) //$NON-NLS-1$ : NLS.bind( Messages.getString( "CopyEntryAsAction.CopyEntry" ), new String[] { type } ) ) //$NON-NLS-1$ //$NON-NLS-2$ + appendix; return text; } else if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0 && getSelectedSearches().length == 1 && getSelectedSearches()[0].getSearchResults() != null && getSelectedSearches()[0].getSearchResults().length > 0 ) { String text = ( getSelectedSearches()[0].getSearchResults().length > 1 ? NLS.bind( Messages .getString( "CopyEntryAsAction.CopyResults" ), new String[] { type } )//$NON-NLS-1$ : NLS.bind( Messages.getString( "CopyEntryAsAction.CopyResult" ), new String[] { type } ) ) //$NON-NLS-1$ + appendix; return text; } return NLS.bind( Messages.getString( "CopyEntryAsAction.CopyEntry" ), new String[] { type + appendix } ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public void run() { // entries to copy List<IEntry> entryList = new ArrayList<IEntry>(); for ( int i = 0; i < getSelectedEntries().length; i++ ) { entryList.add( getSelectedEntries()[i] ); } for ( int i = 0; i < getSelectedSearchResults().length; i++ ) { entryList.add( getSelectedSearchResults()[i].getEntry() ); } for ( int i = 0; i < getSelectedBookmarks().length; i++ ) { IEntry entry = getSelectedBookmarks()[0].getBrowserConnection().getEntryFromCache( getSelectedBookmarks()[0].getDn() ); if ( entry == null ) { ReadEntryRunnable runnable = new ReadEntryRunnable( getSelectedBookmarks()[0].getBrowserConnection(), getSelectedBookmarks()[0].getDn() ); RunnableContextRunner.execute( runnable, null, true ); entry = runnable.getReadEntry(); } entryList.add( entry ); } if ( getSelectedSearches().length == 1 ) { ISearchResult[] results = getSelectedSearches()[0].getSearchResults(); for ( int k = 0; k < results.length; k++ ) { entryList.add( results[k].getEntry() ); } } IEntry[] entries = ( IEntry[] ) entryList.toArray( new IEntry[entryList.size()] ); // check uninitialized entries List<IEntry> uninitializedEntryList = new ArrayList<IEntry>(); for ( int i = 0; entries != null && i < entries.length; i++ ) { if ( !entries[i].isAttributesInitialized() ) { uninitializedEntryList.add( entries[i] ); } } if ( uninitializedEntryList.size() > 0 && ( this.mode == MODE_NORMAL || this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) { IEntry[] uninitializedEntries = ( IEntry[] ) uninitializedEntryList .toArray( new IEntry[uninitializedEntryList.size()] ); InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( uninitializedEntries ); RunnableContextRunner.execute( runnable, null, true ); // SyncInitializeEntryJob job = new // SyncInitializeEntryJob(uninitializedEntries, // InitializeEntryJob.INIT_ATTRIBUTES_MODE, null); // job.execute(); } // serialize StringBuffer text = new StringBuffer(); serialializeEntries( entries, text ); copyToClipboard( text.toString() ); } /** * Serializes Entries. * * @param entries * the Entries to serialize * @param text * the StringBuffer to serialize to */ protected abstract void serialializeEntries( IEntry[] entries, StringBuffer text ); /** * {@inheritDoc} */ public boolean isEnabled() { if ( getSelectedSearchResults().length > 0 && getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length == 0 ) { return ( this.mode == MODE_RETURNING_ATTRIBUTES_ONLY || this.mode == MODE_NORMAL || this.mode == MODE_DN_ONLY || this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ); } if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length > 0 && getSelectedSearches().length == 0 ) { return ( this.mode == MODE_NORMAL || this.mode == MODE_DN_ONLY || this.mode == MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ); } if ( getSelectedEntries().length + getSelectedSearchResults().length + getSelectedBookmarks().length == 0 && getSelectedSearches().length == 1 && getSelectedSearches()[0].getSearchResults() != null && getSelectedSearches()[0].getSearchResults().length > 0 ) { return true; } return false; } /** * Copies text to Clipboard * * @param text * the Text to copy */ protected void copyToClipboard( String text ) { Clipboard clipboard = null; try { clipboard = new Clipboard( Display.getCurrent() ); clipboard.setContents( new Object[] { text }, new Transfer[] { TextTransfer.getInstance() } ); } finally { if ( clipboard != null ) clipboard.dispose(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/BrowserPasteAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/BrowserPasteAction.java
/* * 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.actions; import org.apache.directory.api.ldap.model.message.SearchScope; import org.apache.directory.studio.common.ui.ClipboardUtils; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.actions.PasteAction; import org.apache.directory.studio.ldapbrowser.common.dialogs.EntryExistsCopyStrategyDialogImpl; import org.apache.directory.studio.ldapbrowser.common.dialogs.ScopeDialog; import org.apache.directory.studio.ldapbrowser.common.dnd.EntryTransfer; import org.apache.directory.studio.ldapbrowser.common.dnd.SearchTransfer; import org.apache.directory.studio.ldapbrowser.common.dnd.ValuesTransfer; import org.apache.directory.studio.ldapbrowser.core.jobs.CopyEntriesRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.SearchParameter; import org.apache.directory.studio.ldapbrowser.core.model.impl.Search; import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification; import org.apache.directory.studio.ldifparser.LdifFormatParameters; import org.apache.directory.studio.ldifparser.model.LdifFile; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This class implements the paste action for the LDAP browser view. * It copies attribute-values to another entry. * It invokes an UpdateEntryRunnable. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserPasteAction extends PasteAction { /** * Creates a new instance of BrowserPasteAction. */ public BrowserPasteAction() { super(); } /** * {@inheritDoc} */ public String getText() { // entry IEntry[] entries = getEntriesToPaste(); if ( entries != null ) { return entries.length > 1 ? Messages.getString( "BrowserPasteAction.PasteEntries" ) : Messages.getString( "BrowserPasteAction.PasteEntry" ); //$NON-NLS-1$ //$NON-NLS-2$ } // searches ISearch[] searches = getSearchesToPaste(); if ( searches != null ) { return searches.length > 1 ? Messages.getString( "BrowserPasteAction.PasteSearches" ) : Messages.getString( "BrowserPasteAction.PasteSearch" ); //$NON-NLS-1$ //$NON-NLS-2$ } // value IValue[] values = getValuesToPaste(); if ( values != null ) { return values.length > 1 ? Messages.getString( "BrowserPasteAction.PasteValues" ) : Messages.getString( "BrowserPasteAction.PasteValue" ); //$NON-NLS-1$ //$NON-NLS-2$ } return Messages.getString( "BrowserPasteAction.Paste" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { // entry if ( getEntriesToPaste() != null ) { return true; } // search else if ( getSearchesToPaste() != null ) { return true; } // value else if ( getValuesToPaste() != null ) { return true; } return false; } /** * {@inheritDoc} */ public void run() { // entry IEntry[] entries = getEntriesToPaste(); if ( entries != null ) { pasteEntries( getSelectedEntries()[0], entries ); return; } // search ISearch[] searches = getSearchesToPaste(); if ( searches != null ) { pasteSearches( searches ); return; } // value IValue[] values = getValuesToPaste(); if ( values != null ) { pasteValues( values ); return; } } /** * Pastes the given entries * * @param parent * the parent Entry * @param entriesToPaste * the Entries to paste */ private void pasteEntries( final IEntry parent, final IEntry[] entriesToPaste ) { SearchScope scope = SearchScope.OBJECT; boolean askForScope = false; for ( int i = 0; i < entriesToPaste.length; i++ ) { if ( entriesToPaste[i].hasChildren() ) { askForScope = true; break; } } if ( askForScope ) { ScopeDialog scopeDialog = new ScopeDialog( Display.getDefault().getActiveShell(), Messages.getString( "BrowserPasteAction.SelectCopyDepth" ), //$NON-NLS-1$ entriesToPaste.length > 1 ); scopeDialog.open(); scope = scopeDialog.getScope(); } new StudioBrowserJob( new CopyEntriesRunnable( parent, entriesToPaste, scope, new EntryExistsCopyStrategyDialogImpl( Display.getDefault().getActiveShell() ) ) ).execute(); } private void pasteSearches( ISearch[] searches ) { IBrowserConnection browserConnection = null; if ( getSelectedBrowserViewCategories().length > 0 ) { browserConnection = getSelectedBrowserViewCategories()[0].getParent(); } else if ( getSelectedSearches().length > 0 ) { browserConnection = getSelectedSearches()[0].getBrowserConnection(); } if ( browserConnection != null ) { ISearch clone = null; for ( ISearch search : searches ) { SearchParameter searchParameter = ( SearchParameter ) search.getSearchParameter().clone(); clone = new Search( browserConnection, searchParameter ); browserConnection.getSearchManager().addSearch( clone ); } if ( searches.length == 1 ) { IAdaptable element = ( IAdaptable ) clone; String pageId = BrowserCommonConstants.PROP_SEARCH; String title = clone.getName(); PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn( getShell(), element, pageId, null, null ); if ( dialog != null ) { title = Utils.shorten( title, 30 ); } dialog.getShell().setText( NLS.bind( Messages.getString( "PropertiesAction.PropertiesForX" ), title ) ); //$NON-NLS-1$ dialog.open(); } } } /** * Paste Values * * @param values * the Values to paste */ private void pasteValues( IValue[] values ) { IEntry entry = null; if ( getSelectedEntries().length == 1 ) { entry = getSelectedEntries()[0]; } else if ( getSelectedSearchResults().length == 1 ) { entry = getSelectedSearchResults()[0].getEntry(); } else if ( getSelectedBookmarks().length == 1 ) { entry = getSelectedBookmarks()[0].getEntry(); } // always get the real entry in case it is a bookmark or search continuation if ( entry != null ) { entry = entry.getBrowserConnection().getEntryFromCache( entry.getDn() ); } if ( entry != null ) { IEntry clone = new CompoundModification().cloneEntry( entry ); new CompoundModification().createValues( clone, values ); LdifFile diff = org.apache.directory.studio.ldapbrowser.core.utils.Utils.computeDiff( entry, clone ); if ( diff != null ) { UpdateEntryRunnable runnable = new UpdateEntryRunnable( entry, diff.toFormattedString( LdifFormatParameters.DEFAULT ) ); new StudioBrowserJob( runnable ).execute(); } } } /** * Conditions: * <li>an entry is selected</li> * <li>there are entries in clipboard</li> * * @return */ private IEntry[] getEntriesToPaste() { if ( getSelectedBookmarks().length + getSelectedSearchResults().length + getSelectedSearches().length + getSelectedConnections().length + getSelectedAttributes().length + getSelectedValues().length == 0 && getSelectedEntries().length == 1 ) { Object content = ClipboardUtils.getFromClipboard( EntryTransfer.getInstance() ); if ( content instanceof IEntry[] ) { IEntry[] entries = ( IEntry[] ) content; return entries; } } return null; } /** * Conditions: * <li>a search or category is selected</li> * <li>there are searches in clipboard</li> * * @return */ private ISearch[] getSearchesToPaste() { if ( getSelectedBookmarks().length + getSelectedSearchResults().length + getSelectedEntries().length + getSelectedConnections().length + getSelectedAttributes().length + getSelectedValues().length == 0 && ( getSelectedSearches().length + getSelectedBrowserViewCategories().length > 0 ) ) { Object content = ClipboardUtils.getFromClipboard( SearchTransfer.getInstance() ); if ( content instanceof ISearch[] ) { ISearch[] searches = ( ISearch[] ) content; return searches; } } return null; } /** * Conditions: * <li>an entry, search result, or bookmark is seleted</li> * <li>there are values in clipboard</li> * * @return */ private IValue[] getValuesToPaste() { if ( ( getSelectedAttributes().length + getSelectedValues().length + getSelectedSearchResults().length + getSelectedBookmarks().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedEntries().length == 1 ) ) || ( getSelectedAttributes().length + getSelectedValues().length + getSelectedEntries().length + getSelectedSearchResults().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedBookmarks().length == 1 ) ) || ( getSelectedAttributes().length + getSelectedValues().length + getSelectedEntries().length + getSelectedBookmarks().length + getSelectedSearches().length + getSelectedConnections().length == 0 && ( getSelectedSearchResults().length == 1 ) ) ) { Object content = ClipboardUtils.getFromClipboard( ValuesTransfer.getInstance() ); if ( content instanceof IValue[] ) { IValue[] values = ( IValue[] ) content; return values; } } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/ModificationLogsViewActionProxy.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/ModificationLogsViewActionProxy.java
/* * 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.actions.proxy; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy; import org.eclipse.jface.viewers.Viewer; /** * The ModificationLogsViewActionProxy is a proxy for a real action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsViewActionProxy extends BrowserActionProxy { /** * Creates a new instance of ModificationLogsViewActionProxy. * * @param viewer the viewer * @param action the real action */ public ModificationLogsViewActionProxy( Viewer viewer, BrowserAction action ) { super( viewer, action ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/SearchResultEditorActionProxy.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/SearchResultEditorActionProxy.java
/* * 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.actions.proxy; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorCursor; /** * The SearchResultEditorActionProxy is a proxy for a real action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorActionProxy extends BrowserActionProxy { /** * Creates a new instance of SearchResultEditorActionProxy. * * @param cursor the cursor * @param action the real action */ public SearchResultEditorActionProxy( SearchResultEditorCursor cursor, BrowserAction action ) { super( cursor, action ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/SearchLogsViewActionProxy.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/actions/proxy/SearchLogsViewActionProxy.java
/* * 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.actions.proxy; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy; import org.eclipse.jface.viewers.Viewer; /** * The SearchLogsViewActionProxy is a proxy for a real action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsViewActionProxy extends BrowserActionProxy { /** * Creates a new instance of SearchLogsViewActionProxy. * * @param viewer the viewer * @param action the real action */ public SearchLogsViewActionProxy( Viewer viewer, BrowserAction action ) { super( viewer, action ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OpenSearchLogsPreferencePageAction.java
/* * 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.views.searchlogs; 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; /** * This action opens the prefence page of the search logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSearchLogsPreferencePageAction extends Action { /** * Creates a new instance of OpenSearchLogsPreferencePageAction. */ public OpenSearchLogsPreferencePageAction() { setText( Messages.getString( "OpenSearchLogsPreferencePageAction.Preferences" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenSearchLogsPreferencePageAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String mlPageId = BrowserUIConstants.PREFERENCEPAGEID_SEARCHLOGS; PreferencesUtil.createPreferenceDialogOn( shell, mlPageId, new String[] { mlPageId }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/NewerAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to switch to a newer logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewerAction extends BrowserAction { /** The search logs view. */ private SearchLogsView view; /** * Creates a new instance of NewerAction. * * @param view the search logs view */ public NewerAction( SearchLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { SearchLogsViewInput oldInput = ( SearchLogsViewInput ) getInput(); SearchLogsViewInput newInput = new SearchLogsViewInput( oldInput.getBrowserConnection(), oldInput.getIndex() - 1 ); view.getUniversalListener().setInput( newInput ); view.getUniversalListener().scrollToOldest(); // go to top view.getMainWidget().getSourceViewer().setTopIndex( 0 ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewerAction.Newer" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_NEXT ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return ( getInput() instanceof SearchLogsViewInput ) && ( ( SearchLogsViewInput ) getInput() ).getIndex() > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/RefreshAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to refresh the view from logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RefreshAction extends BrowserAction { /** The search logs view. */ private SearchLogsView view; /** * Creates a new instance of RefreshAction. * * @param view the search logs view */ public RefreshAction( SearchLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { // int topIndex = view.getMainWidget().getSourceViewer().getTopIndex(); view.getUniversalListener().refreshInput(); view.getUniversalListener().scrollToNewest(); // view.getMainWidget().getSourceViewer().setTopIndex(topIndex); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "RefreshAction.Refresh" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getInput() instanceof SearchLogsViewInput; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java
/* * 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.views.searchlogs; import java.util.HashMap; import java.util.Map; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager; import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.SearchLogsViewActionProxy; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IActionBars; /** * The SearchLogsViewActionGroup manages all the actions of the search logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsViewActionGroup implements ActionHandlerManager, IMenuListener { /** The view. */ private SearchLogsView view; /** The Constant olderAction. */ private static final String olderAction = "olderAction"; //$NON-NLS-1$ /** The Constant newerAction. */ private static final String newerAction = "newerAction"; //$NON-NLS-1$ /** The Constant refreshAction. */ private static final String refreshAction = "refreshAction"; //$NON-NLS-1$ /** The Constant refreshAction. */ private static final String clearAction = "clearAction"; //$NON-NLS-1$ /** The Constant exportAction. */ private static final String exportAction = "exportAction"; //$NON-NLS-1$ /** The enable search request logs action. */ private EnableSearchRequestLogsAction enableSearchRequestLogsAction; /** The enable search result entry logs action. */ private EnableSearchResultEntryLogsAction enableSearchResultEntryLogsAction; /** The open search logs preference page action. */ private OpenSearchLogsPreferencePageAction openSearchLogsPreferencePageAction; /** The search logs view action map. */ private Map<String, SearchLogsViewActionProxy> searchLogsViewActionMap; /** * Creates a new instance of SearchLogsViewActionGroup. * * @param view the search logs view */ public SearchLogsViewActionGroup( SearchLogsView view ) { this.view = view; SourceViewer viewer = this.view.getMainWidget().getSourceViewer(); searchLogsViewActionMap = new HashMap<String, SearchLogsViewActionProxy>(); searchLogsViewActionMap.put( olderAction, new SearchLogsViewActionProxy( viewer, new OlderAction( view ) ) ); searchLogsViewActionMap.put( newerAction, new SearchLogsViewActionProxy( viewer, new NewerAction( view ) ) ); searchLogsViewActionMap.put( refreshAction, new SearchLogsViewActionProxy( viewer, new RefreshAction( view ) ) ); searchLogsViewActionMap.put( clearAction, new SearchLogsViewActionProxy( viewer, new ClearAction( view ) ) ); searchLogsViewActionMap.put( exportAction, new SearchLogsViewActionProxy( viewer, new ExportAction() ) ); enableSearchRequestLogsAction = new EnableSearchRequestLogsAction(); enableSearchResultEntryLogsAction = new EnableSearchResultEntryLogsAction(); openSearchLogsPreferencePageAction = new OpenSearchLogsPreferencePageAction(); } /** * Disposes this action group. */ public void dispose() { if ( view != null ) { for ( SearchLogsViewActionProxy action : searchLogsViewActionMap.values() ) { action.dispose(); action = null; } searchLogsViewActionMap.clear(); searchLogsViewActionMap = null; enableSearchRequestLogsAction = null; enableSearchResultEntryLogsAction = null; openSearchLogsPreferencePageAction = null; view = null; } } /** * Fill the action bars. * * @param actionBars the action bars */ public void fillActionBars( IActionBars actionBars ) { // Tool Bar actionBars.getToolBarManager().add( searchLogsViewActionMap.get( clearAction ) ); actionBars.getToolBarManager().add( searchLogsViewActionMap.get( refreshAction ) ); actionBars.getToolBarManager().add( new Separator() ); actionBars.getToolBarManager().add( searchLogsViewActionMap.get( olderAction ) ); actionBars.getToolBarManager().add( searchLogsViewActionMap.get( newerAction ) ); actionBars.getToolBarManager().add( new Separator() ); actionBars.getToolBarManager().add( searchLogsViewActionMap.get( exportAction ) ); // Menu Bar actionBars.getMenuManager().add( enableSearchRequestLogsAction ); actionBars.getMenuManager().add( enableSearchResultEntryLogsAction ); actionBars.getMenuManager().add( new Separator() ); actionBars.getMenuManager().add( openSearchLogsPreferencePageAction ); actionBars.getMenuManager().addMenuListener( new IMenuListener() { public void menuAboutToShow( IMenuManager manager ) { enableSearchRequestLogsAction .setChecked( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() ); enableSearchResultEntryLogsAction .setChecked( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() ); } } ); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager menuManager ) { } /** * Propagates the input to all actions. * * @param input the input */ public void setInput( SearchLogsViewInput input ) { for ( SearchLogsViewActionProxy action : searchLogsViewActionMap.values() ) { action.inputChanged( input ); } } /** * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#activateGlobalActionHandlers() */ public void activateGlobalActionHandlers() { } /** * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#deactivateGlobalActionHandlers() */ public void deactivateGlobalActionHandlers() { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewUniversalListener.java
/* * 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.views.searchlogs; import java.io.File; import java.io.FileReader; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifSearchLogger; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateEvent; import org.apache.directory.studio.ldapbrowser.core.events.BrowserConnectionUpdateListener; import org.apache.directory.studio.ldapbrowser.core.events.ChildrenInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener; import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry; import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent; import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateListener; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.apache.directory.studio.ldifparser.model.container.LdifContainer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.INullSelectionListener; import org.eclipse.ui.IWorkbenchPart; /** * The SearchLogsViewUniversalListener manages all events for the search logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsViewUniversalListener implements BrowserConnectionUpdateListener, SearchUpdateListener, EntryUpdateListener { /** The search log view. */ private SearchLogsView view; /** The current input */ private SearchLogsViewInput input; /** The last refresh timestamp. */ private long lastRefreshTimestamp; /** Listener that listens for selections of connections */ private INullSelectionListener connectionSelectionListener = new INullSelectionListener() { /** * {@inheritDoc} * * This implementation sets the input when another connection was selected. */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { if ( view != null && part != null ) { if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() ) { Connection[] connections = BrowserSelectionUtils.getConnections( selection ); if ( connections.length == 1 ) { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnectionById( connections[0].getId() ); SearchLogsViewInput input = new SearchLogsViewInput( connection, 0 ); setInput( input ); scrollToNewest(); } } } } }; /** * Creates a new instance of SearchLogsViewUniversalListener. * * @param view the search logs view */ public SearchLogsViewUniversalListener( SearchLogsView view ) { this.view = view; this.input = null; EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); EventRegistry.addSearchUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); EventRegistry.addBrowserConnectionUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); } /** * Disposed this listener */ public void dispose() { if ( view != null ) { view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); EventRegistry.removeEntryUpdateListener( this ); EventRegistry.removeSearchUpdateListener( this ); EventRegistry.removeBrowserConnectionUpdateListener( this ); view = null; } } /** * Refreshes the input. */ void refreshInput() { SearchLogsViewInput newInput = input; input = null; setInput( newInput ); } /** * Sets the input. * * @param input the input */ void setInput( SearchLogsViewInput input ) { // only if another connection is selected if ( this.input != input && input.getBrowserConnection().getConnection() != null ) { this.input = input; LdifSearchLogger searchLogger = ConnectionCorePlugin.getDefault().getLdifSearchLogger(); if ( ( input != null ) && ( input.getBrowserConnection() != null ) && ( input.getBrowserConnection().getConnection() != null ) && ( searchLogger != null ) ) { // load file %u %g StringBuffer sb = new StringBuffer(); File[] files = searchLogger.getFiles( input.getBrowserConnection().getConnection() ); int i = input.getIndex(); if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() ) { try ( FileReader fr = new FileReader( files[i] ) ) { char[] cbuf = new char[4096]; for ( int length = fr.read( cbuf ); length > 0; length = fr.read( cbuf ) ) { sb.append( cbuf, 0, length ); } } catch ( Exception e ) { sb.append( e.getMessage() ); } } // change input view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() ); view.getActionGroup().setInput( input ); } } } /** * {@inheritDoc} * * This implementation refreshes the input. */ public void entryUpdated( EntryModificationEvent event ) { if ( event instanceof AttributesInitializedEvent || event instanceof ChildrenInitializedEvent ) { updateInput(); } } /** * {@inheritDoc} * * This implementation refreshes the input. */ public void searchUpdated( SearchUpdateEvent searchUpdateEvent ) { if ( searchUpdateEvent.getDetail() == SearchUpdateEvent.EventDetail.SEARCH_PERFORMED ) { updateInput(); } } /** * {@inheritDoc} * * This implementation refreshes the input. */ public void browserConnectionUpdated( BrowserConnectionUpdateEvent browserConnectionUpdateEvent ) { if ( browserConnectionUpdateEvent.getDetail() == BrowserConnectionUpdateEvent.Detail.BROWSER_CONNECTION_OPENED || browserConnectionUpdateEvent.getDetail() == BrowserConnectionUpdateEvent.Detail.SCHEMA_UPDATED ) { updateInput(); } } private void updateInput() { // performance optimization: refresh only once per second long now = System.currentTimeMillis(); if ( lastRefreshTimestamp + 1000 < now ) { refreshInput(); scrollToNewest(); lastRefreshTimestamp = now; } } /** * Scroll to oldest log entry. */ public void scrollToOldest() { view.getMainWidget().getSourceViewer().setTopIndex( 0 ); } /** * Scroll to newest log entry. */ public void scrollToNewest() { try { LdifContainer record = view.getMainWidget().getLdifModel().getLastContainer(); int offset = record.getOffset(); int line = view.getMainWidget().getSourceViewer().getDocument().getLineOfOffset( offset ); if ( line > 3 ) line -= 3; view.getMainWidget().getSourceViewer().setTopIndex( line ); } catch ( Exception e ) { } } /** * Clears the input and deletes the logfiles for it. */ public void clearInput() { if ( input.getBrowserConnection().getConnection() != null ) { LdifSearchLogger searchLogger = ConnectionCorePlugin.getDefault().getLdifSearchLogger(); searchLogger.dispose( input.getBrowserConnection().getConnection() ); view.getMainWidget().getSourceViewer().setTopIndex( 0 ); view.getMainWidget().getSourceViewer().getDocument().set( "" ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/Messages.java
/* * 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.views.searchlogs; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/OlderAction.java
/* * 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.views.searchlogs; import java.io.File; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifSearchLogger; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to switch to an older logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlderAction extends BrowserAction { /** The search logs view. */ private SearchLogsView view; /** * Creates a new instance of OlderAction. * * @param view the search logs view */ public OlderAction( SearchLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { SearchLogsViewInput oldInput = ( SearchLogsViewInput ) getInput(); SearchLogsViewInput newInput = new SearchLogsViewInput( oldInput.getBrowserConnection(), oldInput.getIndex() + 1 ); view.getUniversalListener().setInput( newInput ); view.getUniversalListener().scrollToNewest(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "OlderAction.Older" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PREVIOUS ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { if ( ( getInput() instanceof SearchLogsViewInput ) ) { SearchLogsViewInput input = ( SearchLogsViewInput ) getInput(); if ( input.getBrowserConnection().getConnection() != null ) { LdifSearchLogger searchLogger = ConnectionCorePlugin.getDefault().getLdifSearchLogger(); File[] files = searchLogger.getFiles( input.getBrowserConnection().getConnection() ); int i = input.getIndex() + 1; if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() ) { return true; } } } return false; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.action.Action; /** * This action is used to toggle the "enable search request logs" preference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EnableSearchRequestLogsAction extends Action { /** * Creates a new instance of EnableSearchRequestLogsAction. */ public EnableSearchRequestLogsAction() { super( Messages.getString( "EnableSearchRequestLogsAction.EnableSearchRequestLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( getText() ); setEnabled( true ); setChecked( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() ); } /** * {@inheritDoc} */ public void run() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, super.isChecked() ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.action.Action; /** * This action is used to toggle the "enable search result entry logs" preference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EnableSearchResultEntryLogsAction extends Action { /** * Creates a new instance of EnableSearchResultEntryLogsAction. */ public EnableSearchResultEntryLogsAction() { super( Messages.getString( "EnableSearchResultEntryLogsAction.EnableSearchResultLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( getText() ); setEnabled( true ); setChecked( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() ); } /** * {@inheritDoc} */ public void run() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, super.isChecked() ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsView.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; /** * The SearchLogsView displays all searched performed * to a connection using LDIF format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsView extends ViewPart { /** The action group. */ private SearchLogsViewActionGroup actionGroup; /** The main widget. */ private LdifEditorWidget mainWidget; /** The universal listener. */ private SearchLogsViewUniversalListener universalListener; /** * Gets the id. * * @return the id */ public static String getId() { return BrowserUIConstants.VIEW_SEARCH_LOGS_VIEW; } /** * Creates a new instance of ModificationLogsView. */ public SearchLogsView() { super(); } /** * {@inheritDoc} */ public void setFocus() { mainWidget.getSourceViewer().getTextWidget().setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( mainWidget != null ) { actionGroup.dispose(); actionGroup = null; universalListener.dispose(); universalListener = null; mainWidget.dispose(); mainWidget = null; } super.dispose(); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout( layout ); // create main widget mainWidget = new LdifEditorWidget( null, "", false ); //$NON-NLS-1$ mainWidget.createWidget( composite ); mainWidget.getSourceViewer().setEditable( false ); // create actions and context menu (and register global actions) actionGroup = new SearchLogsViewActionGroup( this ); actionGroup.fillActionBars( getViewSite().getActionBars() ); // this.actionGroup.fillContextMenu(this.configuration.getContextMenuManager(this.mainWidget.getViewer())); // create the listener universalListener = new SearchLogsViewUniversalListener( this ); // set help context PlatformUI.getWorkbench().getHelpSystem().setHelp( mainWidget.getSourceViewer().getTextWidget(), BrowserUIConstants.PLUGIN_ID + "." + "tools_search_logs_view" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Gets the main widget. * * @return the main widget */ public LdifEditorWidget getMainWidget() { return mainWidget; } /** * Gets the universal listener. * * @return the universal listener */ public SearchLogsViewUniversalListener getUniversalListener() { return universalListener; } /** * Gets the action group. * * @return the action group */ public SearchLogsViewActionGroup getActionGroup() { return actionGroup; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ExportAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ExportAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportSearchLogsWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardDialog; /** * Action to save the log files to a place outside the workspace. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportAction extends BrowserAction { /** * Creates a new instance of SaveAction. */ public ExportAction() { } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "ExportAction.ExportSearchLogs" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return ( getInput() instanceof SearchLogsViewInput ) && ( ( SearchLogsViewInput ) getInput() ).getBrowserConnection().getConnection() != null; } /** * {@inheritDoc} */ public void run() { SearchLogsViewInput input = ( SearchLogsViewInput ) getInput(); if ( input.getBrowserConnection().getConnection() != null ) { ExportSearchLogsWizard wizard = new ExportSearchLogsWizard(); wizard.getSearch().setBrowserConnection( input.getBrowserConnection() ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewInput.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewInput.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; /** * A SearchLogsViewInput represents the input of the search logs view. * It consists of a connection and the index of the displayed log file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsViewInput { /** The browser connection. */ private IBrowserConnection browserConnection; /** The index of the displayed log file */ private int index; /** * Creates a new instance of ModificationLogsViewInput. * * @param browserConnection the browser connection * @param index the index of the displayed log file */ public SearchLogsViewInput( IBrowserConnection browserConnection, int index ) { this.browserConnection = browserConnection; this.index = index; } /** * Gets the browser connection. * * @return the browser connection */ public IBrowserConnection getBrowserConnection() { return browserConnection; } /** * Gets the index of the displayed log file. * * @return the index */ public int getIndex() { return index; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/ClearAction.java
/* * 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.views.searchlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to clear the log files. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ClearAction extends BrowserAction { /** The search logs view. */ private SearchLogsView view; /** * Creates a new instance of ClearAction. * * @param view * the search logs view */ public ClearAction( SearchLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_CLEAR ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "ClearAction.Clear" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return getInput() instanceof SearchLogsViewInput; } /** * {@inheritDoc} */ public void run() { if ( MessageDialog.openConfirm( this.getShell(), Messages.getString( "ClearAction.Delete" ), Messages.getString( "ClearAction.DeleteAllLogFiles" ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ { view.getUniversalListener().clearInput(); new RefreshAction( view ).run(); } } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewActionGroup.java
/* * 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.views.connection; import org.apache.directory.studio.connection.ui.actions.ConnectionViewActionProxy; import org.apache.directory.studio.connection.ui.widgets.ConnectionActionGroup; import org.apache.directory.studio.ldapbrowser.ui.actions.ExportConnectionsAction; import org.apache.directory.studio.ldapbrowser.ui.actions.ImportConnectionsAction; import org.apache.directory.studio.ldapbrowser.ui.actions.ImportExportAction; import org.apache.directory.studio.ldapbrowser.ui.actions.OpenSchemaBrowserAction; import org.apache.directory.studio.ldapbrowser.ui.actions.PasswordModifyExtendedOperationAction; import org.apache.directory.studio.ldapbrowser.ui.actions.ReloadSchemaAction; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchActionConstants; /** * This class manages all the actions of the connection view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConnectionViewActionGroup extends ConnectionActionGroup { /** The connection view */ private ConnectionView view; /** The link with editor action. */ private LinkWithEditorAction linkWithEditorAction; /** The Constant importDsmlAction. */ private static final String importDsmlAction = "importDsmlAction"; //$NON-NLS-1$ /** The Constant exportDsmlAction. */ private static final String exportDsmlAction = "exportDsmlAction"; //$NON-NLS-1$ /** The Constant importLdifAction. */ private static final String importLdifAction = "importLdifAction"; //$NON-NLS-1$ /** The Constant exportLdifAction. */ private static final String exportLdifAction = "exportLdifAction"; //$NON-NLS-1$ /** The Constant exportCsvAction. */ private static final String exportCsvAction = "exportCsvAction"; //$NON-NLS-1$ /** The Constant exportExcelAction. */ private static final String exportExcelAction = "exportExcelAction"; //$NON-NLS-1$ /** The Constant exportOdfAction. */ private static final String exportOdfAction = "exportOdfAction"; //$NON-NLS-1$ /** The Constant importConnectionsAction. */ private static final String importConnectionsAction = "importConnectionsAction"; //$NON-NLS-1$ /** The Constant importConnectionsAction. */ private static final String exportConnectionsAction = "exportConnectionsAction"; //$NON-NLS-1$ /** The Constant openSchemaBrowserAction. */ private static final String openSchemaBrowserAction = "openSchemaBrowserAction"; //$NON-NLS-1$ /** The Constant reloadSchemaAction. */ private static final String reloadSchemaAction = "reloadSchemaAction"; //$NON-NLS-1$ /** The Constant passwordModifyExtendedOperationAction. */ private static final String passwordModifyExtendedOperationAction = "passwordModifyExtendedOperation"; //$NON-NLS-1$ /** * Creates a new instance of ConnectionViewActionGroup and creates * all actions. * * @param view the connection view */ public ConnectionViewActionGroup( ConnectionView view ) { super( view.getMainWidget(), view.getConfiguration() ); this.view = view; TreeViewer viewer = view.getMainWidget().getViewer(); linkWithEditorAction = new LinkWithEditorAction( view ); connectionActionMap.put( importDsmlAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_IMPORT_DSML ) ) ); connectionActionMap.put( exportDsmlAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_EXPORT_DSML ) ) ); connectionActionMap.put( importLdifAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_IMPORT_LDIF ) ) ); connectionActionMap.put( exportLdifAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_EXPORT_LDIF ) ) ); connectionActionMap.put( exportCsvAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_EXPORT_CSV ) ) ); connectionActionMap.put( exportExcelAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_EXPORT_EXCEL ) ) ); connectionActionMap.put( exportOdfAction, new ConnectionViewActionProxy( viewer, this, new ImportExportAction( ImportExportAction.TYPE_EXPORT_ODF ) ) ); connectionActionMap.put( importConnectionsAction, new ConnectionViewActionProxy( viewer, this, new ImportConnectionsAction() ) ); connectionActionMap.put( exportConnectionsAction, new ConnectionViewActionProxy( viewer, this, new ExportConnectionsAction() ) ); connectionActionMap.put( openSchemaBrowserAction, new ConnectionViewActionProxy( viewer, this, new OpenSchemaBrowserAction() ) ); connectionActionMap.put( reloadSchemaAction, new ConnectionViewActionProxy( viewer, this, new ReloadSchemaAction() ) ); connectionActionMap.put( passwordModifyExtendedOperationAction, new ConnectionViewActionProxy( viewer, this, new PasswordModifyExtendedOperationAction() ) ); } /** * {@inheritDoc} */ public void dispose() { if ( view != null ) { linkWithEditorAction.dispose(); linkWithEditorAction = null; view = null; } super.dispose(); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager menuManager ) { // add menuManager.add( ( IAction ) connectionActionMap.get( NEW_CONNECTION_ACTION ) ); menuManager.add( ( IAction ) connectionActionMap.get( NEW_CONNECTION_FOLDER_ACTION ) ); menuManager.add( new Separator() ); // open/close if ( ( ( IAction ) connectionActionMap.get( CLOSE_CONNECTION_ACTION ) ).isEnabled() ) { menuManager.add( ( IAction ) connectionActionMap.get( CLOSE_CONNECTION_ACTION ) ); } else if ( ( ( IAction ) connectionActionMap.get( OPEN_CONNECTION_ACTION ) ).isEnabled() ) { menuManager.add( ( IAction ) connectionActionMap.get( OPEN_CONNECTION_ACTION ) ); } menuManager.add( new Separator() ); menuManager.add( ( IAction ) connectionActionMap.get( openSchemaBrowserAction ) ); menuManager.add( ( IAction ) connectionActionMap.get( reloadSchemaAction ) ); menuManager.add( new Separator() ); // copy/paste/... menuManager.add( ( IAction ) connectionActionMap.get( COPY_CONNECTION_ACTION ) ); menuManager.add( ( IAction ) connectionActionMap.get( PASTE_CONNECTION_ACTION ) ); menuManager.add( ( IAction ) connectionActionMap.get( DELETE_CONNECTION_ACTION ) ); menuManager.add( ( IAction ) connectionActionMap.get( RENAME_CONNECTION_ACTION ) ); menuManager.add( new Separator() ); // import/export MenuManager importMenuManager = new MenuManager( Messages.getString( "ConnectionViewActionGroup.Import" ) ); //$NON-NLS-1$ importMenuManager.add( ( IAction ) connectionActionMap.get( importLdifAction ) ); importMenuManager.add( ( IAction ) connectionActionMap.get( importDsmlAction ) ); importMenuManager.add( new Separator() ); importMenuManager.add( ( IAction ) connectionActionMap.get( importConnectionsAction ) ); importMenuManager.add( new Separator() ); menuManager.add( importMenuManager ); MenuManager exportMenuManager = new MenuManager( Messages.getString( "ConnectionViewActionGroup.Export" ) ); //$NON-NLS-1$ exportMenuManager.add( ( IAction ) connectionActionMap.get( exportLdifAction ) ); exportMenuManager.add( ( IAction ) connectionActionMap.get( exportDsmlAction ) ); exportMenuManager.add( new Separator() ); exportMenuManager.add( ( IAction ) connectionActionMap.get( exportCsvAction ) ); exportMenuManager.add( ( IAction ) connectionActionMap.get( exportExcelAction ) ); exportMenuManager.add( ( IAction ) connectionActionMap.get( exportOdfAction ) ); exportMenuManager.add( new Separator() ); exportMenuManager.add( ( IAction ) connectionActionMap.get( exportConnectionsAction ) ); exportMenuManager.add( new Separator() ); menuManager.add( exportMenuManager ); menuManager.add( new Separator() ); // additions menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); MenuManager extendedOperationsMenuManager = new MenuManager( Messages.getString( "ConnectionViewActionGroup.ExtendedOperations" ) ); //$NON-NLS-1$ extendedOperationsMenuManager.add( connectionActionMap.get( passwordModifyExtendedOperationAction ) ); menuManager.add( extendedOperationsMenuManager ); menuManager.add( new Separator() ); // properties menuManager.add( ( IAction ) connectionActionMap.get( PROPERTY_DIALOG_ACTION ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/LinkWithEditorAction.java
/* * 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.views.connection; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput; import org.apache.directory.studio.ldapbrowser.ui.views.browser.AbstractLinkWithEditorAction; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPart; /** * This class implements the Link With Editor Action for the Connection View. * * This action is not visible to the user, but it listens to to the link * with editor property of the browser view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LinkWithEditorAction extends AbstractLinkWithEditorAction { /** The connection view */ private ConnectionView connectionView; /** * Creates a new instance of LinkWithEditorAction. * * @param connectionView * the associated view */ public LinkWithEditorAction( ConnectionView connectionView ) { super( connectionView, Messages.getString( "LinkWithEditorAction.LinkWithEditor" ) ); //$NON-NLS-1$ this.connectionView = connectionView; super.init(); } /** * Links the view with the right editor * * @param partRef the part */ protected void linkViewWithEditor( IWorkbenchPart part ) { if ( part != null && connectionView != null && part.getSite().getWorkbenchWindow() == connectionView.getSite().getWorkbenchWindow() ) { Object objectToSelect = null; if ( part instanceof IEditorPart ) { IEditorPart editor = ( IEditorPart ) part; IEditorInput input = editor.getEditorInput(); if ( input instanceof EntryEditorInput ) { EntryEditorInput eei = ( EntryEditorInput ) input; IEntry entry = eei.getResolvedEntry(); if ( entry != null ) { objectToSelect = entry.getBrowserConnection().getConnection(); } } else if ( input instanceof SearchResultEditorInput ) { SearchResultEditorInput srei = ( SearchResultEditorInput ) input; ISearch search = srei.getSearch(); if ( search != null ) { objectToSelect = search.getBrowserConnection().getConnection(); } } } if ( objectToSelect != null ) { // do not select if already selected! // necessary to avoid infinite loops! IStructuredSelection selection = ( IStructuredSelection ) connectionView.getMainWidget().getViewer() .getSelection(); if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) ) { connectionView.select( objectToSelect ); } } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/Messages.java
/* * 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.views.connection; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionViewUniversalListener.java
/* * 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.views.connection; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.jobs.OpenConnectionsRunnable; import org.apache.directory.studio.connection.ui.actions.SelectionUtils; import org.apache.directory.studio.connection.ui.widgets.ConnectionUniversalListener; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView; import org.apache.directory.studio.ldapbrowser.ui.views.searchlogs.SearchLogsView; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * The ConnectionViewUniversalListener manages all events for the connection view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConnectionViewUniversalListener extends ConnectionUniversalListener { /** The connection view */ protected ConnectionView view; /** This listener is used to ensure that the browser view is opened when an object in the connection view is selected */ private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { Connection[] connections = SelectionUtils.getConnections( event.getSelection() ); if ( connections.length == 1 ) { ensureViewVisible(); } } }; /** This listener opens/closes a connection when double clicking a connection */ private IDoubleClickListener viewerDoubleClickListener = new IDoubleClickListener() { public void doubleClick( DoubleClickEvent event ) { Connection[] connections = SelectionUtils.getConnections( event.getSelection() ); if ( connections.length == 1 ) { toggleConnection( connections[0] ); } } }; /** * Creates a new instance of ConnectionViewUniversalListener. * * @param view the connection view */ public ConnectionViewUniversalListener( ConnectionView view ) { super( view.getMainWidget().getViewer() ); this.view = view; // listeners viewer.addSelectionChangedListener( viewerSelectionListener ); viewer.addDoubleClickListener( viewerDoubleClickListener ); } /** * {@inheritDoc} */ public void dispose() { this.view = null; super.dispose(); } /** * Ensures that the browser view and modification log views are opended * and ready to show the given selection. * * @param selection the view's selection. */ private void ensureViewVisible() { if ( view != null ) { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( BrowserView.getId(), null, IWorkbenchPage.VIEW_VISIBLE ); } catch ( PartInitException e ) { } catch ( NullPointerException e ) { } try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( ModificationLogsView.getId(), null, IWorkbenchPage.VIEW_CREATE ); } catch ( PartInitException e ) { } catch ( NullPointerException e ) { } try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( SearchLogsView.getId(), null, IWorkbenchPage.VIEW_CREATE ); } catch ( PartInitException e ) { } catch ( NullPointerException e ) { } } } /** * Opens a closed connections or closes an opened connection. * * @param connection the connection */ private void toggleConnection( Connection connection ) { if ( connection.getConnectionWrapper().isConnected() ) { connection.getConnectionWrapper().disconnect(); } else { new StudioBrowserJob( new OpenConnectionsRunnable( connection ) ).execute(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/connection/ConnectionView.java
/* * 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.views.connection; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.ui.widgets.ConnectionConfiguration; import org.apache.directory.studio.connection.ui.widgets.ConnectionWidget; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; /** * This class implements the connection view. It displays all connections. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ConnectionView extends ViewPart { /** The configuration. */ private ConnectionConfiguration configuration; /** The actions */ private ConnectionViewActionGroup actionGroup; /** The main widget */ private ConnectionWidget mainWidget; /** The listeners */ private ConnectionViewUniversalListener universalListener; /** * Returns the connection view ID. * * @return the connection view ID. */ public static String getId() { return BrowserUIConstants.VIEW_CONNECTION_VIEW; } /** * Creates a new instance of ConnectionView. */ public ConnectionView() { } /** * {@inheritDoc} * * This implementation sets focus to the viewer's control. */ public void setFocus() { mainWidget.getViewer().getControl().setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( configuration != null ) { actionGroup.dispose(); actionGroup = null; configuration.dispose(); configuration = null; universalListener.dispose(); universalListener = null; mainWidget.dispose(); mainWidget = null; getSite().setSelectionProvider( null ); } super.dispose(); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout( layout ); PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, BrowserUIConstants.PLUGIN_ID + "." + "tools_connections_view" ); //$NON-NLS-1$ //$NON-NLS-2$ // create configuration configuration = new ConnectionConfiguration(); // create main widget mainWidget = new ConnectionWidget( configuration, getViewSite().getActionBars() ); mainWidget.createWidget( composite ); mainWidget.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() ); // create actions and context menu (and register global actions) actionGroup = new ConnectionViewActionGroup( this ); actionGroup.fillToolBar( mainWidget.getToolBarManager() ); actionGroup.fillMenu( mainWidget.getMenuManager() ); actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() ); IMenuManager contextMenuManager = configuration.getContextMenuManager( mainWidget.getViewer() ); actionGroup.fillContextMenu( contextMenuManager ); getSite().registerContextMenu( ( MenuManager ) contextMenuManager, mainWidget.getViewer() ); // create the listener getSite().setSelectionProvider( mainWidget.getViewer() ); universalListener = new ConnectionViewUniversalListener( this ); } /** * Selects the given object in the tree. The object * must be an IConnection. * * @param obj the object to select */ public void select( Object obj ) { if ( obj instanceof Connection ) { Connection connection = ( Connection ) obj; mainWidget.getViewer().reveal( connection ); mainWidget.getViewer().refresh( connection, true ); mainWidget.getViewer().setSelection( new StructuredSelection( connection ), true ); } } /** * Gets the action group. * * @return the action group */ public ConnectionViewActionGroup getActionGroup() { return actionGroup; } /** * Gets the configuration. * * @return the configuration */ public ConnectionConfiguration getConfiguration() { return configuration; } /** * Gets the main widget. * * @return the main widget */ public ConnectionWidget getMainWidget() { return mainWidget; } /** * Gets the universal listener. * * @return the universal listener */ public ConnectionViewUniversalListener getUniversalListener() { return universalListener; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsView.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; /** * The ModificationLogsView displays all modifications applied * to a connection using LDIF change format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsView extends ViewPart { /** The action group. */ private ModificationLogsViewActionGroup actionGroup; /** The main widget. */ private LdifEditorWidget mainWidget; /** The universal listener. */ private ModificationLogsViewUniversalListener universalListener; /** * Gets the id. * * @return the id */ public static String getId() { return BrowserUIConstants.VIEW_MODIFICATION_LOGS_VIEW; } /** * Creates a new instance of ModificationLogsView. */ public ModificationLogsView() { super(); } /** * {@inheritDoc} */ public void setFocus() { mainWidget.getSourceViewer().getTextWidget().setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( mainWidget != null ) { actionGroup.dispose(); actionGroup = null; universalListener.dispose(); universalListener = null; mainWidget.dispose(); mainWidget = null; } super.dispose(); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout( layout ); // create main widget mainWidget = new LdifEditorWidget( null, "", false ); //$NON-NLS-1$ mainWidget.createWidget( composite ); mainWidget.getSourceViewer().setEditable( false ); // create actions and context menu (and register global actions) actionGroup = new ModificationLogsViewActionGroup( this ); actionGroup.fillActionBars( getViewSite().getActionBars() ); // this.actionGroup.fillContextMenu(this.configuration.getContextMenuManager(this.mainWidget.getViewer())); // create the listener universalListener = new ModificationLogsViewUniversalListener( this ); // set help context PlatformUI.getWorkbench().getHelpSystem().setHelp( mainWidget.getSourceViewer().getTextWidget(), BrowserUIConstants.PLUGIN_ID + "." + "tools_modification_logs_view" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Gets the main widget. * * @return the main widget */ public LdifEditorWidget getMainWidget() { return mainWidget; } /** * Gets the universal listener. * * @return the universal listener */ public ModificationLogsViewUniversalListener getUniversalListener() { return universalListener; } /** * Gets the action group. * * @return the action group */ public ModificationLogsViewActionGroup getActionGroup() { return actionGroup; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/NewerAction.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to switch to a newer logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewerAction extends BrowserAction { /** The modification logs view. */ private ModificationLogsView view; /** * Creates a new instance of NewerAction. * * @param view the modification logs view */ public NewerAction( ModificationLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput(); ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.getBrowserConnection(), oldInput .getIndex() - 1 ); view.getUniversalListener().setInput( newInput ); view.getUniversalListener().scrollToOldest(); // go to top view.getMainWidget().getSourceViewer().setTopIndex( 0 ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "NewerAction.Newer" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_NEXT ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return ( getInput() instanceof ModificationLogsViewInput ) && ( ( ModificationLogsViewInput ) getInput() ).getIndex() > 0; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewInput.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; /** * A ModificationLogsViewInput represents the input of the modification logs view. * It consists of a connection and the index of the displayed log file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsViewInput { /** The browser connection. */ private IBrowserConnection browserConnection; /** The index of the displayed log file */ private int index; /** * Creates a new instance of ModificationLogsViewInput. * * @param browserConnection the browser connection * @param index the index of the displayed log file */ public ModificationLogsViewInput( IBrowserConnection browserConnection, int index ) { this.browserConnection = browserConnection; this.index = index; } /** * Gets the browser connection. * * @return the browser connection */ public IBrowserConnection getBrowserConnection() { return browserConnection; } /** * Gets the index of the displayed log file. * * @return the index */ public int getIndex() { return index; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/RefreshAction.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to refresh the view from logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RefreshAction extends BrowserAction { /** The modification logs view. */ private ModificationLogsView view; /** * Creates a new instance of RefreshAction. * * @param view the modification logs view */ public RefreshAction( ModificationLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { // int topIndex = view.getMainWidget().getSourceViewer().getTopIndex(); view.getUniversalListener().refreshInput(); view.getUniversalListener().scrollToNewest(); // view.getMainWidget().getSourceViewer().setTopIndex(topIndex); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "RefreshAction.Refresh" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { return getInput() instanceof ModificationLogsViewInput; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/Messages.java
/* * 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.views.modificationlogs; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewUniversalListener.java
/* * 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.views.modificationlogs; import java.io.File; import java.io.FileReader; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifModificationLogger; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.ChildrenInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener; import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.apache.directory.studio.ldifparser.model.container.LdifContainer; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.INullSelectionListener; import org.eclipse.ui.IWorkbenchPart; /** * The ModificationLogsViewUniversalListener manages all events for the modification logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsViewUniversalListener implements EntryUpdateListener { /** The modification log view. */ private ModificationLogsView view; /** The current input */ private ModificationLogsViewInput input; /** Listener that listens for selections of connections */ private INullSelectionListener connectionSelectionListener = new INullSelectionListener() { /** * {@inheritDoc} * * This implementation sets the input when another connection was selected. */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { if ( view != null && part != null ) { if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() ) { Connection[] connections = BrowserSelectionUtils.getConnections( selection ); if ( connections.length == 1 ) { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnectionById( connections[0].getId() ); ModificationLogsViewInput input = new ModificationLogsViewInput( connection, 0 ); setInput( input ); scrollToNewest(); } } } } }; /** * Creates a new instance of ModificationLogsViewUniversalListener. * * @param view the modification logs view */ public ModificationLogsViewUniversalListener( ModificationLogsView view ) { this.view = view; this.input = null; EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); } /** * Disposed this listener */ public void dispose() { if ( view != null ) { view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); EventRegistry.removeEntryUpdateListener( this ); view = null; } } /** * Refreshes the input. */ void refreshInput() { ModificationLogsViewInput newInput = input; input = null; setInput( newInput ); } /** * Sets the input. * * @param input the input */ void setInput( ModificationLogsViewInput input ) { // only if another connection is selected if ( this.input != input && input.getBrowserConnection().getConnection() != null ) { this.input = input; LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault().getLdifModificationLogger(); if ( ( input != null ) && ( input.getBrowserConnection() != null ) && ( input.getBrowserConnection().getConnection() != null ) && ( modificationLogger != null ) ) { // load file %u %g StringBuffer sb = new StringBuffer(); File[] files = modificationLogger.getFiles( input.getBrowserConnection().getConnection() ); int i = input.getIndex(); if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() ) { try ( FileReader fr = new FileReader( files[i] ) ) { char[] cbuf = new char[4096]; for ( int length = fr.read( cbuf ); length > 0; length = fr.read( cbuf ) ) { sb.append( cbuf, 0, length ); } } catch ( Exception e ) { sb.append( e.getMessage() ); } } // change input view.getMainWidget().getSourceViewer().getDocument().set( sb.toString() ); view.getActionGroup().setInput( input ); } } } /** * {@inheritDoc} * * This implementation refreshes the input. */ public void entryUpdated( EntryModificationEvent event ) { if ( !( event instanceof AttributesInitializedEvent ) && !( event instanceof ChildrenInitializedEvent ) ) { refreshInput(); scrollToNewest(); } } /** * Scroll to oldest log entry. */ public void scrollToOldest() { view.getMainWidget().getSourceViewer().setTopIndex( 0 ); } /** * Scroll to newest log entry. */ public void scrollToNewest() { try { LdifContainer record = view.getMainWidget().getLdifModel().getLastContainer(); int offset = record.getOffset(); int line = view.getMainWidget().getSourceViewer().getDocument().getLineOfOffset( offset ); if ( line > 3 ) line -= 3; view.getMainWidget().getSourceViewer().setTopIndex( line ); } catch ( Exception e ) { } } /** * Clears the input and deletes the logfiles for it. */ public void clearInput() { if ( input.getBrowserConnection().getConnection() != null ) { LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault().getLdifModificationLogger(); modificationLogger.dispose( input.getBrowserConnection().getConnection() ); view.getMainWidget().getSourceViewer().setTopIndex( 0 ); view.getMainWidget().getSourceViewer().getDocument().set( "" ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OlderAction.java
/* * 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.views.modificationlogs; import java.io.File; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifModificationLogger; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to switch to an older logfile. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OlderAction extends BrowserAction { /** The modification logs view. */ private ModificationLogsView view; /** * Creates a new instance of OlderAction. * * @param view the modification logs view */ public OlderAction( ModificationLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } /** * {@inheritDoc} */ public void run() { ModificationLogsViewInput oldInput = ( ModificationLogsViewInput ) getInput(); ModificationLogsViewInput newInput = new ModificationLogsViewInput( oldInput.getBrowserConnection(), oldInput .getIndex() + 1 ); view.getUniversalListener().setInput( newInput ); view.getUniversalListener().scrollToNewest(); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "OlderAction.Older" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_PREVIOUS ); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public boolean isEnabled() { if ( ( getInput() instanceof ModificationLogsViewInput ) ) { ModificationLogsViewInput input = ( ModificationLogsViewInput ) getInput(); if ( input.getBrowserConnection().getConnection() != null ) { LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault() .getLdifModificationLogger(); File[] files = modificationLogger.getFiles( input.getBrowserConnection().getConnection() ); int i = input.getIndex() + 1; if ( 0 <= i && i < files.length && files[i] != null && files[i].exists() && files[i].canRead() ) { return true; } } } return false; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
/* * 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.views.modificationlogs; import java.util.HashMap; import java.util.Map; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager; import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.ModificationLogsViewActionProxy; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IActionBars; /** * The ModificationLogsViewActionGroup manages all the actions of the modification logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsViewActionGroup implements ActionHandlerManager, IMenuListener { /** The view. */ private ModificationLogsView view; /** The Constant olderAction. */ private static final String olderAction = "olderAction"; //$NON-NLS-1$ /** The Constant newerAction. */ private static final String newerAction = "newerAction"; //$NON-NLS-1$ /** The Constant refreshAction. */ private static final String refreshAction = "refreshAction"; //$NON-NLS-1$ /** The Constant clearAction. */ private static final String clearAction = "clearAction"; //$NON-NLS-1$ /** The Constant exportAction. */ private static final String exportAction = "exportAction"; //$NON-NLS-1$ /** The enable modification logs action. */ private EnableModificationLogsAction enableModificationLogsAction; /** The open modification logs preference page action. */ private OpenModificationLogsPreferencePageAction openModificationLogsPreferencePageAction; /** The modification logs view action map. */ private Map<String, ModificationLogsViewActionProxy> modificationLogsViewActionMap; /** * Creates a new instance of ModificationLogsViewActionGroup. * * @param view the modification logs view */ public ModificationLogsViewActionGroup( ModificationLogsView view ) { this.view = view; SourceViewer viewer = this.view.getMainWidget().getSourceViewer(); modificationLogsViewActionMap = new HashMap<String, ModificationLogsViewActionProxy>(); modificationLogsViewActionMap.put( olderAction, new ModificationLogsViewActionProxy( viewer, new OlderAction( view ) ) ); modificationLogsViewActionMap.put( newerAction, new ModificationLogsViewActionProxy( viewer, new NewerAction( view ) ) ); modificationLogsViewActionMap.put( refreshAction, new ModificationLogsViewActionProxy( viewer, new RefreshAction( view ) ) ); modificationLogsViewActionMap.put( clearAction, new ModificationLogsViewActionProxy( viewer, new ClearAction( view ) ) ); modificationLogsViewActionMap.put( exportAction, new ModificationLogsViewActionProxy( viewer, new ExportAction() ) ); enableModificationLogsAction = new EnableModificationLogsAction(); openModificationLogsPreferencePageAction = new OpenModificationLogsPreferencePageAction(); } /** * Disposes this action group. */ public void dispose() { if ( view != null ) { for ( ModificationLogsViewActionProxy action : modificationLogsViewActionMap.values() ) { action.dispose(); action = null; } modificationLogsViewActionMap.clear(); modificationLogsViewActionMap = null; enableModificationLogsAction = null; openModificationLogsPreferencePageAction = null; view = null; } } /** * Fill the action bars. * * @param actionBars the action bars */ public void fillActionBars( IActionBars actionBars ) { // Tool Bar actionBars.getToolBarManager().add( modificationLogsViewActionMap.get( clearAction ) ); actionBars.getToolBarManager().add( modificationLogsViewActionMap.get( refreshAction ) ); actionBars.getToolBarManager().add( new Separator() ); actionBars.getToolBarManager().add( modificationLogsViewActionMap.get( olderAction ) ); actionBars.getToolBarManager().add( modificationLogsViewActionMap.get( newerAction ) ); actionBars.getToolBarManager().add( new Separator() ); actionBars.getToolBarManager().add( modificationLogsViewActionMap.get( exportAction ) ); // Menu Bar actionBars.getMenuManager().add( enableModificationLogsAction ); actionBars.getMenuManager().add( new Separator() ); actionBars.getMenuManager().add( openModificationLogsPreferencePageAction ); actionBars.getMenuManager().addMenuListener( new IMenuListener() { public void menuAboutToShow( IMenuManager manager ) { enableModificationLogsAction .setChecked( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() ); } } ); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager menuManager ) { } /** * Propagates the input to all actions. * * @param input the input */ public void setInput( ModificationLogsViewInput input ) { for ( ModificationLogsViewActionProxy action : modificationLogsViewActionMap.values() ) { action.inputChanged( input ); } } /** * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#activateGlobalActionHandlers() */ public void activateGlobalActionHandlers() { } /** * @see org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager#deactivateGlobalActionHandlers() */ public void deactivateGlobalActionHandlers() { } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.action.Action; /** * This action is used to toggle the "enable modification logs" preference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EnableModificationLogsAction extends Action { /** * Creates a new instance of EnableModificationLogsAction. */ public EnableModificationLogsAction() { super( Messages.getString( "EnableModificationLogsAction.EnableModificationLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( getText() ); setEnabled( true ); setChecked( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() ); } /** * {@inheritDoc} */ public void run() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, super.isChecked() ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ExportAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ExportAction.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportModificationLogsWizard; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardDialog; /** * Action to save the log files to a place outside the workspace. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportAction extends BrowserAction { /** * Creates a new instance of SaveAction. */ public ExportAction() { } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "ExportAction.ExportModificationLogs" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return ( getInput() instanceof ModificationLogsViewInput ) && ( ( ModificationLogsViewInput ) getInput() ).getBrowserConnection().getConnection() != null; } /** * {@inheritDoc} */ public void run() { ModificationLogsViewInput input = ( ModificationLogsViewInput ) getInput(); if ( input.getBrowserConnection().getConnection() != null ) { ExportModificationLogsWizard wizard = new ExportModificationLogsWizard(); wizard.getSearch().setBrowserConnection( input.getBrowserConnection() ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/OpenModificationLogsPreferencePageAction.java
/* * 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.views.modificationlogs; 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; /** * This action opens the prefence page of the modification logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenModificationLogsPreferencePageAction extends Action { /** * Creates a new instance of OpenModificationLogsPreferencePageAction. */ public OpenModificationLogsPreferencePageAction() { setText( Messages.getString( "OpenModificationLogsPreferencePageAction.Preferences" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenModificationLogsPreferencePageAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String mlPageId = BrowserUIConstants.PREFERENCEPAGEID_MODIFICATIONLOGS; PreferencesUtil.createPreferenceDialogOn( shell, mlPageId, new String[] { mlPageId }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ClearAction.java
/* * 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.views.modificationlogs; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserAction; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; /** * Action to clear the log files. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ClearAction extends BrowserAction { /** The modification logs view. */ private ModificationLogsView view; /** * Creates a new instance of ClearAction. * * @param view * the modification logs view */ public ClearAction( ModificationLogsView view ) { this.view = view; } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_CLEAR ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "ClearAction.Clear" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return getInput() instanceof ModificationLogsViewInput; } /** * {@inheritDoc} */ public void run() { if ( MessageDialog.openConfirm( this.getShell(), Messages.getString( "ClearAction.Delete" ), Messages.getString( "ClearAction.DeleteAllLogFiles" ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ { view.getUniversalListener().clearInput(); new RefreshAction( view ).run(); } } /** * {@inheritDoc} */ public void dispose() { super.dispose(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDITAction.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; /** * The ShowDITAction is used to select wheater the DIT category * should be visible in the browser view or not. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowDITAction extends Action { /** * Creates a new instance of ShowDITAction. */ public ShowDITAction() { super( Messages.getString( "ShowDITAction.ShowDIT" ), IAction.AS_CHECK_BOX ); //$NON-NLS-1$ setEnabled( true ); setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIT ) ); } /** * {@inheritDoc} */ public void run() { BrowserCommonActivator.getDefault().getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIT, isChecked() ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/OpenBrowserPreferencePageAction.java
/* * 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.views.browser; 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; /** * The OpenBrowserPreferencePageAction is used to open the * preference dialog with the browser's preference page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenBrowserPreferencePageAction extends Action { /** * Creates a new instance of OpenBrowserPreferencePageAction. */ public OpenBrowserPreferencePageAction() { super.setText( Messages.getString( "OpenBrowserPreferencePageAction.Preferences" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenBrowserPreferencePageAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String pageId = BrowserUIConstants.PREFERENCEPAGEID_BROWSER; PreferencesUtil.createPreferenceDialogOn( shell, pageId, new String[] { pageId }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowBookmarksAction.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; /** * The ShowBookmarksAction is used to select wheater the bookmark category * should be visible in the browser view or not. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowBookmarksAction extends Action { /** * Creates a new instance of ShowBookmarksAction. */ public ShowBookmarksAction() { super( Messages.getString( "ShowBookmarksAction.ShowBookmarks" ), IAction.AS_CHECK_BOX ); //$NON-NLS-1$ setEnabled( true ); setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS ) ); } /** * {@inheritDoc} */ public void run() { BrowserCommonActivator.getDefault().getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_BOOKMARKS, isChecked() ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewLabelDecorator.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.core.model.IContinuation; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.ILightweightLabelDecorator; import org.eclipse.jface.viewers.LabelProvider; /** * This class implements the label decorator for the browser view. It adds * an overlay image to the main image to mark search results, filtered * entries and inconsistent entries. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserViewLabelDecorator extends LabelProvider implements ILightweightLabelDecorator { /** * {@inheritDoc} */ public void decorate( Object element, IDecoration decoration ) { IEntry entry = null; if ( element instanceof ISearchResult ) { entry = ( ( ISearchResult ) element ).getEntry(); decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OVR_SEARCHRESULT ), IDecoration.BOTTOM_RIGHT ); } else if ( element instanceof IEntry ) { entry = ( IEntry ) element; if ( entry.getChildrenFilter() != null ) { decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OVR_FILTERED ), IDecoration.BOTTOM_RIGHT ); } } if ( entry instanceof IContinuation || element instanceof IContinuation ) { decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_OVR_REF ), IDecoration.TOP_LEFT ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewActionGroup.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAction; import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAllAction; import org.apache.directory.studio.ldapbrowser.common.actions.FetchAliasesAction; import org.apache.directory.studio.ldapbrowser.common.actions.FetchOperationalAttributesAction; import org.apache.directory.studio.ldapbrowser.common.actions.FetchReferralsAction; import org.apache.directory.studio.ldapbrowser.common.actions.FetchSubentriesAction; import org.apache.directory.studio.ldapbrowser.common.actions.RenameAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserViewActionProxy; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserActionGroup; import org.apache.directory.studio.ldapbrowser.ui.actions.BrowserPasteAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyDnAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsCsvAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyEntryAsLdifAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyUrlAction; import org.apache.directory.studio.ldapbrowser.ui.actions.EntryEditorMenuManager; import org.apache.directory.studio.ldapbrowser.ui.actions.GotoDnAction; import org.apache.directory.studio.ldapbrowser.ui.actions.ImportExportAction; import org.apache.directory.studio.ldapbrowser.ui.actions.LocateEntryInDitAction; import org.apache.directory.studio.ldapbrowser.ui.actions.MoveAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewBatchOperationAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewBookmarkAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewContextEntryAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewEntryAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewSearchAction; import org.apache.directory.studio.ldapbrowser.ui.actions.OpenEntryEditorAction; import org.apache.directory.studio.ldapbrowser.ui.actions.PasswordModifyExtendedOperationAction; import org.apache.directory.studio.utils.ActionUtils; import org.eclipse.jface.action.IAction; 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.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.actions.ActionFactory; /** * This class manages all the actions of the browser view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserViewActionGroup extends BrowserActionGroup { /** The action to show/hide the DIT. */ private ShowDITAction showDITAction; /** The action to show/hide searches. */ private ShowSearchesAction showSearchesAction; /** The action to show/hide bookmarks. */ private ShowBookmarksAction showBookmarksAction; /** The action to show/hide metadata. */ private ShowDirectoryMetadataEntriesAction showDirectoryMetadataEntriesAction; /** The action to open the browser's preference page. */ private OpenBrowserPreferencePageAction openBrowserPreferencePageAction; /** The action to link the current editor with the browser view. */ private LinkWithEditorAction linkWithEditorAction; /** The Constant locateEntryInDitAction. */ private static final String locateEntryInDitAction = "locateEntryInDitAction"; //$NON-NLS-1$ /** The Constant gotoDnAction. */ private static final String gotoDnAction = "gotoDnAction"; //$NON-NLS-1$ /** The Constant newEntryAction. */ private static final String newEntryAction = "newEntryAction"; //$NON-NLS-1$ /** The Constant newContextEntryAction. */ private static final String newContextEntryAction = "newContextEntryAction"; //$NON-NLS-1$ /** The Constant newSearchAction. */ private static final String newSearchAction = "newSearchAction"; //$NON-NLS-1$ /** The Constant newBookmarkAction. */ private static final String newBookmarkAction = "newBookmarkAction"; //$NON-NLS-1$ /** The Constant newBatchOperationAction. */ private static final String newBatchOperationAction = "newBatchOperationAction"; //$NON-NLS-1$ /** The Constant copyAction. */ private static final String copyAction = "copyAction"; //$NON-NLS-1$ /** The Constant pasteAction. */ private static final String pasteAction = "pasteAction"; //$NON-NLS-1$ /** The Constant deleteAction. */ private static final String deleteAction = "deleteAction"; //$NON-NLS-1$ /** The Constant moveAction. */ private static final String moveAction = "moveAction"; //$NON-NLS-1$ /** The Constant renameAction. */ private static final String renameAction = "renameAction"; //$NON-NLS-1$ /** The Constant copyDnAction. */ private static final String copyDnAction = "copyDnAction"; //$NON-NLS-1$ /** The Constant copyUrlAction. */ private static final String copyUrlAction = "copyUrlAction"; //$NON-NLS-1$ /** The Constant copyEntryAsLdifDnOnlyAction. */ private static final String copyEntryAsLdifDnOnlyAction = "copyEntryAsLdifDnOnlyAction"; //$NON-NLS-1$ /** The Constant copyEntryAsLdifReturningAttributesOnlyAction. */ private static final String copyEntryAsLdifReturningAttributesOnlyAction = "copyEntryAsLdifReturningAttributesOnlyAction"; //$NON-NLS-1$ /** The Constant copyEntryAsLdifAction. */ private static final String copyEntryAsLdifAction = "copyEntryAsLdifAction"; //$NON-NLS-1$ /** The Constant copyEntryAsLdifOperationalAction. */ private static final String copyEntryAsLdifOperationalAction = "copyEntryAsLdifOperationalAction"; //$NON-NLS-1$ /** The Constant copyEntryAsCsvDnOnlyAction. */ private static final String copyEntryAsCsvDnOnlyAction = "copyEntryAsCsvDnOnlyAction"; //$NON-NLS-1$ /** The Constant copyEntryAsCsvReturningAttributesOnlyAction. */ private static final String copyEntryAsCsvReturningAttributesOnlyAction = "copyEntryAsCsvReturningAttributesOnlyAction"; //$NON-NLS-1$ /** The Constant copyEntryAsCsvAction. */ private static final String copyEntryAsCsvAction = "copyEntryAsCsvAction"; //$NON-NLS-1$ /** The Constant copyEntryAsCsvOperationalAction. */ private static final String copyEntryAsCsvOperationalAction = "copyEntryAsCsvOperationalAction"; //$NON-NLS-1$ /** The Constant deleteAllAction. */ private static final String deleteAllAction = "deleteAllAction"; //$NON-NLS-1$ /** The Constant importDsmlAction. */ private static final String importDsmlAction = "importDsmlAction"; //$NON-NLS-1$ /** The Constant importLdifAction. */ private static final String importLdifAction = "importLdifAction"; //$NON-NLS-1$ /** The Constant exportLdifAction. */ private static final String exportLdifAction = "exportLdifAction"; //$NON-NLS-1$ /** The Constant exportDsmlAction. */ private static final String exportDsmlAction = "exportDsmlAction"; //$NON-NLS-1$ /** The Constant exportCsvAction. */ private static final String exportCsvAction = "exportCsvAction"; //$NON-NLS-1$ /** The Constant exportExcelAction. */ private static final String exportExcelAction = "exportExcelAction"; //$NON-NLS-1$ /** The Constant exportOdfAction. */ private static final String exportOdfAction = "exportOdfAction"; //$NON-NLS-1$ /** The Constant fetchOperationalAttributesAction. */ private static final String fetchOperationalAttributesAction = "fetchOperationalAttributesAction"; //$NON-NLS-1$ /** The Constant fetchAliasesAction. */ private static final String fetchAliasesAction = "fetchAliasesAction"; //$NON-NLS-1$ /** The Constant fetchReferralsAction. */ private static final String fetchReferralsAction = "fetchReferralsAction"; //$NON-NLS-1$ /** The Constant fetchSubentriesAction. */ private static final String fetchSubentriesAction = "fetchSubentriesAction"; //$NON-NLS-1$ /** The Constant openEntryEditorAction. */ private static final String openEntryEditorAction = "openEntryEditor"; //$NON-NLS-1$ /** The Constant passwordModifyExtendedOperationAction. */ private static final String passwordModifyExtendedOperationAction = "passwordModifyExtendedOperation"; //$NON-NLS-1$ /** * Creates a new instance of BrowserViewActionGroup and * creates all the actions. * * @param view the browser view */ public BrowserViewActionGroup( BrowserView view ) { super( view.getMainWidget(), view.getConfiguration() ); TreeViewer viewer = view.getMainWidget().getViewer(); linkWithEditorAction = new LinkWithEditorAction( view ); showDITAction = new ShowDITAction(); showSearchesAction = new ShowSearchesAction(); showBookmarksAction = new ShowBookmarksAction(); showDirectoryMetadataEntriesAction = new ShowDirectoryMetadataEntriesAction(); openBrowserPreferencePageAction = new OpenBrowserPreferencePageAction(); browserActionMap.put( newEntryAction, new BrowserViewActionProxy( viewer, new NewEntryAction( view.getSite() .getWorkbenchWindow() ) ) ); browserActionMap.put( newContextEntryAction, new BrowserViewActionProxy( viewer, new NewContextEntryAction( view.getSite().getWorkbenchWindow() ) ) ); browserActionMap.put( newSearchAction, new BrowserViewActionProxy( viewer, new NewSearchAction() ) ); browserActionMap.put( newBookmarkAction, new BrowserViewActionProxy( viewer, new NewBookmarkAction() ) ); browserActionMap.put( newBatchOperationAction, new BrowserViewActionProxy( viewer, new NewBatchOperationAction() ) ); browserActionMap .put( locateEntryInDitAction, new BrowserViewActionProxy( viewer, new LocateEntryInDitAction() ) ); browserActionMap.put( gotoDnAction, new BrowserViewActionProxy( viewer, new GotoDnAction() ) ); browserActionMap.put( pasteAction, new BrowserViewActionProxy( viewer, new BrowserPasteAction() ) ); browserActionMap.put( copyAction, new BrowserViewActionProxy( viewer, new CopyAction( ( BrowserActionProxy ) browserActionMap.get( pasteAction ) ) ) ); browserActionMap.put( deleteAction, new BrowserViewActionProxy( viewer, new DeleteAction() ) ); browserActionMap.put( moveAction, new BrowserViewActionProxy( viewer, new MoveAction() ) ); browserActionMap.put( renameAction, new BrowserViewActionProxy( viewer, new RenameAction() ) ); browserActionMap.put( copyDnAction, new BrowserViewActionProxy( viewer, new CopyDnAction() ) ); browserActionMap.put( copyUrlAction, new BrowserViewActionProxy( viewer, new CopyUrlAction() ) ); browserActionMap.put( copyEntryAsLdifAction, new BrowserViewActionProxy( viewer, new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_NORMAL ) ) ); browserActionMap.put( copyEntryAsLdifDnOnlyAction, new BrowserViewActionProxy( viewer, new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) ); browserActionMap.put( copyEntryAsLdifReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer, new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) ); browserActionMap.put( copyEntryAsLdifOperationalAction, new BrowserViewActionProxy( viewer, new CopyEntryAsLdifAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) ); browserActionMap.put( copyEntryAsCsvAction, new BrowserViewActionProxy( viewer, new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_NORMAL ) ) ); browserActionMap.put( copyEntryAsCsvDnOnlyAction, new BrowserViewActionProxy( viewer, new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_DN_ONLY ) ) ); browserActionMap.put( copyEntryAsCsvReturningAttributesOnlyAction, new BrowserViewActionProxy( viewer, new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_RETURNING_ATTRIBUTES_ONLY ) ) ); browserActionMap.put( copyEntryAsCsvOperationalAction, new BrowserViewActionProxy( viewer, new CopyEntryAsCsvAction( CopyEntryAsLdifAction.MODE_INCLUDE_OPERATIONAL_ATTRIBUTES ) ) ); browserActionMap.put( deleteAllAction, new BrowserViewActionProxy( viewer, new DeleteAllAction() ) ); browserActionMap.put( importDsmlAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_IMPORT_DSML ) ) ); browserActionMap.put( exportDsmlAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_EXPORT_DSML ) ) ); browserActionMap.put( importLdifAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_IMPORT_LDIF ) ) ); browserActionMap.put( exportLdifAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_EXPORT_LDIF ) ) ); browserActionMap.put( exportCsvAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_EXPORT_CSV ) ) ); browserActionMap.put( exportExcelAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_EXPORT_EXCEL ) ) ); browserActionMap.put( exportOdfAction, new BrowserViewActionProxy( viewer, new ImportExportAction( ImportExportAction.TYPE_EXPORT_ODF ) ) ); browserActionMap.put( fetchOperationalAttributesAction, new BrowserViewActionProxy( viewer, new FetchOperationalAttributesAction() ) ); browserActionMap.put( fetchAliasesAction, new BrowserViewActionProxy( viewer, new FetchAliasesAction() ) ); browserActionMap.put( fetchReferralsAction, new BrowserViewActionProxy( viewer, new FetchReferralsAction() ) ); browserActionMap.put( fetchSubentriesAction, new BrowserViewActionProxy( viewer, new FetchSubentriesAction() ) ); browserActionMap.put( openEntryEditorAction, new BrowserViewActionProxy( viewer, new OpenEntryEditorAction() ) ); browserActionMap.put( passwordModifyExtendedOperationAction, new BrowserViewActionProxy( viewer, new PasswordModifyExtendedOperationAction() ) ); } /** * {@inheritDoc} */ public void dispose() { if ( openBrowserPreferencePageAction != null ) { linkWithEditorAction.dispose(); linkWithEditorAction = null; showDITAction = null; showSearchesAction = null; showBookmarksAction = null; showDirectoryMetadataEntriesAction = null; openBrowserPreferencePageAction = null; } super.dispose(); } /** * {@inheritDoc} */ public void fillToolBar( IToolBarManager toolBarManager ) { toolBarManager.add( browserActionMap.get( UP_ACTION ) ); toolBarManager.add( new Separator() ); toolBarManager.add( browserActionMap.get( REFRESH_ACTION ) ); toolBarManager.add( new Separator() ); toolBarManager.add( collapseAllAction ); toolBarManager.add( linkWithEditorAction ); toolBarManager.update( true ); } /** * {@inheritDoc} */ public void fillMenu( IMenuManager menuManager ) { menuManager.add( openSortDialogAction ); menuManager.add( new Separator() ); menuManager.add( showQuickSearchAction ); menuManager.add( new Separator() ); menuManager.add( showDITAction ); menuManager.add( showSearchesAction ); menuManager.add( showBookmarksAction ); menuManager.add( showDirectoryMetadataEntriesAction ); menuManager.add( new Separator() ); menuManager.add( openBrowserPreferencePageAction ); menuManager.update( true ); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager menuManager ) { // new MenuManager newMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.New" ) ); //$NON-NLS-1$ newMenuManager.add( browserActionMap.get( newEntryAction ) ); newMenuManager.add( browserActionMap.get( newContextEntryAction ) ); newMenuManager.add( new Separator() ); newMenuManager.add( browserActionMap.get( newSearchAction ) ); newMenuManager.add( browserActionMap.get( newBookmarkAction ) ); newMenuManager.add( new Separator() ); newMenuManager.add( browserActionMap.get( newBatchOperationAction ) ); menuManager.add( newMenuManager ); menuManager.add( new Separator() ); // navigation menuManager.add( browserActionMap.get( openEntryEditorAction ) ); MenuManager openWithEntryEditorMenuManager = new EntryEditorMenuManager( mainWidget.getViewer() ); menuManager.add( openWithEntryEditorMenuManager ); BrowserViewActionProxy leid = ( BrowserViewActionProxy ) browserActionMap.get( locateEntryInDitAction ); leid.setImageDescriptor( leid.getAction().getImageDescriptor() ); menuManager.add( leid ); menuManager.add( browserActionMap.get( gotoDnAction ) ); menuManager.add( browserActionMap.get( UP_ACTION ) ); menuManager.add( new Separator() ); // copy/paste/... menuManager.add( browserActionMap.get( copyAction ) ); menuManager.add( browserActionMap.get( pasteAction ) ); menuManager.add( browserActionMap.get( deleteAction ) ); menuManager.add( browserActionMap.get( moveAction ) ); menuManager.add( browserActionMap.get( renameAction ) ); MenuManager advancedMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.Advanced" ) ); //$NON-NLS-1$ advancedMenuManager.add( browserActionMap.get( copyDnAction ) ); advancedMenuManager.add( browserActionMap.get( copyUrlAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( browserActionMap.get( copyEntryAsLdifDnOnlyAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsLdifReturningAttributesOnlyAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsLdifAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsLdifOperationalAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( browserActionMap.get( copyEntryAsCsvDnOnlyAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsCsvReturningAttributesOnlyAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsCsvAction ) ); advancedMenuManager.add( browserActionMap.get( copyEntryAsCsvOperationalAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( browserActionMap.get( deleteAllAction ) ); advancedMenuManager.add( new Separator() ); menuManager.add( advancedMenuManager ); menuManager.add( new Separator() ); // filter, batch menuManager.add( browserActionMap.get( FILTER_CHILDREN_ACTION ) ); if ( ( browserActionMap.get( UNFILTER_CHILDREN_ACTION ) ).isEnabled() ) { menuManager.add( browserActionMap.get( UNFILTER_CHILDREN_ACTION ) ); } menuManager.add( browserActionMap.get( OPEN_QUICK_SEARCH_ACTION ) ); menuManager.add( new Separator() ); // import/export MenuManager importMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.Import" ) ); //$NON-NLS-1$ importMenuManager.add( browserActionMap.get( importLdifAction ) ); importMenuManager.add( browserActionMap.get( importDsmlAction ) ); importMenuManager.add( new Separator() ); menuManager.add( importMenuManager ); MenuManager exportMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.Export" ) ); //$NON-NLS-1$ exportMenuManager.add( browserActionMap.get( exportLdifAction ) ); exportMenuManager.add( browserActionMap.get( exportDsmlAction ) ); exportMenuManager.add( new Separator() ); exportMenuManager.add( browserActionMap.get( exportCsvAction ) ); exportMenuManager.add( browserActionMap.get( exportExcelAction ) ); exportMenuManager.add( browserActionMap.get( exportOdfAction ) ); menuManager.add( exportMenuManager ); menuManager.add( new Separator() ); // refresh menuManager.add( browserActionMap.get( REFRESH_ACTION ) ); MenuManager fetchMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.Fetch" ) ); //$NON-NLS-1$ if ( browserActionMap.get( fetchOperationalAttributesAction ).isEnabled() ) { fetchMenuManager.add( browserActionMap.get( fetchOperationalAttributesAction ) ); } if ( browserActionMap.get( fetchAliasesAction ).isEnabled() ) { fetchMenuManager.add( browserActionMap.get( fetchAliasesAction ) ); } if ( browserActionMap.get( fetchReferralsAction ).isEnabled() ) { fetchMenuManager.add( browserActionMap.get( fetchReferralsAction ) ); } if ( browserActionMap.get( fetchSubentriesAction ).isEnabled() ) { fetchMenuManager.add( browserActionMap.get( fetchSubentriesAction ) ); } menuManager.add( fetchMenuManager ); menuManager.add( new Separator() ); // additions menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); MenuManager extendedOperationsMenuManager = new MenuManager( Messages.getString( "BrowserViewActionGroup.ExtendedOperations" ) ); //$NON-NLS-1$ extendedOperationsMenuManager.add( browserActionMap.get( passwordModifyExtendedOperationAction ) ); menuManager.add( extendedOperationsMenuManager ); menuManager.add( new Separator() ); // properties menuManager.add( browserActionMap.get( PROPERTY_DIALOG_ACTION ) ); } /** * {@inheritDoc} */ public void activateGlobalActionHandlers() { if ( actionBars != null ) { actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), browserActionMap.get( copyAction ) ); actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), browserActionMap.get( pasteAction ) ); actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), browserActionMap.get( deleteAction ) ); actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), browserActionMap.get( moveAction ) ); actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), browserActionMap.get( renameAction ) ); } super.activateGlobalActionHandlers(); IAction leid = browserActionMap.get( locateEntryInDitAction ); ActionUtils.activateActionHandler( leid ); } /** * {@inheritDoc} */ public void deactivateGlobalActionHandlers() { if ( actionBars != null ) { actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.RENAME.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.MOVE.getId(), null ); } super.deactivateGlobalActionHandlers(); IAction leid = browserActionMap.get( locateEntryInDitAction ); ActionUtils.deactivateActionHandler( leid ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/LinkWithEditorAction.java
/* * 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.views.browser; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPart; /** * This class implements the Link With Editor Action for the Browser View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LinkWithEditorAction extends AbstractLinkWithEditorAction { /** The browser view */ private BrowserView browserView; /** * Creates a new instance of LinkWithEditorAction. * * @param browserView * the associated view */ public LinkWithEditorAction( BrowserView browserView ) { super( browserView, Messages.getString( "LinkWithEditorAction.LinkWithEditor" ) ); //$NON-NLS-1$ this.browserView = browserView; super.init(); } /** * Links the view with the right editor * * @param partRef the part */ protected void linkViewWithEditor( IWorkbenchPart part ) { if ( part != null && browserView != null && part.getSite().getWorkbenchWindow() == browserView.getSite().getWorkbenchWindow() ) { Object objectToSelect = null; if ( part instanceof IEditorPart ) { IEditorPart editor = ( IEditorPart ) part; IEditorInput input = editor.getEditorInput(); if ( input instanceof EntryEditorInput ) { EntryEditorInput eei = ( EntryEditorInput ) input; objectToSelect = eei.getInput(); } else if ( input instanceof SearchResultEditorInput ) { SearchResultEditorInput srei = ( SearchResultEditorInput ) input; objectToSelect = srei.getSearch(); } } if ( objectToSelect != null ) { // do not select if already selected! // necessary to avoid infinite loops! IStructuredSelection selection = ( IStructuredSelection ) browserView.getMainWidget().getViewer() .getSelection(); if ( selection.size() != 1 || !selection.getFirstElement().equals( objectToSelect ) ) { browserView.select( objectToSelect ); } } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowSearchesAction.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; /** * The ShowSearchesAction is used to select wheater the search category * should be visible in the browser view or not. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowSearchesAction extends Action { /** * Creates a new instance of ShowSearchesAction. */ public ShowSearchesAction() { super( Messages.getString( "ShowSearchesAction.ShowSearches" ), IAction.AS_CHECK_BOX ); //$NON-NLS-1$ setEnabled( true ); setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_SEARCHES ) ); } /** * {@inheritDoc} */ public void run() { BrowserCommonActivator.getDefault().getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_SEARCHES, isChecked() ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DragListener.java
/* * 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.views.browser; import org.eclipse.swt.dnd.DragSourceListener; /** * This class implements the {@link DragSourceListener} for the browser view. * * TODO: The code isn't working yet, just a test implementation. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DragListener /* implements DragSourceListener */ { // private Clipboard systemClipboard; // private InternalClipboard internalClipboard; // // public DragListener(Shell shell, Clipboard systemClipboard, // InternalClipboard internalClipboard) { // super(shell, "Drag", null, null); // this.systemClipboard = systemClipboard; // this.internalClipboard = internalClipboard; // } // public void dispose() { // this.systemClipboard = null; // this.internalClipboard = null; // super.dispose(); // } // protected void updateEnabledState() { // } // // public void dragStart(DragSourceEvent event) { // //System.out.println("dragStart: " + event); // // if(this.selectedEntries.length > 0 && this.selectedSearches.length == // 0 && this.selectedSearchResults.length == 0) { // /* // IEntry parent = this.selectedEntries[0].getParententry(); // for(int i=1; i<this.selectedEntries.length; i++) { // if(this.selectedEntries[i].getParententry() != parent) { // event.doit = false; // return; // } // } // */ // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN, // this.selectedEntries); // event.doit = true; // } // else if(this.selectedSearchResults.length > 0 && // this.selectedEntries.length == 0 && this.selectedSearches.length == // 0) { // /* // IEntry parent = // this.selectedSearchResults[0].getEntry().getParententry(); // for(int i=1; i<this.selectedSearchResults.length; i++) { // if(this.selectedSearchResults[i].getEntry().getParententry() != // parent) { // event.doit = false; // return; // } // } // */ // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN, // this.selectedSearchResults); // event.doit = true; // } // else if(this.selectedSearches.length > 0 && // this.selectedEntries.length == 0 && this.selectedSearchResults.length // == 0) { // this.internalClipboard.newTransfer(InternalClipboard.TYPE_UNKNOWN, // this.selectedSearches); // event.doit = true; // } // else { // event.doit = false; // } // } // // public void dragSetData(DragSourceEvent event) { // //System.out.println("dragSetDataA: " + event); // //System.out.println("dragSetDataT: " + event.dataType); // //System.out.println("dragSetDataS: " + // BrowserTransfer.getInstance().isSupportedType(event.dataType)); // //System.out.println("dragSetDataE: " + // TextTransfer.getInstance().isSupportedType(event.dataType)); // // if (BrowserTransfer.getInstance().isSupportedType(event.dataType)) { // event.data = this.internalClipboard.getClass().getName(); // } // else if (TextTransfer.getInstance().isSupportedType(event.dataType)) // { // String text = ""; // Object objectToTransfer = // this.internalClipboard.getObjectToTransfer(); // if(objectToTransfer instanceof IEntry[]) { // IEntry[] entries = (IEntry[])objectToTransfer; // if(entries.length > 0) { // text = entries[0].getDn().toString(); // for(int i=1; i<entries.length; i++) { // text += "\n"+entries[i].getDn().toString(); // } // } // } // else if(objectToTransfer instanceof ISearchResult[]) { // ISearchResult[] searchresults = (ISearchResult[])objectToTransfer; // if(searchresults.length > 0) { // text = searchresults[0].getDn().toString(); // for(int i=1; i<searchresults.length; i++) { // text += "\n"+searchresults[i].getDn().toString(); // } // } // } // else if(objectToTransfer instanceof ISearch[]) { // ISearch[] searches = (ISearch[])objectToTransfer; // if(searches.length > 0) { // text = searches[0].getName(); // for(int i=1; i<searches.length; i++) { // text += "\n"+searches[i].getName(); // } // } // } // event.data = text; // } // else { // event.data = null; // } // // //System.out.println("dragSetData2: " + event); // } // // public void dragFinished(org.eclipse.swt.dnd.DragSourceEvent event) { // //System.out.println("dragFinished: " + event); // this.internalClipboard.clear(); // } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/ShowDirectoryMetadataEntriesAction.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; /** * The ShowDirectoryMetadataEntriesAction is used to select wheater metadata entries * should be visible in the browser view or not. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowDirectoryMetadataEntriesAction extends Action { /** * Creates a new instance of ShowDirectoryMetadataEntriesAction. */ public ShowDirectoryMetadataEntriesAction() { super( Messages.getString( "ShowDirectoryMetadataEntriesAction.ShowDirectoryMetadata" ), IAction.AS_CHECK_BOX ); //$NON-NLS-1$ setEnabled( true ); setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES ) ); } /** * {@inheritDoc} */ public void run() { BrowserCommonActivator.getDefault().getPreferenceStore().setValue( BrowserCommonConstants.PREFERENCE_BROWSER_SHOW_DIRECTORY_META_ENTRIES, isChecked() ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/Messages.java
/* * 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.views.browser; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserView.java
/* * 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.views.browser; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserConfiguration; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserWidget; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.IShowInTarget; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.part.ViewPart; /** * This class implements the browser view. It displays the DIT, the searches and the bookmarks. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserView extends ViewPart { /** The configuration */ private BrowserConfiguration configuration; /** The listeners */ private BrowserViewUniversalListener universalListener; /** The actions */ private BrowserViewActionGroup actionGroup; /** The browser's main widget */ private BrowserWidget mainWidget; // private DragAction dragAction; // private DropAction dropAction; /** * Returns the browser view ID. * * @return the browser view ID. */ public static String getId() { return BrowserUIConstants.VIEW_BROWSER_VIEW; } /** * Creates a new instance of BrowserView. */ public BrowserView() { } /** * {@inheritDoc} * * This implementation sets focus to the viewer's control. */ public void setFocus() { mainWidget.getViewer().getControl().setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( configuration != null ) { actionGroup.dispose(); actionGroup = null; universalListener.dispose(); universalListener = null; configuration.dispose(); configuration = null; mainWidget.dispose(); mainWidget = null; getSite().setSelectionProvider( null ); } super.dispose(); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout( layout ); PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, BrowserUIConstants.PLUGIN_ID + "." + "tools_browser_view" ); //$NON-NLS-1$ //$NON-NLS-2$ // create configuration configuration = new BrowserConfiguration(); // create main widget mainWidget = new BrowserWidget( configuration, getViewSite().getActionBars() ); mainWidget.createWidget( composite ); mainWidget.setInput( getSite() ); // create actions and context menu (and register global actions) actionGroup = new BrowserViewActionGroup( this ); actionGroup.fillToolBar( mainWidget.getToolBarManager() ); actionGroup.fillMenu( mainWidget.getMenuManager() ); actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() ); IMenuManager contextMenuManager = mainWidget.getContextMenuManager(); actionGroup.fillContextMenu( contextMenuManager ); getSite().registerContextMenu( ( MenuManager ) contextMenuManager, mainWidget.getViewer() ); // create the listener getSite().setSelectionProvider( mainWidget.getViewer() ); universalListener = new BrowserViewUniversalListener( this ); // DND support // int ops = DND.DROP_COPY | DND.DROP_MOVE; // viewer.addDragSupport(ops, new Transfer[]{TextTransfer.getInstance(), // BrowserTransfer.getInstance()}, this.dragAction); // viewer.addDropSupport(ops, new // Transfer[]{BrowserTransfer.getInstance()}, this.dropAction); } /** * Selects the given object in the tree. The object * must be an IEntry, ISearch, ISearchResult or IBookmark. * * @param obj the object to select */ public void select( Object obj ) { Object objectToSelect = null; if ( obj instanceof ISearch ) { ISearch search = ( ISearch ) obj; universalListener.setInput( search.getBrowserConnection() ); mainWidget.getViewer().expandToLevel( search, 0 ); objectToSelect = search; } if ( obj instanceof ISearchResult ) { ISearchResult searchResult = ( ISearchResult ) obj; ISearch search = searchResult.getSearch(); universalListener.setInput( search.getBrowserConnection() ); mainWidget.getViewer().expandToLevel( search, 1 ); objectToSelect = searchResult; } if ( obj instanceof IBookmark ) { IBookmark bookmark = ( IBookmark ) obj; universalListener.setInput( bookmark.getBrowserConnection() ); mainWidget.getViewer().expandToLevel( bookmark, 0 ); objectToSelect = bookmark; } if ( obj instanceof IEntry ) { IEntry entry = ( IEntry ) obj; universalListener.setInput( entry.getBrowserConnection() ); List<IEntry> entryList = new ArrayList<IEntry>(); IEntry tempEntry = entry; while ( tempEntry.getParententry() != null ) { IEntry parentEntry = tempEntry.getParententry(); entryList.add( 0, tempEntry ); tempEntry = parentEntry; } for ( IEntry childEntry : entryList ) { IEntry parentEntry = childEntry.getParententry(); if ( !parentEntry.isChildrenInitialized() ) { parentEntry.setChildrenInitialized( true ); parentEntry.setHasMoreChildren( true ); } if ( !Arrays.asList( parentEntry.getChildren() ).contains( childEntry ) ) { parentEntry.addChild( childEntry ); } // force refresh of each parent, beginning from the root // if the entry to select was lazy initialized then the // JFace model has no knowledge about it so we must // refresh the JFace model from the browser model mainWidget.getViewer().refresh( parentEntry, true ); } objectToSelect = entry; } if ( objectToSelect != null ) { mainWidget.getViewer().reveal( objectToSelect ); mainWidget.getViewer().refresh( objectToSelect, true ); mainWidget.getViewer().setSelection( new StructuredSelection( objectToSelect ), true ); } } /** * {@inheritDoc} */ public Object getAdapter( Class required ) { if ( IShowInTarget.class.equals( required ) ) { return new IShowInTarget() { public boolean show( ShowInContext context ) { StructuredSelection selection = ( StructuredSelection ) context.getSelection(); Object obj = selection.getFirstElement(); if ( obj instanceof IValue ) { IValue value = ( IValue ) obj; IEntry entry = value.getAttribute().getEntry(); // The entry may be a clone, lookup original entry from entry cache. // The result may be null, in that case the selection won't change. entry = entry.getBrowserConnection().getEntryFromCache( entry.getDn() ); select( entry ); } else if ( obj instanceof IAttribute ) { IAttribute attribute = ( IAttribute ) obj; IEntry entry = attribute.getEntry(); // The entry may be a clone, lookup original entry from entry cache. // The result may be null, in that case the selection won't change. entry = entry.getBrowserConnection().getEntryFromCache( entry.getDn() ); select( entry ); } else if ( obj instanceof ISearchResult ) { ISearchResult sr = ( ISearchResult ) obj; ISearch search = sr.getSearch(); // The search may be a clone, lookup original search from search manager. // The result may be null, in that case the selection won't change. search = search.getBrowserConnection().getSearchManager().getSearch( search.getName() ); select( search ); } return true; } }; } return null; } /** * Gets the action group. * * @return the action group */ public BrowserViewActionGroup getActionGroup() { return actionGroup; } /** * Gets the configuration. * * @return the configuration */ public BrowserConfiguration getConfiguration() { return configuration; } /** * Gets the main widget. * * @return the main widget */ public BrowserWidget getMainWidget() { return mainWidget; } /** * Gets the universal listener. * * @return the universal listener */ public BrowserViewUniversalListener getUniversalListener() { return universalListener; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/BrowserViewUniversalListener.java
/* * 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.views.browser; import java.util.HashMap; import java.util.Map; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry; import org.apache.directory.studio.connection.ui.ConnectionUIPlugin; import org.apache.directory.studio.entryeditors.EntryEditorExtension; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.entryeditors.EntryEditorManager; import org.apache.directory.studio.entryeditors.IEntryEditor; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserContentProvider; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserUniversalListener; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.events.AttributesInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateEvent; import org.apache.directory.studio.ldapbrowser.core.events.BookmarkUpdateListener; import org.apache.directory.studio.ldapbrowser.core.events.BulkModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.ChildrenInitializedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryAddedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryDeletedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryMovedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryRenamedEvent; import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry; import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent; import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateEvent.EventDetail; import org.apache.directory.studio.ldapbrowser.core.events.SearchUpdateListener; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IContinuation; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IQuickSearch; import org.apache.directory.studio.ldapbrowser.core.model.IRootDSE; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditor; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorInput; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.OpenEvent; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.INullSelectionListener; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextService; /** * The BrowserViewUniversalListener manages all events for the browser view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserViewUniversalListener extends BrowserUniversalListener implements SearchUpdateListener, BookmarkUpdateListener { /** This map contains all expanded elements for a particular connection */ private Map<IBrowserConnection, Object[]> connectionToExpandedElementsMap; /** This map contains all selected elements for a particular connection */ private Map<IBrowserConnection, ISelection> connectionToSelectedElementMap; /** The browser view */ private BrowserView view; /** Token used to activate and deactivate shortcuts in the view */ private IContextActivation contextActivation; /** Listener that listens for selections of connections */ private INullSelectionListener connectionSelectionListener = new INullSelectionListener() { /** * {@inheritDoc} * * This implementation sets the input when another connection was selected. */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { if ( view != null && part != null ) { if ( view.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() ) { Connection[] connections = BrowserSelectionUtils.getConnections( selection ); if ( connections.length == 1 ) { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connections[0] ); setInput( connection ); } else { setInput( null ); } } } } }; /** The part listener used to activate and deactivate the shortcuts */ private IPartListener2 partListener = new IPartListener2() { /** * {@inheritDoc} * * This implementation deactivates the shortcuts when the part is deactivated. */ public void partDeactivated( IWorkbenchPartReference partRef ) { if ( partRef.getPart( false ) == view && contextActivation != null ) { view.getActionGroup().deactivateGlobalActionHandlers(); IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter( IContextService.class ); contextService.deactivateContext( contextActivation ); contextActivation = null; } } /** * {@inheritDoc} * * This implementation activates the shortcuts when the part is activated. */ public void partActivated( IWorkbenchPartReference partRef ) { if ( partRef.getPart( false ) == view ) { IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter( IContextService.class ); contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_WINDOWS ); // org.eclipse.ui.contexts.dialogAndWindow // org.eclipse.ui.contexts.window // org.eclipse.ui.text_editor_context view.getActionGroup().activateGlobalActionHandlers(); } } /** * {@inheritDoc} */ public void partBroughtToTop( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partClosed( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partOpened( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partHidden( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partVisible( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partInputChanged( IWorkbenchPartReference partRef ) { } }; /** This listener is used to ensure that the entry editor and search result editor are opened when an object in the browser view is selected */ private ISelectionChangedListener viewerSelectionListener = new ISelectionChangedListener() { /** * {@inheritDoc} */ public void selectionChanged( SelectionChangedEvent event ) { openEditor( event.getSelection() ); } }; /** This listerner is used to listen on the preference settings modifications, especially * the open mode preference value change. */ private IPropertyChangeListener preferencePropertyChangeListener = new IPropertyChangeListener() { /** * {@inheritDoc} */ public void propertyChange( org.eclipse.jface.util.PropertyChangeEvent event ) { if ( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE.equals( event.getProperty() ) ) { setupOpenModeListeners(); } }; }; /** The open mode listener */ private IOpenListener openListener = new IOpenListener() { public void open( OpenEvent event ) { openEditor( event.getSelection() ); } }; /** * Creates a new instance of BrowserViewUniversalListener. * * @param view the browser view */ public BrowserViewUniversalListener( BrowserView view ) { super( view.getMainWidget() ); this.view = view; // create maps connectionToExpandedElementsMap = new HashMap<IBrowserConnection, Object[]>(); connectionToSelectedElementMap = new HashMap<IBrowserConnection, ISelection>(); // register listeners EventRegistry.addSearchUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); EventRegistry.addBookmarkUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionUIPlugin.getDefault().getEventRunner() ); // listener for shortcuts activation/deactivation view.getSite().getPage().addPartListener( partListener ); // listener for connections view.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); // listener for open mode BrowserUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( preferencePropertyChangeListener ); setupOpenModeListeners(); } /** * Sets up the open mode listeners according the preferences. */ private void setupOpenModeListeners() { int openMode = BrowserUIPlugin.getDefault().getPluginPreferences().getInt( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE ); if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR ) { // Historical Behavior viewer.removeOpenListener( openListener ); viewer.addSelectionChangedListener( viewerSelectionListener ); } else if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE ) { // Application Wide Setting viewer.removeSelectionChangedListener( viewerSelectionListener ); viewer.addOpenListener( openListener ); } } /** * Opens an editor to show the given selection. * * @param selection the browser's selection. */ private void openEditor( ISelection selection ) { if ( view != null ) { IEntry[] entries = BrowserSelectionUtils.getEntries( selection ); ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection ); IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection ); ISearch[] searches = BrowserSelectionUtils.getSearches( selection ); EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager(); if ( entries.length + searchResults.length + bookmarks.length == 1 ) { entryEditorManager.openEntryEditor( entries, searchResults, bookmarks ); // atm it is not necessary to blank the search result editor, it blanks itself } else { // Checking if there's at least one entry editor open. // We need to blank them. // This is done before the search result editor is opened, // otherwise the entry editor would be activated. // We can blank them directly here, without using the OpenEntryEditorRunnable. blankSingleTabEntryEditors(); if ( searches.length == 1 ) { try { SearchResultEditorInput input = new SearchResultEditorInput( searches[0] ); view.getSite().getPage().openEditor( input, SearchResultEditor.getId(), false ); } catch ( PartInitException e ) { } } } } } /** * Blanks all single-tab entry editors. */ private void blankSingleTabEntryEditors() { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); for ( IEditorReference ref : activePage.getEditorReferences() ) { IWorkbenchPart part = ref.getPart( false ); if ( part instanceof IEntryEditor ) { IEntryEditor editor = ( IEntryEditor ) part; if ( ( editor != null ) && ( editor.getEntryEditorInput() != null ) && ( editor.getEntryEditorInput().getResolvedEntry() != null ) && ( editor.getEntryEditorInput().getExtension() != null ) && ( !editor.getEntryEditorInput().getExtension().isMultiWindow() ) ) { EntryEditorExtension extension = editor.getEntryEditorInput().getExtension(); String editorId = extension.getEditorId(); EntryEditorInput input = new EntryEditorInput( ( IEntry ) null, extension ); try { view.getSite().getPage().openEditor( input, editorId, false ); } catch ( PartInitException e ) { } } } } } /** * {@inheritDoc} */ public void dispose() { if ( view != null ) { EventRegistry.removeSearchUpdateListener( this ); EventRegistry.removeBookmarkUpdateListener( this ); EventRegistry.removeEntryUpdateListener( this ); ConnectionEventRegistry.removeConnectionUpdateListener( this ); view.getSite().getPage().removePartListener( partListener ); view.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener( ConnectionView.getId(), connectionSelectionListener ); viewer.removeOpenListener( openListener ); viewer.removeSelectionChangedListener( viewerSelectionListener ); view = null; connectionToExpandedElementsMap.clear(); connectionToExpandedElementsMap = null; connectionToSelectedElementMap.clear(); connectionToSelectedElementMap = null; } super.dispose(); } /** * Sets the input to the viewer and saves/restores the expanded and selected elements. * * @param connection the connection input */ void setInput( IBrowserConnection connection ) { // only if another connection is selected if ( connection != viewer.getInput() ) { IBrowserConnection currentConnection = viewer.getInput() instanceof IBrowserConnection ? ( IBrowserConnection ) viewer .getInput() : null; // save expanded elements and selection if ( currentConnection != null ) { connectionToExpandedElementsMap.put( currentConnection, viewer.getExpandedElements() ); if ( !viewer.getSelection().isEmpty() ) { connectionToSelectedElementMap.put( currentConnection, viewer.getSelection() ); } } // change input viewer.setInput( connection ); view.getActionGroup().setInput( connection ); view.getMainWidget().getQuickSearchWidget().setInput( connection ); // restore expanded elements and selection if ( view != null && connection != null ) { if ( connectionToExpandedElementsMap.containsKey( connection ) ) { viewer.setExpandedElements( ( Object[] ) connectionToExpandedElementsMap.get( connection ) ); } if ( connectionToSelectedElementMap.containsKey( connection ) && this.view.getSite().getPage().isPartVisible( view ) ) { viewer.setSelection( ( ISelection ) connectionToSelectedElementMap.get( connection ), true ); } } } } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionOpened(org.apache.directory.studio.connection.core.Connection) */ public void connectionOpened( Connection connection ) { IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); if ( browserConnection == null ) { // // If browser connection is null then it has been temporarily created // by a dialog or other transient entity. Only display in the view those // browser connections stored in the connection manager // return; } // expand viewer viewer.refresh( browserConnection ); viewer.expandToLevel( 2 ); // expand root DSE to show base entries IRootDSE rootDSE = browserConnection.getRootDSE(); viewer.expandToLevel( rootDSE, 1 ); // expand base entries, if requested if ( view.getConfiguration().getPreferences().isExpandBaseEntries() ) { viewer.expandToLevel( rootDSE, 2 ); } } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionClosed(org.apache.directory.studio.connection.core.Connection) */ public void connectionClosed( Connection connection ) { IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); if (browserConnection == null) { // // If browser connection is null then it has been temporarily created // by a dialog or other transient entity. Only display in the view those // browser connections stored in the connection manager // return; } viewer.collapseAll(); connectionToExpandedElementsMap.remove( browserConnection ); connectionToSelectedElementMap.remove( browserConnection ); viewer.refresh( browserConnection ); } /** * {@inheritDoc} * * This viewer selects the updated search. */ public void searchUpdated( SearchUpdateEvent searchUpdateEvent ) { ISearch search = searchUpdateEvent.getSearch(); if ( ( search instanceof IQuickSearch ) && ( searchUpdateEvent.getDetail() == EventDetail.SEARCH_REMOVED ) ) { if ( search.getBrowserConnection().getQuickSearch() == search ) { search.getBrowserConnection().setQuickSearch( null ); } } viewer.refresh(); if ( search instanceof IContinuation ) { viewer.setSelection( new StructuredSelection( search ), true ); } else if ( search.getBrowserConnection().getSearchManager().getSearches().contains( search ) ) { viewer.setSelection( new StructuredSelection( search ), true ); } else if ( ( search instanceof IQuickSearch ) && ( searchUpdateEvent.getDetail() != EventDetail.SEARCH_REMOVED ) ) { if ( search.getBrowserConnection().getQuickSearch() == search ) { viewer.setSelection( new StructuredSelection( search ), true ); } } else { Object searchCategory = ( ( ITreeContentProvider ) viewer.getContentProvider() ).getParent( search ); if ( searchCategory != null ) { viewer.setSelection( new StructuredSelection( searchCategory ), true ); } } } /** * {@inheritDoc} */ public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent ) { viewer.refresh(); } /** * {@inheritDoc} * * This implementation refreshes the tree and * selects an entry depending on the event type. */ public void entryUpdated( EntryModificationEvent event ) { // Don't handle attribute initalization, could cause double // retrieval of children. // // When double-clicking an entry two Jobs/Threads are started: // - InitializeAttributesJob and // - InitializeChildrenJob // If the InitializeAttributesJob is finished first the // AttributesInitializedEvent is fired. If this causes // a refresh of the tree before the children are initialized // another InitializeChildrenJob is executed. if ( event instanceof AttributesInitializedEvent && !( event.getModifiedEntry() instanceof IRootDSE ) ) { return; } if ( event instanceof EntryAddedEvent ) { viewer.refresh( event.getModifiedEntry(), true ); viewer.refresh( event.getModifiedEntry().getParententry(), true ); viewer.setSelection( new StructuredSelection( event.getModifiedEntry() ), true ); } else if ( event instanceof EntryRenamedEvent ) { EntryRenamedEvent ere = ( EntryRenamedEvent ) event; viewer.refresh( ere.getNewEntry().getParententry(), true ); viewer.setSelection( new StructuredSelection( ere.getNewEntry() ), true ); } else if ( event instanceof EntryMovedEvent ) { EntryMovedEvent eme = ( EntryMovedEvent ) event; viewer.refresh( eme.getOldEntry().getParententry(), true ); viewer.refresh( eme.getNewEntry().getParententry(), true ); viewer.setSelection( new StructuredSelection( eme.getNewEntry() ), true ); } else if ( event instanceof EntryDeletedEvent ) { EntryDeletedEvent ede = ( EntryDeletedEvent ) event; if ( ede.getModifiedEntry().getParententry() != null ) { viewer.refresh( ede.getModifiedEntry().getParententry(), true ); viewer.setSelection( new StructuredSelection( ede.getModifiedEntry().getParententry() ), true ); } else { viewer.refresh(); } } else if ( event instanceof BulkModificationEvent ) { viewer.refresh(); } else if ( event instanceof ChildrenInitializedEvent ) { // Getting the children of the entry to collapse their nodes // See DIRSTUDIO-481 (refreshing of attributes and children) Object[] children = ( ( BrowserContentProvider ) viewer.getContentProvider() ).getChildren( event .getModifiedEntry() ); for ( Object child : children ) { // We're only collapsing the node if it is expanded if ( viewer.getExpandedState( child ) ) { viewer.collapseToLevel( child, TreeViewer.ALL_LEVELS ); // There seem to be a bug (maybe it's a feature?!?) with nodes that were expanded // but does not have any child. // The call to 'viewer.collapseToLevel(...)' has no effect, the node stays expanded... if ( viewer.getExpandedState( child ) ) { // In that particular case, we need to remove the child from the tree viewer. // As it's a costly�operation we're only using this in that particular case, // and not as default option. viewer.remove( child ); } } } viewer.refresh( event.getModifiedEntry(), true ); } else if ( !( event.getModifiedEntry() instanceof DummyEntry ) ) { viewer.refresh( event.getModifiedEntry(), true ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/DropListener.java
/* * 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.views.browser; import org.eclipse.swt.dnd.DropTargetListener; /** * This class implements the {@link DropTargetListener} for the browser view. * * TODO: The code isn't working yet, just a test implementation. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class DropListener /* implements DropTargetListener, ModelModifier */ {/* * * private Shell shell; private Clipboard systemClipboard; private * InternalClipboard internalClipboard; * * * public DropListener(Shell shell, Clipboard systemClipboard, * InternalClipboard internalClipboard) { this.shell = shell; * this.systemClipboard = systemClipboard; this.internalClipboard = * internalClipboard; * } public void dispose() { this.shell = null; this.systemClipboard = * null; this.internalClipboard = null; * } * * private int dragOperation = DND.DROP_NONE; * * public void dragEnter(DropTargetEvent event) { * //System.out.println("dragEnter: " + event.detail); dragOperation = * event.detail; event.currentDataType = * BrowserTransfer.getInstance().getSupportedTypes()[0]; * this.check(event); } * * public void dragLeave(DropTargetEvent event) { * //System.out.println("dragLeave: " + event.detail); dragOperation = * DND.DROP_NONE; } * * public void dragOperationChanged(DropTargetEvent event) { * //System.out.println("dragOperationChanged: " + event.detail); * dragOperation = event.detail; this.check(event); } * * public void dragOver(DropTargetEvent event) { * //System.out.println("dragOver: " + event.item.getData()); * * this.check(event); * * //System.out.println("dragOver: " + event.detail); * * //System.out.println(); * //System.out.println(event.item.getClass().getName()); * //System.out.println(event.item.getData().getClass().getName()); * //System.out.println(event.currentDataType.type); } * * private void check(DropTargetEvent event) { if(event.item != null && * event.item.getData() != null) { if * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType)) { * if(event.item.getData() instanceof ISearch && * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) { * event.detail = dragOperation; return; } else if(event.item.getData() * instanceof BrowserCategory && * ((BrowserCategory)event.item.getData()).getType() == * BrowserCategory.TYPE_SEARCHES && * this.internalClipboard.getObjectToTransfer() instanceof ISearch[]) { * event.detail = dragOperation; return; } else if(event.item.getData() * instanceof IEntry && this.internalClipboard.getObjectToTransfer() * instanceof IEntry[]) { event.detail = dragOperation; * * IEntry[] entries = * (IEntry[])this.internalClipboard.getObjectToTransfer(); for(int i=0; * i<entries.length; i++) { if(entries[i].hasChildren()) { event.detail = * DND.DROP_COPY; return; } } * * return; } else if(event.item.getData() instanceof IEntry && * this.internalClipboard.getObjectToTransfer() instanceof * ISearchResult[]) { event.detail = dragOperation; * * ISearchResult[] srs = * (ISearchResult[])this.internalClipboard.getObjectToTransfer(); * for(int i=0; i<srs.length; i++) { * if(!srs[i].getEntry().hasChildren()) { event.detail = DND.DROP_COPY; * return; } } * * return; } else { event.detail = DND.DROP_NONE; } } else { * event.detail = DND.DROP_NONE; } } else { event.detail = * DND.DROP_NONE; } } * * public void drop(DropTargetEvent event) { * * //System.out.println("drop: " + event); * * try { * * if * (BrowserTransfer.getInstance().isSupportedType(event.currentDataType) && * event.data instanceof String && * this.internalClipboard.getClass().getName().equals(event.data)) { * * if(event.detail == DND.DROP_MOVE) { * this.internalClipboard.setOperationType(InternalClipboard.TYPE_MOVE_OPERATION); } * else if(event.detail == DND.DROP_COPY) { * this.internalClipboard.setOperationType(InternalClipboard.TYPE_DUPLICATE_OPERATION); } * else { * this.internalClipboard.setOperationType(InternalClipboard.TYPE_UNKNOWN); } * * * ISearch[] selectedSearches = new ISearch[0]; IEntry[] selectedEntries = * new IEntry[0]; ISearchResult[] selectedSearchResults = new * ISearchResult[0]; BrowserCategory[] selectedBrowserViewCategories = * new BrowserCategory[0]; * * if (event.item != null && event.item.getData() instanceof ISearch) { * selectedSearches = new ISearch[]{(ISearch) event.item.getData()}; } * else if (event.item != null && event.item.getData() instanceof * IEntry) { selectedEntries = new IEntry[]{(IEntry) * event.item.getData()}; } else if (event.item != null && * event.item.getData() instanceof ISearchResult) { * selectedSearchResults = new ISearchResult[]{(ISearchResult) * event.item.getData()}; } else if (event.item != null && * event.item.getData() instanceof BrowserCategory) { * selectedBrowserViewCategories = new * BrowserCategory[]{(BrowserCategory) event.item.getData()}; } * * this.runPaste(this.internalClipboard, selectedSearches, * selectedEntries, selectedSearchResults, * selectedBrowserViewCategories); * * * // // get search to handle and its search manager // ISearch[] * searches = (ISearch[]) event.data; // for(int i=0; i<searches.length; * i++) { // ISearch search = searches[i]; // IConnection connection = * search.getConnection(); // SearchManager dragSearchManager = * connection.getSearchManager(); // // // get position // //int * position = dragSearchManager.indexOf(search); // // // get drop * search manager and drop position, // // default is last and the drop * search // int dropPosition = -1; // SearchManager dropSearchManager = * null; // if (event.item != null && event.item.getData() instanceof * ISearch) { // ISearch dropSearch = (ISearch) event.item.getData(); // * dropSearchManager = dropSearch.getConnection().getSearchManager(); // * dropPosition = dropSearchManager.indexOf(dropSearch); // } else { // * dropSearchManager = this.selectedConnection.getSearchManager(); // * dropPosition = dropSearchManager.getSearchCount(); // } // if * (dropPosition == -1) { // dropSearchManager = dragSearchManager; // * dropPosition = dragSearchManager.getSearchCount(); // } // // // if * MOVE operation, first remove from old position // if (event.detail == * DND.DROP_MOVE && dragSearchManager == dropSearchManager) { // * dragSearchManager.removeSearch(search); // * if(dropPosition>dragSearchManager.getSearchCount()) { // * dropPosition--; // } // dropSearchManager.addSearch(dropPosition, * search); // event.detail = DND.DROP_NONE; // // } else if * (event.detail == DND.DROP_COPY || // (event.detail == DND.DROP_MOVE && * dragSearchManager != dropSearchManager)) { // ISearch newSearch = * (ISearch) search.clone(); // * newSearch.setConnection(dropSearchManager.getConnection()); // * dropSearchManager.addSearch(dropPosition, newSearch); // // } // else { // * event.detail = DND.DROP_NONE; // } // } } } catch (Exception e) { * event.detail = DND.DROP_NONE; e.printStackTrace(); } * } * * public void dropAccept(DropTargetEvent event) { * //System.out.println("dropAccept: " + event.detail + event.feedback); * event.currentDataType = * BrowserTransfer.getInstance().getSupportedTypes()[0]; check(event); } * * * * * public void runPaste(InternalClipboard internalClipboard, ISearch[] * selectedSearches, IEntry[] selectedEntries, ISearchResult[] * selectedSearchResults, BrowserCategory[] * selectedBrowserViewCategories) { Object objectToTransfer = * internalClipboard.getObjectToTransfer(); * * if (objectToTransfer != null && objectToTransfer instanceof ISearch[] && * selectedSearches.length > 0 && selectedEntries.length == 0 && * selectedSearchResults.length == 0) { ISearch[] searchesToTransfer = * (ISearch[]) objectToTransfer; if (searchesToTransfer != null && * searchesToTransfer.length > 0) { ISearch pasteSearch = * selectedSearches[selectedSearches.length-1]; IConnection connection = * pasteSearch.getConnection(); SearchManager searchManager = * connection.getSearchManager(); * * int index = searchManager.indexOf(pasteSearch); * * for(int i=0; i<searchesToTransfer.length; i++) { ISearch newSearch = * (ISearch) searchesToTransfer[i].clone(); * newSearch.setConnection(connection); * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_DUPLICATE_OPERATION) { * searchManager.addSearch(index+1+i, newSearch); } else * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_MOVE_OPERATION) { * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName()); * searchManager.addSearch(index+i, newSearch); * if(searchManager.indexOf(pasteSearch) < index) { index = * searchManager.indexOf(pasteSearch); } } } } } else if * (objectToTransfer != null && objectToTransfer instanceof ISearch[] && * selectedBrowserViewCategories.length == 1 && * selectedBrowserViewCategories[0].getType()==BrowserCategory.TYPE_SEARCHES) { * ISearch[] searchesToTransfer = (ISearch[]) objectToTransfer; if * (searchesToTransfer != null && searchesToTransfer.length > 0) { * IConnection connection = * selectedBrowserViewCategories[0].getParent(); SearchManager * searchManager = connection.getSearchManager(); for(int i=0; i<searchesToTransfer.length; * i++) { ISearch newSearch = (ISearch) searchesToTransfer[i].clone(); * newSearch.setConnection(connection); * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_DUPLICATE_OPERATION) { * searchManager.addSearch(searchManager.getSearchCount(), newSearch); } * else if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_MOVE_OPERATION) { * searchesToTransfer[i].getConnection().getSearchManager().removeSearch(searchesToTransfer[i].getName()); * searchManager.addSearch(searchManager.getSearchCount(), newSearch); } } } } * else if (objectToTransfer != null && objectToTransfer instanceof * IEntry[] && selectedEntries.length == 1 && selectedSearches.length == * 0 && selectedSearchResults.length == 0) { IEntry[] entries = * (IEntry[]) objectToTransfer; if (entries != null && entries.length > * 0) { if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_DUPLICATE_OPERATION) new * CopyEntriesRunnable(selectedEntries[0], entries).execute(); else * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0], * entries); } } else if (objectToTransfer != null && objectToTransfer * instanceof ISearchResult[] && selectedEntries.length == 1 && * selectedSearches.length == 0 && selectedSearchResults.length == 0) { * ISearchResult[] searchResults = (ISearchResult[]) objectToTransfer; * IEntry[] entries = new IEntry[searchResults.length]; for(int i=0; i<searchResults.length; * i++) { entries[i] = searchResults[i].getEntry(); } if (entries != * null && entries.length > 0) { if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_DUPLICATE_OPERATION) new * CopyEntriesRunnable(selectedEntries[0], entries).execute(); else * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_MOVE_OPERATION) this.move(selectedEntries[0], * entries); } } * * if(internalClipboard.getOperationType() == * InternalClipboard.TYPE_MOVE_OPERATION) { internalClipboard.clear(); } } * * private void move (final IEntry newParent, final IEntry[] * entriesToMove) { * * for(int i=0; i<entriesToMove.length; i++) { try { * entriesToMove[i].moveTo(newParent, this); } * catch(ModelModificationException mme) { * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(mme.getMessage(), * mme); } catch(Exception e) { * BrowserUIPlugin.getDefault().getExceptionHandler().handleException(e.getMessage(), * e); } } * * //EventRegistry.fireEntryUpdated(new * ChildrenInitializedEvent(newParent, newParent.getConnection()), * this); } */ }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/AbstractLinkWithEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/browser/AbstractLinkWithEditorAction.java
/* * 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.views.browser; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor; import org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditor; import org.eclipse.jface.action.Action; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.part.ViewPart; /** * This class implements common aspects for the Link With Editor Action. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractLinkWithEditorAction extends Action { /** The view */ private ViewPart viewPart; /** The listener listening on opening/closing editors */ private IPartListener partListener = new IPartListener() { @Override public void partOpened( IWorkbenchPart part ) { registerPropertyListener( part ); } @Override public void partClosed( IWorkbenchPart part ) { unregisterPropertyListener( part ); } @Override public void partDeactivated( IWorkbenchPart part ) { } @Override public void partBroughtToTop( IWorkbenchPart part ) { } @Override public void partActivated( IWorkbenchPart part ) { } }; /** The listener listening on input changes in editors */ private IPropertyListener propertyListener = new IPropertyListener() { @Override public void propertyChanged( Object source, int propId ) { if ( source instanceof IEditorPart && propId == BrowserUIConstants.INPUT_CHANGED ) { linkViewWithEditor( ( IEditorPart ) source ); } } }; private void registerListeners() { // register part listeners viewPart.getSite().getWorkbenchWindow().getPartService().addPartListener( partListener ); // register property listener IEditorReference[] editorReferences = viewPart.getSite().getPage().getEditorReferences(); for ( IEditorReference editorReference : editorReferences ) { IEditorPart editor = editorReference.getEditor( false ); registerPropertyListener( editor ); } } private void registerPropertyListener( IWorkbenchPart part ) { if ( part instanceof EntryEditor || part instanceof SearchResultEditor ) { part.addPropertyListener( propertyListener ); } } private void unregisterListeners() { // unregister part listener viewPart.getSite().getWorkbenchWindow().getPartService().removePartListener( partListener ); // unregister property listener IEditorReference[] editorReferences = viewPart.getSite().getPage().getEditorReferences(); for ( IEditorReference editorReference : editorReferences ) { IEditorPart editor = editorReference.getEditor( false ); unregisterPropertyListener( editor ); } } private void unregisterPropertyListener( IWorkbenchPart part ) { if ( part instanceof EntryEditor || part instanceof SearchResultEditor ) { part.removePropertyListener( propertyListener ); } } public AbstractLinkWithEditorAction( ViewPart viewPart, String message ) { super( message, AS_CHECK_BOX ); //$NON-NLS-1$ setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LINK_WITH_EDITOR ) ); setEnabled( true ); setChecked( BrowserUIPlugin.getDefault().getPreferenceStore() .getBoolean( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR ) ); this.viewPart = viewPart; } protected void init() { // Enable the listeners if ( isChecked() ) { registerListeners(); } } /** * {@inheritDoc} */ public void run() { setChecked( isChecked() ); BrowserUIPlugin.getDefault().getPreferenceStore() .setValue( BrowserUIConstants.PREFERENCE_BROWSER_LINK_WITH_EDITOR, isChecked() ); if ( isChecked() ) { // Enable the listener registerListeners(); // link IEditorPart activeEditor = viewPart.getSite().getWorkbenchWindow().getActivePage().getActiveEditor(); linkViewWithEditor( activeEditor ); } else { // Disable the listener unregisterListeners(); } } /** * Links the view with the right editor * * @param partRef the part */ protected abstract void linkViewWithEditor( IWorkbenchPart part ); /** * Disposes this action. */ public void dispose() { if ( partListener != null && propertyListener != null ) { unregisterListeners(); propertyListener = null; partListener = null; } viewPart = null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorUniversalListener.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetUniversalListener; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; /** * The EntryEditorUniversalListener manages all events for the entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorUniversalListener extends EntryEditorWidgetUniversalListener { /** The entry editor */ private EntryEditor entryEditor; /** Token used to activate and deactivate shortcuts in the editor */ private IContextActivation contextActivation; /** The part listener used to activate and deactivate the shortcuts */ private IPartListener2 partListener = new IPartListener2() { /** * {@inheritDoc} * * This implementation deactivates the shortcuts when the part is deactivated. */ public void partDeactivated( IWorkbenchPartReference partRef ) { if ( partRef.getPart( false ) == entryEditor && contextActivation != null ) { entryEditor.getActionGroup().deactivateGlobalActionHandlers(); IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter( IContextService.class ); contextService.deactivateContext( contextActivation ); contextActivation = null; } } /** * {@inheritDoc} * * This implementation activates the shortcuts when the part is activated. */ public void partActivated( IWorkbenchPartReference partRef ) { if ( partRef.getPart( false ) == entryEditor ) { IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter( IContextService.class ); contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_WINDOWS ); // org.eclipse.ui.contexts.dialogAndWindow // org.eclipse.ui.contexts.window // org.eclipse.ui.text_editor_context entryEditor.getActionGroup().activateGlobalActionHandlers(); } } /** * {@inheritDoc} */ public void partBroughtToTop( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partClosed( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partOpened( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partHidden( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partVisible( IWorkbenchPartReference partRef ) { } /** * {@inheritDoc} */ public void partInputChanged( IWorkbenchPartReference partRef ) { } }; /** * Creates a new instance of EntryEditorUniversalListener. * * @param entryEditor the entry editor */ public EntryEditorUniversalListener( EntryEditor entryEditor ) { super( entryEditor.getMainWidget().getViewer(), entryEditor.getConfiguration(), entryEditor.getActionGroup(), entryEditor.getActionGroup().getOpenDefaultEditorAction() ); this.entryEditor = entryEditor; // register listeners entryEditor.getSite().getPage().addPartListener( partListener ); } /** * {@inheritDoc} */ public void dispose() { if ( entryEditor != null ) { // deregister listeners entryEditor.getSite().getPage().removePartListener( partListener ); entryEditor = null; } super.dispose(); } /** * {@inheritDoc} * * This implementation updates the outline page when the entry is updated. */ public void entryUpdated( EntryModificationEvent event ) { if ( viewer == null || viewer.getTree() == null || viewer.getTree().isDisposed() || viewer.getInput() == null ) { return; } super.entryUpdated( event ); expandFoldedAttributes(); EntryEditorOutlinePage outlinePage = ( EntryEditorOutlinePage ) entryEditor .getAdapter( IContentOutlinePage.class ); if ( outlinePage != null ) { outlinePage.refresh(); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorNavigationLocation.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.entryeditors.EntryEditorExtension; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.entryeditors.EntryEditorManager; import org.apache.directory.studio.entryeditors.EntryEditorUtils; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.ui.IMemento; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.NavigationLocation; /** * This class is used to mark the entry editor input to the navigation history. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorNavigationLocation extends NavigationLocation { /** * Creates a new instance of EntryEditorNavigationLocation. * * @param editor the entry editor */ EntryEditorNavigationLocation( EntryEditor editor ) { super( editor ); } /** * {@inheritDoc} */ public String getText() { String text = EntryEditorUtils.getHistoryNavigationText( getEntryEditorInput() ); return text != null ? text : super.getText(); } /** * {@inheritDoc} */ public void saveState( IMemento memento ) { EntryEditorInput eei = getEntryEditorInput(); if ( eei != null ) { memento.putString( "EXTENSION", eei.getExtension().getId() ); //$NON-NLS-1$ if ( eei.getEntryInput() != null ) { IEntry entry = eei.getEntryInput(); memento.putString( "TYPE", "IEntry" ); //$NON-NLS-1$ //$NON-NLS-2$ memento.putString( "Dn", entry.getDn().getName() ); //$NON-NLS-1$ memento.putString( "CONNECTION", entry.getBrowserConnection().getConnection().getId() ); //$NON-NLS-1$ } else if ( eei.getSearchResultInput() != null ) { ISearchResult searchResult = eei.getSearchResultInput(); memento.putString( "TYPE", "ISearchResult" ); //$NON-NLS-1$ //$NON-NLS-2$ memento.putString( "Dn", searchResult.getDn().getName() ); //$NON-NLS-1$ memento.putString( "SEARCH", searchResult.getSearch().getName() ); //$NON-NLS-1$ memento.putString( "CONNECTION", searchResult.getSearch().getBrowserConnection().getConnection().getId() ); //$NON-NLS-1$ } else if ( eei.getBookmarkInput() != null ) { IBookmark bookmark = eei.getBookmarkInput(); memento.putString( "TYPE", "IBookmark" ); //$NON-NLS-1$ //$NON-NLS-2$ memento.putString( "BOOKMARK", bookmark.getName() ); //$NON-NLS-1$ memento.putString( "CONNECTION", bookmark.getBrowserConnection().getConnection().getId() ); //$NON-NLS-1$ } } } /** * {@inheritDoc} */ public void restoreState( IMemento memento ) { try { String type = memento.getString( "TYPE" ); //$NON-NLS-1$ String extensionId = memento.getString( "EXTENSION" ); //$NON-NLS-1$ EntryEditorManager entryEditorManager = BrowserUIPlugin.getDefault().getEntryEditorManager(); EntryEditorExtension entryEditorExtension = entryEditorManager.getEntryEditorExtension( extensionId ); if ( "IEntry".equals( type ) ) //$NON-NLS-1$ { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnectionById( memento.getString( "CONNECTION" ) ); //$NON-NLS-1$ Dn dn = new Dn( memento.getString( "Dn" ) ); //$NON-NLS-1$ IEntry entry = connection.getEntryFromCache( dn ); super.setInput( new EntryEditorInput( entry, entryEditorExtension ) ); } else if ( "ISearchResult".equals( type ) ) //$NON-NLS-1$ { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnectionById( memento.getString( "CONNECTION" ) ); //$NON-NLS-1$ ISearch search = connection.getSearchManager().getSearch( memento.getString( "SEARCH" ) ); //$NON-NLS-1$ ISearchResult[] searchResults = search.getSearchResults(); Dn dn = new Dn( memento.getString( "Dn" ) ); //$NON-NLS-1$ for ( int i = 0; i < searchResults.length; i++ ) { if ( dn.equals( searchResults[i].getDn() ) ) { super.setInput( new EntryEditorInput( searchResults[i], entryEditorExtension ) ); break; } } } else if ( "IBookmark".equals( type ) ) //$NON-NLS-1$ { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnectionById( memento.getString( "CONNECTION" ) ); //$NON-NLS-1$ IBookmark bookmark = connection.getBookmarkManager().getBookmark( memento.getString( "BOOKMARK" ) ); //$NON-NLS-1$ super.setInput( new EntryEditorInput( bookmark, entryEditorExtension ) ); } } catch ( LdapInvalidDnException e ) { e.printStackTrace(); } } /** * {@inheritDoc} */ public void restoreLocation() { } /** * {@inheritDoc} */ public boolean mergeInto( INavigationLocation currentLocation ) { if ( currentLocation == null ) { return false; } if ( getClass() != currentLocation.getClass() ) { return false; } EntryEditorNavigationLocation location = ( EntryEditorNavigationLocation ) currentLocation; Object other = location.getEntryEditorInput().getInput(); Object entry = getEntryEditorInput().getInput(); if ( other == null && entry == null ) { return true; } else if ( other == null || entry == null ) { return false; } else { return entry.equals( other ); } } /** * {@inheritDoc} */ public void update() { } /** * Gets the input. * * @return the input */ private EntryEditorInput getEntryEditorInput() { Object editorInput = getInput(); if ( editorInput instanceof EntryEditorInput ) { EntryEditorInput entryEditorInput = ( EntryEditorInput ) editorInput; return entryEditorInput; } return null; } /** * {@inheritDoc} */ public String toString() { return "" + getEntryEditorInput().getInput(); //$NON-NLS-1$ } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/OpenEntryEditorPreferencePageAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/OpenEntryEditorPreferencePageAction.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.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; /** * This action opens the preference page of the entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEntryEditorPreferencePageAction extends Action { /** * Creates a new instance of OpenEntryEditorPreferencePageAction. */ public OpenEntryEditorPreferencePageAction() { setText( Messages.getString( "OpenEntryEditorPreferencePageAction.Preferences" ) ); //$NON-NLS-1$ setToolTipText( Messages.getString( "OpenEntryEditorPreferencePageAction.PreferencesToolTip" ) ); //$NON-NLS-1$ setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String eePageId = BrowserUIConstants.PREFERENCEPAGEID_ENTRYEDITOR; String attPageId = BrowserUIConstants.PREFERENCEPAGEID_ATTRIBUTES; PreferencesUtil.createPreferenceDialogOn( shell, eePageId, new String[] { eePageId, attPageId }, null ).open(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LocateSearchResultOrBookmarkAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LocateSearchResultOrBookmarkAction.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.resource.ImageDescriptor; /** * This action is used to locate the search result or bookmark in the LDAP Browser view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LocateSearchResultOrBookmarkAction extends LocateEntryInLdapBrowserAction { /** * Creates a new instance of LocateSearchResultOrBookmarkAction. * * @param entryEditor the entry editor * @param showInMenuManager the menu manager */ public LocateSearchResultOrBookmarkAction( EntryEditor entryEditor, EntryEditorShowInMenuManager showInMenuManager ) { super( entryEditor, showInMenuManager ); } /** * {@inheritDoc} */ public void run() { Object input = showInMenuManager.getInput(); if ( input != null ) { select( input ); } } /** * {@inheritDoc} */ public String getText() { Object input = showInMenuManager.getInput(); if ( input != null ) { if ( input instanceof ISearchResult ) { return Messages.getString( "LocateSearchResultOrBookmarkAction.Searches" ); //$NON-NLS-1$ } else if ( input instanceof IBookmark ) { return Messages.getString( "LocateSearchResultOrBookmarkAction.Bookmarks" ); //$NON-NLS-1$ } } return super.getText(); } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { Object input = showInMenuManager.getInput(); if ( input != null ) { if ( input instanceof ISearchResult ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_SEARCHRESULT_IN_DIT ); } else if ( input instanceof IBookmark ) { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_BOOKMARK_IN_DIT ); } } return super.getImageDescriptor(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/ToggleAutosaveAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/ToggleAutosaveAction.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.jface.action.Action; /** * This action is used to toggle the "auto-save" preference. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ToggleAutosaveAction extends Action { private EntryEditor entryEditor; /** * Creates a new instance of ToggleAutosaveAction. */ public ToggleAutosaveAction( EntryEditor entryEditor ) { super( Messages.getString( "ToggleAutosaveAction.Autosave" ), AS_CHECK_BOX ); //$NON-NLS-1$ setToolTipText( getText() ); setEnabled( true ); this.entryEditor = entryEditor; } @Override public void run() { BrowserCommonActivator.getDefault().getPreferenceStore().setValue( getConstant(), super.isChecked() ); } private String getConstant() { boolean multiTab = entryEditor.getEntryEditorInput().getExtension().isMultiWindow(); if ( multiTab ) { return BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_MULTI_TAB; } else { return BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_SINGLE_TAB; } } public void updateSetChecked() { setChecked( BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( getConstant() ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditorDocumentProvider.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditorDocumentProvider.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import java.util.List; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry; import org.apache.directory.studio.ldapbrowser.core.utils.AttributeComparator; import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification; import org.apache.directory.studio.ldapbrowser.core.utils.ModelConverter; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldifeditor.editor.LdifDocumentProvider; import org.apache.directory.studio.ldifparser.model.container.LdifContainer; import org.apache.directory.studio.ldifparser.model.container.LdifContentRecord; import org.apache.directory.studio.ldifparser.model.container.LdifInvalidContainer; import org.apache.directory.studio.ldifparser.model.container.LdifRecord; import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.osgi.util.NLS; /** * The document provider for the LDIF entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LdifEntryEditorDocumentProvider extends LdifDocumentProvider { private EntryEditorInput input; private boolean inSetContent = false; private LdifEntryEditor editor; public LdifEntryEditorDocumentProvider( LdifEntryEditor editor ) { this.editor = editor; } @Override protected void doSaveDocument( IProgressMonitor monitor, Object element, IDocument document, boolean overwrite ) throws CoreException { LdifRecord[] records = getLdifModel().getRecords(); if ( records.length != 1 || !( records[0] instanceof LdifContentRecord ) ) { throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, Messages .getString( "LdifEntryEditorDocumentProvider.InvalidRecordType" ) ) ); //$NON-NLS-1$ } if ( !records[0].isValid() ) { throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, NLS.bind( Messages .getString( "LdifEntryEditorDocumentProvider.InvalidLdif" ), records[0].getInvalidString() ) ) ); //$NON-NLS-1$ } for ( LdifContainer ldifContainer : getLdifModel().getContainers() ) { if ( ldifContainer instanceof LdifInvalidContainer ) { LdifInvalidContainer cont = ( LdifInvalidContainer ) ldifContainer; throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, NLS.bind( Messages .getString( "LdifEntryEditorDocumentProvider.InvalidLdif" ), cont.getInvalidString() ) ) ); //$NON-NLS-1$ } } EntryEditorInput input = getEntryEditorInput( element ); try { Dn newDn = new Dn( records[0].getDnLine().getValueAsString() ); if ( !newDn.equals( input.getResolvedEntry().getDn() ) ) { throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, NLS.bind( Messages .getString( "LdifEntryEditorDocumentProvider.ModDnNotSupported" ), records[0].getInvalidString() ) ) ); //$NON-NLS-1$ } } catch ( LdapInvalidDnException e ) { throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, Messages .getString( "LdifEntryEditorDocumentProvider.InvalidDN" ) ) ); //$NON-NLS-1$ } IStatus status = input.saveSharedWorkingCopy( false, editor ); if ( status != null && !status.isOK() ) { BrowserUIPlugin.getDefault().getLog().log( status ); throw new CoreException( status ); } } @Override public void documentChanged( DocumentEvent event ) { super.documentChanged( event ); // the document change was caused by the model update // no need to update the model again, don't fire more events if ( inSetContent ) { return; } // only continue if the LDIF model is valid LdifRecord[] records = getLdifModel().getRecords(); if ( records.length != 1 || !( records[0] instanceof LdifContentRecord ) || !records[0].isValid() || !records[0].getDnLine().isValid() ) { return; } for ( LdifContainer ldifContainer : getLdifModel().getContainers() ) { if ( ldifContainer instanceof LdifInvalidContainer ) { return; } } // update shared working copy try { LdifContentRecord modifiedRecord = ( LdifContentRecord ) records[0]; IBrowserConnection browserConnection = input.getSharedWorkingCopy( editor ).getBrowserConnection(); DummyEntry modifiedEntry = ModelConverter.ldifContentRecordToEntry( modifiedRecord, browserConnection ); ( ( DummyEntry ) input.getSharedWorkingCopy( editor ) ).setDn( modifiedEntry.getDn() ); new CompoundModification().replaceAttributes( modifiedEntry, input.getSharedWorkingCopy( editor ), this ); } catch ( LdapInvalidDnException e ) { throw new RuntimeException( e ); } } @Override protected void doResetDocument( Object element, IProgressMonitor monitor ) throws CoreException { // reset working copy first if ( input != null ) { input.resetSharedWorkingCopy( editor ); } super.doResetDocument( element, monitor ); } public void workingCopyModified( EntryEditorInput input, Object source ) { // the model change was caused by the document change // no need to set the content again, don't fire more events if ( source == this ) { return; } IDocument document = getDocument( input ); if ( document != null ) { try { inSetContent = true; IEntry sharedWorkingCopy = input.getSharedWorkingCopy( editor ); setDocumentInput( document, sharedWorkingCopy ); // reset dirty state if ( !input.isSharedWorkingCopyDirty( editor ) ) { super.doResetDocument( input, null ); } } catch ( CoreException e ) { throw new RuntimeException( e ); } finally { inSetContent = false; } } } private void setDocumentInput( IDocument document, IEntry entry ) { // sort attribute-value lines List<IValue> sortedValues = AttributeComparator.toSortedValues( entry ); LdifContentRecord newRecord = LdifContentRecord.create( entry.getDn().getName() ); for ( IValue value : sortedValues ) { newRecord.addAttrVal( ModelConverter.valueToLdifAttrValLine( value ) ); } newRecord.finish( LdifSepLine.create() ); // format String newContent = newRecord.toFormattedString( Utils.getLdifFormatParameters() ); // set content document.set( newContent ); } public IDocument getDocument( Object element ) { if ( element instanceof EntryEditorInput ) { EntryEditorInput input = ( EntryEditorInput ) element; if ( input.getExtension() == null ) { // this is a performance optimization return null; } } return super.getDocument( element ); } @Override protected IDocument createDocument( Object element ) throws CoreException { input = getEntryEditorInput( element ); IEntry entry = getEntryEditorInput( element ).getSharedWorkingCopy( editor ); IDocument document = new Document(); if ( entry != null ) { setDocumentInput( document, entry ); } setupDocument( document ); return document; } private EntryEditorInput getEntryEditorInput( Object element ) throws CoreException { if ( element instanceof EntryEditorInput ) { EntryEditorInput input = ( EntryEditorInput ) element; return input; } else { throw new CoreException( new Status( IStatus.ERROR, BrowserUIConstants.PLUGIN_ID, "Expected EntryEditorInput, was " + element ) ); //$NON-NLS-1$ } } @Override public boolean isModifiable( Object element ) { if ( element instanceof EntryEditorInput ) { EntryEditorInput editorInput = ( EntryEditorInput ) element; IEntry entry = editorInput.getSharedWorkingCopy( editor ); return ( entry != null ); } return false; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorConfiguration.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetConfiguration; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.viewers.TreeViewer; /** * The EntryEditorConfiguration contains the content provider, * label provider, sorter, filter, the context menu manager and the * preferences for the entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorConfiguration extends EntryEditorWidgetConfiguration { /** The entry editor */ private EntryEditor entryEditor; /** * Creates a new instance of EntryEditorConfiguration. */ public EntryEditorConfiguration( EntryEditor entryEditor ) { this.entryEditor = entryEditor; } /** * Gets the value editor manager. * * @param viewer the viewer * * @return the value editor manager */ public ValueEditorManager getValueEditorManager( TreeViewer viewer ) { if ( valueEditorManager == null ) { valueEditorManager = new ValueEditorManager( viewer.getTree(), true, entryEditor.isAutoSave() ); } return valueEditorManager; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorActionGroup.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.connection.ui.actions.CollapseAllAction; import org.apache.directory.studio.connection.ui.actions.ExpandAllAction; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAllValuesAction; import org.apache.directory.studio.ldapbrowser.common.actions.FetchOperationalAttributesAction; import org.apache.directory.studio.ldapbrowser.common.actions.NewAttributeAction; import org.apache.directory.studio.ldapbrowser.common.actions.RefreshAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.EntryEditorActionProxy; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EditAttributeDescriptionAction; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.OpenDefaultEditorAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyAttributeDescriptionAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyDnAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopySearchFilterAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyUrlAction; import org.apache.directory.studio.ldapbrowser.ui.actions.CopyValueAction; import org.apache.directory.studio.ldapbrowser.ui.actions.EntryEditorPropertiesAction; import org.apache.directory.studio.ldapbrowser.ui.actions.LocateDnInDitAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewBatchOperationAction; import org.apache.directory.studio.ldapbrowser.ui.actions.NewSearchAction; import org.apache.directory.studio.ldapbrowser.ui.actions.OpenSchemaBrowserAction; import org.apache.directory.studio.utils.ActionUtils; import org.apache.directory.studio.valueeditors.ValueEditorManager; 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.viewers.TreeViewer; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.actions.ActionFactory; /** * The EntryEditorWidgetActionGroup manages all actions of the entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorActionGroup extends EntryEditorWidgetActionGroup { /** The toggle auto save action */ private ToggleAutosaveAction toggleAutosaveAction; /** The open entry value editor action. */ private EntryEditorActionProxy openEntryValueEditorActionProxy; /** The open entry editor preference page. */ private OpenEntryEditorPreferencePageAction openEntryEditorPreferencePage; /** The collapse all action. */ private CollapseAllAction collapseAllAction; /** The expand all action. */ private ExpandAllAction expandAllAction; /** The 'Show In' menu manager */ private EntryEditorShowInMenuManager showInMenuManager; /** The Constant editAttributeDescriptionAction. */ private static final String editAttributeDescriptionAction = "editAttributeDescriptionAction"; //$NON-NLS-1$ /** The Constant refreshAttributesAction. */ private static final String refreshAttributesAction = "refreshAttributesAction"; //$NON-NLS-1$ /** The Constant newAttributeAction. */ private static final String newAttributeAction = "newAttributeAction"; //$NON-NLS-1$ /** The Constant newSearchAction. */ private static final String newSearchAction = "newSearchDialogAction"; //$NON-NLS-1$ /** The Constant newBatchOperationAction. */ private static final String newBatchOperationAction = "newBatchOperationAction"; //$NON-NLS-1$ /** The Constant copyDnAction. */ private static final String copyDnAction = "copyDnAction"; //$NON-NLS-1$ /** The Constant copyUrlAction. */ private static final String copyUrlAction = "copyUrlAction"; //$NON-NLS-1$ /** The Constant copyAttriuteDescriptionAction. */ private static final String copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction"; //$NON-NLS-1$ /** The Constant copyDisplayValueAction. */ private static final String copyDisplayValueAction = "copyDisplayValueAction"; //$NON-NLS-1$ /** The Constant copyValueUtf8Action. */ private static final String copyValueUtf8Action = "copyValueUtf8Action"; //$NON-NLS-1$ /** The Constant copyValueBase64Action. */ private static final String copyValueBase64Action = "copyValueBase64Action"; //$NON-NLS-1$ /** The Constant copyValueHexAction. */ private static final String copyValueHexAction = "copyValueHexAction"; //$NON-NLS-1$ /** The Constant copyValueAsLdifAction. */ private static final String copyValueAsLdifAction = "copyValueAsLdifAction"; //$NON-NLS-1$ /** The Constant copySearchFilterAction. */ private static final String copySearchFilterAction = "copySearchFilterAction"; //$NON-NLS-1$ /** The Constant copyNotSearchFilterAction. */ private static final String copyNotSearchFilterAction = "copyNotSearchFilterAction"; //$NON-NLS-1$ /** The Constant copyAndSearchFilterAction. */ private static final String copyAndSearchFilterAction = "copyAndSearchFilterAction"; //$NON-NLS-1$ /** The Constant copyOrSearchFilterAction. */ private static final String copyOrSearchFilterAction = "copyOrSearchFilterAction"; //$NON-NLS-1$ /** The Constant deleteAllValuesAction. */ private static final String deleteAllValuesAction = "deleteAllValuesAction"; //$NON-NLS-1$ /** The Constant locateDnInDitAction. */ private static final String locateDnInDitAction = "locateDnInDitAction"; //$NON-NLS-1$ /** The Constant showOcdAction. */ private static final String showOcdAction = "showOcdAction"; //$NON-NLS-1$ /** The Constant showAtdAction. */ private static final String showAtdAction = "showAtdAction"; //$NON-NLS-1$ /** The Constant showEqualityMrdAction. */ private static final String showEqualityMrdAction = "showEqualityMrdAction"; //$NON-NLS-1$ /** The Constant showSubstringMrdAction. */ private static final String showSubstringMrdAction = "showSubstringMrdAction"; //$NON-NLS-1$ /** The Constant showOrderingMrdAction. */ private static final String showOrderingMrdAction = "showOrderingMrdAction"; //$NON-NLS-1$ /** The Constant showLsdAction. */ private static final String showLsdAction = "showLsdAction"; //$NON-NLS-1$ /** The Constant fetchOperationalAttributesAction. */ private static final String fetchOperationalAttributesAction = "fetchOperationalAttributesAction"; //$NON-NLS-1$ /** * Creates a new instance of EntryEditorActionGroup. * * @param entryEditor the entry editor */ public EntryEditorActionGroup( EntryEditor entryEditor ) { super( entryEditor.getMainWidget(), entryEditor.getConfiguration() ); TreeViewer viewer = entryEditor.getMainWidget().getViewer(); ValueEditorManager valueEditorManager = entryEditor.getConfiguration().getValueEditorManager( viewer ); // create OpenDefaultEditorAction with enabled rename action flag openDefaultValueEditorActionProxy.dispose(); openDefaultValueEditorActionProxy = new EntryEditorActionProxy( viewer, new OpenDefaultEditorAction( viewer, openBestValueEditorActionProxy ) ); openEntryValueEditorActionProxy = new EntryEditorActionProxy( viewer, new OpenEntryEditorAction( viewer, valueEditorManager, valueEditorManager.getEntryValueEditor(), this ) ); toggleAutosaveAction = new ToggleAutosaveAction( entryEditor ); openEntryEditorPreferencePage = new OpenEntryEditorPreferencePageAction(); collapseAllAction = new CollapseAllAction( viewer ); expandAllAction = new ExpandAllAction( viewer ); showInMenuManager = new EntryEditorShowInMenuManager( entryEditor ); entryEditorActionMap.put( editAttributeDescriptionAction, new EntryEditorActionProxy( viewer, new EditAttributeDescriptionAction( viewer ) ) ); entryEditorActionMap.put( refreshAttributesAction, new EntryEditorActionProxy( viewer, new RefreshAction() ) ); entryEditorActionMap.put( newAttributeAction, new EntryEditorActionProxy( viewer, new NewAttributeAction() ) ); entryEditorActionMap.put( newSearchAction, new EntryEditorActionProxy( viewer, new NewSearchAction() ) ); entryEditorActionMap.put( newBatchOperationAction, new EntryEditorActionProxy( viewer, new NewBatchOperationAction() ) ); entryEditorActionMap.put( locateDnInDitAction, new EntryEditorActionProxy( viewer, new LocateDnInDitAction() ) ); entryEditorActionMap.put( showOcdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) ); entryEditorActionMap.put( showAtdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) ); entryEditorActionMap.put( showEqualityMrdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) ); entryEditorActionMap.put( showSubstringMrdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) ); entryEditorActionMap.put( showOrderingMrdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) ); entryEditorActionMap.put( showLsdAction, new EntryEditorActionProxy( viewer, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SYNTAX ) ) ); entryEditorActionMap.put( copyDnAction, new EntryEditorActionProxy( viewer, new CopyDnAction() ) ); entryEditorActionMap.put( copyUrlAction, new EntryEditorActionProxy( viewer, new CopyUrlAction() ) ); entryEditorActionMap.put( copyAttriuteDescriptionAction, new EntryEditorActionProxy( viewer, new CopyAttributeDescriptionAction() ) ); entryEditorActionMap.put( copyDisplayValueAction, new EntryEditorActionProxy( viewer, new CopyValueAction( CopyValueAction.Mode.DISPLAY, valueEditorManager ) ) ); entryEditorActionMap.put( copyValueUtf8Action, new EntryEditorActionProxy( viewer, new CopyValueAction( CopyValueAction.Mode.UTF8, valueEditorManager ) ) ); entryEditorActionMap.put( copyValueBase64Action, new EntryEditorActionProxy( viewer, new CopyValueAction( CopyValueAction.Mode.BASE64, valueEditorManager ) ) ); entryEditorActionMap.put( copyValueHexAction, new EntryEditorActionProxy( viewer, new CopyValueAction( CopyValueAction.Mode.HEX, valueEditorManager ) ) ); entryEditorActionMap.put( copyValueAsLdifAction, new EntryEditorActionProxy( viewer, new CopyValueAction( CopyValueAction.Mode.LDIF, valueEditorManager ) ) ); entryEditorActionMap.put( copySearchFilterAction, new EntryEditorActionProxy( viewer, new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) ); entryEditorActionMap.put( copyNotSearchFilterAction, new EntryEditorActionProxy( viewer, new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) ); entryEditorActionMap.put( copyAndSearchFilterAction, new EntryEditorActionProxy( viewer, new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) ); entryEditorActionMap.put( copyOrSearchFilterAction, new EntryEditorActionProxy( viewer, new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) ); entryEditorActionMap.put( deleteAllValuesAction, new EntryEditorActionProxy( viewer, new DeleteAllValuesAction() ) ); entryEditorActionMap.put( fetchOperationalAttributesAction, new EntryEditorActionProxy( viewer, new FetchOperationalAttributesAction() ) ); entryEditorActionMap.put( PROPERTY_DIALOG_ACTION, new EntryEditorActionProxy( viewer, new EntryEditorPropertiesAction( entryEditor ) ) ); } /** * {@inheritDoc} */ public void dispose() { if ( toggleAutosaveAction != null ) { deactivateGlobalActionHandlers(); openEntryValueEditorActionProxy.dispose(); openEntryValueEditorActionProxy = null; openEntryEditorPreferencePage = null; toggleAutosaveAction = null; expandAllAction.dispose(); expandAllAction = null; collapseAllAction.dispose(); collapseAllAction = null; } super.dispose(); } /** * {@inheritDoc} */ public void fillToolBar( IToolBarManager toolBarManager ) { toolBarManager.add( new Separator() ); toolBarManager.add( entryEditorActionMap.get( NEW_VALUE_ACTION ) ); toolBarManager.add( entryEditorActionMap.get( newAttributeAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( entryEditorActionMap.get( DELETE_ACTION ) ); toolBarManager.add( entryEditorActionMap.get( deleteAllValuesAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( entryEditorActionMap.get( refreshAttributesAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( expandAllAction ); toolBarManager.add( collapseAllAction ); toolBarManager.add( new Separator() ); toolBarManager.add( showQuickFilterAction ); toolBarManager.update( true ); } /** * {@inheritDoc} */ public void fillMenu( IMenuManager menuManager ) { menuManager.add( openSortDialogAction ); menuManager.add( new Separator() ); menuManager.add( showDecoratedValuesAction ); menuManager.add( new Separator() ); menuManager.add( toggleAutosaveAction ); menuManager.add( new Separator() ); menuManager.add( openEntryEditorPreferencePage ); menuManager.addMenuListener( new IMenuListener() { public void menuAboutToShow( IMenuManager manager ) { showDecoratedValuesAction.setChecked( !BrowserCommonActivator.getDefault().getPreferenceStore() .getBoolean( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) ); toggleAutosaveAction.updateSetChecked(); } } ); menuManager.update( true ); } /** * {@inheritDoc} */ protected void contextMenuAboutToShow( IMenuManager menuManager ) { // new menuManager.add( entryEditorActionMap.get( newAttributeAction ) ); menuManager.add( entryEditorActionMap.get( NEW_VALUE_ACTION ) ); menuManager.add( entryEditorActionMap.get( newSearchAction ) ); menuManager.add( entryEditorActionMap.get( newBatchOperationAction ) ); menuManager.add( new Separator() ); // navigation menuManager.add( entryEditorActionMap.get( locateDnInDitAction ) ); MenuManager schemaMenuManager = new MenuManager( Messages .getString( "EntryEditorActionGroup.OpenSchemaBrowser" ) ); //$NON-NLS-1$ schemaMenuManager.add( entryEditorActionMap.get( showOcdAction ) ); schemaMenuManager.add( entryEditorActionMap.get( showAtdAction ) ); schemaMenuManager.add( entryEditorActionMap.get( showEqualityMrdAction ) ); schemaMenuManager.add( entryEditorActionMap.get( showSubstringMrdAction ) ); schemaMenuManager.add( entryEditorActionMap.get( showOrderingMrdAction ) ); schemaMenuManager.add( entryEditorActionMap.get( showLsdAction ) ); menuManager.add( schemaMenuManager ); showInMenuManager.createMenuManager( menuManager ); menuManager.add( new Separator() ); // copy, paste, delete menuManager.add( entryEditorActionMap.get( COPY_ACTION ) ); menuManager.add( entryEditorActionMap.get( PASTE_ACTION ) ); menuManager.add( entryEditorActionMap.get( DELETE_ACTION ) ); menuManager.add( entryEditorActionMap.get( SELECT_ALL_ACTION ) ); MenuManager advancedMenuManager = new MenuManager( Messages.getString( "EntryEditorActionGroup.Advanced" ) ); //$NON-NLS-1$ advancedMenuManager.add( entryEditorActionMap.get( copyDnAction ) ); advancedMenuManager.add( entryEditorActionMap.get( copyUrlAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( entryEditorActionMap.get( copyAttriuteDescriptionAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( entryEditorActionMap.get( copyDisplayValueAction ) ); advancedMenuManager.add( entryEditorActionMap.get( copyValueUtf8Action ) ); advancedMenuManager.add( entryEditorActionMap.get( copyValueBase64Action ) ); advancedMenuManager.add( entryEditorActionMap.get( copyValueHexAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( entryEditorActionMap.get( copyValueAsLdifAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( entryEditorActionMap.get( copySearchFilterAction ) ); advancedMenuManager.add( entryEditorActionMap.get( copyNotSearchFilterAction ) ); advancedMenuManager.add( entryEditorActionMap.get( copyAndSearchFilterAction ) ); advancedMenuManager.add( entryEditorActionMap.get( copyOrSearchFilterAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( entryEditorActionMap.get( deleteAllValuesAction ) ); menuManager.add( advancedMenuManager ); menuManager.add( new Separator() ); // edit menuManager.add( entryEditorActionMap.get( editAttributeDescriptionAction ) ); super.addEditMenu( menuManager ); menuManager.add( openEntryValueEditorActionProxy ); menuManager.add( new Separator() ); // refresh menuManager.add( entryEditorActionMap.get( refreshAttributesAction ) ); if ( entryEditorActionMap.get( fetchOperationalAttributesAction ).isEnabled() ) { menuManager.add( entryEditorActionMap.get( fetchOperationalAttributesAction ) ); } menuManager.add( new Separator() ); // additions menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); // properties menuManager.add( entryEditorActionMap.get( PROPERTY_DIALOG_ACTION ) ); } /** * {@inheritDoc} */ public void activateGlobalActionHandlers() { if ( actionBars != null ) { actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), entryEditorActionMap .get( refreshAttributesAction ) ); } super.activateGlobalActionHandlers(); IAction naa = entryEditorActionMap.get( newAttributeAction ); ActionUtils.activateActionHandler( naa ); IAction lid = entryEditorActionMap.get( locateDnInDitAction ); ActionUtils.activateActionHandler( lid ); IAction eada = entryEditorActionMap.get( editAttributeDescriptionAction ); ActionUtils.activateActionHandler( eada ); ActionUtils.activateActionHandler( openEntryValueEditorActionProxy ); } /** * {@inheritDoc} */ public void deactivateGlobalActionHandlers() { if ( actionBars != null ) { actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), null ); } super.deactivateGlobalActionHandlers(); IAction naa = entryEditorActionMap.get( newAttributeAction ); ActionUtils.deactivateActionHandler( naa ); IAction lid = entryEditorActionMap.get( locateDnInDitAction ); ActionUtils.deactivateActionHandler( lid ); IAction eada = entryEditorActionMap.get( editAttributeDescriptionAction ); ActionUtils.deactivateActionHandler( eada ); ActionUtils.deactivateActionHandler( openEntryValueEditorActionProxy ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorOutlinePage.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserLabelProvider; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.apache.directory.studio.ldifeditor.LdifEditorActivator; import org.apache.directory.studio.ldifeditor.LdifEditorConstants; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; /** * This class implements the Outline Page for the Entry Editor. * It used to display LDAP entries. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorOutlinePage extends ContentOutlinePage { /** The editor it is attached to */ private EntryEditor entryEditor; /** This listener updates the viewer if an property (e.g. is operational attributes visible) has been changed */ protected IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { public void propertyChange( PropertyChangeEvent event ) { refresh(); } }; private Composite noOutlineComposite; private Composite composite; private Composite fakeComposite; /** * Creates a new instance of EntryEditorOutlinePage. * * @param entryEditor * the editor the Outline page is attached to */ public EntryEditorOutlinePage( EntryEditor entryEditor ) { this.entryEditor = entryEditor; BrowserCommonActivator.getDefault().getPreferenceStore().addPropertyChangeListener( propertyChangeListener ); } public Control getControl() { return composite; } /** * {@inheritDoc} */ public void createControl( Composite parent ) { // Creating the composite and fake composite this.composite = new Composite( parent, SWT.NONE ); composite.setLayout( new FillLayout() ); this.fakeComposite = new Composite( parent, SWT.NONE ); // Creating the No Outline composite noOutlineComposite = new Composite( composite, SWT.NONE ); noOutlineComposite.setLayout( new FillLayout() ); Label label = new Label( noOutlineComposite, SWT.WRAP ); label.setText( Messages.getString( "EntryEditorOutlinePage.NoOutline" ) ); //$NON-NLS-1$ // Creating the Outline tree viewer super.createControl( parent ); final TreeViewer treeViewer = getTreeViewer(); treeViewer.setLabelProvider( new EntryEditorOutlineLabelProvider() ); treeViewer.setContentProvider( new EntryEditorOutlineContentProvider() ); treeViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { if ( !event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection ) { if ( getEntryEditorWidgetTreeViewerInput() != null ) { List<Object> selectionList = new ArrayList<Object>(); for ( Object element : ( ( IStructuredSelection ) event.getSelection() ).toArray() ) { if ( element instanceof IValue ) { // select the value IValue value = ( IValue ) element; selectionList.add( value ); } else if ( element instanceof IAttribute ) { // select attribute and all values IAttribute attribute = ( IAttribute ) element; selectionList.add( attribute ); selectionList.addAll( Arrays.asList( attribute.getValues() ) ); } else if ( element instanceof EntryWrapper ) { // select all attributes and values IEntry entry = ( ( EntryWrapper ) element ).entry; for ( IAttribute attribute : entry.getAttributes() ) { selectionList.add( attribute ); selectionList.addAll( Arrays.asList( attribute.getValues() ) ); } } } IStructuredSelection selection = new StructuredSelection( selectionList ); TreeViewer entryEditorWidgetTreeViewer = getEntryEditorWidgetTreeViewer(); if ( entryEditorWidgetTreeViewer != null ) { entryEditorWidgetTreeViewer.setSelection( selection ); } } } } } ); treeViewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick( DoubleClickEvent event ) { if ( event.getSelection() instanceof IStructuredSelection ) { Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement(); if ( treeViewer.getExpandedState( obj ) ) { treeViewer.collapseToLevel( obj, 1 ); } else if ( ( ( ITreeContentProvider ) treeViewer.getContentProvider() ).hasChildren( obj ) ) { treeViewer.expandToLevel( obj, 1 ); } } } } ); this.refresh(); } /** * Refreshes this viewer starting with the given element. * * @param element * the element */ public void refresh( Object element ) { final TreeViewer treeViewer = getTreeViewer(); if ( treeViewer != null && treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() ) { TreeViewer entryEditorWidgetTreeViewer = getEntryEditorWidgetTreeViewer(); if ( entryEditorWidgetTreeViewer != null ) { treeViewer.setFilters( entryEditorWidgetTreeViewer.getFilters() ); } treeViewer.refresh( element ); } } /** * Refreshes this viewer completely with information freshly obtained from this viewer's model. */ public void refresh() { TreeViewer treeViewer = getTreeViewer(); if ( treeViewer != null && composite != null ) { if ( hasAnOutline() ) { Control treeViewerControl = treeViewer.getControl(); if ( ( treeViewerControl != null ) && ( !treeViewerControl.isDisposed() ) ) { treeViewerControl.setParent( composite ); } noOutlineComposite.setParent( fakeComposite ); } else { Control treeViewerControl = treeViewer.getControl(); if ( ( treeViewerControl != null ) && ( !treeViewerControl.isDisposed() ) ) { treeViewerControl.setParent( fakeComposite ); } noOutlineComposite.setParent( composite ); } composite.layout(); if ( treeViewer.getTree() != null && !treeViewer.getTree().isDisposed() ) { TreeViewer entryEditorWidgetTreeViewer = getEntryEditorWidgetTreeViewer(); if ( entryEditorWidgetTreeViewer != null ) { treeViewer.setFilters( entryEditorWidgetTreeViewer.getFilters() ); } if ( !treeViewer.getTree().isEnabled() ) { treeViewer.getTree().setEnabled( true ); } IEntry entry = getEntryEditorWidgetTreeViewerInput(); if ( entry == null ) { treeViewer.setInput( null ); treeViewer.getTree().setEnabled( false ); } else { treeViewer.setInput( entry ); treeViewer.expandToLevel( 2 ); } treeViewer.refresh(); } } } /** * {@inheritDoc} */ public void dispose() { super.dispose(); if ( entryEditor != null ) { BrowserCommonActivator.getDefault().getPreferenceStore().removePropertyChangeListener( propertyChangeListener ); entryEditor = null; } } /** * This class implements the ContentProvider used for the Entry Editor Outline View. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ private static class EntryEditorOutlineContentProvider implements ITreeContentProvider { /** * {@inheritDoc} */ public Object[] getChildren( Object element ) { // entry -> entry wrapper // the entry is the input and is not visible, // so we use an wrapper around to make it visible as root element if ( element instanceof IEntry ) { IEntry entry = ( IEntry ) element; return new EntryWrapper[] { new EntryWrapper( entry ) }; } // entry wrapper -> attribute if ( element instanceof EntryWrapper ) { EntryWrapper entryWrapper = ( EntryWrapper ) element; return entryWrapper.entry.getAttributes(); } // attribute -> values else if ( element instanceof IAttribute ) { IAttribute attribute = ( IAttribute ) element; return attribute.getValues(); } else { return new Object[0]; } } /** * {@inheritDoc} */ public Object getParent( Object element ) { return null; } /** * {@inheritDoc} */ public boolean hasChildren( Object element ) { return getChildren( element ) != null && getChildren( element ).length > 0; } /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { return getChildren( inputElement ); } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * This class implements the LabelProvider used for the Entry Editor Outline View * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ private static class EntryEditorOutlineLabelProvider extends LabelProvider { /** * {@inheritDoc} */ public String getText( Object element ) { // Entry if ( element instanceof EntryWrapper ) { IEntry entry = ( ( EntryWrapper ) element ).entry; // Checking the Root DSE if ( entry.getDn() != null && "".equals( entry.getDn().toString() ) ) //$NON-NLS-1$ { // Root DSE return "Root DSE"; //$NON-NLS-1$ } else { // Any other case return entry.getDn().getName(); } } // Attribute else if ( element instanceof IAttribute ) { IAttribute attribute = ( IAttribute ) element; return attribute.getDescription() + " (" + attribute.getValueSize() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } // Value else if ( element instanceof IValue ) { IValue value = ( IValue ) element; return Utils.getShortenedString( value.getStringValue(), 20 ); } else { return ""; //$NON-NLS-1$ } } /** * {@inheritDoc} */ public Image getImage( Object element ) { // Entry if ( element instanceof EntryWrapper ) { IEntry entry = ( ( EntryWrapper ) element ).entry; // Checking the Root DSE if ( entry.getDn() != null && "".equals( entry.getDn().toString() ) ) //$NON-NLS-1$ { // Root DSE return BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_ENTRY_ROOT ); } else { // Any other case return BrowserLabelProvider.getImageByObjectClass( entry ); } } // Attribute else if ( element instanceof IAttribute ) { return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ATTRIBUTE ); } // Value else if ( element instanceof IValue ) { return LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_VALUE ); } else { return null; } } } /** * Wrapper around an entry. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ private static class EntryWrapper { IEntry entry; public EntryWrapper( IEntry entry ) { super(); this.entry = entry; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ( ( entry == null ) ? 0 : entry.hashCode() ); return result; } @Override public boolean equals( Object obj ) { if ( this == obj ) return true; if ( obj == null ) return false; if ( getClass() != obj.getClass() ) return false; EntryWrapper other = ( EntryWrapper ) obj; if ( entry == null ) { if ( other.entry != null ) return false; } else if ( !entry.equals( other.entry ) ) return false; return true; } } /** * Indicates if the entry has an outline. * * @return <code>true</code> if the entry editor has an outline, * <code>false</code> if not. */ private boolean hasAnOutline() { return getEntryEditorWidgetTreeViewerInput() != null; } /** * Gets the entryEditor.getMainWidget().getViewer() or null. */ private TreeViewer getEntryEditorWidgetTreeViewer() { if ( entryEditor != null ) { EntryEditorWidget mainWidget = entryEditor.getMainWidget(); if ( mainWidget != null ) { TreeViewer viewer = mainWidget.getViewer(); return viewer; } } return null; } /** * Gets the entryEditor.getMainWidget().getViewer().getInput() if input is an IEntry or null. */ private IEntry getEntryEditorWidgetTreeViewerInput() { TreeViewer viewer = getEntryEditorWidgetTreeViewer(); if ( viewer != null ) { Object o = viewer.getInput(); if ( o instanceof IEntry ) { return ( IEntry ) o; } } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditorNavigationLocation.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditorNavigationLocation.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.entryeditors.EntryEditorUtils; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextSelectionNavigationLocation; /** * Represents the text selection context marked for the user in the navigation history. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LdifEntryEditorNavigationLocation extends TextSelectionNavigationLocation { public LdifEntryEditorNavigationLocation( ITextEditor part, boolean initialize ) { super( part, initialize ); } /** * {@inheritDoc} */ public String getText() { String text = EntryEditorUtils.getHistoryNavigationText( getEntryEditorInput() ); return text != null ? text : super.getText(); } /** * {@inheritDoc} */ public boolean mergeInto( INavigationLocation currentLocation ) { if ( currentLocation == null ) { return false; } if ( getClass() != currentLocation.getClass() ) { return false; } LdifEntryEditorNavigationLocation location = ( LdifEntryEditorNavigationLocation ) currentLocation; Object other = location.getEntryEditorInput().getInput(); Object entry = getEntryEditorInput().getInput(); if ( other == null && entry == null ) { return true; } else if ( other == null || entry == null ) { return false; } else { return entry.equals( other ); } } private EntryEditorInput getEntryEditorInput() { Object editorInput = getInput(); if ( editorInput instanceof EntryEditorInput ) { EntryEditorInput entryEditorInput = ( EntryEditorInput ) editorInput; return entryEditorInput; } return null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/Messages.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * This class get messages from the resources file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class Messages { /** The resource name */ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( Messages.class.getPackage().getName() + ".messages" ); /** * Get back a message from the resource file given a key * * @param key The key associated with the message * @return The found message */ public static String getString( String key ) { try { return RESOURCE_BUNDLE.getString( key ); } catch ( MissingResourceException e ) { return '!' + key + '!'; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LocateEntryInLdapBrowserAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LocateEntryInLdapBrowserAction.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.eclipse.jface.action.Action; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * This action is used to locate the input entry in the LDAP Browser DIT. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LocateEntryInLdapBrowserAction extends Action { /** The entry editor */ protected EntryEditor entryEditor; /** The menu manager */ protected EntryEditorShowInMenuManager showInMenuManager; /** * Creates a new instance of LocateEntryInLdapBrowserAction. * * @param entryEditor the entry editor * @param showInMenuManager the menu manager */ public LocateEntryInLdapBrowserAction( EntryEditor entryEditor, EntryEditorShowInMenuManager showInMenuManager ) { super(); this.entryEditor = entryEditor; this.showInMenuManager = showInMenuManager; } /** * {@inheritDoc} */ public void run() { if ( entryEditor != null ) { EntryEditorInput editorInput = entryEditor.getEntryEditorInput(); if ( editorInput != null ) { IEntry entry = editorInput.getResolvedEntry(); if ( entry != null ) { select( entry ); } } } } /** * Select the object in the LDAP Browser. * * @param o the object */ protected void select( Object o ) { String targetId = BrowserView.getId(); IViewPart targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView( targetId ); if ( targetView == null ) { try { targetView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( targetId, null, IWorkbenchPage.VIEW_ACTIVATE ); } catch ( PartInitException e ) { } } if ( targetView instanceof BrowserView ) { ( ( BrowserView ) targetView ).select( o ); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate( targetView ); } } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "LocateEntryInLdapBrowserAction.LDAPBrowser" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public String getToolTipText() { return getText(); } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_ENTRY_IN_DIT ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/OpenEntryEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/OpenEntryEditorAction.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.AbstractOpenEditorAction; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidgetActionGroup; import org.apache.directory.studio.ldapbrowser.common.wizards.EditEntryWizard; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; 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.TreeViewer; import org.eclipse.jface.wizard.WizardDialog; /** * Action to open the entry editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEntryEditorAction extends AbstractOpenEditorAction { /** The value editor. */ private IValueEditor valueEditor; /** * Creates a new instance of OpenEntryEditorAction. * * @param viewer the viewer * @param valueEditorManager the value editor manager * @param valueEditor the value editor * @param actionGroup the action group */ public OpenEntryEditorAction( TreeViewer viewer, ValueEditorManager valueEditorManager, IValueEditor valueEditor, EntryEditorWidgetActionGroup actionGroup ) { super( viewer, valueEditorManager, actionGroup ); setCellEditor( valueEditor.getCellEditor() ); this.valueEditor = valueEditor; } /** * Gets the value editor. * * @return the value editor */ public IValueEditor getValueEditor() { return valueEditor; } /** * {@inheritDoc} */ public void run() { IEntry entry = getSelectedValues().length > 0 ? getSelectedValues()[0].getAttribute().getEntry() : getSelectedAttributes().length > 0 ? getSelectedAttributes()[0].getEntry() : ( getInput() instanceof IEntry ) ? ( IEntry ) getInput() : null; if ( entry != null ) { // disable action handlers actionGroup.deactivateGlobalActionHandlers(); EditEntryWizard wizard = new EditEntryWizard( entry ); WizardDialog dialog = new WizardDialog( getShell(), wizard ); dialog.setBlockOnOpen( true ); dialog.create(); dialog.open(); // enable action handlers actionGroup.activateGlobalActionHandlers(); } } /** * {@inheritDoc} */ public void dispose() { valueEditor = null; super.dispose(); } /** * {@inheritDoc} */ public String getCommandId() { return BrowserCommonConstants.ACTION_ID_EDIT_RECORD; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_ENTRY_EDITOR ); } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "OpenEntryEditorAction.EditEntry" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabEntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabEntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; /** * An entry editor the opens a new editor tab for each entry. * * TODO: Configurable modificaton mode * Right now the modification mode is fixed: no immediate commit of changes, * instead the editor follows the open-save-close lifecycle. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MultiTabEntryEditor extends EntryEditor { /** * Gets the ID of the MultiTabEntryEditor. * * @return the id of the MultiTabEntryEditor */ public static String getId() { return BrowserUIConstants.EDITOR_MULTI_TAB_ENTRY_EDITOR; } /** * {@inheritDoc} */ @Override public boolean isAutoSave() { return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_MULTI_TAB ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabEntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabEntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; /** * An entry editor the opens all entries in one single editor tab. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SingleTabEntryEditor extends EntryEditor { /** * Gets the ID of the SingleTabEntryEditor. * * @return the id of the SingleTabEntryEditor */ public static String getId() { return BrowserUIConstants.EDITOR_SINGLE_TAB_ENTRY_EDITOR; } /** * {@inheritDoc} */ @Override public boolean isAutoSave() { return BrowserCommonActivator.getDefault().getPreferenceStore().getBoolean( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_SINGLE_TAB ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorShowInMenuManager.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditorShowInMenuManager.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ContributionItemFactory; /** * The EntryEditorShowInMenuManager manages actions for the "Show In" menu manager. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorShowInMenuManager { /** The entry editor */ private EntryEditor entryEditor; /** The locate entry in DIT action */ private LocateEntryInLdapBrowserAction locateEntryInDitAction; /** The locate search result or bookmark action */ private LocateSearchResultOrBookmarkAction locateSearchResultOrBookmarkAction; /** * Creates a new instance of EntryEditorShowInMenuManager. * * @param entryEditor the entry editor */ public EntryEditorShowInMenuManager( EntryEditor entryEditor ) { this.entryEditor = entryEditor; locateEntryInDitAction = new LocateEntryInLdapBrowserAction( entryEditor, this ); locateSearchResultOrBookmarkAction = new LocateSearchResultOrBookmarkAction( entryEditor, this ); } /** * Creates the menu manager. * * @param parent parent menu manager */ public void createMenuManager( IMenuManager parent ) { MenuManager showInMenuManager = new MenuManager( Messages.getString( "EntryEditorShowInMenuManager.ShowIn" ) ); //$NON-NLS-1$ parent.add( showInMenuManager ); Object input = getInput(); if ( input != null ) { showInMenuManager.add( locateEntryInDitAction ); if ( inputIsSearchResultOrBookmark() ) { showInMenuManager.add( locateSearchResultOrBookmarkAction ); } } showInMenuManager.add( ContributionItemFactory.VIEWS_SHOW_IN.create( PlatformUI.getWorkbench() .getActiveWorkbenchWindow() ) ); } /** * Gets the input. * * @return the input */ public Object getInput() { if ( entryEditor != null ) { EntryEditorInput editorInput = entryEditor.getEntryEditorInput(); if ( editorInput != null ) { return editorInput.getInput(); } } return null; } /** * Indicates if the input is a search result or a bookmark. * * @return <code>true</code> if the input is a search result or a bookmark, * <code>false</code> if not. */ private boolean inputIsSearchResultOrBookmark() { Object input = getInput(); return ( ( input instanceof ISearchResult ) || ( input instanceof IBookmark ) ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabLdifEntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/MultiTabLdifEntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; /** * An entry editor that uses LDIF format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MultiTabLdifEntryEditor extends LdifEntryEditor { /** * Gets the ID of the MultiTabLdifEntryEditor. * * @return the id of the MultiTabLdifEntryEditor */ public static String getId() { return BrowserUIConstants.EDITOR_MULTI_TAB_LDIF_ENTRY_EDITOR; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/LdifEntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.entryeditors.EntryEditorUtils; import org.apache.directory.studio.entryeditors.IEntryEditor; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldifeditor.editor.LdifEditor; import org.apache.directory.studio.ldifeditor.editor.LdifOutlinePage; import org.apache.directory.studio.utils.ActionUtils; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.resource.ImageDescriptor; 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.IShowEditorInput; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; /** * An entry editor that uses LDIF format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class LdifEntryEditor extends LdifEditor implements IEntryEditor, IShowEditorInput { private static final String REFRESH_ACTION = "RefreshAction"; //$NON-NLS-1$ private static final String FETCH_OPERATIONAL_ATTRIBUTES_ACTION = "FetchOperationalAttributesAction"; //$NON-NLS-1$ private boolean inShowEditorInput = false; private IAction refreshAction = new Action() { @Override public ImageDescriptor getImageDescriptor() { return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_REFRESH ); } @Override public String getText() { return org.apache.directory.studio.ldapbrowser.common.actions.Messages .getString( "RefreshAction.RelaodAttributes" ); //$NON-NLS-1$ } @Override public boolean isEnabled() { return ( getEntryEditorInput().getResolvedEntry() != null ); } @Override public String getActionDefinitionId() { return "org.eclipse.ui.file.refresh"; //$NON-NLS-1$ } @Override public void run() { IEntry entry = getEntryEditorInput().getResolvedEntry(); new StudioBrowserJob( new InitializeAttributesRunnable( entry ) ).execute(); } }; private IAction fetchOperationalAttributesAction = new Action() { @Override public int getStyle() { return Action.AS_CHECK_BOX; } @Override public String getText() { return org.apache.directory.studio.ldapbrowser.common.actions.Messages .getString( "FetchOperationalAttributesAction.FetchOperationalAttributes" ); //$NON-NLS-1$ } @Override public boolean isEnabled() { IEntry entry = getEntryEditorInput().getResolvedEntry(); if ( entry != null ) { entry = entry.getBrowserConnection().getEntryFromCache( entry.getDn() ); return !entry.getBrowserConnection().isFetchOperationalAttributes(); } return false; } @Override public void run() { IEntry entry = getEntryEditorInput().getResolvedEntry(); entry = entry.getBrowserConnection().getEntryFromCache( entry.getDn() ); boolean init = !entry.isInitOperationalAttributes(); entry.setInitOperationalAttributes( init ); new StudioBrowserJob( new InitializeAttributesRunnable( entry ) ).execute(); } }; public LdifEntryEditor() { super(); // use our own document provider that saves changes to the directory setDocumentProvider( new LdifEntryEditorDocumentProvider( this ) ); } @Override public void init( IEditorSite site, IEditorInput input ) throws PartInitException { super.init( site, input ); } @Override protected void doSetInput( IEditorInput input ) throws CoreException { super.doSetInput( input ); IEntry entry = getEntryEditorInput().getResolvedEntry(); if ( entry != null ) { setConnection( entry.getBrowserConnection() ); } } @Override public void createPartControl( Composite parent ) { // don't show the tool bar showToolBar = false; super.createPartControl( parent ); } @Override public boolean isSaveAsAllowed() { // Allowing "Save As..." requires an IPathEditorInput. // Would makes things much more complex, maybe we could add this later. return false; } @Override public void dispose() { super.dispose(); } /** * @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class) */ public Object getAdapter( Class required ) { // Overwriting the outline page if ( IContentOutlinePage.class.equals( required ) ) { if ( outlinePage == null || outlinePage.getControl() == null || outlinePage.getControl().isDisposed() ) { outlinePage = new LdifOutlinePage( this, true ); } return outlinePage; } // In all other cases, refering to the super class return super.getAdapter( required ); } @Override protected void createActions() { super.createActions(); setAction( REFRESH_ACTION, refreshAction ); setAction( FETCH_OPERATIONAL_ATTRIBUTES_ACTION, fetchOperationalAttributesAction ); } @Override protected void editorContextMenuAboutToShow( IMenuManager menu ) { super.editorContextMenuAboutToShow( menu ); IEntry entry = getEntryEditorInput().getResolvedEntry(); fetchOperationalAttributesAction.setChecked( ( entry != null ) ? entry.isInitOperationalAttributes() : false ); addAction( menu, ITextEditorActionConstants.GROUP_REST, REFRESH_ACTION ); addAction( menu, ITextEditorActionConstants.GROUP_REST, FETCH_OPERATIONAL_ATTRIBUTES_ACTION ); } @Override public void activateGlobalActionHandlers() { ActionUtils.activateActionHandler( refreshAction ); } @Override public void deactivateGlobalActionHandlers() { ActionUtils.deactivateActionHandler( refreshAction ); } @Override public INavigationLocation createNavigationLocation() { return new LdifEntryEditorNavigationLocation( this, true ); } @Override public INavigationLocation createEmptyNavigationLocation() { return new LdifEntryEditorNavigationLocation( this, false ); } /** * This implementation returns always false. * * {@inheritDoc} */ public boolean isAutoSave() { return false; } /** * This implementation returns always true. * * {@inheritDoc} */ public boolean canHandle( IEntry entry ) { return true; } /** * {@inheritDoc} */ public EntryEditorInput getEntryEditorInput() { return EntryEditorUtils.getEntryEditorInput( getEditorInput() ); } /** * {@inheritDoc} */ public void workingCopyModified( Object source ) { ( ( LdifEntryEditorDocumentProvider ) getDocumentProvider() ).workingCopyModified( getEntryEditorInput(), source ); } public void showEditorInput( IEditorInput input ) { if ( inShowEditorInput ) { /* * This is to avoid recursion when using history navigation: * - when selecting an entry this method is called * - this method fires an input changed event * - the LinkWithEditorAction gets the event and selects the entry in the browser tree * - this selection fires an selection event * - the selection event causes an openEditor() that calls this method again */ return; } try { inShowEditorInput = true; if ( input instanceof EntryEditorInput ) { EntryEditorInput eei = ( EntryEditorInput ) input; /* * Optimization: no need to set the input again if the same input is already set */ if ( getEntryEditorInput() != null && getEntryEditorInput().getResolvedEntry() == eei.getResolvedEntry() ) { return; } // If the editor is dirty, let's ask for a save before changing the input if ( isDirty() ) { if ( !EntryEditorUtils.askSaveSharedWorkingCopyBeforeInputChange( this ) ) { return; } } // now set the real input and mark history location doSetInput( input ); getSite().getPage().getNavigationHistory().markLocation( this ); firePropertyChange( BrowserUIConstants.INPUT_CHANGED ); } } catch ( CoreException e ) { throw new RuntimeException( e ); } finally { inShowEditorInput = false; } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/EntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.entryeditors.EntryEditorInput; import org.apache.directory.studio.entryeditors.EntryEditorUtils; import org.apache.directory.studio.entryeditors.IEntryEditor; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.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.IShowEditorInput; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; /** * The EntryEditor is an {@link IEditorPart} is used to display and edit the attributes of an entry. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class EntryEditor extends EditorPart implements IEntryEditor, INavigationLocationProvider, IReusableEditor, IShowEditorInput { /** The editor configuration. */ protected EntryEditorConfiguration configuration; /** The action group. */ protected EntryEditorActionGroup actionGroup; /** The main widget. */ protected EntryEditorWidget mainWidget; /** The universal listener. */ protected EntryEditorUniversalListener universalListener; /** The outline page. */ protected EntryEditorOutlinePage outlinePage; IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { @Override public void propertyChange( org.eclipse.jface.util.PropertyChangeEvent event ) { // set the input again if the auto-save option has been changed if ( event.getProperty() != null ) { if ( event.getProperty().equals( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_SINGLE_TAB ) || event.getProperty().equals( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_AUTOSAVE_MULTI_TAB ) ) { setInput( getEditorInput() ); } } } }; /** * {@inheritDoc} */ @Override public void init( IEditorSite site, IEditorInput input ) throws PartInitException { setSite( site ); setInput( input ); BrowserCommonActivator.getDefault().getPreferenceStore().addPropertyChangeListener( propertyChangeListener ); } /** * {@inheritDoc} */ @Override public void setInput( IEditorInput input ) { super.setInput( input ); EntryEditorInput eei = getEntryEditorInput(); setEntryEditorWidgetInput( eei ); setEditorName( eei ); // refresh outline if ( outlinePage != null ) { outlinePage.refresh(); } } /** * {@inheritDoc} */ @Override public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.verticalSpacing = 0; composite.setLayout( layout ); PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, BrowserUIConstants.PLUGIN_ID + "." + "tools_table_entry_editor" ); //$NON-NLS-1$ //$NON-NLS-2$ // create configuration configuration = new EntryEditorConfiguration( this ); // create main widget mainWidget = new EntryEditorWidget( configuration ); mainWidget.createWidget( composite ); // create actions and context menu and register global actions actionGroup = new EntryEditorActionGroup( this ); actionGroup.fillToolBar( mainWidget.getToolBarManager() ); actionGroup.fillMenu( mainWidget.getMenuManager() ); actionGroup.enableGlobalActionHandlers( getEditorSite().getActionBars() ); actionGroup.fillContextMenu( mainWidget.getContextMenuManager() ); // create the listener getSite().setSelectionProvider( mainWidget.getViewer() ); universalListener = new EntryEditorUniversalListener( this ); setInput( getEditorInput() ); } /** * {@inheritDoc} */ @Override public void setFocus() { mainWidget.setFocus(); } /** * {@inheritDoc} */ @Override public Object getAdapter( Class required ) { if ( IContentOutlinePage.class.equals( required ) ) { if ( outlinePage == null || outlinePage.getControl() == null || outlinePage.getControl().isDisposed() ) { outlinePage = new EntryEditorOutlinePage( this ); } return outlinePage; } return super.getAdapter( required ); } /** * {@inheritDoc} */ @Override public void dispose() { if ( configuration != null ) { universalListener.dispose(); universalListener = null; mainWidget.dispose(); mainWidget = null; actionGroup.dispose(); actionGroup = null; configuration.dispose(); configuration = null; getSite().setSelectionProvider( null ); BrowserCommonActivator.getDefault().getPreferenceStore().removePropertyChangeListener( propertyChangeListener ); } super.dispose(); } /** * {@inheritDoc} */ @Override public void doSave( final IProgressMonitor monitor ) { if ( !isAutoSave() ) { EntryEditorInput eei = getEntryEditorInput(); eei.saveSharedWorkingCopy( true, this ); } } /** * {@inheritDoc} */ @Override public void doSaveAs() { } /** * {@inheritDoc} */ @Override public boolean isDirty() { return getEntryEditorInput().isSharedWorkingCopyDirty( this ); } /** * {@inheritDoc} */ @Override public boolean isSaveAsAllowed() { return false; } /** * Gets the action group. * * @return the action group */ public EntryEditorActionGroup getActionGroup() { return actionGroup; } /** * Gets the configuration. * * @return the configuration */ public EntryEditorConfiguration getConfiguration() { return configuration; } /** * Gets the main widget. * * @return the main widget */ public EntryEditorWidget getMainWidget() { return mainWidget; } /** * Gets the outline page. * * @return the outline page */ public EntryEditorOutlinePage getOutlinePage() { return outlinePage; } /** * Gets the universal listener. * * @return the universal listener */ public EntryEditorUniversalListener getUniversalListener() { return universalListener; } /** * {@inheritDoc} */ @Override public INavigationLocation createEmptyNavigationLocation() { return null; } /** * {@inheritDoc} */ @Override public INavigationLocation createNavigationLocation() { return new EntryEditorNavigationLocation( this ); } /** * Sets the editor name. * * @param input the new editor name */ protected void setEditorName( EntryEditorInput input ) { setPartName( input.getName() ); } /** * This implementation returns always true. * * {@inheritDoc} */ @Override public boolean canHandle( IEntry entry ) { return true; } /** * {@inheritDoc} */ @Override public EntryEditorInput getEntryEditorInput() { return EntryEditorUtils.getEntryEditorInput( getEditorInput() ); } /** * {@inheritDoc} */ @Override public void workingCopyModified( Object source ) { if ( mainWidget != null && !mainWidget.getViewer().isCellEditorActive() ) { ISelection selection = mainWidget.getViewer().getSelection(); mainWidget.getViewer().refresh(); mainWidget.getViewer().setSelection( selection ); } if ( !isAutoSave() ) { // mark as dirty firePropertyChange( PROP_DIRTY ); } } /** * Sets the entry editor widget input. A clone of the real entry * with a read-only connection is used for that. * @param eei */ private void setEntryEditorWidgetInput( EntryEditorInput eei ) { if ( mainWidget != null ) { universalListener.setInput( eei.getSharedWorkingCopy( this ) ); /* * Explicitly deselect previously selected attributes and values. * This avoids disabled actions if the new input is equal but not * identical to the previous input. This happens for example if * an ISearchResult or IBookmark object is open and afterwards * the IEntry object is opened. */ mainWidget.getViewer().setSelection( StructuredSelection.EMPTY ); } } /** * {@inheritDoc} */ @Override public void showEditorInput( IEditorInput input ) { if ( input instanceof EntryEditorInput ) { /* * Optimization: no need to set the input again if the same input is already set */ if ( getEntryEditorInput() != null && getEntryEditorInput().getResolvedEntry() == ( ( EntryEditorInput ) input ).getResolvedEntry() ) { return; } // If the editor is dirty, let's ask for a save before changing the input if ( isDirty() && !EntryEditorUtils.askSaveSharedWorkingCopyBeforeInputChange( this ) ) { return; } // now set the real input and mark history location setInput( input ); getSite().getPage().getNavigationHistory().markLocation( this ); firePropertyChange( BrowserUIConstants.INPUT_CHANGED ); } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabLdifEntryEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/entry/SingleTabLdifEntryEditor.java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.apache.directory.studio.ldapbrowser.ui.editors.entry; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; /** * An single-tab entry editor that uses LDIF format. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SingleTabLdifEntryEditor extends LdifEntryEditor { /** * Gets the ID of the SingleTabLdifEntryEditor. * * @return the id of the SingleTabLdifEntryEditor */ public static String getId() { return BrowserUIConstants.EDITOR_SINGLE_TAB_LDIF_ENTRY_EDITOR; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditor.java
/* * 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.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.EntryUpdateListener; import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry; import org.apache.directory.studio.ldapbrowser.core.events.ValueAddedEvent; import org.apache.directory.studio.ldapbrowser.core.events.ValueDeletedEvent; import org.apache.directory.studio.ldapbrowser.core.events.ValueModifiedEvent; import org.apache.directory.studio.ldapbrowser.core.events.ValueMultiModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.ValueRenamedEvent; import org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.apache.directory.studio.ldifparser.LdifFormatParameters; import org.apache.directory.studio.ldifparser.model.LdifFile; 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.IShowEditorInput; 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; /** * The SearchResultEditor is an {@link IEditorPart} is used to display and edit * the attributes of the results of a search. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditor extends EditorPart implements INavigationLocationProvider, IReusableEditor, IShowEditorInput, IPropertyChangeListener { /** The configuration. */ private SearchResultEditorConfiguration configuration; /** The action group. */ private SearchResultEditorActionGroup actionGroup; /** The main widget. */ private SearchResultEditorWidget mainWidget; /** The universal listener. */ private SearchResultEditorUniversalListener universalListener; protected EntryUpdateListener entryUpdateListener = new EntryUpdateListener() { public void entryUpdated( EntryModificationEvent event ) { if ( mainWidget.getViewer() == null || mainWidget.getViewer().getInput() == null ) { return; } IEntry modifiedEntry = event.getModifiedEntry(); IEntry originalEntry = modifiedEntry.getBrowserConnection().getEntryFromCache( modifiedEntry.getDn() ); ISearchResult referenceCopy = configuration.getCursor( mainWidget.getViewer() ).getSelectedReferenceCopy(); ISearchResult workingCopy = configuration.getCursor( mainWidget.getViewer() ).getSelectedSearchResult(); // check on object identity, nothing should be done for equal objects from other editors if ( workingCopy != null && workingCopy.getEntry() == modifiedEntry ) { // only save if we receive a real value modification event if ( !( event instanceof ValueAddedEvent || event instanceof ValueDeletedEvent || event instanceof ValueModifiedEvent || event instanceof ValueRenamedEvent || event instanceof ValueMultiModificationEvent ) ) { return; } // consistency check: don't save if there is an empty value, silently return in that case for ( IAttribute attribute : modifiedEntry.getAttributes() ) { for ( IValue value : attribute.getValues() ) { if ( value.isEmpty() ) { return; } } } LdifFile diff = Utils.computeDiff( referenceCopy.getEntry(), modifiedEntry ); if ( diff != null ) { // save UpdateEntryRunnable runnable = new UpdateEntryRunnable( originalEntry, diff .toFormattedString( LdifFormatParameters.DEFAULT ) ); RunnableContextRunner.execute( runnable, null, true ); } configuration.getCursor( mainWidget.getViewer() ).resetCopies(); } } }; /** * Gets the ID of the SearchResultEditor. * * @return the id of the SearchResultEditor */ public static String getId() { return BrowserUIConstants.EDITOR_SEARCH_RESULT; } /** * {@inheritDoc} */ public void setInput( IEditorInput input ) { super.setInput( input ); if ( input instanceof SearchResultEditorInput && universalListener != null ) { setPartName( input.getName() ); SearchResultEditorInput srei = ( SearchResultEditorInput ) input; setSearchResultEditorWidgetInput( srei ); } } public void showEditorInput( IEditorInput input ) { if ( input instanceof SearchResultEditorInput ) { /* * Optimization: no need to set the input again if the same input is already set */ if ( getEditorInput() != null && getEditorInput().equals( input ) ) { return; } // now set the real input and mark history location setInput( input ); getSite().getPage().getNavigationHistory().markLocation( this ); firePropertyChange( BrowserUIConstants.INPUT_CHANGED ); } } private void setSearchResultEditorWidgetInput( SearchResultEditorInput srei ) { ISearch search = srei.getSearch(); universalListener.setInput( search ); } /** * Refreshes this search result editor. */ public void refresh() { if ( universalListener != null ) { universalListener.refreshInput(); } } /** * {@inheritDoc} */ public void init( IEditorSite site, IEditorInput input ) throws PartInitException { setSite( site ); setInput( input ); EventRegistry .addEntryUpdateListener( entryUpdateListener, BrowserCommonActivator.getDefault().getEventRunner() ); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; // layout.horizontalSpacing = 0; layout.verticalSpacing = 0; composite.setLayout( layout ); PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, BrowserUIConstants.PLUGIN_ID + "." + "tools_search_result_editor" ); //$NON-NLS-1$ //$NON-NLS-2$ // create configuration configuration = new SearchResultEditorConfiguration( this ); // create main widget mainWidget = new SearchResultEditorWidget( configuration ); mainWidget.createWidget( composite ); // create actions and context menu (and register global actions) actionGroup = new SearchResultEditorActionGroup( this ); actionGroup.fillToolBar( mainWidget.getToolBarManager() ); actionGroup.fillMenu( mainWidget.getMenuManager() ); actionGroup.enableGlobalActionHandlers( getEditorSite().getActionBars() ); actionGroup.fillContextMenu( configuration.getContextMenuManager( mainWidget.getViewer() ) ); // create the listener universalListener = new SearchResultEditorUniversalListener( this ); getSite().setSelectionProvider( configuration.getCursor( mainWidget.getViewer() ) ); this.setInput( getEditorInput() ); BrowserUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this ); } /** * {@inheritDoc} */ public void setFocus() { mainWidget.setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( configuration != null ) { EventRegistry.removeEntryUpdateListener( entryUpdateListener ); actionGroup.dispose(); actionGroup = null; universalListener.dispose(); universalListener = null; mainWidget.dispose(); mainWidget = null; configuration.dispose(); configuration = null; getSite().setSelectionProvider( null ); BrowserUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this ); } super.dispose(); } /** * {@inheritDoc} */ public void doSave( IProgressMonitor monitor ) { } /** * {@inheritDoc} */ public void doSaveAs() { } /** * {@inheritDoc} */ public boolean isDirty() { return false; } /** * {@inheritDoc} */ public boolean isSaveAsAllowed() { return false; } /** * {@inheritDoc} */ public INavigationLocation createEmptyNavigationLocation() { return null; } /** * {@inheritDoc} */ public INavigationLocation createNavigationLocation() { return new SearchResultEditorNavigationLocation( this ); } /** * {@inheritDoc} */ 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 ); } /** * Gets the action group. * * @return the action group */ public SearchResultEditorActionGroup getActionGroup() { return actionGroup; } /** * Gets the configuration. * * @return the configuration */ public SearchResultEditorConfiguration getConfiguration() { return configuration; } /** * Gets the main widget. * * @return the main widget */ public SearchResultEditorWidget getMainWidget() { return mainWidget; } /** * Gets the universal listener. * * @return the universal listener */ public SearchResultEditorUniversalListener getUniversalListener() { return universalListener; } /** * {@inheritDoc} */ public void propertyChange( PropertyChangeEvent event ) { refresh(); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorFilter.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorFilter.java
/* * 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.ArrayList; import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; /** * The SearchResultEditorFilter implements the filter for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorFilter extends ViewerFilter { /** The content provider. */ protected SearchResultEditorContentProvider contentProvider; /** The quick filter value. */ protected String quickFilterValue; /** The show Dn flag. */ private boolean showDn; /** * Creates a new instance of SearchResultEditorFilter. */ public SearchResultEditorFilter() { this.quickFilterValue = ""; //$NON-NLS-1$ } /** * Connects this filter with the given content provider. * * @param viewer the viewer */ public void connect( SearchResultEditorContentProvider contentProvider ) { this.contentProvider = contentProvider; } /** * Called when the input of the viewer changes. * * @param newSearch the new search * @param showDn the show Dn flag */ public void inputChanged( ISearch newSearch, boolean showDn ) { this.showDn = showDn; } /** * Checks if is filtered. * * @return true, if is filtered */ public boolean isFiltered() { return quickFilterValue != null && !"".equals( quickFilterValue ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public Object[] filter( Viewer viewer, Object parent, Object[] elements ) { if ( isFiltered() ) { int size = elements.length; ArrayList<Object> out = new ArrayList<Object>( 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; } } /** * {@inheritDoc} */ 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]; AttributeHierarchy 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; } } } } } if ( showDn && searchResult.getDn().getName().toUpperCase().indexOf( quickFilterValue.toUpperCase() ) > -1 ) { return true; } return false; } else { return true; } } /** * Checks if the value goes through quick filter. * * @param value the value * * @return true, if successful */ private boolean goesThroughQuickFilter( IValue value ) { if ( value.isString() && value.getStringValue().toUpperCase().indexOf( quickFilterValue.toUpperCase() ) == -1 ) { return false; } else if ( value.isBinary() ) { return false; } return true; } /** * Disposes this filter. */ public void dispose() { contentProvider = null; } /** * Gets the quick filter value. * * @return the quick filter value */ public String getQuickFilterValue() { return quickFilterValue; } /** * Sets the quick filter value. * * @param quickFilterValue the new quick filter value */ public void setQuickFilterValue( String quickFilterValue ) { if ( !this.quickFilterValue.equals( quickFilterValue ) ) { this.quickFilterValue = quickFilterValue; if ( contentProvider != null ) { contentProvider.refresh(); } } } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorSorter.java
/* * 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 java.util.Comparator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.ISearchResult; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.TableColumn; /** * The SearchResultEditorSorter implements the Sorter for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorSorter extends ViewerSorter implements SelectionListener { /** The content provider. */ protected SearchResultEditorContentProvider contentProvider; /** The search. */ private ISearch search; /** The columns. */ private TableColumn[] columns; /** The show Dn flag. */ private boolean showDn; /** The sort property. */ private int sortBy; /** The sort order. */ private int sortOrder; /** * Connects this sorter to the given content provider. * * @param contentProvider the content provider */ public void connect( SearchResultEditorContentProvider contentProvider ) { this.contentProvider = contentProvider; sortBy = 0; sortOrder = BrowserCoreConstants.SORT_ORDER_NONE; columns = contentProvider.getViewer().getTable().getColumns(); for ( TableColumn column : columns ) { column.addSelectionListener( this ); } } /** * Called when the input of the viewer has been changed. * * @param newSearch the new search * @param showDn the show Dn flag */ public void inputChanged( ISearch newSearch, boolean showDn ) { this.search = newSearch; this.showDn = showDn; if ( columns != null ) { for ( TableColumn column : columns ) { column.removeSelectionListener( this ); } } columns = contentProvider.getViewer().getTable().getColumns(); for ( TableColumn column : columns ) { column.addSelectionListener( this ); } // check sort column int visibleColumns = search.getReturningAttributes().length; if ( showDn ) { visibleColumns++; } if ( visibleColumns < sortBy + 1 ) { setSortColumn( 0 ); setSortColumn( 0 ); setSortColumn( 0 ); } } public void dispose() { if ( columns != null ) { for ( TableColumn column : columns ) { if ( !column.isDisposed() ) { column.removeSelectionListener( this ); } } } columns = null; search = null; contentProvider = null; } /** * {@inheritDoc} */ public void widgetDefaultSelected( SelectionEvent e ) { } /** * {@inheritDoc} */ public void widgetSelected( SelectionEvent e ) { if ( e.widget instanceof TableColumn ) { int index = contentProvider.getViewer().getTable().indexOf( ( ( TableColumn ) e.widget ) ); setSortColumn( index ); } } /** * Sets the sort column. * * @param index the new sort column */ private void setSortColumn( int index ) { if ( sortBy == index ) { // toggle sort order sortOrder = sortOrder == BrowserCoreConstants.SORT_ORDER_ASCENDING ? BrowserCoreConstants.SORT_ORDER_DESCENDING : sortOrder == BrowserCoreConstants.SORT_ORDER_DESCENDING ? BrowserCoreConstants.SORT_ORDER_NONE : BrowserCoreConstants.SORT_ORDER_ASCENDING; } else { // set new sort by sortBy = index; sortOrder = BrowserCoreConstants.SORT_ORDER_ASCENDING; } if ( sortOrder == BrowserCoreConstants.SORT_ORDER_NONE ) { sortBy = BrowserCoreConstants.SORT_BY_NONE; } TableColumn[] columns = contentProvider.getViewer().getTable().getColumns(); for ( TableColumn column : columns ) { column.setImage( null ); } if ( sortOrder == BrowserCoreConstants.SORT_ORDER_ASCENDING ) { ( columns[index] ).setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_SORT_ASCENDING ) ); } else if ( sortOrder == BrowserCoreConstants.SORT_ORDER_DESCENDING ) { ( columns[index] ).setImage( BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_SORT_DESCENDING ) ); } else { ( columns[index] ).setImage( null ); } contentProvider.refresh(); } /** * Checks if is sorted. * * @return true, if is sorted */ public boolean isSorted() { // return sortOrder != SORT_ORDER_NONE; return true; } /** * {@inheritDoc} */ public void sort( final Viewer viewer, Object[] elements ) { if ( isSorted() ) { Arrays.sort( elements, new Comparator<Object>() { public int compare( Object a, Object b ) { return SearchResultEditorSorter.this.compare( viewer, a, b ); } } ); } } /** * {@inheritDoc} */ public int compare( Viewer viewer, Object o1, Object o2 ) { if ( search == null ) { return equal(); } ISearchResult sr1 = ( ISearchResult ) o1; ISearchResult sr2 = ( ISearchResult ) o2; IEntry entry1 = sr1.getEntry(); IEntry entry2 = sr2.getEntry(); if ( entry1 == null ) { if ( entry2 == null ) { return equal(); } else { return lessThan(); } } else if ( entry2 == null ) { return greaterThan(); } else { String attributeName; if ( showDn && ( sortBy == 0 ) ) { attributeName = BrowserUIConstants.DN; } else if ( showDn && ( sortBy > 0 ) ) { attributeName = search.getReturningAttributes()[sortBy - 1]; } else { attributeName = search.getReturningAttributes()[sortBy]; } if ( attributeName == BrowserUIConstants.DN ) { // compare normalized names return compare( entry1.getDn().getNormName(), entry2.getDn().getNormName() ); } else { AttributeHierarchy ah1 = entry1.getAttributeWithSubtypes( attributeName ); AttributeHierarchy ah2 = entry2.getAttributeWithSubtypes( attributeName ); if ( ah1 == null ) { if ( ah2 == null ) { return equal(); } else { return lessThan(); } } else if ( ah2 == null ) { return greaterThan(); } else { IAttribute attribute1 = ah1.getAttribute(); IAttribute attribute2 = ah2.getAttribute(); String value1 = getValue( attribute1 ); String value2 = getValue( attribute2 ); return compare( value1, value2 ); } } } } /** * Gets the value. * * @param attribute the attribute * * @return the value */ private String getValue( IAttribute attribute ) { if ( attribute.getValueSize() > 0 ) { return attribute.getStringValue(); } else { return ""; //$NON-NLS-1$ } } /** * Gets the less than value. * * @return the less than value */ private int lessThan() { return sortOrder == BrowserCoreConstants.SORT_ORDER_ASCENDING ? -1 : 1; } /** * Gets the equal value. * * @return the equal value */ private int equal() { return 0; } /** * Gets the greater than value. * * @return the greater than value */ private int greaterThan() { return sortOrder == BrowserCoreConstants.SORT_ORDER_ASCENDING ? 1 : -1; } /** * Compare two strings. * * @param s1 the 1st string * @param s2 the 2nd string * * @return the compare result */ private int compare( String s1, String s2 ) { return sortOrder == BrowserCoreConstants.SORT_ORDER_ASCENDING ? s1.compareToIgnoreCase( s2 ) : s2 .compareToIgnoreCase( s1 ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/AbstractOpenEditorAction.java
/* * 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; /** * Base class for all value editor actions of the search result editor. * It manages activation and closing of value editors. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class AbstractOpenEditorAction extends BrowserAction implements FocusListener, KeyListener { /** The value editor manager. */ protected ValueEditorManager valueEditorManager; /** The viewer. */ protected TableViewer viewer; /** The cursor. */ protected SearchResultEditorCursor cursor; /** The cell editor. */ protected CellEditor cellEditor; /** The is active flag. */ private boolean isActive; /** The actionGroup. */ protected SearchResultEditorActionGroup actionGroup; /** * Creates a new instance of AbstractOpenEditorAction. * * @param viewer the viewer * @param cursor the cursor * @param valueEditorManager the value editor manager * @param actionGroup the action group */ protected AbstractOpenEditorAction( TableViewer viewer, SearchResultEditorCursor cursor, ValueEditorManager valueEditorManager, SearchResultEditorActionGroup actionGroup ) { this.viewer = viewer; this.cursor = cursor; this.valueEditorManager = valueEditorManager; this.actionGroup = actionGroup; this.isActive = false; } /** * {@inheritDoc} */ public CellEditor getCellEditor() { return cellEditor; } /** * {@inheritDoc} */ public void run() { activateEditor(); } /** * Activates the editor. */ private void activateEditor() { Object element = cursor.getRow().getData(); String property = ( String ) viewer.getColumnProperties()[cursor.getColumn()]; if ( !viewer.isCellEditorActive() && viewer.getCellModifier().canModify( element, property ) ) { // disable action handlers actionGroup.deactivateGlobalActionHandlers(); // set cell editor to viewer for ( int i = 0; i < viewer.getCellEditors().length; i++ ) { viewer.getCellEditors()[i] = cellEditor; } // add listener for end of editing if ( cellEditor.getControl() != null ) { cellEditor.getControl().addFocusListener( this ); cellEditor.getControl().addKeyListener( this ); } // deactivate cursor cursor.setVisible( false ); // start editing isActive = true; viewer.editElement( element, cursor.getColumn() ); viewer.setSelection( null, true ); viewer.getTable().setSelection( new TableItem[0] ); if ( !viewer.isCellEditorActive() ) { editorClosed(); } } else { valueEditorManager.setUserSelectedValueEditor( null ); } } private void editorClosed() { // clear active flag isActive = false; // remove cell editors from viewer to prevent auto-editing for ( int i = 0; i < viewer.getCellEditors().length; i++ ) { viewer.getCellEditors()[i] = null; } // remove listener if ( cellEditor.getControl() != null ) { cellEditor.getControl().removeFocusListener( this ); cellEditor.getControl().removeKeyListener( this ); } valueEditorManager.setUserSelectedValueEditor( null ); // activate cursor cursor.setVisible( true ); viewer.refresh(); cursor.redraw(); cursor.getDisplay().asyncExec( new Runnable() { public void run() { cursor.setFocus(); } } ); // enable action handlers actionGroup.activateGlobalActionHandlers(); } /** * {@inheritDoc} */ public void focusGained( FocusEvent e ) { } /** * {@inheritDoc} */ public void focusLost( FocusEvent e ) { editorClosed(); } /** * {@inheritDoc} */ public void keyPressed( KeyEvent e ) { if ( e.character == SWT.ESC && e.stateMask == SWT.NONE ) { e.doit = false; } } /** * {@inheritDoc} */ public void keyReleased( KeyEvent e ) { } /** * {@inheritDoc} */ public boolean isActive() { return isActive; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/ShowQuickFilterAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/ShowQuickFilterAction.java
/* * 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.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.action.Action; import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds; public class ShowQuickFilterAction extends Action { /** The Constant SHOW_QUICKFILTER_DIALOGSETTING_KEY. */ public static final String SHOW_QUICKFILTER_DIALOGSETTING_KEY = ShowQuickFilterAction.class.getName() + ".showQuickFilter"; //$NON-NLS-1$ /** The quick filter widget. */ private SearchResultEditorQuickFilterWidget quickFilterWidget; public ShowQuickFilterAction( SearchResultEditorQuickFilterWidget quickFilterWidget ) { super( Messages.getString( "ShowQuickFilterAction.ShowQuickFilter" ), AS_CHECK_BOX ); //$NON-NLS-1$ super.setToolTipText( Messages.getString( "ShowQuickFilterAction.ShowQuickFilterToolTip" ) ); //$NON-NLS-1$ super.setImageDescriptor( BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_FILTER ) ); super.setActionDefinitionId( IWorkbenchActionDefinitionIds.FIND_REPLACE ); super.setEnabled( true ); this.quickFilterWidget = quickFilterWidget; if ( BrowserUIPlugin.getDefault().getDialogSettings().get( SHOW_QUICKFILTER_DIALOGSETTING_KEY ) == null ) { BrowserUIPlugin.getDefault().getDialogSettings().put( SHOW_QUICKFILTER_DIALOGSETTING_KEY, false ); } super.setChecked( BrowserUIPlugin.getDefault().getDialogSettings().getBoolean( SHOW_QUICKFILTER_DIALOGSETTING_KEY ) ); quickFilterWidget.setActive( isChecked() ); } /** * {@inheritDoc} */ public void run() { boolean checked = isChecked(); super.setChecked( !checked ); BrowserUIPlugin.getDefault().getDialogSettings().put( SHOW_QUICKFILTER_DIALOGSETTING_KEY, isChecked() ); if ( quickFilterWidget != null ) { quickFilterWidget.setActive( isChecked() ); } } /** * {@inheritDoc} * * This implementation does nothing. Toggling of the checked state is done within the run() method. */ public void setChecked( boolean checked ) { } /** * Disposes this action. */ public void dispose() { quickFilterWidget = null; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false