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/editors/searchresult/SearchResultEditorNavigationLocation.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorNavigationLocation.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.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IMemento; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.NavigationLocation; /** * This class is used to mark the search result editor input to the navigation history. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorNavigationLocation extends NavigationLocation { /** * Creates a new instance of SearchResultEditorNavigationLocation. * * @param editor the search result editor */ SearchResultEditorNavigationLocation( SearchResultEditor editor ) { super( editor ); } /** * {@inheritDoc} */ public String getText() { ISearch search = getSearch(); if ( search != null ) { String connectionName = search.getBrowserConnection().getConnection() != null ? " - " //$NON-NLS-1$ + search.getBrowserConnection().getConnection().getName() : ""; //$NON-NLS-1$ return NLS.bind( Messages.getString( "SearchResultEditorNavigationLocation.Search" ), new String[] { search.getName() } ) //$NON-NLS-1$ + connectionName; } else { return super.getText(); } } /** * {@inheritDoc} */ public void saveState( IMemento memento ) { ISearch search = getSearch(); memento.putString( "SEARCH", search.getName() ); //$NON-NLS-1$ memento.putString( "CONNECTION", search.getBrowserConnection().getConnection().getId() ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void restoreState( IMemento memento ) { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById( memento.getString( "CONNECTION" ) ); //$NON-NLS-1$ ISearch search = connection.getSearchManager().getSearch( memento.getString( "SEARCH" ) ); //$NON-NLS-1$ super.setInput( new SearchResultEditorInput( search ) ); } /** * {@inheritDoc} */ public void restoreLocation() { IEditorPart editorPart = getEditorPart(); if ( editorPart instanceof SearchResultEditor ) { SearchResultEditor searchResultEditor = ( SearchResultEditor ) editorPart; searchResultEditor.setInput( ( SearchResultEditorInput ) getInput() ); } } /** * {@inheritDoc} */ public boolean mergeInto( INavigationLocation currentLocation ) { if ( currentLocation == null ) { return false; } if ( getClass() != currentLocation.getClass() ) { return false; } SearchResultEditorNavigationLocation location = ( SearchResultEditorNavigationLocation ) currentLocation; ISearch other = location.getSearch(); ISearch search = getSearch(); if ( other == null && search == null ) { return true; } else if ( other == null || search == null ) { return false; } else { return search.equals( other ); } } /** * {@inheritDoc} */ public void update() { } /** * Gets the search. * * @return the search */ private ISearch getSearch() { Object editorInput = getInput(); if ( editorInput instanceof SearchResultEditorInput ) { SearchResultEditorInput searchResultEditorInput = ( SearchResultEditorInput ) editorInput; ISearch search = searchResultEditorInput.getSearch(); if ( search != null ) { return search; } } return null; } /** * {@inheritDoc} */ public String toString() { return "" + getSearch(); //$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/searchresult/ShowLinksAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/ShowLinksAction.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.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.action.Action; /** * Action to enable/disable DNs as link. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowLinksAction extends Action { /** * Creates a new instance of ShowLinksAction. */ public ShowLinksAction() { super( Messages.getString( "ShowLinksAction.DNAsLink" ), AS_CHECK_BOX ); //$NON-NLS-1$ super.setToolTipText( getText() ); super.setEnabled( true ); super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ) ); } /** * {@inheritDoc} */ public void run() { BrowserUIPlugin.getDefault().getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS, super.isChecked() ); } /** * Disposes this action. */ public void 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/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SingleTabSearchResultEditorMatchingStrategy.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.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorMatchingStrategy; import org.eclipse.ui.IEditorReference; /** * Matching strategy for a single tab search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SingleTabSearchResultEditorMatchingStrategy implements IEditorMatchingStrategy { /** * Returns true if the input is a {@link SearchResultEditorInput}. */ public boolean matches( IEditorReference editorRef, IEditorInput input ) { if ( !( input instanceof SearchResultEditorInput ) ) { return false; } 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/searchresult/SearchResultEditorActionGroup.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorActionGroup.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.HashMap; import java.util.Iterator; 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.common.actions.CopyAction; import org.apache.directory.studio.ldapbrowser.common.actions.NewValueAction; import org.apache.directory.studio.ldapbrowser.common.actions.PropertiesAction; import org.apache.directory.studio.ldapbrowser.common.actions.RefreshAction; import org.apache.directory.studio.ldapbrowser.common.actions.ShowDecoratedValuesAction; import org.apache.directory.studio.ldapbrowser.common.actions.ValueEditorPreferencesAction; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager; import org.apache.directory.studio.ldapbrowser.common.actions.proxy.BrowserActionProxy; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; 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.CopyEntryAsCsvAction; 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.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.ldapbrowser.ui.actions.OpenSearchResultAction; import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.SearchResultEditorActionProxy; import org.apache.directory.studio.utils.ActionUtils; import org.apache.directory.studio.valueeditors.IValueEditor; 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.TableViewer; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ContributionItemFactory; /** * The SearchResultEditorActionGroup manages all actions of the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorActionGroup implements ActionHandlerManager, IMenuListener { /** The show Dn action. */ private ShowDNAction showDNAction; /** The show links action. */ private ShowLinksAction showLinksAction; /** The show decorated values action. */ private ShowDecoratedValuesAction showDecoratedValuesAction; /** The open search result editor preference page. */ private OpenSearchResultEditorPreferencePage openSearchResultEditorPreferencePage; /** The show quick filter action. */ private ShowQuickFilterAction showQuickFilterAction; /** The open default editor action. */ private SearchResultEditorActionProxy openDefaultValueEditorActionProxy; /** The open best editor action. */ private SearchResultEditorActionProxy openBestValueEditorActionProxy; /** The open editor actions. */ private SearchResultEditorActionProxy[] openValueEditorActionProxies; /** The open entry value editor action. */ private SearchResultEditorActionProxy openEntryValueEditorActionProxy; /** The open value editor preferences action. */ private ValueEditorPreferencesAction openValueEditorPreferencesAction; private static final String copyTableAction = "copyTableAction"; //$NON-NLS-1$ private static final String refreshSearchAction = "refreshSearchAction"; //$NON-NLS-1$ private final static String newValueAction = "newValueAction"; //$NON-NLS-1$ private final static String newSearchAction = "newSearchAction"; //$NON-NLS-1$ private static final String newBatchOperationAction = "newBatchOperationAction"; //$NON-NLS-1$ private final static String copyAction = "copyAction"; //$NON-NLS-1$ private final static String pasteAction = "pasteAction"; //$NON-NLS-1$ private final static String deleteAction = "deleteAction"; //$NON-NLS-1$ private static final String copyDnAction = "copyDnAction"; //$NON-NLS-1$ private static final String copyUrlAction = "copyUrlAction"; //$NON-NLS-1$ private static final String copyAttriuteDescriptionAction = "copyAttriuteDescriptionAction"; //$NON-NLS-1$ private static final String copyDisplayValueAction = "copyDisplayValueAction"; //$NON-NLS-1$ private static final String copyValueUtf8Action = "copyValueUtf8Action"; //$NON-NLS-1$ private static final String copyValueBase64Action = "copyValueBase64Action"; //$NON-NLS-1$ private static final String copyValueHexAction = "copyValueHexAction"; //$NON-NLS-1$ private static final String copyValueAsLdifAction = "copyValueAsLdifAction"; //$NON-NLS-1$ private static final String copySearchFilterAction = "copySearchFilterAction"; //$NON-NLS-1$ private static final String copyNotSearchFilterAction = "copyNotSearchFilterAction"; //$NON-NLS-1$ private static final String copyAndSearchFilterAction = "copyAndSearchFilterAction"; //$NON-NLS-1$ private static final String copyOrSearchFilterAction = "copyOrSearchFilterAction"; //$NON-NLS-1$ private static final String openSearchResultAction = "showEntryInSearchResultsAction"; //$NON-NLS-1$ private static final String locateDnInDitAction = "locateDnInDitAction"; //$NON-NLS-1$ private static final String showOcdAction = "showOcdAction"; //$NON-NLS-1$ private static final String showAtdAction = "showAtdAction"; //$NON-NLS-1$ private static final String showEqualityMrdAction = "showEqualityMrdAction"; //$NON-NLS-1$ private static final String showSubstringMrdAction = "showSubstringMrdAction"; //$NON-NLS-1$ private static final String showOrderingMrdAction = "showOrderingMrdAction"; //$NON-NLS-1$ private static final String showLsdAction = "showLsdAction"; //$NON-NLS-1$ private final static String propertyDialogAction = "propertyDialogAction"; //$NON-NLS-1$ /** The search result editor action map. */ private Map<String, SearchResultEditorActionProxy> searchResultEditorActionMap; /** The action bars. */ private IActionBars actionBars; /** The search result editor. */ private SearchResultEditor searchResultEditor; /** * Creates a new instance of SearchResultEditorActionGroup. * * @param searchResultEditor the search result editor */ public SearchResultEditorActionGroup( SearchResultEditor searchResultEditor ) { this.searchResultEditor = searchResultEditor; searchResultEditorActionMap = new HashMap<String, SearchResultEditorActionProxy>(); TableViewer viewer = searchResultEditor.getMainWidget().getViewer(); SearchResultEditorCursor cursor = searchResultEditor.getConfiguration().getCursor( viewer ); ValueEditorManager valueEditorManager = searchResultEditor.getConfiguration().getValueEditorManager( viewer ); showDNAction = new ShowDNAction(); showLinksAction = new ShowLinksAction(); showDecoratedValuesAction = new ShowDecoratedValuesAction(); openSearchResultEditorPreferencePage = new OpenSearchResultEditorPreferencePage(); showQuickFilterAction = new ShowQuickFilterAction( searchResultEditor.getMainWidget().getQuickFilterWidget() ); openBestValueEditorActionProxy = new SearchResultEditorActionProxy( cursor, new OpenBestEditorAction( viewer, cursor, valueEditorManager, this ) ); openDefaultValueEditorActionProxy = new SearchResultEditorActionProxy( cursor, new OpenDefaultEditorAction( viewer, cursor, valueEditorManager, openBestValueEditorActionProxy, this ) ); IValueEditor[] valueEditors = searchResultEditor.getConfiguration().getValueEditorManager( viewer ) .getAllValueEditors(); openValueEditorActionProxies = new SearchResultEditorActionProxy[valueEditors.length]; for ( int i = 0; i < openValueEditorActionProxies.length; i++ ) { openValueEditorActionProxies[i] = new SearchResultEditorActionProxy( cursor, new OpenEditorAction( viewer, cursor, valueEditorManager, valueEditors[i], this ) ); } openEntryValueEditorActionProxy = new SearchResultEditorActionProxy( cursor, new OpenEntryEditorAction( viewer, cursor, valueEditorManager, valueEditorManager.getEntryValueEditor(), this ) ); openValueEditorPreferencesAction = new ValueEditorPreferencesAction(); searchResultEditorActionMap.put( copyTableAction, new SearchResultEditorActionProxy( cursor, new CopyEntryAsCsvAction( CopyEntryAsCsvAction.MODE_TABLE ) ) ); searchResultEditorActionMap.put( refreshSearchAction, new SearchResultEditorActionProxy( cursor, new RefreshAction() ) ); searchResultEditorActionMap.put( newValueAction, new SearchResultEditorActionProxy( cursor, new NewValueAction() ) ); searchResultEditorActionMap.put( newSearchAction, new SearchResultEditorActionProxy( cursor, new NewSearchAction() ) ); searchResultEditorActionMap.put( newBatchOperationAction, new SearchResultEditorActionProxy( cursor, new NewBatchOperationAction() ) ); searchResultEditorActionMap.put( locateDnInDitAction, new SearchResultEditorActionProxy( cursor, new LocateDnInDitAction() ) ); searchResultEditorActionMap.put( openSearchResultAction, new SearchResultEditorActionProxy( cursor, new OpenSearchResultAction() ) ); searchResultEditorActionMap.put( showOcdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_OBJECTCLASS ) ) ); searchResultEditorActionMap.put( showAtdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ATTRIBUTETYPE ) ) ); searchResultEditorActionMap.put( showEqualityMrdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_EQUALITYMATCHINGRULE ) ) ); searchResultEditorActionMap.put( showSubstringMrdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SUBSTRINGMATCHINGRULE ) ) ); searchResultEditorActionMap.put( showOrderingMrdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_ORDERINGMATCHINGRULE ) ) ); searchResultEditorActionMap.put( showLsdAction, new SearchResultEditorActionProxy( cursor, new OpenSchemaBrowserAction( OpenSchemaBrowserAction.MODE_SYNTAX ) ) ); searchResultEditorActionMap.put( pasteAction, new SearchResultEditorActionProxy( cursor, new SearchResultEditorPasteAction() ) ); searchResultEditorActionMap.put( copyAction, new SearchResultEditorActionProxy( cursor, new CopyAction( ( BrowserActionProxy ) this.searchResultEditorActionMap.get( pasteAction ), valueEditorManager ) ) ); searchResultEditorActionMap.put( deleteAction, new SearchResultEditorActionProxy( cursor, new SearchResultDeleteAction() ) ); searchResultEditorActionMap.put( copyDnAction, new SearchResultEditorActionProxy( cursor, new CopyDnAction() ) ); searchResultEditorActionMap .put( copyUrlAction, new SearchResultEditorActionProxy( cursor, new CopyUrlAction() ) ); searchResultEditorActionMap.put( copyAttriuteDescriptionAction, new SearchResultEditorActionProxy( cursor, new CopyAttributeDescriptionAction() ) ); searchResultEditorActionMap.put( copyDisplayValueAction, new SearchResultEditorActionProxy( cursor, new CopyValueAction( CopyValueAction.Mode.DISPLAY, valueEditorManager ) ) ); searchResultEditorActionMap.put( copyValueUtf8Action, new SearchResultEditorActionProxy( cursor, new CopyValueAction( CopyValueAction.Mode.UTF8, valueEditorManager ) ) ); searchResultEditorActionMap.put( copyValueBase64Action, new SearchResultEditorActionProxy( cursor, new CopyValueAction( CopyValueAction.Mode.BASE64, valueEditorManager ) ) ); searchResultEditorActionMap.put( copyValueHexAction, new SearchResultEditorActionProxy( cursor, new CopyValueAction( CopyValueAction.Mode.HEX, valueEditorManager ) ) ); searchResultEditorActionMap.put( copyValueAsLdifAction, new SearchResultEditorActionProxy( cursor, new CopyValueAction( CopyValueAction.Mode.LDIF, valueEditorManager ) ) ); searchResultEditorActionMap.put( copySearchFilterAction, new SearchResultEditorActionProxy( cursor, new CopySearchFilterAction( CopySearchFilterAction.MODE_EQUALS ) ) ); searchResultEditorActionMap.put( copyNotSearchFilterAction, new SearchResultEditorActionProxy( cursor, new CopySearchFilterAction( CopySearchFilterAction.MODE_NOT ) ) ); searchResultEditorActionMap.put( copyAndSearchFilterAction, new SearchResultEditorActionProxy( cursor, new CopySearchFilterAction( CopySearchFilterAction.MODE_AND ) ) ); searchResultEditorActionMap.put( copyOrSearchFilterAction, new SearchResultEditorActionProxy( cursor, new CopySearchFilterAction( CopySearchFilterAction.MODE_OR ) ) ); searchResultEditorActionMap.put( propertyDialogAction, new SearchResultEditorActionProxy( cursor, new PropertiesAction() ) ); } /** * Disposes this action group. */ public void dispose() { if ( searchResultEditor != null ) { showDecoratedValuesAction = null; showDNAction.dispose(); showDNAction = null; showLinksAction.dispose(); showLinksAction = null; openSearchResultEditorPreferencePage = null; showQuickFilterAction.dispose(); showQuickFilterAction = null; openDefaultValueEditorActionProxy.dispose(); openDefaultValueEditorActionProxy = null; openBestValueEditorActionProxy.dispose(); openBestValueEditorActionProxy = null; for ( int i = 0; i < openValueEditorActionProxies.length; i++ ) { openValueEditorActionProxies[i].dispose(); openValueEditorActionProxies[i] = null; } openEntryValueEditorActionProxy.dispose(); openEntryValueEditorActionProxy = null; openValueEditorPreferencesAction = null; for ( Iterator<String> it = this.searchResultEditorActionMap.keySet().iterator(); it.hasNext(); ) { String key = it.next(); SearchResultEditorActionProxy action = searchResultEditorActionMap.get( key ); action.dispose(); action = null; it.remove(); } searchResultEditorActionMap.clear(); searchResultEditorActionMap = null; actionBars = null; searchResultEditor = null; } } /** * Fills the tool bar. * * @param toolBarManager the tool bar manager */ public void fillToolBar( IToolBarManager toolBarManager ) { toolBarManager.add( new Separator() ); toolBarManager.add( searchResultEditorActionMap.get( newValueAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( searchResultEditorActionMap.get( deleteAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( searchResultEditorActionMap.get( refreshSearchAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( searchResultEditorActionMap.get( copyTableAction ) ); toolBarManager.add( new Separator() ); toolBarManager.add( showQuickFilterAction ); toolBarManager.update( true ); } /** * Fills the menu. * * @param menuManager the menu manager */ public void fillMenu( IMenuManager menuManager ) { menuManager.add( showDNAction ); menuManager.add( showLinksAction ); menuManager.add( showDecoratedValuesAction ); menuManager.add( new Separator() ); menuManager.add( openSearchResultEditorPreferencePage ); menuManager.addMenuListener( new IMenuListener() { public void menuAboutToShow( IMenuManager manager ) { showDecoratedValuesAction.setChecked( !BrowserCommonActivator.getDefault().getPreferenceStore() .getBoolean( BrowserCommonConstants.PREFERENCE_SHOW_RAW_VALUES ) ); } } ); menuManager.update( true ); } /** * Enable global action handlers. * * @param actionBars the action bars */ public void enableGlobalActionHandlers( IActionBars actionBars ) { this.actionBars = actionBars; } /** * Fills the context menu. * * @param menuManager the menu manager */ public void fillContextMenu( IMenuManager menuManager ) { menuManager.setRemoveAllWhenShown( true ); menuManager.addMenuListener( this ); } /** * {@inheritDoc} */ public void menuAboutToShow( IMenuManager menuManager ) { // new menuManager.add( searchResultEditorActionMap.get( newValueAction ) ); menuManager.add( searchResultEditorActionMap.get( newSearchAction ) ); menuManager.add( searchResultEditorActionMap.get( newBatchOperationAction ) ); menuManager.add( new Separator() ); // navigation menuManager.add( searchResultEditorActionMap.get( locateDnInDitAction ) ); menuManager.add( searchResultEditorActionMap.get( openSearchResultAction ) ); MenuManager schemaMenuManager = new MenuManager( Messages .getString( "SearchResultEditorActionGroup.OpenSchemaBrowser" ) ); //$NON-NLS-1$ schemaMenuManager.add( searchResultEditorActionMap.get( showOcdAction ) ); schemaMenuManager.add( searchResultEditorActionMap.get( showAtdAction ) ); schemaMenuManager.add( searchResultEditorActionMap.get( showEqualityMrdAction ) ); schemaMenuManager.add( searchResultEditorActionMap.get( showSubstringMrdAction ) ); schemaMenuManager.add( searchResultEditorActionMap.get( showOrderingMrdAction ) ); schemaMenuManager.add( searchResultEditorActionMap.get( showLsdAction ) ); menuManager.add( schemaMenuManager ); MenuManager showInSubMenu = new MenuManager( Messages.getString( "SearchResultEditorActionGroup.ShowIn" ) ); //$NON-NLS-1$ showInSubMenu.add( ContributionItemFactory.VIEWS_SHOW_IN.create( PlatformUI.getWorkbench() .getActiveWorkbenchWindow() ) ); menuManager.add( showInSubMenu ); menuManager.add( new Separator() ); // copy, paste, delete menuManager.add( searchResultEditorActionMap.get( copyAction ) ); menuManager.add( searchResultEditorActionMap.get( pasteAction ) ); menuManager.add( searchResultEditorActionMap.get( deleteAction ) ); MenuManager advancedMenuManager = new MenuManager( Messages .getString( "SearchResultEditorActionGroup.Advanced" ) ); //$NON-NLS-1$ advancedMenuManager.add( searchResultEditorActionMap.get( copyDnAction ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyUrlAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( searchResultEditorActionMap.get( copyAttriuteDescriptionAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( searchResultEditorActionMap.get( copyDisplayValueAction ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyValueUtf8Action ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyValueBase64Action ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyValueHexAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( searchResultEditorActionMap.get( copyValueAsLdifAction ) ); advancedMenuManager.add( new Separator() ); advancedMenuManager.add( searchResultEditorActionMap.get( copySearchFilterAction ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyNotSearchFilterAction ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyAndSearchFilterAction ) ); advancedMenuManager.add( searchResultEditorActionMap.get( copyOrSearchFilterAction ) ); menuManager.add( advancedMenuManager ); menuManager.add( new Separator() ); // edit menuManager.add( openDefaultValueEditorActionProxy ); MenuManager editorMenuManager = new MenuManager( Messages.getString( "SearchResultEditorActionGroup.EditValue" ) ); //$NON-NLS-1$ if ( openBestValueEditorActionProxy.isEnabled() ) { editorMenuManager.add( openBestValueEditorActionProxy ); editorMenuManager.add( new Separator() ); } for ( int i = 0; i < openValueEditorActionProxies.length; i++ ) { if ( openValueEditorActionProxies[i].isEnabled() && ( ( OpenEditorAction ) openValueEditorActionProxies[i].getAction() ).getValueEditor().getClass() != ( ( OpenBestEditorAction ) openBestValueEditorActionProxy .getAction() ).getBestValueEditor().getClass() ) { editorMenuManager.add( openValueEditorActionProxies[i] ); } } editorMenuManager.add( new Separator() ); editorMenuManager.add( openValueEditorPreferencesAction ); menuManager.add( editorMenuManager ); menuManager.add( openEntryValueEditorActionProxy ); menuManager.add( new Separator() ); // refresh menuManager.add( searchResultEditorActionMap.get( refreshSearchAction ) ); menuManager.add( new Separator() ); // additions menuManager.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); // / properties menuManager.add( searchResultEditorActionMap.get( propertyDialogAction ) ); } /** * {@inheritDoc} */ public void activateGlobalActionHandlers() { if ( actionBars != null ) { actionBars .setGlobalActionHandler( ActionFactory.COPY.getId(), searchResultEditorActionMap.get( copyAction ) ); actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), searchResultEditorActionMap .get( pasteAction ) ); actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), searchResultEditorActionMap .get( deleteAction ) ); actionBars.setGlobalActionHandler( ActionFactory.REFRESH.getId(), searchResultEditorActionMap .get( refreshSearchAction ) ); actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), searchResultEditorActionMap .get( propertyDialogAction ) ); actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), showQuickFilterAction ); actionBars.updateActionBars(); } IAction nva = searchResultEditorActionMap.get( newValueAction ); ActionUtils.activateActionHandler( nva ); IAction lid = searchResultEditorActionMap.get( locateDnInDitAction ); ActionUtils.activateActionHandler( lid ); IAction osr = searchResultEditorActionMap.get( openSearchResultAction ); ActionUtils.activateActionHandler( osr ); ActionUtils.activateActionHandler( openDefaultValueEditorActionProxy ); ActionUtils.activateActionHandler( openEntryValueEditorActionProxy ); } /** * {@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.REFRESH.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), null ); actionBars.setGlobalActionHandler( ActionFactory.PROPERTIES.getId(), null ); actionBars.updateActionBars(); } IAction nva = searchResultEditorActionMap.get( newValueAction ); ActionUtils.deactivateActionHandler( nva ); IAction lid = searchResultEditorActionMap.get( locateDnInDitAction ); ActionUtils.deactivateActionHandler( lid ); IAction osr = searchResultEditorActionMap.get( openSearchResultAction ); ActionUtils.deactivateActionHandler( osr ); ActionUtils.deactivateActionHandler( openDefaultValueEditorActionProxy ); ActionUtils.deactivateActionHandler( openEntryValueEditorActionProxy ); } /** * Gets the open best editor action. * * @return the open best editor action */ public OpenBestEditorAction getOpenBestEditorAction() { return ( OpenBestEditorAction ) openBestValueEditorActionProxy.getAction(); } /** * Sets the input. * * @param search the new input */ public void setInput( ISearch search ) { for ( SearchResultEditorActionProxy action : searchResultEditorActionMap.values() ) { action.inputChanged( search ); } } /** * Checks if is editor active. * * @return true, if is editor active */ public boolean isEditorActive() { if ( ( ( AbstractOpenEditorAction ) openDefaultValueEditorActionProxy.getAction() ).isActive() ) { return true; } if ( ( ( AbstractOpenEditorAction ) openBestValueEditorActionProxy.getAction() ).isActive() ) { return true; } if ( ( ( AbstractOpenEditorAction ) openEntryValueEditorActionProxy.getAction() ).isActive() ) { return true; } for ( int i = 0; i < openValueEditorActionProxies.length; i++ ) { if ( ( ( AbstractOpenEditorAction ) openValueEditorActionProxies[i].getAction() ).isActive() ) { 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/editors/searchresult/SearchResultEditorContentProvider.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorContentProvider.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.core.model.ISearch; 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.ILazyContentProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; /** * The SearchResultEditorContentProvider implements the content provider for * the search resutl editor. It accepts an {@link ISearch} as input. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorContentProvider implements ILazyContentProvider { /** The main widget. */ private SearchResultEditorWidget mainWidget; /** The configuration. */ private SearchResultEditorConfiguration configuration; /** The input. */ private Object input; /** The elements. */ private Object[] elements; /** The filtered and sorted elements. */ private Object[] filteredAndSortedElements; /** * Creates a new instance of SearchResultEditorContentProvider. * * @param mainWidget the main widget * @param configuration the configuration */ public SearchResultEditorContentProvider( SearchResultEditorWidget mainWidget, SearchResultEditorConfiguration configuration ) { this.mainWidget = mainWidget; this.configuration = configuration; this.configuration.getFilter().connect( this ); this.configuration.getSorter().connect( this ); } /** * {@inheritDoc} */ public void dispose() { mainWidget = null; configuration = null; elements = null; filteredAndSortedElements = null; } /** * Refreshes the viewer. */ public void refresh() { filterAndSort(); mainWidget.getViewer().refresh(); } /** * Filters and sorts the viewer. */ private void filterAndSort() { filteredAndSortedElements = elements; // filter and sort, use Job if too much elements if ( configuration.getFilter().isFiltered() || configuration.getSorter().isSorted() ) { if ( elements.length > BrowserUIPlugin.getDefault().getPreferenceStore() .getInt( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT ) && mainWidget.getViewer() != null && !mainWidget.getViewer().getTable().isDisposed() ) { // deactivate fitering and sorting for large data set // FilterAndSortRunnable runnable = new FilterAndSortRunnable( configuration, mainWidget, elements ); // RunnableContextRunner.execute( runnable, null, true ); // filteredAndSortedElements = runnable.getFilteredAndSortedElements(); } else if ( elements.length > 0 && mainWidget.getViewer() != null && !mainWidget.getViewer().getTable().isDisposed() ) { filteredAndSortedElements = configuration.getFilter().filter( mainWidget.getViewer(), "", elements ); //$NON-NLS-1$ configuration.getSorter().sort( mainWidget.getViewer(), filteredAndSortedElements ); } } // update virtual table mainWidget.getViewer().setItemCount( filteredAndSortedElements.length ); // update state String url = ""; //$NON-NLS-1$ boolean enabled = true; if ( input instanceof ISearch ) { ISearch search = ( ISearch ) input; if ( filteredAndSortedElements.length < elements.length ) { url += filteredAndSortedElements.length + Messages.getString( "SearchResultEditorContentProvider.Of" ); //$NON-NLS-1$ } if ( search.getSearchResults() == null ) { url += Messages.getString( "SearchResultEditorContentProvider.SearchNotPerformed" ); //$NON-NLS-1$ enabled = false; } else if ( search.getSearchResults().length == 1 ) { url += search.getSearchResults().length + Messages.getString( "SearchResultEditorContentProvider.Result" ); //$NON-NLS-1$ } else { url += search.getSearchResults().length + Messages.getString( "SearchResultEditorContentProvider.Results" ); //$NON-NLS-1$ } // url += search.getURL(); url += Messages.getString( "SearchResultEditorContentProvider.SearchBase" ) + search.getSearchBase().getName() + " - "; //$NON-NLS-1$ //$NON-NLS-2$ url += Messages.getString( "SearchResultEditorContentProvider.Filter" ) + search.getFilter(); //$NON-NLS-1$ boolean showDn = BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) || search.getReturningAttributes().length == 0; configuration.getFilter().inputChanged( search, showDn ); configuration.getSorter().inputChanged( search, showDn ); } else { url = Messages.getString( "SearchResultEditorContentProvider.NoSearchSelected" ); //$NON-NLS-1$ enabled = false; } if ( mainWidget.getInfoText() != null && !mainWidget.getInfoText().isDisposed() ) { mainWidget.getInfoText().setText( url ); } if ( mainWidget.getQuickFilterWidget() != null ) { mainWidget.getQuickFilterWidget().setEnabled( enabled ); } if ( mainWidget.getViewer() != null && !mainWidget.getViewer().getTable().isDisposed() ) { mainWidget.getViewer().getTable().setEnabled( enabled ); } } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { this.input = newInput; this.elements = getElements( newInput ); } /** * Gets the elements. * * @param inputElement the input element * * @return the elements */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof ISearch ) { ISearch search = ( ISearch ) inputElement; ISearchResult[] results = search.getSearchResults(); if ( results != null ) { return results; } } return new Object[0]; } /** * Gets the viewer. * * @return the viewer */ public TableViewer getViewer() { return mainWidget.getViewer(); } /** * {@inheritDoc} */ public void updateElement( int index ) { if ( filteredAndSortedElements != null && filteredAndSortedElements.length > 0 && index < filteredAndSortedElements.length ) { mainWidget.getViewer().replace( filteredAndSortedElements[index], 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/editors/searchresult/OpenBestEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.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.Collection; import org.apache.directory.api.ldap.model.schema.AttributeType; 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.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.apache.directory.studio.valueeditors.IValueEditor; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.osgi.util.NLS; /** * The OpenBestEditorAction is used to edit a value with the best value editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenBestEditorAction extends AbstractOpenEditorAction { /** The best value editor. */ private IValueEditor bestValueEditor; /** * Creates a new instance of OpenBestEditorAction. * * @param viewer the viewer * @param cursor the cursor * @param valueEditorManager the value editor manager * @param actionGroup the action group */ public OpenBestEditorAction( TableViewer viewer, SearchResultEditorCursor cursor, ValueEditorManager valueEditorManager, SearchResultEditorActionGroup actionGroup ) { super( viewer, cursor, valueEditorManager, actionGroup ); } /** * Gets the best value editor. * * @return the best value editor */ public IValueEditor getBestValueEditor() { return this.bestValueEditor; } /** * {@inheritDoc} */ public void dispose() { bestValueEditor = null; super.dispose(); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return isEnabled() ? bestValueEditor.getValueEditorImageDescriptor() : null; } /** * {@inheritDoc} */ public String getText() { return isEnabled() ? bestValueEditor.getValueEditorName() : null; } /** * {@inheritDoc} */ public boolean isEnabled() { if ( getSelectedSearchResults().length == 1 && getSelectedProperties().length == 1 && viewer.getCellModifier().canModify( getSelectedSearchResults()[0], getSelectedProperties()[0] ) ) { if ( getSelectedAttributeHierarchies().length == 0 ) { bestValueEditor = valueEditorManager.getCurrentValueEditor( getSelectedSearchResults()[0].getEntry(), getSelectedProperties()[0] ); } else { bestValueEditor = valueEditorManager.getCurrentValueEditor( getSelectedAttributeHierarchies()[0] ); } super.cellEditor = bestValueEditor.getCellEditor(); return true; } else { super.cellEditor = null; return false; } } /** * {@inheritDoc} */ public void run() { boolean ok = true; // validate non-modifiable attributes AttributeHierarchy[] attributeHierarchies = getSelectedAttributeHierarchies(); if ( attributeHierarchies.length == 1 ) { AttributeHierarchy attributeHierarchy = attributeHierarchies[0]; StringBuffer message = new StringBuffer(); if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 ) { // validate if value is allowed IEntry entry = attributeHierarchy.getAttribute().getEntry(); Collection<AttributeType> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry ); AttributeType atd = attributeHierarchy.getAttribute().getAttributeTypeDescription(); if ( !allAtds.contains( atd ) ) { message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.AttributeNotInSubSchema" ), //$NON-NLS-1$ attributeHierarchy.getAttribute().getDescription() ) ); message.append( BrowserCoreConstants.LINE_SEPARATOR ); message.append( BrowserCoreConstants.LINE_SEPARATOR ); } } if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 && attributeHierarchy.getAttributeDescription().equalsIgnoreCase( attributeHierarchy.getAttribute().getValues()[0].getAttribute().getDescription() ) && !attributeHierarchy.getAttribute().getValues()[0].isRdnPart() ) { // validate non-modifiable attributes IValue value = attributeHierarchy.getAttribute().getValues()[0]; if ( !value.isEmpty() && !SchemaUtils.isModifiable( value.getAttribute().getAttributeTypeDescription() ) ) { message .append( NLS .bind( Messages.getString( "OpenBestEditorAction.EditValueNotModifiable" ), value.getAttribute().getDescription() ) ); //$NON-NLS-1$ message.append( BrowserCoreConstants.LINE_SEPARATOR ); message.append( BrowserCoreConstants.LINE_SEPARATOR ); } } if ( message.length() > 0 ) { message.append( Messages.getString( "OpenBestEditorAction.EditValueQuestion" ) ); //$NON-NLS-1$ ok = MessageDialog.openConfirm( getShell(), getText(), message.toString() ); } } if ( ok ) { super.run(); } } }
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/FilterAndSortRunnable.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/FilterAndSortRunnable.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.common.core.jobs.StudioProgressMonitor; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.jobs.StudioConnectionRunnableWithProgress; /** * Runnable to filter and sort the search result editor asynchronously to avoid * freezing the GUI. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class FilterAndSortRunnable implements StudioConnectionRunnableWithProgress { /** The configuration. */ private SearchResultEditorConfiguration configuration; /** The main widget. */ private SearchResultEditorWidget mainWidget; /** All elements, unfiltered and unsorted. */ private Object[] elements; /** The filtered and sorted elements. */ private Object[] filteredAndSortedElements; /** * Creates a new instance of FilterAndSortRunnable. * * @param configuration the configuration * @param mainWidget the main widget * @param elements the elements, unfiltered and unsorted */ public FilterAndSortRunnable( SearchResultEditorConfiguration configuration, SearchResultEditorWidget mainWidget, Object[] elements ) { this.configuration = configuration; this.mainWidget = mainWidget; this.elements = elements; } /** * {@inheritDoc} */ public String getName() { return ""; //$NON-NLS-1$ } /** * {@inheritDoc} */ public Object[] getLockedObjects() { return new Object[0]; } /** * {@inheritDoc} */ public void run( StudioProgressMonitor monitor ) { monitor.beginTask( Messages.getString( "FilterAndSortRunnable.FilterAndSort" ), 3 ); //$NON-NLS-1$ monitor.worked( 1 ); monitor.setTaskName( Messages.getString( "FilterAndSortRunnable.FilterAndSort" ) ); //$NON-NLS-1$ monitor.reportProgress( Messages.getString( "FilterAndSortRunnable.Filtering" ) ); //$NON-NLS-1$ this.filteredAndSortedElements = this.configuration.getFilter().filter( this.mainWidget.getViewer(), "", //$NON-NLS-1$ elements ); monitor.worked( 1 ); monitor.reportProgress( Messages.getString( "FilterAndSortRunnable.Sorting" ) ); //$NON-NLS-1$ this.configuration.getSorter().sort( this.mainWidget.getViewer(), this.filteredAndSortedElements ); monitor.worked( 1 ); } /** * {@inheritDoc} */ public Connection[] getConnections() { return null; } /** * {@inheritDoc} */ public String getErrorMessage() { return ""; //$NON-NLS-1$ } /** * Gets the filtered and sorted elements. * * @return the filtered and sorted elements */ public Object[] getFilteredAndSortedElements() { return filteredAndSortedElements; } }
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/OpenEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenEditorAction.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 org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy; import org.apache.directory.studio.valueeditors.IValueEditor; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.TableViewer; /** * The OpenEditorAction is used to edit a value with a specific value editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenEditorAction extends AbstractOpenEditorAction { /** The value editor. */ private IValueEditor valueEditor; /** * Creates a new instance of OpenEditorAction. * * @param viewer the viewer * @param cursor the cursor * @param valueEditorManager the value editor manager * @param valueEditor the value editor * @param actionGroup the action group */ public OpenEditorAction( TableViewer viewer, SearchResultEditorCursor cursor, ValueEditorManager valueEditorManager, IValueEditor valueEditor, SearchResultEditorActionGroup actionGroup ) { super( viewer, cursor, valueEditorManager, actionGroup ); super.cellEditor = valueEditor.getCellEditor(); this.valueEditor = valueEditor; } /** * Gets the value editor. * * @return the value editor */ public IValueEditor getValueEditor() { return valueEditor; } /** * {@inheritDoc} */ public void run() { valueEditorManager.setUserSelectedValueEditor( valueEditor ); super.run(); } /** * {@inheritDoc} */ public void dispose() { valueEditor = null; super.dispose(); } /** * {@inheritDoc} */ public String getCommandId() { return null; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return valueEditor.getValueEditorImageDescriptor(); } /** * {@inheritDoc} */ public String getText() { return valueEditor.getValueEditorName(); } /** * {@inheritDoc} */ public boolean isEnabled() { if ( getSelectedSearchResults().length == 1 && getSelectedProperties().length == 1 && viewer.getCellModifier().canModify( getSelectedSearchResults()[0], getSelectedProperties()[0] ) ) { IValueEditor[] alternativeVps; if ( getSelectedAttributeHierarchies().length == 0 ) { return false; } else { AttributeHierarchy ah = getSelectedAttributeHierarchies()[0]; alternativeVps = valueEditorManager.getAlternativeValueEditors( ah ); return Arrays.asList( alternativeVps ).contains( valueEditor ) && valueEditor.getRawValue( ah ) != null; } } else { 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/searchresult/SearchResultEditorPasteAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorPasteAction.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.common.ui.ClipboardUtils; import org.apache.directory.studio.ldapbrowser.common.actions.PasteAction; import org.apache.directory.studio.ldapbrowser.common.dnd.ValuesTransfer; import org.apache.directory.studio.ldapbrowser.core.model.IAttribute; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.impl.Value; import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification; /** * This class implements the paste action for the search result editor. * It copies the value af a copied attribute-value to another attribute. * It does not invoke an UpdateEntryRunnable but only updates the model. */ public class SearchResultEditorPasteAction extends PasteAction { /** * Creates a new instance of SearchResultEditorPasteAction. */ public SearchResultEditorPasteAction() { super(); } /** * {@inheritDoc} */ public String getText() { IValue[] values = getValuesToPaste(); if ( values != null ) { return values.length > 1 ? Messages.getString( "SearchResultEditorPasteAction.PasteValues" ) : Messages.getString( "SearchResultEditorPasteAction.PasteValue" ); //$NON-NLS-1$ //$NON-NLS-2$ } return Messages.getString( "SearchResultEditorPasteAction.Paste" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { if ( getValuesToPaste() != null ) { return true; } return false; } /** * {@inheritDoc} */ public void run() { IValue[] values = getValuesToPaste(); if ( values != null ) { IAttribute attribute = getSelectedAttributeHierarchies()[0].getAttribute(); IEntry entry = attribute.getEntry(); IValue[] newValues = new IValue[values.length]; for ( int v = 0; v < values.length; v++ ) { newValues[v] = new Value( attribute, values[v].getRawValue() ); } // only modify the model // the modification at the directory is done by SearchResultEditor.entryUpdateListener new CompoundModification().createValues( entry, newValues ); } } /** * Conditions: * <li> an search result and a mv-attribute are selected * <li> there are IValues in clipboard. * * @return the values to paste */ private IValue[] getValuesToPaste() { if ( getSelectedEntries().length + getSelectedBookmarks().length + getSelectedValues().length + getSelectedAttributes().length + getSelectedSearches().length == 0 && getSelectedSearchResults().length == 1 && getSelectedAttributeHierarchies().length == 1 && getSelectedAttributeHierarchies()[0].size() == 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/editors/searchresult/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/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.searchresult; 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/searchresult/SearchResultEditorQuickFilterWidget.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorQuickFilterWidget.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.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; /** * The SearchResultEditorQuickFilterWidget implements an instant search * for the search result edtior. It contains one fields for all displayed values. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorQuickFilterWidget { /** The filter. */ private SearchResultEditorFilter filter; /** The parent. */ private Composite parent; /** The composite. */ private Composite composite; /** The inner composite. */ private Composite innerComposite; /** The quick filter value text. */ private Text quickFilterValueText; /** The clear quick filter button. */ private Button clearQuickFilterButton; /** * Creates a new instance of SearchResultEditorQuickFilterWidget. * * @param filter the filter */ public SearchResultEditorQuickFilterWidget( SearchResultEditorFilter filter ) { this.filter = filter; } /** * Creates the outer composite. * * @param parent the parent */ public void createComposite( Composite parent ) { this.parent = parent; composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); GridLayout gl = new GridLayout(); gl.marginHeight = 2; gl.marginWidth = 2; composite.setLayout( gl ); // Setting the default width and height of the composite to 0 GridData compositeGridData = new GridData( SWT.NONE, SWT.NONE, false, false ); compositeGridData.heightHint = 0; compositeGridData.widthHint = 0; composite.setLayoutData( compositeGridData ); innerComposite = null; } /** * Creates the inner composite with its input fields. */ private void create() { // Reseting the layout of the composite to be displayed correctly GridData compositeGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); composite.setLayoutData( compositeGridData ); innerComposite = BaseWidgetUtils.createColumnContainer( this.composite, 2, 1 ); quickFilterValueText = new Text( innerComposite, SWT.BORDER ); quickFilterValueText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); quickFilterValueText.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { filter.setQuickFilterValue( quickFilterValueText.getText() ); clearQuickFilterButton.setEnabled( !"".equals( quickFilterValueText.getText() ) ); //$NON-NLS-1$ } } ); clearQuickFilterButton = new Button( innerComposite, SWT.PUSH ); clearQuickFilterButton.setToolTipText( Messages .getString( "SearchResultEditorQuickFilterWidget.ClearQuickFilterToolTip" ) ); //$NON-NLS-1$ clearQuickFilterButton.setImage( BrowserCommonActivator.getDefault() .getImage( BrowserCommonConstants.IMG_CLEAR ) ); clearQuickFilterButton.setEnabled( false ); clearQuickFilterButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { if ( !"".equals( quickFilterValueText.getText() ) ) //$NON-NLS-1$ quickFilterValueText.setText( "" ); //$NON-NLS-1$ } } ); setEnabled( composite.isEnabled() ); composite.layout( true, true ); parent.layout( true, true ); } /** * Destroys the inner widget. */ private void destroy() { // Reseting the layout of the composite with a width and height set to 0 GridData compositeGridData = new GridData( SWT.NONE, SWT.NONE, false, false ); compositeGridData.heightHint = 0; compositeGridData.widthHint = 0; composite.setLayoutData( compositeGridData ); if ( !"".equals( quickFilterValueText.getText() ) ) //$NON-NLS-1$ { quickFilterValueText.setText( "" ); //$NON-NLS-1$ } innerComposite.dispose(); innerComposite = null; composite.layout( true, true ); parent.layout( true, true ); } /** * Disposes this widget. */ public void dispose() { if ( innerComposite != null && !innerComposite.isDisposed() ) { quickFilterValueText.dispose(); quickFilterValueText = null; clearQuickFilterButton = null; innerComposite = null; } if ( filter != null ) { composite.dispose(); composite = null; parent = null; filter = null; } } /** * Enables or disables this quick filter widget. * * @param enabled true to enable this quick filter widget, false to disable it */ public void setEnabled( boolean enabled ) { if ( composite != null && !composite.isDisposed() ) { composite.setEnabled( enabled ); } if ( innerComposite != null && !innerComposite.isDisposed() ) { innerComposite.setEnabled( enabled ); quickFilterValueText.setEnabled( enabled ); clearQuickFilterButton.setEnabled( enabled ); } } /** * Activates or deactivates this quick filter widget. * * @param visible true to create this quick filter widget, false to destroy it */ public void setActive( boolean visible ) { if ( visible && innerComposite == null && composite != null ) { create(); this.quickFilterValueText.setFocus(); } else if ( !visible && innerComposite != null && composite != null ) { destroy(); } } }
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/ShowDNAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/ShowDNAction.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.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.action.Action; /** * Action to show/hide the Dn column. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowDNAction extends Action { /** * Creates a new instance of ShowDNAction. */ public ShowDNAction() { super( Messages.getString( "ShowDNAction.ShowDN" ), AS_CHECK_BOX ); //$NON-NLS-1$ super.setToolTipText( getText() ); super.setEnabled( true ); super.setChecked( BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) ); } /** * {@inheritDoc} */ public void run() { BrowserUIPlugin.getDefault().getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN, super.isChecked() ); } /** * Disposes this action. */ public void 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/editors/searchresult/OpenEntryEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/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.searchresult; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; 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.TableViewer; 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 cursor the cursor * @param valueEditorManager the value editor manager * @param valueEditor the value editor * @param actionGroup the action group */ public OpenEntryEditorAction( TableViewer viewer, SearchResultEditorCursor cursor, ValueEditorManager valueEditorManager, IValueEditor valueEditor, SearchResultEditorActionGroup actionGroup ) { super( viewer, cursor, valueEditorManager, actionGroup ); super.cellEditor = valueEditor.getCellEditor(); this.valueEditor = valueEditor; } /** * Gets the value editor. * * @return the value editor */ public IValueEditor getValueEditor() { return valueEditor; } /** * {@inheritDoc} */ public void run() { IEntry entry = getSelectedSearchResults().length > 0 ? getSelectedSearchResults()[0].getEntry() : 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 null; } /** * {@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/searchresult/SearchResultEditorCursor.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCursor.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 java.util.Iterator; import java.util.List; 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.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.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute; import org.apache.directory.studio.ldapbrowser.core.model.impl.SearchResult; import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableCursor; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Display; /** * The cursor implementation for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorCursor extends TableCursor implements ISelectionProvider, EntryUpdateListener { /** The viewer. */ private TableViewer viewer; /** The selection changes listener list. */ private List<ISelectionChangedListener> selectionChangesListenerList; /** The cloned reference copy of the search result under the cursor */ private ISearchResult referenceCopy; /** The cloned working copy of the search result under the cursor */ private ISearchResult workingCopy; /** * Creates a new instance of SearchResultEditorCursor. * * @param viewer the viewer */ public SearchResultEditorCursor( TableViewer viewer ) { super( viewer.getTable(), SWT.NONE ); this.viewer = viewer; this.selectionChangesListenerList = new ArrayList<ISelectionChangedListener>(); setBackground( Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION ) ); setForeground( Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION_TEXT ) ); EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); initSelectionChecker(); initSelectionProvider(); } /** * Initializes the selection checker. */ private void initSelectionChecker() { addSelectionListener( new SelectionListener() { public void widgetSelected( SelectionEvent e ) { checkSelection(); } public void widgetDefaultSelected( SelectionEvent e ) { checkSelection(); } private void checkSelection() { if ( viewer != null && viewer.getColumnProperties() != null && viewer.getColumnProperties().length - 1 < getColumn() ) { setSelection( getRow(), viewer.getColumnProperties().length - 1 ); } } } ); } /** * Initializes the selection provider. */ private void initSelectionProvider() { addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { for ( Iterator<?> it = selectionChangesListenerList.iterator(); it.hasNext(); ) { ( ( ISelectionChangedListener ) it.next() ).selectionChanged( new SelectionChangedEvent( SearchResultEditorCursor.this, getSelection() ) ); } } } ); } /** * {@inheritDoc} */ public boolean setFocus() { return super.setFocus(); } /** * {@inheritDoc} */ public void dispose() { EventRegistry.removeEntryUpdateListener( this ); viewer = null; super.dispose(); } /** * {@inheritDoc} */ public void entryUpdated( EntryModificationEvent event ) { viewer.refresh(); redraw(); } /** * Gets the selected property. * * @return the selected property */ public String getSelectedProperty() { if ( !isDisposed() && getRow() != null && viewer != null && viewer.getColumnProperties() != null && viewer.getColumnProperties().length >= getColumn() + 1 ) { String property = ( String ) viewer.getColumnProperties()[getColumn()]; return property; } return null; } /** * Gets the selected attribute hierarchy. * * @return the selected attribute hierarchy */ public AttributeHierarchy getSelectedAttributeHierarchy() { if ( !isDisposed() && getRow() != null && viewer != null && viewer.getColumnProperties() != null && viewer.getColumnProperties().length >= getColumn() + 1 ) { ISearchResult sr = getSelectedSearchResult(); String property = ( String ) viewer.getColumnProperties()[getColumn()]; if ( sr != null && !BrowserUIConstants.DN.equals( property ) ) { AttributeHierarchy ah = sr.getAttributeWithSubtypes( property ); if ( ah == null ) { ah = new AttributeHierarchy( sr.getEntry(), property, new IAttribute[] { new Attribute( sr.getEntry(), property ) } ); } return ah; } } return null; } /** * Gets the selected search result. * * @return the selected search result */ public ISearchResult getSelectedSearchResult() { if ( !isDisposed() && getRow() != null ) { Object o = getRow().getData(); if ( o instanceof ISearchResult ) { ISearchResult sr = ( ISearchResult ) o; if ( !sr.equals( workingCopy ) ) { IEntry entry = sr.getEntry(); IEntry referenceEntry = new CompoundModification().cloneEntry( entry ); referenceCopy = new SearchResult( referenceEntry, sr.getSearch() ); IEntry workingEntry = new CompoundModification().cloneEntry( entry ); workingCopy = new SearchResult( workingEntry, sr.getSearch() ); } return workingCopy; } } return null; } /** * Gets the selected reference copy. * * @return the selected reference copy, may be null */ public ISearchResult getSelectedReferenceCopy() { return referenceCopy; } /** * Resets reference and working copy copy. */ public void resetCopies() { referenceCopy = null; workingCopy = null; // update all actions with the fresh selection for ( Iterator<?> it = selectionChangesListenerList.iterator(); it.hasNext(); ) { ( ( ISelectionChangedListener ) it.next() ).selectionChanged( new SelectionChangedEvent( SearchResultEditorCursor.this, getSelection() ) ); } } /** * {@inheritDoc} */ public void addSelectionChangedListener( ISelectionChangedListener listener ) { if ( !selectionChangesListenerList.contains( listener ) ) { selectionChangesListenerList.add( listener ); } } /** * {@inheritDoc} */ public ISelection getSelection() { ISearchResult searchResult = getSelectedSearchResult(); AttributeHierarchy ah = getSelectedAttributeHierarchy(); String property = getSelectedProperty(); List<Object> list = new ArrayList<Object>(); if ( searchResult != null ) { list.add( searchResult ); } if ( ah != null ) { list.add( ah ); } if ( property != null ) { list.add( property ); } return new StructuredSelection( list ); } /** * {@inheritDoc} */ public void removeSelectionChangedListener( ISelectionChangedListener listener ) { if ( selectionChangesListenerList.contains( listener ) ) { selectionChangesListenerList.remove( listener ); } } /** * {@inheritDoc} */ public void setSelection( ISelection selection ) { } }
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/SearchResultEditorCellModifier.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorCellModifier.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 java.util.List; 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.ISearchResult; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute; import org.apache.directory.studio.ldapbrowser.core.utils.CompoundModification; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.swt.widgets.Item; /** * The SearchResultEditorCellModifier implements the {@link ICellModifier} interface * for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorCellModifier implements ICellModifier { /** The value editor manager. */ private ValueEditorManager valueEditorManager; /** The cursor */ private SearchResultEditorCursor cursor; /** * Creates a new instance of SearchResultEditorCellModifier. * * @param valueEditorManager the value editor manager * @param cursor the cursor */ public SearchResultEditorCellModifier( ValueEditorManager valueEditorManager, SearchResultEditorCursor cursor ) { this.valueEditorManager = valueEditorManager; this.cursor = cursor; } /** * Disposes this cell modifier. */ public void dispose() { valueEditorManager = null; } /** * {@inheritDoc} */ public boolean canModify( Object element, String property ) { if ( element instanceof ISearchResult && property != null ) { ISearchResult result = ( ISearchResult ) element; AttributeHierarchy ah = result.getAttributeWithSubtypes( property ); // check Dn if ( BrowserUIConstants.DN.equals( property ) ) { return false; } // attribute dummy if ( ah == null ) { ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[] { new Attribute( result.getEntry(), property ) } ); } // call value editor return valueEditorManager.getCurrentValueEditor( ah ).getRawValue( ah ) != null; } else { return false; } } /** * {@inheritDoc} */ public Object getValue( Object element, String property ) { if ( element instanceof ISearchResult && property != null ) { // perform modifications on the clone ISearchResult result = cursor.getSelectedSearchResult(); AttributeHierarchy ah = result.getAttributeWithSubtypes( property ); if ( !canModify( element, property ) ) { return null; } if ( ah == null ) { ah = new AttributeHierarchy( result.getEntry(), property, new IAttribute[] { new Attribute( result.getEntry(), property ) } ); } return valueEditorManager.getCurrentValueEditor( ah ).getRawValue( ah ); } else { return null; } } /** * {@inheritDoc} */ public void modify( Object element, String property, Object newRawValue ) { if ( element instanceof Item ) { element = ( ( Item ) element ).getData(); } if ( element instanceof ISearchResult && property != null ) { // perform modifications on the clone ISearchResult result = cursor.getSelectedSearchResult(); AttributeHierarchy ah = result.getAttributeWithSubtypes( property ); // switch operation: if ( ah == null && newRawValue != null ) { new CompoundModification().createValue( result.getEntry(), property, newRawValue ); } else if ( ah != null && newRawValue == null ) { List<IValue> values = new ArrayList<IValue>(); for ( IAttribute attribute : ah.getAttributes() ) { for ( IValue value : attribute.getValues() ) { values.add( value ); } } new CompoundModification().deleteValues( values ); } else if ( ah != null && ah.size() == 1 && ah.getAttribute().getValueSize() == 1 && newRawValue != null ) { new CompoundModification().modifyValue( ah.getAttribute().getValues()[0], newRawValue ); } } } }
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/SearchResultEditorUniversalListener.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorUniversalListener.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.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.core.events.EmptyValueAddedEvent; 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.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.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.actions.OpenSearchResultAction; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.INullSelectionListener; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.Hyperlink; /** * The SearchResultEditorUniversalListener manages all events for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorUniversalListener implements SearchUpdateListener, EntryUpdateListener { /** The search result editor */ private SearchResultEditor editor; /** The table viewer */ private TableViewer viewer; /** The cursor */ private SearchResultEditorCursor cursor; /** The action used to start the default value editor */ private OpenBestEditorAction startEditAction; /** The selected search that is displayed in the search result editor */ private ISearch selectedSearch; /** The hyperlink used for DNs */ private Hyperlink dnLink; /** The table editor, used to display the hyperlink */ private TableEditor tableEditor; /** Token used to activate and deactivate shortcuts in the editor */ private IContextActivation contextActivation; /** Listener that listens for selections of ISearch objects. */ private INullSelectionListener searchSelectionListener = new INullSelectionListener() { /** * {@inheritDoc} * * This implementation sets the editor's input when a search is selected. */ public void selectionChanged( IWorkbenchPart part, ISelection selection ) { if ( editor != null && part != null ) { if ( editor.getSite().getWorkbenchWindow() == part.getSite().getWorkbenchWindow() ) { ISearch[] searches = BrowserSelectionUtils.getSearches( selection ); Object[] objects = BrowserSelectionUtils.getObjects( selection ); if ( searches.length == 1 && objects.length == 1 ) { editor.setInput( new SearchResultEditorInput( searches[0] ) ); } else { editor.setInput( new SearchResultEditorInput( 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 ) == editor && contextActivation != null ) { editor.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 ) == editor ) { IContextService contextService = ( IContextService ) PlatformUI.getWorkbench().getAdapter( IContextService.class ); contextActivation = contextService.activateContext( BrowserCommonConstants.CONTEXT_WINDOWS ); editor.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 ) { } }; /** The listener used to handle clicks to the Dn hyper link */ private IHyperlinkListener dnHyperlinkListener = new IHyperlinkListener() { /** * {@inheritDoc} * * This implementation opens the search result when clicking thd Dn link. */ public void linkActivated( HyperlinkEvent e ) { ISearchResult sr = ( ISearchResult ) e.widget.getData(); OpenSearchResultAction action = new OpenSearchResultAction(); action.setSelectedSearchResults( new ISearchResult[] { sr } ); action.run(); } /** * {@inheritDoc} */ public void linkEntered( HyperlinkEvent e ) { } /** * {@inheritDoc} */ public void linkExited( HyperlinkEvent e ) { } }; /** This listener removes the Dn link when then mouse exits the hyperlink control */ private MouseTrackListener dnMouseTrackListener = new MouseTrackListener() { /** * {@inheritDoc} */ public void mouseEnter( MouseEvent e ) { } /** * {@inheritDoc} * * This implementation removed the Dn link. */ public void mouseExit( MouseEvent e ) { if ( !dnLink.isDisposed() ) { dnLink.setVisible( false ); tableEditor.setEditor( null ); } } public void mouseHover( MouseEvent e ) { } }; /** This listener renders the Dn hyperlink when the mouse cursor moves over the Dn */ private MouseMoveListener cursorMouseMoveListener = new MouseMoveListener() { /** * {@inheritDoc} * * This implementation renders the Dn link. */ public void mouseMove( MouseEvent e ) { if ( !cursor.isDisposed() ) { TableItem item = cursor.getRow(); if ( cursor.getColumn() == 0 && "Dn".equalsIgnoreCase( cursor.getRow().getParent().getColumns()[0].getText() ) ) //$NON-NLS-1$ { checkDnLink( item ); } } } }; /** This listener renders the Dn link when the mouse cursor moves over the Dn */ private MouseMoveListener viewerMouseMoveListener = new MouseMoveListener() { /** * {@inheritDoc} * * This implementation renders the Dn link. */ public void mouseMove( MouseEvent e ) { if ( !viewer.getTable().isDisposed() ) { TableItem item = viewer.getTable().getItem( new Point( e.x, e.y ) ); viewer.getTable().getColumns()[0].getWidth(); if ( e.x > 0 && e.x < viewer.getTable().getColumns()[0].getWidth() && "Dn".equalsIgnoreCase( viewer.getTable().getColumns()[0].getText() ) ) //$NON-NLS-1$ { checkDnLink( item ); } } } }; /** This listener starts the value editor and toggles the cursor's background color */ private SelectionListener cursorSelectionListener = new SelectionAdapter() { /** * {@inheritDoc} * * This implementation sets the cursor's background color. */ public void widgetSelected( SelectionEvent e ) { // viewer.setSelection(new StructuredSelection(getRow()), true); // viewer.getTable().setSelection(new TableItem[]{getRow()}); viewer.setSelection( null, true ); viewer.getTable().setSelection( new TableItem[0] ); ISearchResult result = cursor.getSelectedSearchResult(); String property = cursor.getSelectedProperty(); if ( property != null && result != null && viewer.getCellModifier().canModify( result, property ) ) { cursor.setBackground( Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION ) ); } else { cursor.setBackground( Display.getDefault().getSystemColor( SWT.COLOR_TITLE_INACTIVE_FOREGROUND ) ); } // cursor.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); } /** * {@inheritDoc} * * This implementation starts the value editor when pressing enter. */ public void widgetDefaultSelected( SelectionEvent e ) { viewer.setSelection( null, true ); viewer.getTable().setSelection( new TableItem[0] ); if ( startEditAction.isEnabled() ) startEditAction.run(); } }; /** This listener starts the value editor when double-clicking a cell */ private MouseListener cursorMouseListener = new MouseAdapter() { /** * {@inheritDoc} * * This implementation starts the value editor when double-clicking a cell. */ public void mouseDoubleClick( MouseEvent e ) { viewer.setSelection( null, true ); viewer.getTable().setSelection( new TableItem[0] ); if ( startEditAction.isEnabled() ) startEditAction.run(); } /** * {@inheritDoc} */ public void mouseDown( MouseEvent e ) { } /** * {@inheritDoc} */ public void mouseUp( MouseEvent e ) { } }; /** This listener starts the value editor when typing */ private KeyListener cursorKeyListener = new KeyListener() { /** * {@inheritDoc} * * This implementation starts the value editor when a non-control key is pressed. */ public void keyPressed( KeyEvent e ) { if ( e.character != '\0' && e.character != SWT.CR && e.character != SWT.LF && e.character != SWT.BS && e.character != SWT.DEL && e.character != SWT.TAB && e.character != SWT.ESC && ( e.stateMask == 0 || e.stateMask == SWT.SHIFT ) ) { if ( startEditAction.isEnabled() && startEditAction.getBestValueEditor().getCellEditor() instanceof TextCellEditor ) { startEditAction.run(); CellEditor editor = viewer.getCellEditors()[cursor.getColumn()]; if ( editor instanceof TextCellEditor ) { editor.setValue( String.valueOf( e.character ) ); ( ( Text ) editor.getControl() ).setSelection( 1 ); } } } } /** * {@inheritDoc} */ public void keyReleased( KeyEvent e ) { } }; /** * Creates a new instance of SearchResultEditorUniversalListener. * * @param editor the search result editor */ public SearchResultEditorUniversalListener( SearchResultEditor editor ) { this.editor = editor; startEditAction = editor.getActionGroup().getOpenBestEditorAction(); viewer = editor.getMainWidget().getViewer(); cursor = editor.getConfiguration().getCursor( viewer ); // create dn link control dnLink = new Hyperlink( viewer.getTable(), SWT.NONE ); dnLink.setLayoutData( new GridData( SWT.BOTTOM, SWT.LEFT, true, true ) ); dnLink.setText( "" ); //$NON-NLS-1$ dnLink.setMenu( viewer.getTable().getMenu() ); tableEditor = new TableEditor( viewer.getTable() ); tableEditor.horizontalAlignment = SWT.LEFT; tableEditor.verticalAlignment = SWT.BOTTOM; tableEditor.grabHorizontal = true; tableEditor.grabVertical = true; // init listeners dnLink.addHyperlinkListener( dnHyperlinkListener ); dnLink.addMouseTrackListener( dnMouseTrackListener ); cursor.addMouseMoveListener( cursorMouseMoveListener ); cursor.addSelectionListener( cursorSelectionListener ); cursor.addMouseListener( cursorMouseListener ); cursor.addKeyListener( cursorKeyListener ); viewer.getTable().addMouseMoveListener( viewerMouseMoveListener ); editor.getSite().getPage().addPartListener( partListener ); editor.getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener( BrowserView.getId(), searchSelectionListener ); EventRegistry.addSearchUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); EventRegistry.addEntryUpdateListener( this, BrowserCommonActivator.getDefault().getEventRunner() ); } /** * Disposes the listener. */ public void dispose() { if ( editor != null ) { editor.getSite().getPage().removePartListener( partListener ); editor.getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener( BrowserView.getId(), searchSelectionListener ); EventRegistry.removeSearchUpdateListener( this ); EventRegistry.removeEntryUpdateListener( this ); selectedSearch = null; startEditAction = null; cursor = null; viewer = null; editor = null; } } /** * {@inheritDoc} * * This implementation refreshes the search result editor. */ public void searchUpdated( SearchUpdateEvent searchUpdateEvent ) { if ( selectedSearch == searchUpdateEvent.getSearch() ) { refreshInput(); } } /** * {@inheritDoc} * * This implementation refreshes the search result editor * or starts the value editor if an empty value was added. */ public void entryUpdated( EntryModificationEvent event ) { if ( event instanceof EmptyValueAddedEvent && !editor.getActionGroup().isEditorActive() ) { EmptyValueAddedEvent evae = ( EmptyValueAddedEvent ) event; IAttribute att = evae.getAddedValue().getAttribute(); AttributeHierarchy ah = cursor.getSelectedAttributeHierarchy(); if ( ah != null && ah.contains( att ) ) { viewer.setSelection( null, true ); viewer.getTable().setSelection( new TableItem[0] ); if ( startEditAction.isEnabled() ) { startEditAction.run(); } } } else { viewer.refresh( true ); cursor.notifyListeners( SWT.Selection, new Event() ); } } /** * Sets the input. * * @param search the search */ void setInput( ISearch search ) { selectedSearch = search; refreshInput(); editor.getActionGroup().setInput( search ); } /** * Refreshes the input, makes columns visible or hides columns depending on the number * of returning attributes. */ void refreshInput() { // create at least on column ensureColumnCount( 1 ); // get all columns TableColumn[] columns = viewer.getTable().getColumns(); // number of used columns int usedColumns; if ( selectedSearch != null ) { // get displayed attributes boolean showDn = BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) || selectedSearch.getReturningAttributes().length == 0; String[] attributes; if ( showDn ) { attributes = new String[selectedSearch.getReturningAttributes().length + 1]; attributes[0] = "Dn"; //$NON-NLS-1$ System.arraycopy( selectedSearch.getReturningAttributes(), 0, attributes, 1, attributes.length - 1 ); } else { attributes = selectedSearch.getReturningAttributes(); } // create missing columns if ( attributes.length > columns.length ) { ensureColumnCount( attributes.length ); columns = viewer.getTable().getColumns(); } // set column headers for ( int i = 0; i < attributes.length; i++ ) { columns[i].setText( attributes[i] ); } viewer.setColumnProperties( attributes ); // set input ( ( SearchResultEditorLabelProvider ) viewer.getLabelProvider() ).inputChanged( selectedSearch, showDn ); viewer.setInput( selectedSearch ); // this.viewer.refresh(); // update cell editors CellEditor[] editors = new CellEditor[attributes.length]; viewer.setCellEditors( editors ); if ( attributes.length > 0 ) { int width = viewer.getTable().getClientArea().width / attributes.length; for ( int i = 0; i < attributes.length; i++ ) { columns[i].setWidth( width ); } } // layout columns // for(int i=0; i<attributes.length; i++) { // columns[i].pack(); // } usedColumns = attributes.length; } else { viewer.setInput( null ); columns[0].setText( "Dn" ); //$NON-NLS-1$ columns[0].pack(); usedColumns = 1; } // make unused columns invisible for ( int i = usedColumns; i < columns.length; i++ ) { columns[i].setWidth( 0 ); columns[i].setText( " " ); //$NON-NLS-1$ } // refresh content provider (sorter and filter) editor.getConfiguration().getContentProvider( editor.getMainWidget() ).refresh(); // this.cursor.setFocus(); } /** * Ensures that the table contains at least the number of * the requested columns. * * @param count the requested number of columns */ private void ensureColumnCount( int count ) { TableColumn[] columns = viewer.getTable().getColumns(); if ( columns.length < count ) { for ( int i = columns.length; i < count; i++ ) { TableColumn column = new TableColumn( viewer.getTable(), SWT.LEFT ); column.setText( "" ); //$NON-NLS-1$ column.setWidth( 0 ); column.setResizable( true ); column.setMoveable( true ); } } } /** * Renders the Dn link. * * @param item the table item */ private void checkDnLink( TableItem item ) { if ( dnLink == null || dnLink.isDisposed() || tableEditor == null || viewer.getTable().isDisposed() || cursor.isDisposed() ) { return; } boolean showLinks = BrowserUIPlugin.getDefault().getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ); if ( showLinks ) { boolean linkVisible = false; if ( item != null ) { Object data = item.getData(); if ( data instanceof ISearchResult ) { ISearchResult sr = ( ISearchResult ) data; item.getFont(); viewer.getTable().getColumn( 0 ).getWidth(); viewer.getTable().getItemHeight(); // dnLink.setText("<a>"+sr.getDn().toString()+"</a>"); dnLink.setData( sr ); dnLink.setText( sr.getDn().getName() ); dnLink.setUnderlined( true ); dnLink.setFont( item.getFont() ); dnLink.setForeground( item.getForeground() ); dnLink.setBackground( item.getBackground() ); dnLink.setBounds( item.getBounds( 0 ) ); tableEditor.setEditor( dnLink, item, 0 ); linkVisible = true; } } if ( !linkVisible ) { dnLink.setVisible( false ); tableEditor.setEditor( 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/searchresult/SearchResultEditorInput.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorInput.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.core.model.IBrowserConnection; 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.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; /** * The input for the search result editor. * * There is a trick to provide a single instance of the search result editor: * <ul> * <li>If oneInstanceHackEnabled is true the equals method returns always * true as long as the compared object is also of type SearchResultEditorInput. * With this trick only one instance of the search result editor is opened * by the eclipse editor framework. * <li>If oneInstanceHackEnabled is false the equals method returns * true only if the wrapped objects (ISearch) are equal. This is * necessary for the history navigation because it must be able * to distinguish the different input objects. * </ul> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorInput implements IEditorInput { /** The search input */ private ISearch search; /** Flag indicating this is a dummy input */ private boolean dummy; /** * Creates a new instance of SearchResultEditorInput. * * @param search the search input */ public SearchResultEditorInput( ISearch search ) { this( search, false ); } /** * Creates a new instance of SearchResultEditorInput. * * @param search the search input * @param dummy the is dummy flag */ /*package*/SearchResultEditorInput( ISearch search, boolean dummy ) { this.search = search; this.dummy = dummy; } /** * This implementation always return false because * a search should not be visible in the * "File Most Recently Used" menu. * * {@inheritDoc} */ public boolean exists() { return false; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SEARCHRESULTEDITOR ); } /** * {@inheritDoc} */ public String getName() { if ( search != null ) { return search.getName(); } return Messages.getString( "SearchResultEditorContentProvider.NoSearchSelected" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public String getToolTipText() { if ( search != null ) { String toolTipText = search.getUrl().toString(); IBrowserConnection browserConnection = search.getBrowserConnection(); if ( browserConnection != null && browserConnection.getConnection() != null ) { toolTipText += " - " + browserConnection.getConnection().getName();//$NON-NLS-1$ } return toolTipText; } return Messages.getString( "SearchResultEditorContentProvider.NoSearchSelected" ); //$NON-NLS-1$ } /** * This implementation always return null. * * {@inheritDoc} */ public IPersistableElement getPersistable() { return null; } /** * {@inheritDoc} */ public Object getAdapter( Class adapter ) { return null; } /** * Gets the search input, may be null. * * @return the search input or null */ public ISearch getSearch() { return search; } /** * {@inheritDoc} */ public int hashCode() { if ( dummy ) { return 0; } return getToolTipText().hashCode(); } /** * {@inheritDoc} */ public boolean equals( Object obj ) { if ( !( obj instanceof SearchResultEditorInput ) ) { return false; } SearchResultEditorInput other = ( SearchResultEditorInput ) obj; if ( dummy && other.dummy ) { return true; } if ( dummy != other.dummy ) { return false; } if ( this.search == null && other.search == null ) { return true; } else if ( this.search == null || other.search == null ) { return false; } else { return other.search.equals( this.search ); } } }
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/SearchResultEditorConfiguration.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorConfiguration.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.valueeditors.ValueEditorManager; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IWorkbenchPart; /** * The SearchResultEditorConfiguration contains the content provider, * label provider, cursor, sorter, filter, the context menu manager and the * preferences for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorConfiguration { /** The disposed flag. */ private boolean disposed = false; /** The cursor. */ protected SearchResultEditorCursor cursor; protected SearchResultEditorSorter sorter; protected SearchResultEditorFilter filter; protected SearchResultEditorContentProvider contentProvider; protected SearchResultEditorLabelProvider labelProvider; protected SearchResultEditorCellModifier cellModifier; protected ValueEditorManager valueEditorManager; protected MenuManager contextMenuManager; /** * Creates a new instance of SearchResultEditorConfiguration. * * @param part the workbench part */ public SearchResultEditorConfiguration( IWorkbenchPart part ) { super(); } /** * Disposes this configuration. */ public void dispose() { if ( !disposed ) { if ( contentProvider != null ) { contentProvider.dispose(); contentProvider = null; } if ( labelProvider != null ) { labelProvider.dispose(); labelProvider = null; } if ( cellModifier != null ) { cellModifier.dispose(); cellModifier = null; } if ( valueEditorManager != null ) { valueEditorManager.dispose(); valueEditorManager = null; } if ( contextMenuManager != null ) { contextMenuManager.dispose(); contextMenuManager = null; } if ( cursor != null ) { cursor.dispose(); cursor = null; } disposed = true; } } /** * Gets the sorter. * * @return the sorter */ public SearchResultEditorSorter getSorter() { if ( sorter == null ) { sorter = new SearchResultEditorSorter(); } return sorter; } /** * Gets the filter. * * @return the filter */ public SearchResultEditorFilter getFilter() { if ( filter == null ) { filter = new SearchResultEditorFilter(); } return filter; } /** * Gets the context menu manager. * * @param viewer the viewer * * @return the context menu manager */ public IMenuManager getContextMenuManager( TableViewer viewer ) { if ( contextMenuManager == null ) { contextMenuManager = new MenuManager(); Menu menu = contextMenuManager.createContextMenu( viewer.getControl() ); getCursor( viewer ).setMenu( menu ); } return contextMenuManager; } /** * Gets the content provider. * * @param mainWidget the main widget * * @return the content provider */ public SearchResultEditorContentProvider getContentProvider( SearchResultEditorWidget mainWidget ) { if ( contentProvider == null ) { contentProvider = new SearchResultEditorContentProvider( mainWidget, this ); } return contentProvider; } /** * Gets the label provider. * * @param viewer the viewer * * @return the label provider */ public SearchResultEditorLabelProvider getLabelProvider( TableViewer viewer ) { if ( labelProvider == null ) { labelProvider = new SearchResultEditorLabelProvider( getValueEditorManager( viewer ) ); } return labelProvider; } /** * Gets the cell modifier. * * @param viewer the viewer * * @return the cell modifier */ public SearchResultEditorCellModifier getCellModifier( TableViewer viewer ) { if ( cellModifier == null ) { cellModifier = new SearchResultEditorCellModifier( getValueEditorManager( viewer ), getCursor( viewer ) ); } return cellModifier; } /** * Gets the cursor. * * @param viewer the viewer * * @return the cursor */ public SearchResultEditorCursor getCursor( TableViewer viewer ) { if ( cursor == null ) { cursor = new SearchResultEditorCursor( viewer ); } return cursor; } /** * Gets the value editor manager. * * @param viewer the viewer * * @return the value editor manager */ public ValueEditorManager getValueEditorManager( TableViewer viewer ) { if ( valueEditorManager == null ) { valueEditorManager = new ValueEditorManager( viewer.getTable(), true, true ); } 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/searchresult/SearchResultDeleteAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultDeleteAction.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.Collection; import java.util.HashSet; import org.apache.directory.studio.ldapbrowser.common.actions.DeleteAction; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; /** * Special delete action to avoid the deletion of the whole entry. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultDeleteAction extends DeleteAction { private static Collection<IEntry> EMPTY = new HashSet<IEntry>(); /** * Takes care that not the whole selected entry is deleted, but only * the selected attribute. */ protected Collection<IEntry> getEntries() { return EMPTY; } }
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/SearchResultEditorLabelProvider.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorLabelProvider.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.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.ui.BrowserUIConstants; import org.apache.directory.studio.valueeditors.IValueEditor; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.viewers.ITableColorProvider; import org.eclipse.jface.viewers.ITableFontProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; /** * The label provider for the search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorLabelProvider extends LabelProvider implements ITableLabelProvider, ITableFontProvider, ITableColorProvider { /** The value editor manager. */ private ValueEditorManager valueEditorManager; /** The search. */ private ISearch search; /** The show Dn flag. */ private boolean showDn; /** * Creates a new instance of SearchResultEditorLabelProvider. * * @param viewer the viewer * @param valueEditorManager the value editor manager */ public SearchResultEditorLabelProvider( ValueEditorManager valueEditorManager ) { this.valueEditorManager = valueEditorManager; } /** * 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; } /** * {@inheritDoc} */ public final String getColumnText( Object obj, int index ) { if ( obj instanceof ISearchResult ) { String property; try { ISearchResult result = ( ISearchResult ) obj; if ( showDn && index == 0 ) { property = BrowserUIConstants.DN; } else if ( showDn && index > 0 ) { property = search.getReturningAttributes()[index - 1]; } else { property = search.getReturningAttributes()[index]; } if ( property == BrowserUIConstants.DN ) { return result.getDn().getName(); } else { AttributeHierarchy ah = result.getAttributeWithSubtypes( property ); return getDisplayValue( ah ); } } catch ( ArrayIndexOutOfBoundsException aioobe ) { // occurs on "invisible" columns return ""; //$NON-NLS-1$ } } else if ( obj != null ) { return obj.toString(); } else { return ""; //$NON-NLS-1$ } } /** * {@inheritDoc} */ public final Image getColumnImage( Object obj, int index ) { return null; } /** * Gets the display value. * * @param ah the ah * * @return the display value */ private String getDisplayValue( AttributeHierarchy ah ) { IValueEditor vp = valueEditorManager.getCurrentValueEditor( ah ); if ( vp == null ) { return ""; //$NON-NLS-1$ } String value = vp.getDisplayValue( ah ); if ( value.length() > 50 ) { value = value.substring( 0, 47 ) + "..."; //$NON-NLS-1$ } return value; } /** * {@inheritDoc} */ public Font getFont( Object element, int index ) { if ( element instanceof ISearchResult ) { ISearchResult result = ( ISearchResult ) element; String property = null; if ( showDn && index == 0 ) { property = BrowserUIConstants.DN; } else if ( showDn && index > 0 && index - 1 < result.getSearch().getReturningAttributes().length ) { property = result.getSearch().getReturningAttributes()[index - 1]; } else if ( index < result.getSearch().getReturningAttributes().length ) { property = result.getSearch().getReturningAttributes()[index]; } if ( property != null && property == BrowserUIConstants.DN ) { return null; } else if ( property != null ) { AttributeHierarchy ah = result.getAttributeWithSubtypes( property ); if ( ah != null ) { for ( int i = 0; i < ah.getAttributes().length; i++ ) { IAttribute attribute = ah.getAttributes()[i]; if ( attribute.isObjectClassAttribute() ) { FontData[] fontData = PreferenceConverter.getFontDataArray( BrowserCommonActivator .getDefault().getPreferenceStore(), BrowserCommonConstants.PREFERENCE_OBJECTCLASS_FONT ); return BrowserCommonActivator.getDefault().getFont( fontData ); } else if ( attribute.isMustAttribute() ) { FontData[] fontData = PreferenceConverter.getFontDataArray( BrowserCommonActivator .getDefault().getPreferenceStore(), BrowserCommonConstants.PREFERENCE_MUSTATTRIBUTE_FONT ); return BrowserCommonActivator.getDefault().getFont( fontData ); } else if ( attribute.isOperationalAttribute() ) { FontData[] fontData = PreferenceConverter.getFontDataArray( BrowserCommonActivator .getDefault().getPreferenceStore(), BrowserCommonConstants.PREFERENCE_OPERATIONALATTRIBUTE_FONT ); return BrowserCommonActivator.getDefault().getFont( fontData ); } else { FontData[] fontData = PreferenceConverter .getFontDataArray( BrowserCommonActivator.getDefault().getPreferenceStore(), BrowserCommonConstants.PREFERENCE_MAYATTRIBUTE_FONT ); return BrowserCommonActivator.getDefault().getFont( fontData ); } } } } } return null; } /** * {@inheritDoc} */ public Color getForeground( Object element, int index ) { return null; } /** * {@inheritDoc} */ public Color getBackground( Object element, int index ) { 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/searchresult/OpenDefaultEditorAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenDefaultEditorAction.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.BrowserCommonConstants; import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.SearchResultEditorActionProxy; import org.apache.directory.studio.valueeditors.ValueEditorManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.TableViewer; /** * The OpenBestEditorAction is used to edit a value with the best value editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenDefaultEditorAction extends AbstractOpenEditorAction { /** The best value editor proxy. */ private SearchResultEditorActionProxy bestValueEditorProxy; /** * Creates a new instance of OpenDefaultEditorAction. * * @param viewer the viewer * @param cursor the cursor * @param valueEditorManager the value editor manager * @param bestValueEditorProxy the best value editor proxy * @param actionGroup the action group */ public OpenDefaultEditorAction( TableViewer viewer, SearchResultEditorCursor cursor, ValueEditorManager valueEditorManager, SearchResultEditorActionProxy bestValueEditorProxy, SearchResultEditorActionGroup actionGroup ) { super( viewer, cursor, valueEditorManager, actionGroup ); this.bestValueEditorProxy = bestValueEditorProxy; } /** * {@inheritDoc} */ public void run() { bestValueEditorProxy.run(); } /** * {@inheritDoc} */ public void dispose() { bestValueEditorProxy = null; super.dispose(); } /** * {@inheritDoc} */ public String getCommandId() { return BrowserCommonConstants.ACTION_ID_EDIT_VALUE; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { if ( bestValueEditorProxy != null ) { return bestValueEditorProxy.getImageDescriptor(); } else { return null; } } /** * {@inheritDoc} */ public String getText() { return Messages.getString( "OpenDefaultEditorAction.EditValue" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public boolean isEnabled() { if ( bestValueEditorProxy != null ) { return bestValueEditorProxy.isEnabled(); } else { 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/searchresult/SearchResultEditorWidget.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/SearchResultEditorWidget.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.common.ui.widgets.ViewFormWidget; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; /** * The EntryEditorWidget is a widget to display and edit the attributes of * the results of a search. * * It provides a context menu and a local toolbar with actions to * manage attributes. Further there is an instant search feature to filter * the visible search results. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorWidget extends ViewFormWidget { /** The configuration. */ private SearchResultEditorConfiguration configuration; /** The quick filter widget. */ private SearchResultEditorQuickFilterWidget quickFilterWidget; /** The table. */ private Table table; /** The viewer. */ private TableViewer viewer; /** * Creates a new instance of SearchResultEditorWidget. * * @param configuration the configuration */ public SearchResultEditorWidget( SearchResultEditorConfiguration configuration ) { this.configuration = configuration; } /** * {@inheritDoc} */ protected Control createContent( Composite parent ) { // create quick filter quickFilterWidget = new SearchResultEditorQuickFilterWidget( configuration.getFilter() ); quickFilterWidget.createComposite( parent ); // create table widget and viewer table = new Table( parent, SWT.BORDER | SWT.HIDE_SELECTION | SWT.VIRTUAL ); table.setHeaderVisible( true ); table.setLinesVisible( true ); table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); viewer = new TableViewer( table ); viewer.setUseHashlookup( true ); // setup providers viewer.setContentProvider( configuration.getContentProvider( this ) ); viewer.setLabelProvider( configuration.getLabelProvider( viewer ) ); // set table cell editors viewer.setCellModifier( configuration.getCellModifier( viewer ) ); return table; } /** * Sets the input. * * @param input the new input */ public void setInput( Object input ) { viewer.setInput( input ); } /** * Sets the focus. */ public void setFocus() { configuration.getCursor( viewer ).setFocus(); } /** * {@inheritDoc} */ public void dispose() { if ( viewer != null ) { configuration.dispose(); if ( quickFilterWidget != null ) { quickFilterWidget.dispose(); quickFilterWidget = null; } table = null; viewer = null; } super.dispose(); } /** * Gets the viewer. * * @return the viewer */ public TableViewer getViewer() { return viewer; } /** * Gets the quick filter widget. * * @return the quick filter widget */ public SearchResultEditorQuickFilterWidget getQuickFilterWidget() { return quickFilterWidget; } }
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/OpenSearchResultEditorPreferencePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenSearchResultEditorPreferencePage.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.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 search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class OpenSearchResultEditorPreferencePage extends Action { /** * Creates a new instance of OpenSearchResultEditorPreferencePage. */ public OpenSearchResultEditorPreferencePage() { super.setText( Messages.getString( "OpenSearchResultEditorPreferencePage.Preferences" ) ); //$NON-NLS-1$ super.setToolTipText( Messages.getString( "OpenSearchResultEditorPreferencePage.PreferencesToolTip" ) ); //$NON-NLS-1$ super.setEnabled( true ); } /** * {@inheritDoc} */ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String srePageId = BrowserUIConstants.PREFERENCEPAGEID_SEARCHRESULTEDITOR; String attPageId = BrowserUIConstants.PREFERENCEPAGEID_ATTRIBUTES; PreferencesUtil.createPreferenceDialogOn( shell, srePageId, new String[] { srePageId, attPageId }, null ).open(); } }
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/schemabrowser/SchemaBrowserManager.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserManager.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; /** * The SchemaBrowserManager is used to set and get the the input * of the single schema browser instance. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaBrowserManager { /** The dummy input, to find the single schema browser instance */ private static SchemaBrowserInput DUMMY_INPUT = new SchemaBrowserInput( null, null ); /** * Sets the input to the schema browser. * * @param connection the connection * @param schemaElement the schema element */ public static void setInput( IBrowserConnection connection, AbstractSchemaObject schemaElement ) { SchemaBrowserInput input = new SchemaBrowserInput( connection, schemaElement ); setInput( input ); } /** * Sets the input to the schema browser. * * @param input the input */ private static void setInput( SchemaBrowserInput input ) { SchemaBrowser editor = ( SchemaBrowser ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .findEditor( DUMMY_INPUT ); if ( editor == null && input != null ) { // open new schema browser try { editor = ( SchemaBrowser ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor( input, SchemaBrowser.getId(), false ); editor.setInput( input ); } catch ( PartInitException e ) { e.printStackTrace(); } } else if ( editor != null ) { // set the input to already opened schema browser editor.setInput( input ); // bring schema browser to top if ( !PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().isPartVisible( editor ) ) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop( 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/schemabrowser/LdapSyntaxDescriptionPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/LdapSyntaxDescriptionPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.graphics.Image; /** * The LdapSyntaxDescriptionPage displays a list with all * syntax descriptions and hosts the detail page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LdapSyntaxDescriptionPage extends SchemaPage { /** * Creates a new instance of LdapSyntaxDescriptionPage. * * @param schemaBrowser the schema browser */ public LdapSyntaxDescriptionPage( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ protected String getTitle() { return Messages.getString( "LdapSyntaxDescriptionPage.Syntaxes" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String getFilterDescription() { return Messages.getString( "LdapSyntaxDescriptionPage.SelectASyntax" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected IStructuredContentProvider getContentProvider() { return new LSDContentProvider(); } /** * {@inheritDoc} */ protected ITableLabelProvider getLabelProvider() { return new LSDLabelProvider(); } /** * {@inheritDoc} */ protected ViewerSorter getSorter() { return new LSDViewerSorter(); } /** * {@inheritDoc} */ protected ViewerFilter getFilter() { return new LSDViewerFilter(); } /** * {@inheritDoc} */ protected SchemaDetailsPage getDetailsPage() { return new LdapSyntaxDescriptionDetailsPage( this, this.toolkit ); } /** * The content provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class LSDContentProvider implements IStructuredContentProvider { /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof Schema ) { Schema schema = ( Schema ) inputElement; if ( schema != null && schema.getLdapSyntaxDescriptions() != null ) { return schema.getLdapSyntaxDescriptions().toArray(); } } return new Object[0]; } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * The label provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class LSDLabelProvider extends LabelProvider implements ITableLabelProvider { /** * {@inheritDoc} */ public String getColumnText( Object obj, int index ) { if ( obj instanceof LdapSyntax ) { return SchemaUtils.toString( ( LdapSyntax ) obj ); } return obj.toString(); } /** * {@inheritDoc} */ public Image getColumnImage( Object obj, int index ) { return null; } } /** * The sorter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class LSDViewerSorter extends ViewerSorter { /** * {@inheritDoc} */ public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof LdapSyntax ) { e1 = SchemaUtils.toString( ( LdapSyntax ) e1 ); } if ( e2 instanceof LdapSyntax ) { e2 = SchemaUtils.toString( ( LdapSyntax ) e2 ); } return e1.toString().compareTo( e2.toString() ); } } /** * The filter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class LSDViewerFilter extends ViewerFilter { /** * {@inheritDoc} */ public boolean select( Viewer viewer, Object parentElement, Object element ) { if ( element instanceof LdapSyntax ) { LdapSyntax lsd = ( LdapSyntax ) element; boolean matched = Strings.toLowerCase( SchemaUtils.toString( lsd ) ) .indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1 || Strings.toLowerCase( lsd.getOid() ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1; return matched; } 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/schemabrowser/SchemaPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.IFormColors; import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * A base implementation used from all schema master pages. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class SchemaPage { /** The connection widget */ protected BrowserConnectionWidgetContributionItem connectionCombo; /** The show default schema action */ protected ShowDefaultSchemaAction showDefaultSchemaAction; /** The reload schema action */ protected ReloadSchemaAction reloadSchemaAction; /** The schema browser */ protected SchemaBrowser schemaBrowser; /** The toolkit used to create controls */ protected FormToolkit toolkit; /** The outer form */ protected Form form; /** The sash form, used to split the master and detail form */ protected SashForm sashForm; /** The master form, contains the schema element list */ protected ScrolledForm masterForm; /** The detail form, contains the schema details */ protected ScrolledForm detailForm; /** The schema details page */ protected SchemaDetailsPage detailsPage; /** The section of the master form */ protected Section section; /** The filter field of the master form */ protected Text filterText; /** The list with all schema elements */ protected TableViewer viewer; /** Flag indicating if the viewer's selection is changed programatically */ protected boolean inChange; /** * Creates a new instance of SchemaPage. * * @param schemaBrowser the schema browser */ public SchemaPage( SchemaBrowser schemaBrowser ) { this.schemaBrowser = schemaBrowser; this.inChange = false; } /** * Refreshes this schema page. */ public void refresh() { Schema schema = null; if ( showDefaultSchemaAction.isChecked() ) { schema = Schema.DEFAULT_SCHEMA; } else if ( getConnection() != null ) { schema = getConnection().getSchema(); } if ( viewer.getInput() != schema ) { viewer.setInput( schema ); viewer.setSelection( StructuredSelection.EMPTY ); } form.setText( getTitle() ); viewer.refresh(); } /** * Gets the title of this schema page. * * @return the title */ protected abstract String getTitle(); /** * Gets the filter description. * * @return the filter description */ protected abstract String getFilterDescription(); /** * Gets the content provider. * * @return the content provider */ protected abstract IStructuredContentProvider getContentProvider(); /** * Gets the label provider. * * @return the label provider */ protected abstract ITableLabelProvider getLabelProvider(); /** * Gets the sorter. * * @return the sorter */ protected abstract ViewerSorter getSorter(); /** * Gets the filter. * * @return the filter */ protected abstract ViewerFilter getFilter(); /** * Gets the details page. * * @return the details page */ protected abstract SchemaDetailsPage getDetailsPage(); /** * Creates the master page. * * @param body the parent composite */ //protected abstract void createMaster( Composite body ); private void createMaster( Composite parent ) { // create section section = toolkit.createSection( parent, Section.DESCRIPTION ); section.marginWidth = 10; section.marginHeight = 12; section.setText( getTitle() ); section.setDescription( getFilterDescription() ); toolkit.createCompositeSeparator( section ); // create client Composite client = toolkit.createComposite( section, SWT.WRAP ); GridLayout layout = new GridLayout( 2, false ); layout.marginWidth = 5; layout.marginHeight = 5; client.setLayout( layout ); section.setClient( client ); // create filter field toolkit.createLabel( client, Messages.getString( "SchemaPage.Filter" ) ); //$NON-NLS-1$ this.filterText = toolkit.createText( client, "", SWT.NONE | SWT.SEARCH | SWT.CANCEL ); //$NON-NLS-1$ this.filterText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); this.filterText.setData( FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER ); this.filterText.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { viewer.refresh(); } } ); // create table Table t = toolkit.createTable( client, SWT.NONE ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.horizontalSpan = 2; gd.heightHint = 20; gd.widthHint = 100; t.setLayoutData( gd ); toolkit.paintBordersFor( client ); // setup viewer viewer = new TableViewer( t ); viewer.setContentProvider( getContentProvider() ); viewer.setLabelProvider( getLabelProvider() ); viewer.setSorter( getSorter() ); viewer.addFilter( getFilter() ); } /** * Creates the detail page. * * @param body the parent composite */ private void createDetail( Composite body ) { detailsPage = getDetailsPage(); detailsPage.createContents( this.detailForm ); } /** * Selects the given object in the list. Causes also an input * change of the details page. * * @param obj the object to select */ public void select( Object obj ) { ISelection newSelection = new StructuredSelection( obj ); ISelection oldSelection = this.viewer.getSelection(); if ( !newSelection.equals( oldSelection ) ) { inChange = true; this.viewer.setSelection( newSelection, true ); if ( this.viewer.getSelection().isEmpty() ) { this.filterText.setText( "" ); //$NON-NLS-1$ this.viewer.setSelection( newSelection, true ); } inChange = false; } } /** * Disposed this page and the details page. */ public void dispose() { this.detailsPage.dispose(); this.schemaBrowser = null; this.toolkit.dispose(); this.toolkit = null; } /** * Creates this schema page and details page. * * @param parent the parent composite * @return the created composite. */ Control createControl( Composite parent ) { this.toolkit = new FormToolkit( parent.getDisplay() ); this.form = this.toolkit.createForm( parent ); this.form.getBody().setLayout( new FillLayout() ); this.sashForm = new SashForm( this.form.getBody(), SWT.HORIZONTAL ); this.sashForm.setLayout( new FillLayout() ); this.masterForm = this.toolkit.createScrolledForm( this.sashForm ); this.detailForm = new ScrolledForm( this.sashForm, SWT.V_SCROLL | this.toolkit.getOrientation() ); this.detailForm.setExpandHorizontal( true ); this.detailForm.setExpandVertical( true ); this.detailForm.setBackground( this.toolkit.getColors().getBackground() ); this.detailForm.setForeground( this.toolkit.getColors().getColor( IFormColors.TITLE ) ); this.detailForm.setFont( JFaceResources.getHeaderFont() ); this.sashForm.setWeights( new int[] { 50, 50 } ); this.masterForm.getBody().setLayout( new FillLayout() ); this.createMaster( this.masterForm.getBody() ); this.detailForm.getBody().setLayout( new FillLayout() ); this.createDetail( this.detailForm.getBody() ); viewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { ISelection selection = event.getSelection(); if ( selection.isEmpty() ) { detailsPage.setInput( null ); } else { Object obj = ( ( StructuredSelection ) selection ).getFirstElement(); detailsPage.setInput( obj ); // Do not set the input of the schema browser if // the selection was changed programatically. if ( !inChange && obj instanceof AbstractSchemaObject ) { schemaBrowser.setInput( new SchemaBrowserInput( getConnection(), ( AbstractSchemaObject ) obj ) ); } } } } ); connectionCombo = new BrowserConnectionWidgetContributionItem( this ); this.form.getToolBarManager().add( connectionCombo ); this.form.getToolBarManager().add( new Separator() ); showDefaultSchemaAction = new ShowDefaultSchemaAction( schemaBrowser ); this.form.getToolBarManager().add( showDefaultSchemaAction ); this.form.getToolBarManager().add( new Separator() ); reloadSchemaAction = new ReloadSchemaAction( this ); this.form.getToolBarManager().add( reloadSchemaAction ); this.form.updateToolBar(); this.refresh(); return this.form; } /** * Gets the schema browser. * * @return the schema browser */ public SchemaBrowser getSchemaBrowser() { return schemaBrowser; } /** * Gets the connection. * * @return the connection */ public IBrowserConnection getConnection() { return connectionCombo.getConnection(); } /** * Sets the connection. * * @param connection the connection */ public void setConnection( IBrowserConnection connection ) { connectionCombo.setConnection( connection ); reloadSchemaAction.updateEnabledState(); refresh(); } /** * Checks if is show default schema. * * @return true, if is show default schema */ public boolean isShowDefaultSchema() { return showDefaultSchemaAction.isChecked(); } /** * Sets the show default schema flag. * * @param b the show default schema flag */ public void setShowDefaultSchema( boolean b ) { showDefaultSchemaAction.setChecked( b ); connectionCombo.updateEnabledState(); reloadSchemaAction.updateEnabledState(); refresh(); } }
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/schemabrowser/ReloadSchemaAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ReloadSchemaAction.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.schemabrowser; import org.apache.directory.studio.ldapbrowser.core.jobs.ReloadSchemaRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; 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.action.Action; /** * This action reloads the schema. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ReloadSchemaAction extends Action { /** The schema page */ private SchemaPage schemaPage; /** * Creates a new instance of ReloadSchemaAction. * * @param schemaPage the schema page */ public ReloadSchemaAction( SchemaPage schemaPage ) { super( Messages.getString( "ReloadSchemaAction.ReloadSchema" ) ); //$NON-NLS-1$ super.setToolTipText( Messages.getString( "ReloadSchemaAction.ReloadSchemaToolTip" ) ); //$NON-NLS-1$ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_REFRESH ) ); super.setEnabled( true ); this.schemaPage = schemaPage; } /** * {@inheritDoc} */ public void run() { final IBrowserConnection browserConnection = schemaPage.getConnection(); if ( browserConnection != null ) { new StudioBrowserJob( new ReloadSchemaRunnable( browserConnection ) ).execute(); schemaPage.getSchemaBrowser().refresh(); } } /** * Disposes this action. */ public void dispose() { schemaPage = null; } /** * Updates the enabled state. */ public void updateEnabledState() { setEnabled( schemaPage.getConnection() != null && !schemaPage.isShowDefaultSchema() ); } }
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/schemabrowser/MatchingRuleUseDescriptionDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/MatchingRuleUseDescriptionDetailsPage.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.schemabrowser; import java.util.List; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.MatchingRuleUse; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; public class MatchingRuleUseDescriptionDetailsPage extends SchemaDetailsPage { /** The main section, contains oid, names and desc */ private Section mainSection; /** The numeric oid field */ private Text numericOidText; /** The name link */ private Hyperlink nameLink; /** The description field */ private Text descText; /** The flag section, contains obsolete */ private Section flagSection; /** The obsolete field */ private Label isObsoleteText; /** The applies section, contains links */ private Section appliesSection; /** * Creates a new instance of MatchingRuleUseDescriptionDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ public MatchingRuleUseDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit ) { super( schemaPage, toolkit ); } /** * {@inheritDoc} */ public void createContents( final ScrolledForm detailForm ) { this.detailForm = detailForm; detailForm.getBody().setLayout( new GridLayout() ); // create main section mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); mainSection.setText( Messages.getString( "MatchingRuleUseDescriptionDetailsPage.Details" ) ); //$NON-NLS-1$ mainSection.marginWidth = 0; mainSection.marginHeight = 0; mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mainSection ); // create flag section flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); flagSection.setText( Messages.getString( "MatchingRuleUseDescriptionDetailsPage.Flags" ) ); //$NON-NLS-1$ flagSection.marginWidth = 0; flagSection.marginHeight = 0; flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( flagSection ); // create flag content Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP ); GridLayout flagLayout = new GridLayout(); flagLayout.numColumns = 1; flagLayout.marginWidth = 0; flagLayout.marginHeight = 0; flagClient.setLayout( flagLayout ); flagSection.setClient( flagClient ); isObsoleteText = toolkit.createLabel( flagClient, Messages .getString( "MatchingRuleUseDescriptionDetailsPage.Obsolete" ), SWT.CHECK ); //$NON-NLS-1$ isObsoleteText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); isObsoleteText.setEnabled( false ); // create applies section appliesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); appliesSection.setText( Messages.getString( "MatchingRuleUseDescriptionDetailsPage.Applies" ) ); //$NON-NLS-1$ appliesSection.marginWidth = 0; appliesSection.marginHeight = 0; appliesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( appliesSection ); appliesSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create raw section super.createRawSection(); } /** * {@inheritDoc} */ public void setInput( Object input ) { MatchingRuleUse mrud = null; if ( input instanceof MatchingRuleUse ) { mrud = ( MatchingRuleUse ) input; } // create main content this.createMainContent( mrud ); // set flag isObsoleteText.setEnabled( mrud != null && mrud.isObsolete() ); // create contents of dynamic sections this.createAppliesContents( mrud ); super.createRawContents( mrud ); this.detailForm.reflow( true ); } /** * Creates the content of the main section. It is newly created * on every input change to ensure a proper layout of * multilined descriptions. * * @param mrud the matching rule use description */ private void createMainContent( MatchingRuleUse mrud ) { // dispose old content if ( mainSection.getClient() != null ) { mainSection.getClient().dispose(); } // create new client Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP ); GridLayout mainLayout = new GridLayout( 2, false ); mainClient.setLayout( mainLayout ); mainSection.setClient( mainClient ); // create new content if ( mrud != null ) { toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleUseDescriptionDetailsPage.NumericOID" ), SWT.NONE ); //$NON-NLS-1$ numericOidText = toolkit.createText( mainClient, getNonNullString( mrud.getOid() ), SWT.NONE ); numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); numericOidText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleUseDescriptionDetailsPage.MatchingRules" ), SWT.NONE ); //$NON-NLS-1$ nameLink = toolkit.createHyperlink( mainClient, "", SWT.WRAP ); //$NON-NLS-1$ nameLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); nameLink.addHyperlinkListener( this ); Schema schema = getSchema(); MatchingRule mrd = schema.hasMatchingRuleDescription( mrud.getOid() ) ? schema .getMatchingRuleDescription( mrud.getOid() ) : null; nameLink .setText( getNonNullString( mrd != null ? SchemaUtils.toString( mrd ) : SchemaUtils.toString( mrud ) ) ); nameLink.setHref( mrd ); nameLink.setUnderlined( mrd != null ); nameLink.setEnabled( mrd != null ); toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleUseDescriptionDetailsPage.Description" ), SWT.NONE ); //$NON-NLS-1$ descText = toolkit.createText( mainClient, getNonNullString( mrud.getDescription() ), SWT.WRAP | SWT.MULTI ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.widthHint = detailForm.getForm().getSize().x - 100 - 60; descText.setLayoutData( gd ); descText.setEditable( false ); } mainSection.layout(); } /** * Creates the content of the applies section. * It is newly created on every input change because the content * of this section is dynamic. * * @param mrud the matching rule use description */ private void createAppliesContents( MatchingRuleUse mrud ) { // dispose old content if ( appliesSection.getClient() != null ) { appliesSection.getClient().dispose(); } // create new client Composite appliesClient = toolkit.createComposite( appliesSection, SWT.WRAP ); appliesClient.setLayout( new GridLayout() ); appliesSection.setClient( appliesClient ); // create content if ( mrud != null ) { List<String> names = mrud.getApplicableAttributeOids(); if ( names != null && !names.isEmpty() ) { appliesSection .setText( NLS .bind( Messages.getString( "MatchingRuleUseDescriptionDetailsPage.AppliesCount" ), new Object[] { names.size() } ) ); //$NON-NLS-1$ Schema schema = getSchema(); for ( String name : names ) { if ( schema.hasAttributeTypeDescription( name ) ) { AttributeType appliesAtd = schema.getAttributeTypeDescription( name ); Hyperlink appliesLink = toolkit.createHyperlink( appliesClient, SchemaUtils .toString( appliesAtd ), SWT.WRAP ); appliesLink.setHref( appliesAtd ); appliesLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); appliesLink.setUnderlined( true ); appliesLink.setEnabled( true ); appliesLink.addHyperlinkListener( this ); } else { Hyperlink appliesLink = toolkit.createHyperlink( appliesClient, name, SWT.WRAP ); appliesLink.setHref( null ); appliesLink.setUnderlined( false ); appliesLink.setEnabled( false ); } } } else { appliesSection.setText( NLS.bind( Messages .getString( "MatchingRuleUseDescriptionDetailsPage.AppliesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text usedFromText = toolkit.createText( appliesClient, getNonNullString( null ), SWT.NONE ); usedFromText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedFromText.setEditable( false ); } } else { appliesSection.setText( Messages.getString( "MatchingRuleUseDescriptionDetailsPage.Applies" ) ); //$NON-NLS-1$ } appliesSection.layout(); } }
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/schemabrowser/MatchingRuleDescriptionDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/MatchingRuleDescriptionDetailsPage.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.schemabrowser; import java.util.Collection; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * The MatchingRuleDescriptionDetailsPage displays the details of an * matching rule description. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MatchingRuleDescriptionDetailsPage extends SchemaDetailsPage { /** The main section, contains oid, names and desc */ private Section mainSection; /** The numeric oid field */ private Text numericOidText; /** The names field */ private Text namesText; /** The description field */ private Text descText; /** The flag section, contains obsolete */ private Section flagSection; /** The obsolete field */ private Label isObsoleteText; /** The syntax section, contains syntax description and a link to the syntax */ private Section syntaxSection; /** The syntax description field */ private Text syntaxDescText; /** The link to the syntax */ private Hyperlink syntaxLink; /** The used from section, contains links to attribute types */ private Section usedFromSection; /** * Creates a new instance of MatchingRuleDescriptionDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ public MatchingRuleDescriptionDetailsPage( SchemaPage scheamPage, FormToolkit toolkit ) { super( scheamPage, toolkit ); } /** * {@inheritDoc} */ public void createContents( final ScrolledForm detailForm ) { this.detailForm = detailForm; detailForm.getBody().setLayout( new GridLayout() ); // create main section mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); mainSection.setText( Messages.getString( "MatchingRuleDescriptionDetailsPage.Details" ) ); //$NON-NLS-1$ mainSection.marginWidth = 0; mainSection.marginHeight = 0; mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mainSection ); // create flag section flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); flagSection.setText( Messages.getString( "MatchingRuleDescriptionDetailsPage.Flags" ) ); //$NON-NLS-1$ flagSection.marginWidth = 0; flagSection.marginHeight = 0; flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( flagSection ); // create flag content Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP ); GridLayout flagLayout = new GridLayout(); flagLayout.numColumns = 1; flagLayout.marginWidth = 0; flagLayout.marginHeight = 0; flagClient.setLayout( flagLayout ); flagSection.setClient( flagClient ); isObsoleteText = toolkit.createLabel( flagClient, Messages .getString( "MatchingRuleDescriptionDetailsPage.Obsolete" ), SWT.CHECK ); //$NON-NLS-1$ isObsoleteText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); isObsoleteText.setEnabled( false ); // create syntax section syntaxSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); syntaxSection.setText( Messages.getString( "MatchingRuleDescriptionDetailsPage.Syntax" ) ); //$NON-NLS-1$ syntaxSection.marginWidth = 0; syntaxSection.marginHeight = 0; syntaxSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( syntaxSection ); // create syntax content Composite syntaxClient = toolkit.createComposite( syntaxSection, SWT.WRAP ); GridLayout syntaxLayout = new GridLayout(); syntaxLayout.numColumns = 2; syntaxLayout.marginWidth = 0; syntaxLayout.marginHeight = 0; syntaxClient.setLayout( syntaxLayout ); syntaxSection.setClient( syntaxClient ); toolkit.createLabel( syntaxClient, Messages.getString( "MatchingRuleDescriptionDetailsPage.SyntaxOID" ), SWT.NONE ); //$NON-NLS-1$ syntaxLink = toolkit.createHyperlink( syntaxClient, "", SWT.WRAP ); //$NON-NLS-1$ syntaxLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); syntaxLink.addHyperlinkListener( this ); toolkit.createLabel( syntaxClient, Messages.getString( "MatchingRuleDescriptionDetailsPage.SyntaxDescription" ), SWT.NONE ); //$NON-NLS-1$ syntaxDescText = toolkit.createText( syntaxClient, "", SWT.NONE ); //$NON-NLS-1$ syntaxDescText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); syntaxDescText.setEditable( false ); // create used from section usedFromSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); usedFromSection.setText( Messages.getString( "MatchingRuleDescriptionDetailsPage.UsedFrom" ) ); //$NON-NLS-1$ usedFromSection.marginWidth = 0; usedFromSection.marginHeight = 0; usedFromSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( usedFromSection ); usedFromSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create raw section createRawSection(); } /** * {@inheritDoc} */ public void setInput( Object input ) { MatchingRule mrd = null; if ( input instanceof MatchingRule ) { mrd = ( MatchingRule ) input; } // create main content createMainContent( mrd ); // set flag isObsoleteText.setEnabled( mrd != null && mrd.isObsolete() ); // set syntax content String lsdOid = null; LdapSyntax lsd = null; if ( mrd != null ) { Schema schema = getSchema(); lsdOid = mrd.getSyntaxOid(); if ( lsdOid != null && schema.hasLdapSyntaxDescription( lsdOid ) ) { lsd = schema.getLdapSyntaxDescription( lsdOid ); } } syntaxLink.setText( getNonNullString( lsd != null ? lsd.getOid() : lsdOid ) ); syntaxLink.setHref( lsd ); syntaxLink.setUnderlined( lsd != null ); syntaxLink.setEnabled( lsd != null ); syntaxDescText.setText( getNonNullString( lsd != null ? lsd.getDescription() : null ) ); syntaxSection.layout(); // create contents of dynamic sections createUsedFromContents( mrd ); createRawContents( mrd ); detailForm.reflow( true ); } /** * Creates the content of the main section. It is newly created * on every input change to ensure a proper layout of * multilined descriptions. * * @param mrd the matching rule description */ private void createMainContent( MatchingRule mrd ) { // dispose old content if ( mainSection.getClient() != null ) { mainSection.getClient().dispose(); } // create new client Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP ); GridLayout mainLayout = new GridLayout( 2, false ); mainClient.setLayout( mainLayout ); mainSection.setClient( mainClient ); // create new content if ( mrd != null ) { toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleDescriptionDetailsPage.NumericOID" ), SWT.NONE ); //$NON-NLS-1$ numericOidText = toolkit.createText( mainClient, getNonNullString( mrd.getOid() ), SWT.NONE ); numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); numericOidText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleDescriptionDetailsPage.MatchingRule" ), SWT.NONE ); //$NON-NLS-1$ namesText = toolkit.createText( mainClient, getNonNullString( SchemaUtils.toString( mrd ) ), SWT.NONE ); namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); namesText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "MatchingRuleDescriptionDetailsPage.Description" ), SWT.NONE ); //$NON-NLS-1$ descText = toolkit.createText( mainClient, getNonNullString( mrd.getDescription() ), SWT.WRAP | SWT.MULTI ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.widthHint = detailForm.getForm().getSize().x - 100 - 60; descText.setLayoutData( gd ); descText.setEditable( false ); } mainSection.layout(); } /** * Creates the content of the used from section. * It is newly created on every input change because the content * of this section is dynamic. * * @param mrd the matching rule description */ private void createUsedFromContents( MatchingRule mrd ) { // dispose old content if ( usedFromSection.getClient() != null ) { usedFromSection.getClient().dispose(); } // create new client Composite usedFromClient = toolkit.createComposite( usedFromSection, SWT.WRAP ); usedFromClient.setLayout( new GridLayout() ); usedFromSection.setClient( usedFromClient ); // create new content if ( mrd != null ) { Collection<AttributeType> usedFromATDs = SchemaUtils.getUsedFromAttributeTypeDescriptions( mrd, getSchema() ); if ( usedFromATDs != null && usedFromATDs.size() > 0 ) { usedFromSection .setText( NLS .bind( Messages.getString( "MatchingRuleDescriptionDetailsPage.UsedFromCount" ), new Object[] { usedFromATDs.size() } ) ); //$NON-NLS-1$ for ( AttributeType atd : usedFromATDs ) { Hyperlink usedFromLink = toolkit.createHyperlink( usedFromClient, SchemaUtils.toString( atd ), SWT.WRAP ); usedFromLink.setHref( atd ); usedFromLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedFromLink.setUnderlined( true ); usedFromLink.setEnabled( true ); usedFromLink.addHyperlinkListener( this ); } } else { usedFromSection.setText( NLS.bind( Messages .getString( "MatchingRuleDescriptionDetailsPage.UsedFromCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text usedFromText = toolkit.createText( usedFromClient, getNonNullString( null ), SWT.NONE ); usedFromText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedFromText.setEditable( false ); } } else { usedFromSection.setText( Messages.getString( "MatchingRuleDescriptionDetailsPage.UsedFrom" ) ); //$NON-NLS-1$ } usedFromSection.layout(); } }
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/schemabrowser/SchemaBrowser.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowser.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.MatchingRuleUse; import org.apache.directory.api.ldap.model.schema.ObjectClass; 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.core.runtime.IProgressMonitor; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.INavigationLocationProvider; import org.eclipse.ui.IReusableEditor; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.EditorPart; /** * The schema browser editor part. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaBrowser extends EditorPart implements INavigationLocationProvider, IReusableEditor { /** The tab folder with all the schema element tabs */ private CTabFolder tabFolder; /** The object class tab */ private CTabItem ocdTab; /** The object class page */ private ObjectClassDescriptionPage ocdPage; /** The attribute type tab */ private CTabItem atdTab; /** The attribute type page */ private AttributeTypeDescriptionPage atdPage; /** The matching rule tab */ private CTabItem mrdTab; /** The matching rule page */ private MatchingRuleDescriptionPage mrdPage; /** The matching rule use tab */ private CTabItem mrudTab; /** The matching rule use page */ private MatchingRuleUseDescriptionPage mrudPage; /** The syntax tab */ private CTabItem lsdTab; /** The syntax page */ private LdapSyntaxDescriptionPage lsdPage; /** * Gets the ID of the schema browser. * * @return the ID of the schema browser */ public static String getId() { return BrowserUIConstants.EDITOR_SCHEMA_BROWSER; } /** * {@inheritDoc} */ public void init( IEditorSite site, IEditorInput input ) throws PartInitException { setSite( site ); // mark dummy location, necessary because the first marked // location doesn't appear in history setInput( new SchemaBrowserInput( null, null ) ); getSite().getPage().getNavigationHistory().markLocation( this ); // set real input setInput( input ); } /** * {@inheritDoc} */ public void dispose() { ocdPage.dispose(); atdPage.dispose(); mrdPage.dispose(); mrudPage.dispose(); lsdPage.dispose(); tabFolder.dispose(); super.dispose(); } /** * {@inheritDoc} */ public void createPartControl( Composite parent ) { tabFolder = new CTabFolder( parent, SWT.BOTTOM ); ocdTab = new CTabItem( tabFolder, SWT.NONE ); ocdTab.setText( Messages.getString( "SchemaBrowser.ObjectClasses" ) ); //$NON-NLS-1$ ocdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_OCD ) ); ocdPage = new ObjectClassDescriptionPage( this ); Control ocdPageControl = ocdPage.createControl( tabFolder ); ocdTab.setControl( ocdPageControl ); atdTab = new CTabItem( tabFolder, SWT.NONE ); atdTab.setText( Messages.getString( "SchemaBrowser.AttributeTypes" ) ); //$NON-NLS-1$ atdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_ATD ) ); atdPage = new AttributeTypeDescriptionPage( this ); Control atdPageControl = atdPage.createControl( tabFolder ); atdTab.setControl( atdPageControl ); mrdTab = new CTabItem( tabFolder, SWT.NONE ); mrdTab.setText( Messages.getString( "SchemaBrowser.MatchingRules" ) ); //$NON-NLS-1$ mrdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRD ) ); mrdPage = new MatchingRuleDescriptionPage( this ); Control mrdPageControl = mrdPage.createControl( tabFolder ); mrdTab.setControl( mrdPageControl ); mrudTab = new CTabItem( tabFolder, SWT.NONE ); mrudTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_MRUD ) ); mrudTab.setText( Messages.getString( "SchemaBrowser.MatchingRulesUse" ) ); //$NON-NLS-1$ mrudPage = new MatchingRuleUseDescriptionPage( this ); Control mrudPageControl = mrudPage.createControl( tabFolder ); mrudTab.setControl( mrudPageControl ); lsdTab = new CTabItem( tabFolder, SWT.NONE ); lsdTab.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LSD ) ); lsdTab.setText( Messages.getString( "SchemaBrowser.Syntaxes" ) ); //$NON-NLS-1$ lsdPage = new LdapSyntaxDescriptionPage( this ); Control lsdPageControl = lsdPage.createControl( tabFolder ); lsdTab.setControl( lsdPageControl ); // set default selection tabFolder.setSelection( ocdTab ); // init help context PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, BrowserUIConstants.PLUGIN_ID + "." + "tools_schema_browser" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( tabFolder, BrowserUIConstants.PLUGIN_ID + "." + "tools_schema_browser" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( ocdPageControl, BrowserUIConstants.PLUGIN_ID + "." + "tools_schema_browser" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public void setInput( IEditorInput input ) { super.setInput( input ); if ( input instanceof SchemaBrowserInput && tabFolder != null ) { SchemaBrowserInput sbi = ( SchemaBrowserInput ) input; // set connection; IBrowserConnection connection = sbi.getConnection(); setConnection( connection ); // set schema element and activate tab AbstractSchemaObject schemaElement = sbi.getSchemaElement(); if ( schemaElement instanceof ObjectClass ) { ocdPage.select( schemaElement ); tabFolder.setSelection( ocdTab ); } else if ( schemaElement instanceof AttributeType ) { atdPage.select( schemaElement ); tabFolder.setSelection( atdTab ); } else if ( schemaElement instanceof MatchingRule ) { mrdPage.select( schemaElement ); tabFolder.setSelection( mrdTab ); } else if ( schemaElement instanceof MatchingRuleUse ) { mrudPage.select( schemaElement ); tabFolder.setSelection( mrudTab ); } else if ( schemaElement instanceof LdapSyntax ) { lsdPage.select( schemaElement ); tabFolder.setSelection( lsdTab ); } if ( connection != null && schemaElement != null ) { // disable one instance hack before fireing the input change event // otherwise the navigation history is cleared. // Note: seems this behavior has been changed with Eclipse 3.3 SchemaBrowserInput.enableOneInstanceHack( false ); firePropertyChange( IEditorPart.PROP_INPUT ); // enable one instance hack for marking the location // Note: seems this behavior has been changed with Eclipse 3.3 SchemaBrowserInput.enableOneInstanceHack( true ); getSite().getPage().getNavigationHistory().markLocation( this ); } // finally enable the one instance hack SchemaBrowserInput.enableOneInstanceHack( true ); } } /** * Refreshes all pages. */ public void refresh() { ocdPage.refresh(); atdPage.refresh(); mrdPage.refresh(); mrudPage.refresh(); lsdPage.refresh(); } /** * Sets the show defauls schema flag to all pages. * * @param b the default schema flag */ public void setShowDefaultSchema( boolean b ) { ocdPage.setShowDefaultSchema( b ); atdPage.setShowDefaultSchema( b ); mrdPage.setShowDefaultSchema( b ); mrudPage.setShowDefaultSchema( b ); lsdPage.setShowDefaultSchema( b ); } /** * Sets the connection. * * @param connection the connection */ public void setConnection( IBrowserConnection connection ) { ocdPage.setConnection( connection ); atdPage.setConnection( connection ); mrdPage.setConnection( connection ); mrudPage.setConnection( connection ); lsdPage.setConnection( connection ); } /** * {@inheritDoc} */ public void setFocus() { } /** * {@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 SchemaBrowserNavigationLocation( 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/editors/schemabrowser/AttributeTypeDescriptionDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/AttributeTypeDescriptionDetailsPage.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.schemabrowser; import java.util.Collection; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.ldap.model.schema.UsageEnum; import org.apache.directory.studio.common.ui.CommonUIConstants; import org.apache.directory.studio.common.ui.CommonUIPlugin; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * The AttributeTypeDescriptionDetailsPage displays the details of an * attribute type description. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AttributeTypeDescriptionDetailsPage extends SchemaDetailsPage { /** The main section, contains oid, names, desc and usage */ private Section mainSection; /** The numeric oid field */ private Text numericOidText; /** The names field */ private Text namesText; /** The description field */ private Text descText; /** The usage field */ private Text usageText; /** The flag section, contains sv, obsolete, collective and read-only */ private Section flagSection; /** The single-valued label */ private Label singleValuedLabel; /** The obsolete label */ private Label isObsoleteLabel; /** The collective label */ private Label collectiveLabel; /** The no-user-modification label */ private Label noUserModificationLabel; /** The syntax section, contains syntax description, lenth and a link to the syntax */ private Section syntaxSection; /** The syntax description field */ private Text syntaxDescText; /** The syntax length field */ private Text lengthText; /** The link to the syntax */ private Hyperlink syntaxLink; /** The matching rules section, contains links to matching rules */ private Section matchingRulesSection; /** The link to the equality matching rule */ private Hyperlink equalityLink; /** The link to the substring matching rule */ private Hyperlink substringLink; /** The link to the ordering matching rule */ private Hyperlink orderingLink; /** The section with other matching rules */ private Section otherMatchSection; /** The section with links to object classes using the selected attribute as must */ private Section usedAsMustSection; /** The section with links to object classes using the selected attribute as may */ private Section usedAsMaySection; /** The section with a link to the superior attribute type */ private Section supertypeSection; /** The section with links to the derived attribute types */ private Section subtypesSection; /** * Creates a new instance of AttributeTypeDescriptionDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ public AttributeTypeDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit ) { super( schemaPage, toolkit ); } /** * {@inheritDoc} */ protected void createContents( final ScrolledForm detailForm ) { this.detailForm = detailForm; detailForm.getBody().setLayout( new GridLayout() ); // create main section mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); mainSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Details" ) ); //$NON-NLS-1$ mainSection.marginWidth = 0; mainSection.marginHeight = 0; mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mainSection ); // create flag section flagSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); flagSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Flags" ) ); //$NON-NLS-1$ flagSection.marginWidth = 0; flagSection.marginHeight = 0; flagSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( flagSection ); // create flags content Composite flagClient = toolkit.createComposite( flagSection, SWT.WRAP ); GridLayout flagLayout = new GridLayout(); flagLayout.numColumns = 4; flagLayout.marginWidth = 0; flagLayout.marginHeight = 0; flagClient.setLayout( flagLayout ); flagSection.setClient( flagClient ); singleValuedLabel = toolkit.createLabel( flagClient, Messages .getString( "AttributeTypeDescriptionDetailsPage.SingleValued" ), SWT.CHECK ); //$NON-NLS-1$ singleValuedLabel.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); noUserModificationLabel = toolkit.createLabel( flagClient, Messages .getString( "AttributeTypeDescriptionDetailsPage.ReadOnly" ), SWT.CHECK ); //$NON-NLS-1$ noUserModificationLabel.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); collectiveLabel = toolkit.createLabel( flagClient, Messages .getString( "AttributeTypeDescriptionDetailsPage.Collective" ), SWT.CHECK ); //$NON-NLS-1$ collectiveLabel.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); isObsoleteLabel = toolkit.createLabel( flagClient, Messages .getString( "AttributeTypeDescriptionDetailsPage.Obsolete" ), SWT.CHECK ); //$NON-NLS-1$ isObsoleteLabel.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); // create syntax section syntaxSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); syntaxSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Syntax" ) ); //$NON-NLS-1$ syntaxSection.marginWidth = 0; syntaxSection.marginHeight = 0; syntaxSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( syntaxSection ); // create syntax content Composite syntaxClient = toolkit.createComposite( syntaxSection, SWT.WRAP ); GridLayout syntaxLayout = new GridLayout(); syntaxLayout.numColumns = 2; syntaxLayout.marginWidth = 0; syntaxLayout.marginHeight = 0; syntaxClient.setLayout( syntaxLayout ); syntaxSection.setClient( syntaxClient ); toolkit.createLabel( syntaxClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.SyntaxOID" ), SWT.NONE ); //$NON-NLS-1$ syntaxLink = toolkit.createHyperlink( syntaxClient, "", SWT.WRAP ); //$NON-NLS-1$ syntaxLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); syntaxLink.addHyperlinkListener( this ); toolkit.createLabel( syntaxClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.SyntaxDescription" ), SWT.NONE ); //$NON-NLS-1$ syntaxDescText = toolkit.createText( syntaxClient, "", SWT.NONE ); //$NON-NLS-1$ syntaxDescText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); syntaxDescText.setEditable( false ); toolkit .createLabel( syntaxClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.Length" ), SWT.NONE ); //$NON-NLS-1$ lengthText = toolkit.createText( syntaxClient, "", SWT.NONE ); //$NON-NLS-1$ lengthText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); lengthText.setEditable( false ); // create matching rules section matchingRulesSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); matchingRulesSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.MatchingRules" ) ); //$NON-NLS-1$ matchingRulesSection.marginWidth = 0; matchingRulesSection.marginHeight = 0; matchingRulesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( matchingRulesSection ); // create matching rules content Composite matchClient = toolkit.createComposite( matchingRulesSection, SWT.WRAP ); GridLayout matchLayout = new GridLayout(); matchLayout.numColumns = 2; matchLayout.marginWidth = 0; matchLayout.marginHeight = 0; matchClient.setLayout( matchLayout ); matchingRulesSection.setClient( matchClient ); toolkit.createLabel( matchClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.EqualityMatch" ), SWT.NONE ); //$NON-NLS-1$ equalityLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP ); //$NON-NLS-1$ equalityLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); equalityLink.addHyperlinkListener( this ); toolkit.createLabel( matchClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.SubstringMatch" ), SWT.NONE ); //$NON-NLS-1$ substringLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP ); //$NON-NLS-1$ substringLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); substringLink.addHyperlinkListener( this ); toolkit.createLabel( matchClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.OrderingMatch" ), SWT.NONE ); //$NON-NLS-1$ orderingLink = toolkit.createHyperlink( matchClient, "", SWT.WRAP ); //$NON-NLS-1$ orderingLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); orderingLink.addHyperlinkListener( this ); // create other matching rules section otherMatchSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); otherMatchSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.OtherMatchingRules" ) ); //$NON-NLS-1$ otherMatchSection.marginWidth = 0; otherMatchSection.marginHeight = 0; otherMatchSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( otherMatchSection ); otherMatchSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create used as must section usedAsMustSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); usedAsMustSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.UsedAsMust" ) ); //$NON-NLS-1$ usedAsMustSection.marginWidth = 0; usedAsMustSection.marginHeight = 0; usedAsMustSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( usedAsMustSection ); usedAsMustSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create used as may section usedAsMaySection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); usedAsMaySection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.UsedAsMay" ) ); //$NON-NLS-1$ usedAsMaySection.marginWidth = 0; usedAsMaySection.marginHeight = 0; usedAsMaySection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( usedAsMaySection ); usedAsMaySection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create supertype section supertypeSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); supertypeSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Supertype" ) ); //$NON-NLS-1$ supertypeSection.marginWidth = 0; supertypeSection.marginHeight = 0; supertypeSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( supertypeSection ); supertypeSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create subtypes section subtypesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); subtypesSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Subtypes" ) ); //$NON-NLS-1$ subtypesSection.marginWidth = 0; subtypesSection.marginHeight = 0; subtypesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( subtypesSection ); subtypesSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create raw section createRawSection(); } /** * {@inheritDoc} */ public void setInput( Object input ) { AttributeType atd = null; if ( input instanceof AttributeType ) { atd = ( AttributeType ) input; } // create main content createMainContent( atd ); // set flags if ( ( atd != null ) && ( atd.isSingleValued() ) ) { singleValuedLabel.setForeground( getColor( CommonUIConstants.DEFAULT_COLOR ) ); } else { singleValuedLabel.setForeground( getColor( CommonUIConstants.DISABLED_COLOR ) ); } if ( atd != null && atd.isObsolete() ) { isObsoleteLabel.setForeground( getColor( CommonUIConstants.DEFAULT_COLOR ) ); } else { isObsoleteLabel.setForeground( getColor( CommonUIConstants.DISABLED_COLOR ) ); } if ( atd != null && atd.isCollective() ) { collectiveLabel.setForeground( getColor( CommonUIConstants.DEFAULT_COLOR ) ); } else { collectiveLabel.setForeground( getColor( CommonUIConstants.DISABLED_COLOR ) ); } if ( atd != null && !atd.isUserModifiable() ) { noUserModificationLabel.setForeground( getColor( CommonUIConstants.DEFAULT_COLOR ) ); } else { noUserModificationLabel.setForeground( getColor( CommonUIConstants.DISABLED_COLOR ) ); } flagSection.layout(); // set syntax content String lsdOid = null; LdapSyntax lsd = null; long lsdLength = 0; if ( atd != null ) { lsdOid = SchemaUtils.getSyntaxNumericOidTransitive( atd, getSchema() ); if ( lsdOid != null && getSchema().hasLdapSyntaxDescription( lsdOid ) ) { lsd = getSchema().getLdapSyntaxDescription( lsdOid ); } lsdLength = SchemaUtils.getSyntaxLengthTransitive( atd, getSchema() ); } syntaxLink.setText( getNonNullString( lsd != null ? lsd.getOid() : lsdOid ) ); syntaxLink.setHref( lsd ); syntaxLink.setUnderlined( lsd != null ); syntaxLink.setEnabled( lsd != null ); syntaxDescText.setText( getNonNullString( lsd != null ? lsd.getDescription() : null ) ); lengthText.setText( getNonNullString( lsdLength > 0 ? Long.toString( lsdLength ) : null ) ); syntaxSection.layout(); // set matching rules content String emrOid = null; MatchingRule emr = null; if ( atd != null ) { emrOid = SchemaUtils.getEqualityMatchingRuleNameOrNumericOidTransitive( atd, getSchema() ); if ( emrOid != null && getSchema().hasMatchingRuleDescription( emrOid ) ) { emr = getSchema().getMatchingRuleDescription( emrOid ); } } equalityLink.setText( getNonNullString( emr != null ? SchemaUtils.toString( emr ) : emrOid ) ); equalityLink.setHref( emr ); equalityLink.setUnderlined( emr != null ); equalityLink.setEnabled( emr != null ); String smrOid = null; MatchingRule smr = null; if ( atd != null ) { smrOid = SchemaUtils.getSubstringMatchingRuleNameOrNumericOidTransitive( atd, getSchema() ); if ( smrOid != null && getSchema().hasMatchingRuleDescription( smrOid ) ) { smr = getSchema().getMatchingRuleDescription( smrOid ); } } substringLink.setText( getNonNullString( smr != null ? SchemaUtils.toString( smr ) : smrOid ) ); substringLink.setHref( smr ); substringLink.setUnderlined( smr != null ); substringLink.setEnabled( smr != null ); String omrOid = null; MatchingRule omr = null; if ( atd != null ) { omrOid = SchemaUtils.getOrderingMatchingRuleNameOrNumericOidTransitive( atd, getSchema() ); if ( omrOid != null && getSchema().hasMatchingRuleDescription( omrOid ) ) { omr = getSchema().getMatchingRuleDescription( omrOid ); } } orderingLink.setText( getNonNullString( omr != null ? SchemaUtils.toString( omr ) : omrOid ) ); orderingLink.setHref( omr ); orderingLink.setUnderlined( omr != null ); orderingLink.setEnabled( omr != null ); matchingRulesSection.layout(); // create contents of dynamic sections createOtherMatchContent( atd ); createUsedAsMustContent( atd ); createUsedAsMayContent( atd ); createSupertypeContent( atd ); createSubtypesContent( atd ); createRawContents( atd ); detailForm.reflow( true ); } private Color getColor( String color ) { return CommonUIPlugin.getDefault().getColor( color ); } /** * Creates the content of the main section. It is newly created * on every input change to ensure a proper layout of * multilined descriptions. * * @param atd the attribute type description */ private void createMainContent( AttributeType atd ) { // dispose old content if ( mainSection.getClient() != null ) { mainSection.getClient().dispose(); } // create new client Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP ); GridLayout mainLayout = new GridLayout( 2, false ); mainClient.setLayout( mainLayout ); mainSection.setClient( mainClient ); // create new content if ( atd != null ) { toolkit.createLabel( mainClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.NumericOID" ), SWT.NONE ); //$NON-NLS-1$ numericOidText = toolkit.createText( mainClient, getNonNullString( atd.getOid() ), SWT.NONE ); numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); numericOidText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.AttributeNames" ), SWT.NONE ); //$NON-NLS-1$ namesText = toolkit.createText( mainClient, getNonNullString( SchemaUtils.toString( atd ) ), SWT.NONE ); namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); namesText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.Description" ), SWT.WRAP ); //$NON-NLS-1$ descText = toolkit.createText( mainClient, getNonNullString( atd.getDescription() ), SWT.WRAP | SWT.MULTI ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.widthHint = detailForm.getForm().getSize().x - 100 - 60; descText.setLayoutData( gd ); descText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "AttributeTypeDescriptionDetailsPage.Usage" ), SWT.NONE ); //$NON-NLS-1$ usageText = toolkit.createText( mainClient, getNonNullString( UsageEnum.render( atd.getUsage() ) ), SWT.NONE ); usageText.setLayoutData( new GridData( GridData.GRAB_HORIZONTAL ) ); usageText.setEditable( false ); } mainSection.layout(); } /** * Creates the content of the other matching rules section. * It is newly created on every input change because the content * of this section is dynamic. * * @param atd the attribute type description */ private void createOtherMatchContent( AttributeType atd ) { // dispose old content if ( otherMatchSection.getClient() != null ) { otherMatchSection.getClient().dispose(); } // create new client Composite otherMatchClient = toolkit.createComposite( otherMatchSection, SWT.WRAP ); otherMatchClient.setLayout( new GridLayout() ); otherMatchSection.setClient( otherMatchClient ); // create new content, either links to other matching rules // or a dash if no other matching rules exist. if ( atd != null ) { Collection<String> otherMrdNames = SchemaUtils.getOtherMatchingRuleDescriptionNames( atd, getSchema() ); if ( otherMrdNames != null && otherMrdNames.size() > 0 ) { otherMatchSection .setText( NLS .bind( Messages.getString( "AttributeTypeDescriptionDetailsPage.OtherMatchingRulesCount" ), new Object[] { otherMrdNames.size() } ) ); //$NON-NLS-1$ for ( String mrdName : otherMrdNames ) { if ( getSchema().hasMatchingRuleDescription( mrdName ) ) { MatchingRule mrd = getSchema().getMatchingRuleDescription( mrdName ); Hyperlink otherMatchLink = toolkit.createHyperlink( otherMatchClient, SchemaUtils .toString( mrd ), SWT.WRAP ); otherMatchLink.setHref( mrd ); otherMatchLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); otherMatchLink.setUnderlined( true ); otherMatchLink.setEnabled( true ); otherMatchLink.addHyperlinkListener( this ); } else { Hyperlink otherMatchLink = toolkit.createHyperlink( otherMatchClient, mrdName, SWT.WRAP ); otherMatchLink.setHref( null ); otherMatchLink.setUnderlined( false ); otherMatchLink.setEnabled( false ); } } } else { otherMatchSection.setText( NLS.bind( Messages .getString( "AttributeTypeDescriptionDetailsPage.OtherMatchingRulesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text otherText = toolkit.createText( otherMatchClient, getNonNullString( null ), SWT.NONE ); otherText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); otherText.setEditable( false ); } } else { otherMatchSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.OtherMatchingRules" ) ); //$NON-NLS-1$ } otherMatchSection.layout(); } /** * Creates the content of the supertype section. * It is newly created on every input change because the content * of this section is dynamic. * * @param atd the attribute type description */ private void createSupertypeContent( AttributeType atd ) { // dispose old content if ( supertypeSection.getClient() != null ) { supertypeSection.getClient().dispose(); } // create new client Composite superClient = toolkit.createComposite( supertypeSection, SWT.WRAP ); superClient.setLayout( new GridLayout() ); supertypeSection.setClient( superClient ); // create new content, either a link to the superior attribute type // or a dash if no supertype exists. if ( atd != null ) { String superType = atd.getSuperiorOid(); if ( superType != null ) { supertypeSection.setText( NLS.bind( Messages .getString( "AttributeTypeDescriptionDetailsPage.SupertypeCount" ), new Object[] { 1 } ) ); //$NON-NLS-1$ if ( getSchema().hasAttributeTypeDescription( superType ) ) { AttributeType supAtd = getSchema().getAttributeTypeDescription( superType ); Hyperlink superLink = toolkit.createHyperlink( superClient, SchemaUtils.toString( supAtd ), SWT.WRAP ); superLink.setHref( supAtd ); superLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); superLink.setUnderlined( true ); superLink.setEnabled( true ); superLink.addHyperlinkListener( this ); } else { Hyperlink superLink = toolkit.createHyperlink( superClient, superType, SWT.WRAP ); superLink.setHref( null ); superLink.setUnderlined( false ); superLink.setEnabled( false ); } } else { supertypeSection.setText( NLS.bind( Messages .getString( "AttributeTypeDescriptionDetailsPage.SupertypeCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text supText = toolkit.createText( superClient, getNonNullString( null ), SWT.NONE ); supText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); supText.setEditable( false ); } } else { supertypeSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Supertype" ) ); //$NON-NLS-1$ } supertypeSection.layout(); } /** * Creates the content of the subtypes. * It is newly created on every input change because the content * of this section is dynamic. * * @param atd the attribute type description */ private void createSubtypesContent( AttributeType atd ) { // dispose old content if ( subtypesSection.getClient() != null ) { subtypesSection.getClient().dispose(); } // create new client Composite subClient = toolkit.createComposite( subtypesSection, SWT.WRAP ); subClient.setLayout( new GridLayout() ); subtypesSection.setClient( subClient ); // create new content, either links to subtypes or a dash if no subtypes exist. if ( atd != null ) { Collection<AttributeType> derivedAtds = SchemaUtils.getDerivedAttributeTypeDescriptions( atd, getSchema() ); if ( derivedAtds != null && derivedAtds.size() > 0 ) { subtypesSection .setText( NLS .bind( Messages.getString( "AttributeTypeDescriptionDetailsPage.SubtypesCount" ), new Object[] { derivedAtds.size() } ) ); //$NON-NLS-1$ for ( AttributeType derivedAtd : derivedAtds ) { Hyperlink subAttributeTypeLink = toolkit.createHyperlink( subClient, SchemaUtils .toString( derivedAtd ), SWT.WRAP ); subAttributeTypeLink.setHref( derivedAtd ); subAttributeTypeLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); subAttributeTypeLink.setUnderlined( true ); subAttributeTypeLink.setEnabled( true ); subAttributeTypeLink.addHyperlinkListener( this ); } } else { subtypesSection.setText( NLS.bind( Messages .getString( "AttributeTypeDescriptionDetailsPage.SubtypesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text subText = toolkit.createText( subClient, getNonNullString( null ), SWT.NONE ); subText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); subText.setEditable( false ); } } else { subtypesSection.setText( Messages.getString( "AttributeTypeDescriptionDetailsPage.Subtypes" ) ); //$NON-NLS-1$ } subtypesSection.layout(); } /** * Creates the content of the used as must section. * It is newly created on every input change because the content * of this section is dynamic. * * @param atd the attribute type description */ private void createUsedAsMustContent( AttributeType atd ) { // dispose old content if ( usedAsMustSection.getClient() != null ) { usedAsMustSection.getClient().dispose(); } // create new client Composite mustClient = toolkit.createComposite( usedAsMustSection, SWT.WRAP ); mustClient.setLayout( new GridLayout() ); usedAsMustSection.setClient( mustClient ); // create new content, either links to objectclasses or a dash if ( atd != null ) { Collection<ObjectClass> usedAsMusts = SchemaUtils.getUsedAsMust( atd, getSchema() ); if ( usedAsMusts != null && usedAsMusts.size() > 0 ) { usedAsMustSection .setText( NLS .bind( Messages.getString( "AttributeTypeDescriptionDetailsPage.UsedAsMustCount" ), new Object[] { usedAsMusts.size() } ) ); //$NON-NLS-1$ for ( ObjectClass ocd : usedAsMusts ) { Hyperlink usedAsMustLink = toolkit.createHyperlink( mustClient, SchemaUtils.toString( ocd ), SWT.WRAP ); usedAsMustLink.setHref( ocd ); usedAsMustLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedAsMustLink.setUnderlined( true ); usedAsMustLink.setEnabled( true ); usedAsMustLink.addHyperlinkListener( this ); } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
true
apache/directory-studio
https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ObjectClassDescriptionPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ObjectClassDescriptionPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.graphics.Image; /** * The ObjectClassDescriptionPage displays a list with all * object class descriptions and hosts the detail page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ObjectClassDescriptionPage extends SchemaPage { /** * Creates a new instance of ObjectClassDescriptionPage. * * @param schemaBrowser the schema browser */ public ObjectClassDescriptionPage( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ protected String getTitle() { return Messages.getString( "ObjectClassDescriptionPage.ObjectClasses" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String getFilterDescription() { return Messages.getString( "ObjectClassDescriptionPage.SelectObjectClass" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected IStructuredContentProvider getContentProvider() { return new OCDContentProvider(); } /** * {@inheritDoc} */ protected ITableLabelProvider getLabelProvider() { return new OCDLabelProvider(); } /** * {@inheritDoc} */ protected ViewerSorter getSorter() { return new OCDViewerSorter(); } /** * {@inheritDoc} */ protected ViewerFilter getFilter() { return new OCDViewerFilter(); } /** * {@inheritDoc} */ protected SchemaDetailsPage getDetailsPage() { return new ObjectClassDescriptionDetailsPage( this, this.toolkit ); } /** * The content provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class OCDContentProvider implements IStructuredContentProvider { /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof Schema ) { Schema schema = ( Schema ) inputElement; if ( schema != null ) { return schema.getObjectClassDescriptions().toArray(); } } return new Object[0]; } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * The label provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class OCDLabelProvider extends LabelProvider implements ITableLabelProvider { /** * {@inheritDoc} */ public String getColumnText( Object obj, int index ) { if ( obj instanceof ObjectClass ) { return SchemaUtils.toString( ( ObjectClass ) obj ); } return obj.toString(); } /** * {@inheritDoc} */ public Image getColumnImage( Object obj, int index ) { return null; } } /** * The sorter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class OCDViewerSorter extends ViewerSorter { /** * {@inheritDoc} */ public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof ObjectClass ) { e1 = SchemaUtils.toString( ( ObjectClass ) e1 ); } if ( e2 instanceof ObjectClass ) { e2 = SchemaUtils.toString( ( ObjectClass ) e2 ); } return e1.toString().compareTo( e2.toString() ); } } /** * The filter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class OCDViewerFilter extends ViewerFilter { /** * {@inheritDoc} */ public boolean select( Viewer viewer, Object parentElement, Object element ) { if ( element instanceof ObjectClass ) { ObjectClass ocd = ( ObjectClass ) element; boolean matched = Strings.toLowerCase( SchemaUtils.toString( ocd ) ) .indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1 || Strings.toLowerCase( ocd.getOid() ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1; return matched; } 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/schemabrowser/ObjectClassDescriptionDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ObjectClassDescriptionDetailsPage.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.schemabrowser; import java.util.Collection; import java.util.List; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * The ObjectClassDescriptionDetailsPage displays the details of an * object class description. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ObjectClassDescriptionDetailsPage extends SchemaDetailsPage { /** The main section, contains oid, names, desc and kind */ private Section mainSection; /** The numeric oid field */ private Text numericOidText; /** The names field */ private Text namesText; /** The description field */ private Text descText; /** The kind field */ private Text kindText; /** The section with links to superior object classes */ private Section superclassesSection; /** The section with links to derived object classes */ private Section subclassesSection; /** The section with links to must attribute types */ private Section mustSection; /** The section with links to may attribute types */ private Section maySection; /** * Creates a new instance of ObjectClassDescriptionDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ public ObjectClassDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit ) { super( schemaPage, toolkit ); } /** * {@inheritDoc} */ public void createContents( final ScrolledForm detailForm ) { this.detailForm = detailForm; detailForm.getBody().setLayout( new GridLayout() ); // create main section mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); mainSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.Details" ) ); //$NON-NLS-1$ mainSection.marginWidth = 0; mainSection.marginHeight = 0; mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mainSection ); // create must section mustSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); mustSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.MustAttributes" ) ); //$NON-NLS-1$ mustSection.marginWidth = 0; mustSection.marginHeight = 0; mustSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mustSection ); mustSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create may section maySection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); maySection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.MayAttributes" ) ); //$NON-NLS-1$ maySection.marginWidth = 0; maySection.marginHeight = 0; maySection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( maySection ); maySection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create superior section superclassesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); superclassesSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.Superclasses" ) ); //$NON-NLS-1$ superclassesSection.marginWidth = 0; superclassesSection.marginHeight = 0; superclassesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( superclassesSection ); superclassesSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create subclasses section subclassesSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); subclassesSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.Subclasses" ) ); //$NON-NLS-1$ subclassesSection.marginWidth = 0; subclassesSection.marginHeight = 0; subclassesSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( subclassesSection ); subclassesSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create raw section createRawSection(); } /** * {@inheritDoc} */ public void setInput( Object input ) { ObjectClass ocd = null; if ( input instanceof ObjectClass ) { ocd = ( ObjectClass ) input; } // create main content this.createMainContent( ocd ); // create contents of dynamic sections this.createSuperclassContents( ocd ); this.createSubclassContents( ocd ); this.createMustContents( ocd ); this.createMayContents( ocd ); super.createRawContents( ocd ); this.detailForm.reflow( true ); } /** * Creates the content of the main section. It is newly created * on every input change to ensure a proper layout of * multilined descriptions. * * @param ocd the object class description */ private void createMainContent( ObjectClass ocd ) { // dispose old content if ( mainSection.getClient() != null ) { mainSection.getClient().dispose(); } // create new client Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP ); GridLayout mainLayout = new GridLayout( 2, false ); mainClient.setLayout( mainLayout ); mainSection.setClient( mainClient ); // create new content if ( ocd != null ) { toolkit.createLabel( mainClient, Messages.getString( "ObjectClassDescriptionDetailsPage.NumericOID" ), SWT.NONE ); //$NON-NLS-1$ numericOidText = toolkit.createText( mainClient, getNonNullString( ocd.getOid() ), SWT.NONE ); numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); numericOidText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "ObjectClassDescriptionDetailsPage.ObjectclassNames" ), SWT.NONE ); //$NON-NLS-1$ namesText = toolkit.createText( mainClient, getNonNullString( SchemaUtils.toString( ocd ) ), SWT.NONE ); namesText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); namesText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "ObjectClassDescriptionDetailsPage.Description" ), SWT.NONE ); //$NON-NLS-1$ descText = toolkit.createText( mainClient, getNonNullString( ocd.getDescription() ), SWT.WRAP | SWT.MULTI ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.widthHint = detailForm.getForm().getSize().x - 100 - 60; descText.setLayoutData( gd ); descText.setEditable( false ); String kind = ""; //$NON-NLS-1$ switch ( ocd.getType() ) { case STRUCTURAL: kind = Messages.getString( "ObjectClassDescriptionDetailsPage.Structural" ); //$NON-NLS-1$ break; case ABSTRACT: kind = Messages.getString( "ObjectClassDescriptionDetailsPage.Abstract" ); //$NON-NLS-1$ break; case AUXILIARY: kind = Messages.getString( "ObjectClassDescriptionDetailsPage.Auxiliary" ); //$NON-NLS-1$ break; } if ( ocd.isObsolete() ) { kind += Messages.getString( "ObjectClassDescriptionDetailsPage.Obsolete" ); //$NON-NLS-1$ } toolkit.createLabel( mainClient, Messages.getString( "ObjectClassDescriptionDetailsPage.ObjectclassKind" ), SWT.NONE ); //$NON-NLS-1$ kindText = toolkit.createText( mainClient, getNonNullString( kind ), SWT.NONE ); kindText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); kindText.setEditable( false ); } mainSection.layout(); } /** * Creates the content of the must section. * It is newly created on every input change because the content * of this section is dynamic. * * @param ocd the object class description */ private void createMustContents( ObjectClass ocd ) { // dispose old content if ( mustSection.getClient() != null ) { mustSection.getClient().dispose(); } // create new client Composite mustClient = toolkit.createComposite( mustSection, SWT.WRAP ); mustClient.setLayout( new GridLayout() ); mustSection.setClient( mustClient ); // create new content if ( ocd != null ) { Collection<String> names = SchemaUtils.getMustAttributeTypeDescriptionNamesTransitive( ocd, getSchema() ); if ( names != null && names.size() > 0 ) { mustSection .setText( NLS .bind( Messages.getString( "ObjectClassDescriptionDetailsPage.MustAttributesCount" ), new Object[] { names.size() } ) ); //$NON-NLS-1$ for ( String name : names ) { if ( getSchema().hasAttributeTypeDescription( name ) ) { AttributeType mustAtd = getSchema().getAttributeTypeDescription( name ); Hyperlink mustLink = toolkit.createHyperlink( mustClient, SchemaUtils.toString( mustAtd ), SWT.WRAP ); mustLink.setHref( mustAtd ); mustLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); mustLink.setUnderlined( true ); mustLink.setEnabled( true ); mustLink.addHyperlinkListener( this ); } else { Hyperlink mustLink = toolkit.createHyperlink( mustClient, name, SWT.WRAP ); mustLink.setHref( null ); mustLink.setUnderlined( false ); mustLink.setEnabled( false ); } } } else { mustSection.setText( NLS.bind( Messages .getString( "ObjectClassDescriptionDetailsPage.MustAttributesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text mustText = toolkit.createText( mustClient, getNonNullString( null ), SWT.NONE ); mustText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); mustText.setEditable( false ); } } else { mustSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.MustAttributes" ) ); //$NON-NLS-1$ } mustSection.layout(); } /** * Creates the content of the may section. * It is newly created on every input change because the content * of this section is dynamic. * * @param ocd the object class description */ private void createMayContents( ObjectClass ocd ) { // dispose old content if ( maySection.getClient() != null ) { maySection.getClient().dispose(); } // create new client Composite mayClient = toolkit.createComposite( maySection, SWT.WRAP ); mayClient.setLayout( new GridLayout() ); maySection.setClient( mayClient ); // create new content if ( ocd != null ) { Collection<String> names = SchemaUtils.getMayAttributeTypeDescriptionNamesTransitive( ocd, getSchema() ); if ( names != null && names.size() > 0 ) { maySection .setText( NLS .bind( Messages.getString( "ObjectClassDescriptionDetailsPage.MayAttributesCount" ), new Object[] { names.size() } ) ); //$NON-NLS-1$ for ( String name : names ) { if ( getSchema().hasAttributeTypeDescription( name ) ) { AttributeType mayAtd = getSchema().getAttributeTypeDescription( name ); Hyperlink mayLink = toolkit.createHyperlink( mayClient, SchemaUtils.toString( mayAtd ), SWT.WRAP ); mayLink.setHref( mayAtd ); mayLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); mayLink.setUnderlined( true ); mayLink.setEnabled( true ); mayLink.addHyperlinkListener( this ); } else { Hyperlink mayLink = toolkit.createHyperlink( mayClient, name, SWT.WRAP ); mayLink.setHref( null ); mayLink.setUnderlined( false ); mayLink.setEnabled( false ); } } } else { maySection.setText( NLS.bind( Messages .getString( "ObjectClassDescriptionDetailsPage.MayAttributesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text mayText = toolkit.createText( mayClient, getNonNullString( null ), SWT.NONE ); mayText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); mayText.setEditable( false ); } } else { maySection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.MayAttributes" ) ); //$NON-NLS-1$ } maySection.layout(); } /** * Creates the content of the sub classes section. * It is newly created on every input change because the content * of this section is dynamic. * * @param ocd the object class description */ private void createSubclassContents( ObjectClass ocd ) { // dispose old content if ( subclassesSection.getClient() != null ) { subclassesSection.getClient().dispose(); } // create new client Composite subClient = toolkit.createComposite( subclassesSection, SWT.WRAP ); subClient.setLayout( new GridLayout() ); subclassesSection.setClient( subClient ); // create new content if ( ocd != null ) { List<ObjectClass> subOcds = SchemaUtils.getSubObjectClassDescriptions( ocd, getSchema() ); if ( subOcds != null && subOcds.size() > 0 ) { subclassesSection .setText( NLS .bind( Messages.getString( "ObjectClassDescriptionDetailsPage.SubclassesCount" ), new Object[] { subOcds.size() } ) ); //$NON-NLS-1$ for ( ObjectClass subOcd : subOcds ) { Hyperlink subLink = toolkit.createHyperlink( subClient, SchemaUtils.toString( subOcd ), SWT.WRAP ); subLink.setHref( subOcd ); subLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); subLink.setUnderlined( true ); subLink.setEnabled( true ); subLink.addHyperlinkListener( this ); } } else { subclassesSection.setText( NLS.bind( Messages .getString( "ObjectClassDescriptionDetailsPage.SubclassesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text derivedText = toolkit.createText( subClient, getNonNullString( null ), SWT.NONE ); derivedText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); derivedText.setEditable( false ); } } else { subclassesSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.Subclasses" ) ); //$NON-NLS-1$ } subclassesSection.layout(); } /** * Creates the content of the super classes section. * It is newly created on every input change because the content * of this section is dynamic. * * @param ocd the object class description */ private void createSuperclassContents( ObjectClass ocd ) { // dispose old content if ( superclassesSection.getClient() != null ) { superclassesSection.getClient().dispose(); } // create new client Composite superClient = toolkit.createComposite( superclassesSection, SWT.WRAP ); superClient.setLayout( new GridLayout() ); superclassesSection.setClient( superClient ); // create new content if ( ocd != null ) { List<String> names = ocd.getSuperiorOids(); if ( names != null && names.size() > 0 ) { superclassesSection .setText( NLS .bind( Messages.getString( "ObjectClassDescriptionDetailsPage.SuperclassesCount" ), new Object[] { names.size() } ) ); //$NON-NLS-1$ Composite supClient = toolkit.createComposite( superClient, SWT.WRAP ); GridLayout gl = new GridLayout(); gl.marginWidth = 0; gl.marginHeight = 0; supClient.setLayout( gl ); for ( String name : names ) { if ( getSchema().hasObjectClassDescription( name ) ) { ObjectClass supOcd = getSchema().getObjectClassDescription( name ); Hyperlink superLink = toolkit.createHyperlink( supClient, SchemaUtils.toString( supOcd ), SWT.WRAP ); superLink.setHref( supOcd ); superLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); superLink.setUnderlined( true ); superLink.setEnabled( true ); superLink.addHyperlinkListener( this ); } else { Hyperlink superLink = toolkit.createHyperlink( supClient, name, SWT.WRAP ); superLink.setHref( null ); superLink.setUnderlined( false ); superLink.setEnabled( false ); } } } else { superclassesSection.setText( NLS.bind( Messages .getString( "ObjectClassDescriptionDetailsPage.SuperclassesCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text superText = toolkit.createText( superClient, getNonNullString( null ), SWT.NONE ); superText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); superText.setEditable( false ); } } else { superclassesSection.setText( Messages.getString( "ObjectClassDescriptionDetailsPage.Superclasses" ) ); //$NON-NLS-1$ } superclassesSection.layout(); } }
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/schemabrowser/SchemaBrowserInput.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserInput.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; 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.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; /** * The input for the schema browser. * * There is a trick to provide a single instance of the schema browser: * <ul> * <li>If oneInstanceHackEnabled is true the equals method returns always * true as long as the compared object is also of type SchemaBrowserInput. * With this trick only one instance of the schema browser is opened * by the eclipse editor framework. * <li>If oneInstanceHackEnabled is false the equals method returns * true only if the wrapped objects (IConnection and SchemaPart) are equal. * This is necessary for the history navigation because it must be able * to distinguish the different input objects. * </ul> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaBrowserInput implements IEditorInput { /** The connection */ private IBrowserConnection connection; /** The schema element */ private AbstractSchemaObject schemaElement; /** One instance hack flag */ private static boolean oneInstanceHackEnabled = true; /** * Creates a new instance of SchemaBrowserInput. * * @param connection the connection * @param schemaElement the schema element input */ public SchemaBrowserInput( IBrowserConnection connection, AbstractSchemaObject schemaElement ) { this.connection = connection; this.schemaElement = schemaElement; } // /** // * Creates a new instance of SchemaBrowserInput. // * // *@param connection the connection // * @param schemaElement the schema element input // */ // public SchemaBrowserInput( Connection connection, SchemaPart schemaElement ) // { // this.connection = BrowserCorePlugin.getDefault().getConnectionManager().getConnection( connection ); // this.schemaElement = schemaElement; // } /** * This implementation always return false because * a schema element should not be visible in the * "File Most Recently Used" menu. * * {@inheritDoc} */ public boolean exists() { return false; } /** * {@inheritDoc} */ public ImageDescriptor getImageDescriptor() { return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_BROWSER_SCHEMABROWSEREDITOR ); } /** * {@inheritDoc} */ public String getName() { return Messages.getString( "SchemaBrowserInput.SchemaBrowser" ); //$NON-NLS-1$ } /** * This implementation always return null. * * {@inheritDoc} */ public IPersistableElement getPersistable() { return null; } /** * {@inheritDoc} */ public String getToolTipText() { return ""; //$NON-NLS-1$ } /** * {@inheritDoc} */ public Object getAdapter( Class adapter ) { return null; } /** * Gets the connection. * * @return the connection */ public IBrowserConnection getConnection() { return connection; } /** /** * Gets the schema element, may be null. * * @return the schema element or null */ public AbstractSchemaObject getSchemaElement() { return schemaElement; } /** * {@inheritDoc} */ public int hashCode() { return getToolTipText().hashCode(); } /** * {@inheritDoc} */ public boolean equals( Object obj ) { boolean equal; if ( oneInstanceHackEnabled ) { equal = ( obj instanceof SchemaBrowserInput ); } else { if ( obj instanceof SchemaBrowserInput ) { SchemaBrowserInput other = ( SchemaBrowserInput ) obj; if ( this.connection == null && other.connection == null ) { return true; } else if ( this.connection == null || other.connection == null ) { return false; } else if ( !this.connection.equals( other.connection ) ) { return false; } else if ( this.schemaElement == null && other.schemaElement == null ) { return true; } else if ( this.schemaElement == null || other.schemaElement == null ) { return false; } else { equal = other.schemaElement.equals( this.schemaElement ); } } else { equal = false; } } return equal; } /** * Enables or disabled the one instance hack. * * @param b * true to enable the one instance hack, * false to disable the one instance hack */ public static void enableOneInstanceHack( boolean b ) { oneInstanceHackEnabled = b; } }
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/schemabrowser/MatchingRuleDescriptionPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/MatchingRuleDescriptionPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.graphics.Image; /** * The MatchingRuleDescriptionPage displays a list with all * matching rule descriptions and hosts the detail page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MatchingRuleDescriptionPage extends SchemaPage { /** * Creates a new instance of MatchingRuleDescriptionPage. * * @param schemaBrowser the schema browser */ public MatchingRuleDescriptionPage( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ protected String getTitle() { return Messages.getString( "MatchingRuleDescriptionPage.MatchingRules" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String getFilterDescription() { return Messages.getString( "MatchingRuleDescriptionPage.SelectMatchingRule" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected IStructuredContentProvider getContentProvider() { return new MRDContentProvider(); } /** * {@inheritDoc} */ protected ITableLabelProvider getLabelProvider() { return new MRDLabelProvider(); } /** * {@inheritDoc} */ protected ViewerSorter getSorter() { return new MRDViewerSorter(); } /** * {@inheritDoc} */ protected ViewerFilter getFilter() { return new MRDViewerFilter(); } /** * {@inheritDoc} */ protected SchemaDetailsPage getDetailsPage() { return new MatchingRuleDescriptionDetailsPage( this, this.toolkit ); } /** * The content provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRDContentProvider implements IStructuredContentProvider { /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof Schema ) { Schema schema = ( Schema ) inputElement; if ( schema != null && schema.getMatchingRuleDescriptions() != null ) { return schema.getMatchingRuleDescriptions().toArray(); } } return new Object[0]; } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * The label provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRDLabelProvider extends LabelProvider implements ITableLabelProvider { /** * {@inheritDoc} */ public String getColumnText( Object obj, int index ) { if ( obj instanceof MatchingRule ) { return SchemaUtils.toString( ( MatchingRule ) obj ); } return obj.toString(); } /** * {@inheritDoc} */ public Image getColumnImage( Object obj, int index ) { return null; } } /** * The sorter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRDViewerSorter extends ViewerSorter { /** * {@inheritDoc} */ public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof MatchingRule ) { e1 = SchemaUtils.toString( ( MatchingRule ) e1 ); } if ( e2 instanceof MatchingRule ) { e2 = SchemaUtils.toString( ( MatchingRule ) e2 ); } return e1.toString().compareTo( e2.toString() ); } } /** * The filter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRDViewerFilter extends ViewerFilter { /** * {@inheritDoc} */ public boolean select( Viewer viewer, Object parentElement, Object element ) { if ( element instanceof MatchingRule ) { MatchingRule mrd = ( MatchingRule ) element; boolean matched = Strings.toLowerCase( SchemaUtils.toString( mrd ) ) .indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1 || Strings.toLowerCase( mrd.getOid() ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1; return matched; } 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/schemabrowser/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/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.schemabrowser; 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/schemabrowser/SchemaDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaDetailsPage.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.schemabrowser; import java.util.List; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * A base implementation used from all schema detail pages. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class SchemaDetailsPage implements IHyperlinkListener { /** The raw section, displays the schema attibute value */ protected Section rawSection; /** The text with the schema attribute value */ protected Text rawText; /** The toolkit used to create controls */ protected FormToolkit toolkit; /** The master schema page */ protected SchemaPage schemaPage; /** The detail page form */ protected ScrolledForm detailForm; /** * Creates a new instance of SchemaDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ protected SchemaDetailsPage( SchemaPage schemaPage, FormToolkit toolkit ) { this.schemaPage = schemaPage; this.toolkit = toolkit; } /** * Disposes this details page. */ public void dispose() { } /** * {@inheritDoc} */ public void linkActivated( HyperlinkEvent e ) { Object obj = e.getHref(); if ( obj instanceof AbstractSchemaObject ) { schemaPage.getSchemaBrowser().setInput( new SchemaBrowserInput( schemaPage.getConnection(), ( AbstractSchemaObject ) obj ) ); } } /** * {@inheritDoc} */ public void linkEntered( HyperlinkEvent e ) { } /** * {@inheritDoc} */ public void linkExited( HyperlinkEvent e ) { } /** * Sets the input of this details page. * * @param input the input */ public abstract void setInput( Object input ); /** * Creates the contents of the details page. * * @param detailForm the parent */ protected abstract void createContents( final ScrolledForm detailForm ); /** * Creates the raw content section. */ protected void createRawSection() { rawSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); rawSection.setText( Messages.getString( "SchemaDetailsPage.RawSchemaDefinition" ) ); //$NON-NLS-1$ rawSection.marginWidth = 0; rawSection.marginHeight = 0; rawSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( rawSection ); rawSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); } /** * Creates the contents of the raw section. * * @param schemaPart the schema part to display */ protected void createRawContents( AbstractSchemaObject asd ) { if ( rawSection.getClient() != null && !rawSection.getClient().isDisposed() ) { rawSection.getClient().dispose(); } Composite client = toolkit.createComposite( rawSection, SWT.WRAP ); client.setLayout( new GridLayout() ); rawSection.setClient( client ); if ( asd != null ) { rawText = toolkit.createText( client, getNonNullString( SchemaUtils.getLdifLine( asd ) ), SWT.WRAP | SWT.MULTI ); GridData gd2 = new GridData( GridData.FILL_HORIZONTAL ); gd2.widthHint = detailForm.getForm().getSize().x - 100 - 60; // detailForm.getForm().getVerticalBar().getSize().x // gd2.widthHint = 10; rawText.setLayoutData( gd2 ); rawText.setEditable( false ); } rawSection.layout(); } /** * Gets the schema. * * @return the schema */ protected Schema getSchema() { return schemaPage.getConnection().getSchema(); } /** * Helper method, return a dash "-" if the given string is null. * * @param s the string * @return the given string or a dash "-" if the given string is null. */ protected String getNonNullString( String s ) { return s == null ? "-" : s; //$NON-NLS-1$ } /** * Helper method, return a dash "-" if the given string is null. * * @param s the string * @return the given string or a dash "-" if the given string is null. */ private String getNonNullString( List<String> s ) { if ( s == null || s.isEmpty() ) { return "-"; //$NON-NLS-1$ } return s.get( 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/editors/schemabrowser/LdapSyntaxDescriptionDetailsPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/LdapSyntaxDescriptionDetailsPage.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.schemabrowser; import java.util.Collection; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.forms.events.ExpansionAdapter; import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Hyperlink; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; /** * The LdapSyntaxDescriptionDetailsPage displays the details of an * syntax description. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class LdapSyntaxDescriptionDetailsPage extends SchemaDetailsPage { /** The main section, contains oid and desc */ private Section mainSection; /** The used from section, contains links to attribute types */ private Section usedFromSection; /** * Creates a new instance of LdapSyntaxDescriptionDetailsPage. * * @param schemaPage the master schema page * @param toolkit the toolkit used to create controls */ public LdapSyntaxDescriptionDetailsPage( SchemaPage schemaPage, FormToolkit toolkit ) { super( schemaPage, toolkit ); } /** * {@inheritDoc} */ public void createContents( final ScrolledForm detailForm ) { this.detailForm = detailForm; detailForm.getBody().setLayout( new GridLayout() ); // create main section mainSection = toolkit.createSection( detailForm.getBody(), SWT.NONE ); mainSection.setText( Messages.getString( "LdapSyntaxDescriptionDetailsPage.Details" ) ); //$NON-NLS-1$ mainSection.marginWidth = 0; mainSection.marginHeight = 0; mainSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( mainSection ); // create used from section usedFromSection = toolkit.createSection( detailForm.getBody(), Section.TWISTIE ); usedFromSection.setText( Messages.getString( "LdapSyntaxDescriptionDetailsPage.UsedFrom" ) ); //$NON-NLS-1$ usedFromSection.marginWidth = 0; usedFromSection.marginHeight = 0; usedFromSection.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); toolkit.createCompositeSeparator( usedFromSection ); usedFromSection.addExpansionListener( new ExpansionAdapter() { public void expansionStateChanged( ExpansionEvent e ) { detailForm.reflow( true ); } } ); // create raw section createRawSection(); } /** * {@inheritDoc} */ public void setInput( Object input ) { LdapSyntax lsd = null; if ( input instanceof LdapSyntax ) { lsd = ( LdapSyntax ) input; } createMainContent( lsd ); createUsedFromContents( lsd ); createRawContents( lsd ); detailForm.reflow( true ); } /** * Creates the content of the main section. It is newly created * on every input change to ensure a proper layout of * multilined descriptions. * * @param lsd the syntax description */ private void createMainContent( LdapSyntax lsd ) { // dispose old content if ( mainSection.getClient() != null ) { mainSection.getClient().dispose(); } // create new client Composite mainClient = toolkit.createComposite( mainSection, SWT.WRAP ); GridLayout mainLayout = new GridLayout( 2, false ); mainClient.setLayout( mainLayout ); mainSection.setClient( mainClient ); // create new content if ( lsd != null ) { toolkit.createLabel( mainClient, Messages.getString( "LdapSyntaxDescriptionDetailsPage.NumericOID" ), SWT.NONE ); //$NON-NLS-1$ Text numericOidText = toolkit.createText( mainClient, getNonNullString( lsd.getOid() ), SWT.NONE ); numericOidText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); numericOidText.setEditable( false ); toolkit.createLabel( mainClient, Messages.getString( "LdapSyntaxDescriptionDetailsPage.Description" ), SWT.NONE ); //$NON-NLS-1$ Text descText = toolkit.createText( mainClient, getNonNullString( lsd.getDescription() ), SWT.WRAP | SWT.MULTI ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.widthHint = detailForm.getForm().getSize().x - 100 - 60; descText.setLayoutData( gd ); descText.setEditable( false ); } mainSection.layout(); } /** * Creates the content of the used from section. * It is newly created on every input change because the content * of this section is dynamic. * * @param lsd the syntax description */ private void createUsedFromContents( LdapSyntax lsd ) { // dispose old content if ( usedFromSection.getClient() != null && !usedFromSection.getClient().isDisposed() ) { usedFromSection.getClient().dispose(); } // create new client Composite usedFromClient = toolkit.createComposite( usedFromSection, SWT.WRAP ); usedFromClient.setLayout( new GridLayout() ); usedFromSection.setClient( usedFromClient ); // create content if ( lsd != null ) { Collection<AttributeType> usedFromATDs = SchemaUtils.getUsedFromAttributeTypeDescriptions( lsd, getSchema() ); if ( usedFromATDs != null && !usedFromATDs.isEmpty() ) { usedFromSection .setText( NLS .bind( Messages.getString( "LdapSyntaxDescriptionDetailsPage.UsedFromCount" ), new Object[] { usedFromATDs.size() } ) ); //$NON-NLS-1$ for ( AttributeType atd : usedFromATDs ) { Hyperlink usedFromLink = toolkit.createHyperlink( usedFromClient, SchemaUtils.toString( atd ), SWT.WRAP ); usedFromLink.setHref( atd ); usedFromLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedFromLink.setUnderlined( true ); usedFromLink.setEnabled( true ); usedFromLink.addHyperlinkListener( this ); } } else { usedFromSection.setText( NLS.bind( Messages .getString( "LdapSyntaxDescriptionDetailsPage.UsedFromCount" ), new Object[] { 0 } ) ); //$NON-NLS-1$ Text usedFromText = toolkit.createText( usedFromClient, getNonNullString( null ), SWT.NONE ); usedFromText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); usedFromText.setEditable( false ); } } else { usedFromSection.setText( Messages.getString( "LdapSyntaxDescriptionDetailsPage.UsedFrom" ) ); //$NON-NLS-1$ } usedFromSection.layout(); } }
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/schemabrowser/AttributeTypeDescriptionPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/AttributeTypeDescriptionPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.graphics.Image; /** * The AttributeTypeDescriptionPage displays a list with all * attribute type descriptions and hosts the detail page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AttributeTypeDescriptionPage extends SchemaPage { /** * Creates a new instance of AttributeTypeDescriptionPage. * * @param schemaBrowser the schema browser */ public AttributeTypeDescriptionPage( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ protected String getTitle() { return Messages.getString( "AttributeTypeDescriptionPage.AttributeTypes" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String getFilterDescription() { return Messages.getString( "AttributeTypeDescriptionPage.SelectAttributeType" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected IStructuredContentProvider getContentProvider() { return new ATDContentProvider(); } /** * {@inheritDoc} */ protected ITableLabelProvider getLabelProvider() { return new ATDLabelProvider(); } /** * {@inheritDoc} */ protected ViewerSorter getSorter() { return new ATDViewerSorter(); } /** * {@inheritDoc} */ protected ViewerFilter getFilter() { return new ATDViewerFilter(); } /** * {@inheritDoc} */ protected SchemaDetailsPage getDetailsPage() { return new AttributeTypeDescriptionDetailsPage( this, this.toolkit ); } /** * The content provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class ATDContentProvider implements IStructuredContentProvider { /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof Schema ) { Schema schema = ( Schema ) inputElement; if ( schema != null ) { return schema.getAttributeTypeDescriptions().toArray(); } } return new Object[0]; } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * The label provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class ATDLabelProvider extends LabelProvider implements ITableLabelProvider { /** * {@inheritDoc} */ public String getColumnText( Object obj, int index ) { if ( obj instanceof AttributeType ) { return SchemaUtils.toString( ( AbstractSchemaObject ) obj ); } return obj.toString(); } /** * {@inheritDoc} */ public Image getColumnImage( Object obj, int index ) { return null; } } /** * The sorter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class ATDViewerSorter extends ViewerSorter { /** * {@inheritDoc} */ public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof AttributeType ) { e1 = SchemaUtils.toString( ( AbstractSchemaObject ) e1 ); } if ( e2 instanceof AttributeType ) { e2 = SchemaUtils.toString( ( AbstractSchemaObject ) e2 ); } return e1.toString().compareTo( e2.toString() ); } } /** * The filter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class ATDViewerFilter extends ViewerFilter { /** * {@inheritDoc} */ public boolean select( Viewer viewer, Object parentElement, Object element ) { if ( element instanceof AttributeType ) { AttributeType atd = ( AttributeType ) element; boolean matched = Strings.toLowerCase( SchemaUtils.toString( atd ) ) .indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1 || Strings.toLowerCase( atd.getOid() ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1; return matched; } 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/schemabrowser/BrowserConnectionWidgetContributionItem.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/BrowserConnectionWidgetContributionItem.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.schemabrowser; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionFolder; import org.apache.directory.studio.connection.core.event.ConnectionEventRegistry; import org.apache.directory.studio.connection.core.event.ConnectionUpdateListener; import org.apache.directory.studio.connection.ui.ConnectionUIPlugin; import org.apache.directory.studio.ldapbrowser.common.widgets.search.BrowserConnectionWidget; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.jface.action.ContributionItem; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.ToolItem; /** * A contribution item that adds a BrowserConnectionWidget with connections to the toolbar. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserConnectionWidgetContributionItem extends ContributionItem implements ConnectionUpdateListener { /** The schema page */ private SchemaPage schemaPage; /** The tool item */ private ToolItem toolitem; /** The tool item composite */ private Composite toolItemComposite; private BrowserConnectionWidget browserConnectionWidget; /** * Creates a new instance of ConnectionContributionItem. * * @param schemaPage the schema page */ public BrowserConnectionWidgetContributionItem( SchemaPage schemaPage ) { this.schemaPage = schemaPage; } /** * Creates and returns the control for this contribution item * under the given parent composite. * * @param parent the parent composite * @return the new control */ private Control createControl( Composite parent ) { // Creating the ToolItem Composite toolItemComposite = new Composite( parent, SWT.NONE ); GridLayout gridLayout = new GridLayout( 2, false ); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; toolItemComposite.setLayout( gridLayout ); toolItemComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // Creating the Browser Connection Widget browserConnectionWidget = new BrowserConnectionWidget(); browserConnectionWidget.createWidget( toolItemComposite ); browserConnectionWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { schemaPage.getSchemaBrowser().setInput( new SchemaBrowserInput( getConnection(), null ) ); } } ); ConnectionEventRegistry.addConnectionUpdateListener( this, ConnectionUIPlugin.getDefault().getEventRunner() ); // Initializing the width for the toolbar item toolitem.setWidth( 250 ); return toolItemComposite; } /** * @see org.eclipse.jface.action.ContributionItem#dispose() */ public void dispose() { ConnectionEventRegistry.removeConnectionUpdateListener( this ); toolItemComposite.dispose(); toolItemComposite = null; browserConnectionWidget = null; } /** * The control item implementation of this <code>IContributionItem</code> * method calls the <code>createControl</code> method. * * @param parent the parent of the control to fill */ public final void fill( Composite parent ) { createControl( parent ); } /** * The control item implementation of this <code>IContributionItem</code> * method throws an exception since controls cannot be added to menus. * * @param parent the menu * @param index menu index */ public final void fill( Menu parent, int index ) { throw new UnsupportedOperationException( Messages.getString( "BrowserConnectionWidgetContributionItem.CantAddControl" ) ); //$NON-NLS-1$ } /** * The control item implementation of this <code>IContributionItem</code> * method calls the <code>createControl</code> method to * create a control under the given parent, and then creates * a new tool item to hold it. * * @param parent the ToolBar to add the new control to * @param index the index */ public void fill( ToolBar parent, int index ) { toolitem = new ToolItem( parent, SWT.SEPARATOR, index ); Control control = createControl( parent ); toolitem.setControl( control ); } /** * Gets the connection. * * @return the connection */ public IBrowserConnection getConnection() { return browserConnectionWidget.getBrowserConnection(); } /** * Sets the connection. * * @param connection the connection */ public void setConnection( IBrowserConnection connection ) { browserConnectionWidget.setBrowserConnection( connection ); } /** * Updates the enabled state. */ public void updateEnabledState() { browserConnectionWidget.setEnabled( !schemaPage.isShowDefaultSchema() ); } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionUpdated(org.apache.directory.studio.connection.core.Connection) */ public final void connectionUpdated( Connection connection ) { if ( connection == null ) { return; } IBrowserConnection selectedConnection = browserConnectionWidget.getBrowserConnection(); if ( connection.equals( selectedConnection.getConnection() ) ) { browserConnectionWidget.setBrowserConnection( browserConnectionWidget.getBrowserConnection() ); } } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionAdded(org.apache.directory.studio.connection.core.Connection) */ public void connectionAdded( Connection connection ) { // Nothing to do } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionRemoved(org.apache.directory.studio.connection.core.Connection) */ public void connectionRemoved( Connection connection ) { if ( connection == null ) { return; } IBrowserConnection selectedConnection = browserConnectionWidget.getBrowserConnection(); if ( connection.equals( selectedConnection.getConnection() ) ) { schemaPage.getSchemaBrowser().setInput( new SchemaBrowserInput( null, null ) ); } } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionOpened(org.apache.directory.studio.connection.core.Connection) */ public void connectionOpened( Connection connection ) { // Nothing to do } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionClosed(org.apache.directory.studio.connection.core.Connection) */ public void connectionClosed( Connection connection ) { // Nothing to do } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionFolderModified(org.apache.directory.studio.connection.core.ConnectionFolder) */ public void connectionFolderModified( ConnectionFolder connectionFolder ) { // Nothing to do } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionFolderAdded(org.apache.directory.studio.connection.core.ConnectionFolder) */ public void connectionFolderAdded( ConnectionFolder connectionFolder ) { // Nothing to do } /** * @see org.apache.directory.studio.connection.core.event.ConnectionUpdateListener#connectionFolderRemoved(org.apache.directory.studio.connection.core.ConnectionFolder) */ public void connectionFolderRemoved( ConnectionFolder connectionFolder ) { // Nothing to do } }
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/schemabrowser/MatchingRuleUseDescriptionPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/MatchingRuleUseDescriptionPage.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.MatchingRuleUse; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.graphics.Image; /** * The MatchingRuleUseDescriptionPage displays a list with all * matching rule use descriptions and hosts the detail page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class MatchingRuleUseDescriptionPage extends SchemaPage { /** * * Creates a new instance of MatchingRuleUseDescriptionPage. * * @param schemaBrowser the schema browser */ public MatchingRuleUseDescriptionPage( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ protected String getTitle() { return Messages.getString( "MatchingRuleUseDescriptionPage.MatchingRule" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String getFilterDescription() { return Messages.getString( "MatchingRuleUseDescriptionPage.SelectMatchingRule" ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected IStructuredContentProvider getContentProvider() { return new MRUDContentProvider(); } /** * {@inheritDoc} */ protected ITableLabelProvider getLabelProvider() { return new MRUDLabelProvider(); } /** * {@inheritDoc} */ protected ViewerSorter getSorter() { return new MRUDViewerSorter(); } /** * {@inheritDoc} */ protected ViewerFilter getFilter() { return new MRUDViewerFilter(); } /** * {@inheritDoc} */ protected SchemaDetailsPage getDetailsPage() { return new MatchingRuleUseDescriptionDetailsPage( this, this.toolkit ); } /** * The content provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRUDContentProvider implements IStructuredContentProvider { /** * {@inheritDoc} */ public Object[] getElements( Object inputElement ) { if ( inputElement instanceof Schema ) { Schema schema = ( Schema ) inputElement; if ( schema != null && schema.getMatchingRuleUseDescriptions() != null ) { return schema.getMatchingRuleUseDescriptions().toArray(); } } return new Object[0]; } /** * {@inheritDoc} */ public void dispose() { } /** * {@inheritDoc} */ public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { } } /** * The label provider used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRUDLabelProvider extends LabelProvider implements ITableLabelProvider { /** * {@inheritDoc} */ public String getColumnText( Object obj, int index ) { if ( obj instanceof MatchingRuleUse ) { return SchemaUtils.toString( ( MatchingRuleUse ) obj ); } return obj.toString(); } /** * {@inheritDoc} */ public Image getColumnImage( Object obj, int index ) { return null; } } /** * The sorter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRUDViewerSorter extends ViewerSorter { /** * {@inheritDoc} */ public int compare( Viewer viewer, Object e1, Object e2 ) { if ( e1 instanceof MatchingRuleUse ) { e1 = SchemaUtils.toString( ( MatchingRuleUse ) e1 ); } if ( e2 instanceof MatchingRuleUse ) { e2 = SchemaUtils.toString( ( MatchingRuleUse ) e2 ); } return e1.toString().compareTo( e2.toString() ); } } /** * The filter used by the viewer. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class MRUDViewerFilter extends ViewerFilter { /** * {@inheritDoc} */ public boolean select( Viewer viewer, Object parentElement, Object element ) { if ( element instanceof MatchingRuleUse ) { MatchingRuleUse mrud = ( MatchingRuleUse ) element; boolean matched = Strings.toLowerCase( SchemaUtils.toString( mrud ) ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1 || Strings.toLowerCase( mrud.getOid() ).indexOf( Strings.toLowerCase( filterText.getText() ) ) != -1; return matched; } 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/schemabrowser/ShowDefaultSchemaAction.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/ShowDefaultSchemaAction.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.schemabrowser; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.action.Action; /** * This action toggles between connection specific schemas and the default schema. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ShowDefaultSchemaAction extends Action { /** The schema browser */ private SchemaBrowser schemaBrowser; /** * Creates a new instance of ShowDefaultSchemaAction. * * @param schemaBrowser the schema browser */ public ShowDefaultSchemaAction( SchemaBrowser schemaBrowser ) { super( Messages.getString( "ShowDefaultSchemaAction.ShowDefaultSchema" ), Action.AS_CHECK_BOX ); //$NON-NLS-1$ super.setToolTipText( Messages.getString( "ShowDefaultSchemaAction.ShowDefaultSchemaToolTip" ) ); //$NON-NLS-1$ super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_DEFAULT_SCHEMA ) ); super.setEnabled( true ); this.schemaBrowser = schemaBrowser; } /** * {@inheritDoc} */ public void run() { this.schemaBrowser.setShowDefaultSchema( isChecked() ); } /** * Disposes this action. */ public void dispose() { this.schemaBrowser = null; } }
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/schemabrowser/SchemaBrowserNavigationLocation.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/schemabrowser/SchemaBrowserNavigationLocation.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.schemabrowser; import org.apache.directory.api.ldap.model.schema.AbstractSchemaObject; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.api.ldap.model.schema.LdapSyntax; import org.apache.directory.api.ldap.model.schema.MatchingRule; import org.apache.directory.api.ldap.model.schema.MatchingRuleUse; import org.apache.directory.api.ldap.model.schema.ObjectClass; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IMemento; import org.eclipse.ui.INavigationLocation; import org.eclipse.ui.NavigationLocation; /** * This class is used to mark the schema browser input to the navigation history. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaBrowserNavigationLocation extends NavigationLocation { /** * Creates a new instance of SchemaBrowserNavigationLocation. * * @param schemaBrowser the schema browser */ SchemaBrowserNavigationLocation( SchemaBrowser schemaBrowser ) { super( schemaBrowser ); } /** * {@inheritDoc} */ public String getText() { AbstractSchemaObject schemaElement = getSchemaElement(); if ( schemaElement != null ) { if ( schemaElement instanceof ObjectClass ) { return Messages.getString( "SchemaBrowserNavigationLocation.ObjectClass" ) + SchemaUtils.toString( schemaElement ); //$NON-NLS-1$ } else if ( schemaElement instanceof AttributeType ) { return Messages.getString( "SchemaBrowserNavigationLocation.AttributeType" ) + SchemaUtils.toString( schemaElement ); //$NON-NLS-1$ } else if ( schemaElement instanceof LdapSyntax ) { return Messages.getString( "SchemaBrowserNavigationLocation.Syntax" ) + SchemaUtils.toString( schemaElement ); //$NON-NLS-1$ } else if ( schemaElement instanceof MatchingRule ) { return Messages.getString( "SchemaBrowserNavigationLocation.MatchingRule" ) + SchemaUtils.toString( schemaElement ); //$NON-NLS-1$ } else if ( schemaElement instanceof MatchingRuleUse ) { return Messages.getString( "SchemaBrowserNavigationLocation.MatchingRuleUse" ) + SchemaUtils.toString( schemaElement ); //$NON-NLS-1$ } else { return SchemaUtils.toString( schemaElement ); } } else { return super.getText(); } } /** * {@inheritDoc} */ public void saveState( IMemento memento ) { IBrowserConnection connection = getConnection(); AbstractSchemaObject schemaElement = getSchemaElement(); memento.putString( "CONNECTION", connection.getConnection().getId() ); //$NON-NLS-1$ memento.putString( "SCHEMAELEMENTYPE", schemaElement.getClass().getName() ); //$NON-NLS-1$ memento.putString( "SCHEMAELEMENTOID", schemaElement.getOid() ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void restoreState( IMemento memento ) { IBrowserConnection connection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnectionById( memento.getString( "CONNECTION" ) ); //$NON-NLS-1$ String schemaElementType = memento.getString( "SCHEMAELEMENTYPE" ); //$NON-NLS-1$ String schemaElementOid = memento.getString( "SCHEMAELEMENTOID" ); //$NON-NLS-1$ AbstractSchemaObject schemaElement = null; if ( ObjectClass.class.getName().equals( schemaElementType ) ) { schemaElement = connection.getSchema().getObjectClassDescription( schemaElementOid ); } else if ( AttributeType.class.getName().equals( schemaElementType ) ) { schemaElement = connection.getSchema().getAttributeTypeDescription( schemaElementOid ); } else if ( LdapSyntax.class.getName().equals( schemaElementType ) ) { schemaElement = connection.getSchema().getLdapSyntaxDescription( schemaElementOid ); } else if ( MatchingRule.class.getName().equals( schemaElementType ) ) { schemaElement = connection.getSchema().getMatchingRuleDescription( schemaElementOid ); } else if ( MatchingRuleUse.class.getName().equals( schemaElementType ) ) { schemaElement = connection.getSchema().getMatchingRuleUseDescription( schemaElementOid ); } super.setInput( new SchemaBrowserInput( connection, schemaElement ) ); } /** * {@inheritDoc} */ public void restoreLocation() { IEditorPart editorPart = getEditorPart(); if ( editorPart instanceof SchemaBrowser ) { SchemaBrowser schemaBrowser = ( SchemaBrowser ) editorPart; Object input = getInput(); if ( input instanceof SchemaBrowserInput ) { SchemaBrowserInput sbi = ( SchemaBrowserInput ) input; if ( sbi.getConnection() != null && sbi.getSchemaElement() != null ) { schemaBrowser.setInput( sbi ); } } } } /** * {@inheritDoc} */ public boolean mergeInto( INavigationLocation currentLocation ) { if ( currentLocation == null ) { return false; } if ( getClass() != currentLocation.getClass() ) { return false; } SchemaBrowserNavigationLocation location = ( SchemaBrowserNavigationLocation ) currentLocation; AbstractSchemaObject other = location.getSchemaElement(); AbstractSchemaObject element = getSchemaElement(); if ( other == null && element == null ) { return true; } else if ( other == null || element == null ) { return false; } else { return element.equals( other ); } } /** * {@inheritDoc} */ public void update() { } /** * Gets the schema element. * * @return the schema element */ private AbstractSchemaObject getSchemaElement() { Object editorInput = getInput(); if ( editorInput instanceof SchemaBrowserInput ) { SchemaBrowserInput schemaBrowserInput = ( SchemaBrowserInput ) editorInput; AbstractSchemaObject schemaElement = schemaBrowserInput.getSchemaElement(); if ( schemaElement != null ) { return schemaElement; } } return null; } /** * Gets the connection. * * @return the connection */ private IBrowserConnection getConnection() { Object editorInput = getInput(); if ( editorInput instanceof SchemaBrowserInput ) { SchemaBrowserInput schemaBrowserInput = ( SchemaBrowserInput ) editorInput; return schemaBrowserInput.getConnection(); } return null; } /** * {@inheritDoc} */ public String toString() { return "" + getSchemaElement(); //$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/dialogs/PasswordModifyExtendedOperationDialog.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/PasswordModifyExtendedOperationDialog.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.dialogs; import org.apache.commons.lang3.StringUtils; import org.apache.directory.api.ldap.codec.api.LdapApiService; import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory; import org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyRequest; import org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyResponse; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.util.Strings; import org.apache.directory.studio.common.ui.dialogs.MessageDialogWithTextarea; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget; import org.apache.directory.studio.ldapbrowser.core.events.EntryModificationEvent; import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry; import org.apache.directory.studio.ldapbrowser.core.jobs.ExtendedOperationRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; /** ` * The PasswordModifyExtendedOperationDialog is used to ask for input for the RFC 3062 LDAP Password Modify Extended Operation. * <pre> * .------------------------------------------------- -. * | Password Modify Extended Operation | * +---------------------------------------------------+ * | User identity: [ ] | * | [ ] Use bind user identity | * | Old password: [ ] | * | [ ] Old password not available | * | New password: [ ] | * | [ ] Generate new password | * | [ ] Show passwords | * | | * | (Cancel) ( OK ) | * .___________________________________________________. * </pre> * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class PasswordModifyExtendedOperationDialog extends Dialog { private IBrowserConnection connection; private IEntry entry; private Dn userIdentity = null; private String oldPassword = StringUtils.EMPTY; private String newPassword = StringUtils.EMPTY; private EntryWidget entryWidget; private Button useBindUserIdentityCheckbox; private Text oldPasswordText; private Button noOldPasswordCheckbox; private Text newPasswordText; private Button generateNewPasswordCheckbox; private Button showPasswordsCheckbox; public PasswordModifyExtendedOperationDialog( Shell parentShell, IBrowserConnection connection, IEntry entry ) { super( parentShell ); this.connection = connection; this.entry = entry; if ( entry != null ) { this.userIdentity = entry.getDn(); } } @Override protected void configureShell( Shell shell ) { super.configureShell( shell ); shell.setText( Messages.getString( "PasswordModifyExtendedOperationDialog.Title" ) ); //$NON-NLS-1$ ); } @Override protected void buttonPressed( int buttonId ) { if ( buttonId == IDialogConstants.OK_ID ) { userIdentity = entryWidget.getDn(); oldPassword = oldPasswordText.getText(); newPassword = newPasswordText.getText(); // Build extended request LdapApiService ldapApiService = LdapApiServiceFactory.getSingleton(); PasswordModifyRequest request = ( PasswordModifyRequest ) ldapApiService.getExtendedRequestFactories() .get( PasswordModifyRequest.EXTENSION_OID ).newRequest(); if ( !useBindUserIdentityCheckbox.getSelection() ) { request.setUserIdentity( Strings.getBytesUtf8( userIdentity.getName() ) ); } if ( !noOldPasswordCheckbox.getSelection() ) { request.setOldPassword( Strings.getBytesUtf8( oldPassword ) ); } if ( !generateNewPasswordCheckbox.getSelection() ) { request.setNewPassword( Strings.getBytesUtf8( newPassword ) ); } ExtendedOperationRunnable runnable = new ExtendedOperationRunnable( connection, request ); // Execute extended operations ProgressMonitorDialog dialog = new ProgressMonitorDialog( getShell() ); IStatus status = RunnableContextRunner.execute( runnable, dialog, true ); // Check for error status if ( !status.isOK() ) { // Error already handled, don't close dialog return; } // Update entry if ( entry != null ) { EventRegistry.fireEntryUpdated( new EntryModificationEvent( entry.getBrowserConnection(), entry ), this ); } // Show generated password PasswordModifyResponse response = ( PasswordModifyResponse ) runnable.getResponse(); if ( response.getGenPassword() != null ) { String generatedPassword = Strings.utf8ToString( response.getGenPassword() ); new MessageDialogWithTextarea( getShell(), Messages.getString( "PasswordModifyExtendedOperationDialog.GeneratedPasswordTitle" ), Messages.getString( "PasswordModifyExtendedOperationDialog.GeneratedPasswordMessage" ), generatedPassword ).open(); } // Continue to close dialog } else { userIdentity = null; oldPassword = null; newPassword = null; } super.buttonPressed( buttonId ); } /** * The listener for the "use bind user identity" checkbox */ private SelectionAdapter useBindUserIdentityCheckboxListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { if ( useBindUserIdentityCheckbox.getSelection() ) { entryWidget.setInput( connection, null ); entryWidget.setEnabled( false ); } else { entryWidget.setEnabled( true ); } validate(); } }; /** * The listener for the "no old password" checkbox */ private SelectionAdapter noOldPasswordCheckboxListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { if ( noOldPasswordCheckbox.getSelection() ) { oldPasswordText.setText( StringUtils.EMPTY ); oldPasswordText.setEnabled( false ); } else { oldPasswordText.setEnabled( true ); } validate(); } }; /** * The listener for the "generate new password" checkbox */ private SelectionAdapter generateNewPasswordCheckboxListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { if ( generateNewPasswordCheckbox.getSelection() ) { newPasswordText.setText( StringUtils.EMPTY ); newPasswordText.setEnabled( false ); } else { newPasswordText.setEnabled( true ); } validate(); } }; /** * The listener for the "show passwords" checkbox */ private SelectionAdapter showPasswordsCheckboxListener = new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent event ) { if ( showPasswordsCheckbox.getSelection() ) { oldPasswordText.setEchoChar( '\0' ); newPasswordText.setEchoChar( '\0' ); } else { oldPasswordText.setEchoChar( '\u2022' ); newPasswordText.setEchoChar( '\u2022' ); } } }; @Override protected Control createContents( Composite parent ) { Control contents = super.createContents( parent ); validate(); return contents; } @Override protected Control createDialogArea( Composite parent ) { // Composite Composite composite = new Composite( parent, SWT.NONE ); GridLayout layout = new GridLayout( 3, false ); layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING ); layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING ); composite.setLayout( layout ); GridData compositeGridData = new GridData( SWT.FILL, SWT.FILL, true, true ); compositeGridData.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH * 3 / 2 ); composite.setLayoutData( compositeGridData ); // User identity BaseWidgetUtils.createLabel( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.UserIdentity" ), 1 ); //$NON-NLS-1$ entryWidget = new EntryWidget( connection, userIdentity ); entryWidget.addWidgetModifyListener( event -> validate() ); entryWidget.createWidget( composite ); // Use bind user identity checkbox BaseWidgetUtils.createLabel( composite, StringUtils.EMPTY, 1 ); useBindUserIdentityCheckbox = BaseWidgetUtils.createCheckbox( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.UseBindUserIdentity" ), 2 ); //$NON-NLS-1$ useBindUserIdentityCheckbox.addSelectionListener( useBindUserIdentityCheckboxListener ); // Old password text BaseWidgetUtils.createLabel( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.OldPassword" ), 1 ); //$NON-NLS-1$ oldPasswordText = BaseWidgetUtils.createText( composite, oldPassword, 2 ); oldPasswordText.setEchoChar( '\u2022' ); oldPasswordText.addModifyListener( event -> validate() ); // No old password checkbox BaseWidgetUtils.createLabel( composite, StringUtils.EMPTY, 1 ); noOldPasswordCheckbox = BaseWidgetUtils.createCheckbox( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.NoOldPassword" ), 2 ); //$NON-NLS-1$ noOldPasswordCheckbox.addSelectionListener( noOldPasswordCheckboxListener ); // New password text BaseWidgetUtils.createLabel( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.NewPassword" ), 1 ); //$NON-NLS-1$ newPasswordText = BaseWidgetUtils.createText( composite, newPassword, 2 ); newPasswordText.setEchoChar( '\u2022' ); newPasswordText.addModifyListener( event -> validate() ); // Generate new password checkbox BaseWidgetUtils.createLabel( composite, StringUtils.EMPTY, 1 ); generateNewPasswordCheckbox = BaseWidgetUtils.createCheckbox( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.GenerateNewPassword" ), 2 ); //$NON-NLS-1$ generateNewPasswordCheckbox.addSelectionListener( generateNewPasswordCheckboxListener ); // Show password checkbox BaseWidgetUtils.createLabel( composite, StringUtils.EMPTY, 1 ); showPasswordsCheckbox = BaseWidgetUtils.createCheckbox( composite, Messages.getString( "PasswordModifyExtendedOperationDialog.ShowPasswords" ), 2 ); //$NON-NLS-1$ showPasswordsCheckbox.addSelectionListener( showPasswordsCheckboxListener ); applyDialogFont( composite ); return composite; } private void validate() { if ( getButton( IDialogConstants.OK_ID ) != null ) { boolean userIdentityInputValid = useBindUserIdentityCheckbox.getSelection() || ( entryWidget.getDn() != null && !entryWidget.getDn().isEmpty() ); boolean oldPasswordInputValid = noOldPasswordCheckbox.getSelection() || !oldPasswordText.getText().isEmpty(); boolean newPasswordInputValid = generateNewPasswordCheckbox.getSelection() || !newPasswordText.getText().isEmpty(); getButton( IDialogConstants.OK_ID ) .setEnabled( userIdentityInputValid && oldPasswordInputValid && newPasswordInputValid ); } } /** * Returns the user identity. * * @return the user identity, may be null if dialog was canceled */ public Dn getUserIdentity() { return userIdentity; } /** * Returns the old password. * * @return the old password, may be empty, null if dialog was canceled */ public String getOldPassword() { return oldPassword; } /** * Returns the new password. * * @return the new password, may be empty, null if dialog was canceled */ public String getNewPassword() { return newPassword; } }
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/dialogs/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/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.dialogs; 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/dialogs/EncoderDecoderDialog.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/EncoderDecoderDialog.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.dialogs; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldifparser.LdifUtils; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class EncoderDecoderDialog extends Dialog { private Text iso88591Text; private Text iso88591HexText; private Text utf8Text; private Text utf8HexText; private Text base64Text; private Text errorText; private boolean inModify = false; public EncoderDecoderDialog( Shell parentShell ) { super( parentShell ); super.setShellStyle( super.getShellStyle() | SWT.RESIZE ); } protected void configureShell( Shell shell ) { super.configureShell( shell ); shell.setText( Messages.getString( "EncoderDecoderDialog.LDAPEncodeDecoder" ) ); //$NON-NLS-1$ //shell.setImage( BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_IMAGEEDITOR ) ); } protected Control createDialogArea( Composite parent ) { Composite composite2 = ( Composite ) super.createDialogArea( parent ); GridData gd1 = new GridData( GridData.FILL_BOTH ); gd1.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); gd1.heightHint = convertVerticalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); composite2.setLayoutData( gd1 ); Composite composite = BaseWidgetUtils.createColumnContainer( composite2, 2, 1 ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); Label iso8859Label = new Label( composite, SWT.NONE ); iso8859Label.setText( Messages.getString( "EncoderDecoderDialog.ISOColon" ) ); //$NON-NLS-1$ iso88591Text = new Text( composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL ); GridData gd = new GridData( GridData.FILL_BOTH ); iso88591Text.setLayoutData( gd ); Label iso8859HexLabel = new Label( composite, SWT.NONE ); iso8859HexLabel.setText( Messages.getString( "EncoderDecoderDialog.ISOHex" ) ); //$NON-NLS-1$ iso88591HexText = new Text( composite, SWT.BORDER | SWT.READ_ONLY ); iso88591HexText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); Label utf8Label = new Label( composite, SWT.NONE ); utf8Label.setText( Messages.getString( "EncoderDecoderDialog.UTF" ) ); //$NON-NLS-1$ utf8Text = new Text( composite, SWT.BORDER ); utf8Text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); Label utf8HexLabel = new Label( composite, SWT.NONE ); utf8HexLabel.setText( Messages.getString( "EncoderDecoderDialog.UTFHex" ) ); //$NON-NLS-1$ utf8HexText = new Text( composite, SWT.BORDER | SWT.READ_ONLY ); utf8HexText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); Label base64Label = new Label( composite, SWT.NONE ); base64Label.setText( Messages.getString( "EncoderDecoderDialog.BASE" ) ); //$NON-NLS-1$ base64Text = new Text( composite, SWT.BORDER ); base64Text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); errorText = new Text( composite, SWT.BORDER | SWT.READ_ONLY ); gd = new GridData( GridData.FILL_HORIZONTAL ); gd.horizontalSpan = 2; errorText.setLayoutData( gd ); iso88591Text.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { if ( !inModify ) { inModify = true; try { String isoString = iso88591Text.getText(); byte[] isoBytes = isoString.getBytes( "ISO-8859-1" ); //$NON-NLS-1$ String utf8String = new String( isoBytes, "UTF-8" ); //$NON-NLS-1$ iso88591HexText.setText( LdifUtils.hexEncode( isoBytes ) ); utf8Text.setText( utf8String ); utf8HexText.setText( LdifUtils.hexEncode( utf8String.getBytes( "UTF-8" ) ) ); //$NON-NLS-1$ base64Text.setText( LdifUtils.base64encode( isoBytes ) ); errorText.setText( "" ); //$NON-NLS-1$ } catch ( Exception ex ) { errorText.setText( ex.getMessage() ); ex.printStackTrace(); } finally { inModify = false; } } } } ); utf8Text.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { if ( !inModify ) { inModify = true; try { String utf8String = utf8Text.getText(); byte[] utf8Bytes = utf8String.getBytes( "UTF-8" ); //$NON-NLS-1$ String isoString = new String( utf8Bytes, "ISO-8859-1" ); //$NON-NLS-1$ iso88591Text.setText( isoString ); iso88591HexText.setText( LdifUtils.hexEncode( isoString.getBytes( "ISO-8859-1" ) ) ); //$NON-NLS-1$ utf8HexText.setText( LdifUtils.hexEncode( utf8Bytes ) ); base64Text.setText( LdifUtils.base64encode( utf8Bytes ) ); errorText.setText( "" ); //$NON-NLS-1$ } catch ( Exception ex ) { errorText.setText( ex.getMessage() ); ex.printStackTrace(); } finally { inModify = false; } } } } ); base64Text.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { if ( !inModify ) { inModify = true; try { byte[] base64Bytes = LdifUtils.base64decodeToByteArray( base64Text.getText() ); String isoString = new String( base64Bytes, "ISO-8859-1" ); //$NON-NLS-1$ String utf8String = LdifUtils.utf8decode( base64Bytes ); iso88591Text.setText( isoString ); iso88591HexText.setText( LdifUtils.hexEncode( isoString.getBytes( "ISO-8859-1" ) ) ); //$NON-NLS-1$ utf8Text.setText( utf8String ); utf8HexText.setText( LdifUtils.hexEncode( utf8String.getBytes( "UTF-8" ) ) ); //$NON-NLS-1$ errorText.setText( "" ); //$NON-NLS-1$ } catch ( Exception ex ) { errorText.setText( ex.getMessage() ); ex.printStackTrace(); } finally { inModify = false; } } } } ); return composite; } }
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/dialogs/properties/SchemaPropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SchemaPropertyPage.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.dialogs.properties; import java.io.File; import java.text.DateFormat; import java.util.Date; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager; import org.apache.directory.studio.ldapbrowser.core.jobs.ReloadSchemaRunnable; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * Property page to shows some meta information of the schema and the * schema cache. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SchemaPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** Text field containing the Dn of the schema entry. */ private Text dnText; /** Text field containing the create timestamp of the schema entry. */ private Text ctText; /** Text field containing the modify timestamp of the schema entry. */ private Text mtText; /** Button to reload the scheam. */ private Button reloadSchemaButton; /** Text field containing the path to the schema cache file. */ private Text cachePathText; /** Text field containing last modify date of the schema cache file. */ private Text cacheDateText; /** Text field containing the size of the schema cache file. */ private Text cacheSizeText; /** * Instantiates a new schema property page. */ public SchemaPropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); Group infoGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "SchemaPropertyPage.SchemaInformation" ), 1 ); //$NON-NLS-1$ Composite infoComposite = BaseWidgetUtils.createColumnContainer( infoGroup, 2, 1 ); Composite infoGroupLeft = BaseWidgetUtils.createColumnContainer( infoComposite, 2, 1 ); BaseWidgetUtils.createLabel( infoGroupLeft, Messages.getString( "SchemaPropertyPage.SchemaDN" ), 1 ); //$NON-NLS-1$ dnText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "-", 1, 200 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( infoGroupLeft, Messages.getString( "SchemaPropertyPage.CreateTimestamp" ), 1 ); //$NON-NLS-1$ ctText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "-", 1, 200 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( infoGroupLeft, Messages.getString( "SchemaPropertyPage.ModifyTimestamp" ), 1 ); //$NON-NLS-1$ mtText = BaseWidgetUtils.createWrappedLabeledText( infoGroupLeft, "-", 1, 200 ); //$NON-NLS-1$ reloadSchemaButton = BaseWidgetUtils.createButton( infoComposite, "-", 1 ); //$NON-NLS-1$ GridData gd = new GridData(); gd.verticalAlignment = SWT.BOTTOM; reloadSchemaButton.setLayoutData( gd ); reloadSchemaButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { reloadSchema(); } } ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); Group cacheGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "SchemaPropertyPage.SchemaCache" ), 1 ); //$NON-NLS-1$ Composite cacheComposite = BaseWidgetUtils.createColumnContainer( cacheGroup, 2, 1 ); BaseWidgetUtils.createLabel( cacheComposite, Messages.getString( "SchemaPropertyPage.CacheLocation" ), 1 ); //$NON-NLS-1$ cachePathText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "-", 1, 200 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( cacheComposite, Messages.getString( "SchemaPropertyPage.CacheDate" ), 1 ); //$NON-NLS-1$ cacheDateText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "-", 1, 200 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( cacheComposite, Messages.getString( "SchemaPropertyPage.CacheSize" ), 1 ); //$NON-NLS-1$ cacheSizeText = BaseWidgetUtils.createWrappedLabeledText( cacheComposite, "-", 1, 200 ); //$NON-NLS-1$ IBrowserConnection connection = RootDSEPropertyPage.getConnection( getElement() ); update( connection ); return composite; } /** * Reloads schema. */ private void reloadSchema() { final IBrowserConnection browserConnection = RootDSEPropertyPage.getConnection( getElement() ); ReloadSchemaRunnable runnable = new ReloadSchemaRunnable( browserConnection ); RunnableContextRunner.execute( runnable, null, true ); update( browserConnection ); } /** * Updates the text fields. * * @param browserConnection the connection */ private void update( IBrowserConnection browserConnection ) { if ( !dnText.isDisposed() ) { Schema schema = null; if ( browserConnection != null ) { schema = browserConnection.getSchema(); } if ( schema != null && schema.getDn() != null ) { dnText.setText( schema.getDn().toString() ); } else { dnText.setText( "-" ); //$NON-NLS-1$ } if ( schema != null && schema.getCreateTimestamp() != null ) { ctText.setText( schema.getCreateTimestamp() ); } else { ctText.setText( "-" ); //$NON-NLS-1$ } if ( schema != null && schema.getModifyTimestamp() != null ) { mtText.setText( schema.getModifyTimestamp() ); } else { mtText.setText( "-" ); //$NON-NLS-1$ } if ( schema != null ) { reloadSchemaButton.setText( Messages.getString( "SchemaPropertyPage.ReloadSchema" ) ); //$NON-NLS-1$ } else { reloadSchemaButton.setText( Messages.getString( "SchemaPropertyPage.LoadSchema" ) ); //$NON-NLS-1$ } if ( browserConnection != null ) { String cacheFileName = BrowserConnectionManager.getSchemaCacheFileName( browserConnection .getConnection().getId() ); File cacheFile = new File( cacheFileName ); if ( cacheFile.exists() ) { cachePathText.setText( cacheFile.getPath() ); DateFormat format = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.MEDIUM ); cacheDateText.setText( format.format( new Date( cacheFile.lastModified() ) ) ); cacheSizeText.setText( Utils.formatBytes( cacheFile.length() ) ); } else { cachePathText.setText( "-" ); //$NON-NLS-1$ cacheDateText.setText( "-" ); //$NON-NLS-1$ cacheSizeText.setText( "-" ); //$NON-NLS-1$ } } reloadSchemaButton.setEnabled( true ); } } /** * Checks if is disposed. * * @return true, if is disposed */ public boolean isDisposed() { return dnText.isDisposed(); } }
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/dialogs/properties/EntryPropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/EntryPropertyPage.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.dialogs.properties; import org.apache.directory.api.ldap.model.constants.SchemaConstants; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeAttributesRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.InitializeChildrenRunnable; 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.eclipse.core.runtime.IAdaptable; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * This page shows some info about the selected Entry. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** The dn text. */ private Text dnText; /** The url text. */ private Text urlText; /** The ct text. */ private Text ctText; /** The cn text. */ private Text cnText; /** The mt text. */ private Text mtText; /** The mn text. */ private Text mnText; /** The reload cmi button. */ private Button reloadCmiButton; /** The size text. */ private Text sizeText; /** The children text. */ private Text childrenText; /** The attributes text. */ private Text attributesText; /** The values text. */ private Text valuesText; /** The include operational attributes button. */ private Button includeOperationalAttributesButton; /** The reload entry button. */ private Button reloadEntryButton; /** * Creates a new instance of EntryPropertyPage. */ public EntryPropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); Composite mainGroup = BaseWidgetUtils.createColumnContainer( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), 2, 1 ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "EntryPropertyPage.DN" ), 1 ); //$NON-NLS-1$ dnText = BaseWidgetUtils.createWrappedLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData dnTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); dnTextGridData.widthHint = 300; dnText.setLayoutData( dnTextGridData ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "EntryPropertyPage.URL" ), 1 ); //$NON-NLS-1$ urlText = BaseWidgetUtils.createWrappedLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData urlTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); urlTextGridData.widthHint = 300; urlText.setLayoutData( urlTextGridData ); Group cmiGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "EntryPropertyPage.CreateModifyinformation" ), 1 ); //$NON-NLS-1$ Composite cmiComposite = BaseWidgetUtils.createColumnContainer( cmiGroup, 3, 1 ); BaseWidgetUtils.createLabel( cmiComposite, Messages.getString( "EntryPropertyPage.CreateTimestamp" ), 1 ); //$NON-NLS-1$ ctText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 ); //$NON-NLS-1$ GridData ctTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); ctTextGridData.widthHint = 300; ctText.setLayoutData( ctTextGridData ); BaseWidgetUtils.createLabel( cmiComposite, Messages.getString( "EntryPropertyPage.CreatorsName" ), 1 ); //$NON-NLS-1$ cnText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 ); //$NON-NLS-1$ GridData cnTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); cnTextGridData.widthHint = 300; cnText.setLayoutData( cnTextGridData ); BaseWidgetUtils.createLabel( cmiComposite, Messages.getString( "EntryPropertyPage.ModifyTimestamp" ), 1 ); //$NON-NLS-1$ mtText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 2 ); //$NON-NLS-1$ GridData mtTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); mtTextGridData.widthHint = 300; mtText.setLayoutData( mtTextGridData ); BaseWidgetUtils.createLabel( cmiComposite, Messages.getString( "EntryPropertyPage.ModifiersName" ), 1 ); //$NON-NLS-1$ mnText = BaseWidgetUtils.createLabeledText( cmiComposite, "", 1 ); //$NON-NLS-1$ GridData mnTextGridData = new GridData( GridData.FILL_HORIZONTAL ); mnTextGridData.widthHint = 300; mnText.setLayoutData( mnTextGridData ); reloadCmiButton = BaseWidgetUtils.createButton( cmiComposite, "", 1 ); //$NON-NLS-1$ GridData gd = new GridData(); gd.verticalAlignment = SWT.BOTTOM; gd.horizontalAlignment = SWT.RIGHT; reloadCmiButton.setLayoutData( gd ); reloadCmiButton.addSelectionListener( new SelectionListener() { public void widgetSelected( SelectionEvent e ) { reloadOperationalAttributes(); } public void widgetDefaultSelected( SelectionEvent e ) { } } ); Group sizingGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "EntryPropertyPage.SizingInformation" ), 1 ); //$NON-NLS-1$ Composite sizingComposite = BaseWidgetUtils.createColumnContainer( sizingGroup, 3, 1 ); BaseWidgetUtils.createLabel( sizingComposite, Messages.getString( "EntryPropertyPage.EntrySize" ), 1 ); //$NON-NLS-1$ sizeText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 ); //$NON-NLS-1$ GridData sizeTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); sizeTextGridData.widthHint = 300; sizeText.setLayoutData( sizeTextGridData ); BaseWidgetUtils.createLabel( sizingComposite, Messages.getString( "EntryPropertyPage.NumberOfChildren" ), 1 ); //$NON-NLS-1$ childrenText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 ); //$NON-NLS-1$ GridData childrenTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); childrenTextGridData.widthHint = 300; childrenText.setLayoutData( childrenTextGridData ); BaseWidgetUtils.createLabel( sizingComposite, Messages.getString( "EntryPropertyPage.NumberOfAttributes" ), 1 ); //$NON-NLS-1$ attributesText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 ); //$NON-NLS-1$ GridData attributesTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); attributesTextGridData.widthHint = 300; attributesText.setLayoutData( attributesTextGridData ); BaseWidgetUtils.createLabel( sizingComposite, Messages.getString( "EntryPropertyPage.NumberOfValues" ), 1 ); //$NON-NLS-1$ valuesText = BaseWidgetUtils.createLabeledText( sizingComposite, "", 2 ); //$NON-NLS-1$ GridData valuesTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ); valuesTextGridData.widthHint = 300; valuesText.setLayoutData( valuesTextGridData ); includeOperationalAttributesButton = BaseWidgetUtils.createCheckbox( sizingComposite, Messages .getString( "EntryPropertyPage.IncludeoperationalAttributes" ), 2 ); //$NON-NLS-1$ includeOperationalAttributesButton.addSelectionListener( new SelectionListener() { public void widgetSelected( SelectionEvent e ) { entryUpdated( getEntry( getElement() ) ); } public void widgetDefaultSelected( SelectionEvent e ) { } } ); reloadEntryButton = BaseWidgetUtils.createButton( sizingComposite, "", 1 ); //$NON-NLS-1$ gd = new GridData(); gd.verticalAlignment = SWT.BOTTOM; gd.horizontalAlignment = SWT.RIGHT; reloadEntryButton.setLayoutData( gd ); reloadEntryButton.addSelectionListener( new SelectionListener() { public void widgetSelected( SelectionEvent e ) { reloadEntry(); } public void widgetDefaultSelected( SelectionEvent e ) { } } ); entryUpdated( getEntry( getElement() ) ); return composite; } /** * Reload operational attributes. */ private void reloadOperationalAttributes() { IEntry entry = EntryPropertyPage.getEntry( getElement() ); entry.setInitOperationalAttributes( true ); InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( entry ); RunnableContextRunner.execute( runnable, null, true ); entryUpdated( entry ); } /** * Reload entry. */ private void reloadEntry() { IEntry entry = EntryPropertyPage.getEntry( getElement() ); entry.setInitOperationalAttributes( true ); InitializeChildrenRunnable runnable1 = new InitializeChildrenRunnable( false, entry ); InitializeAttributesRunnable runnable2 = new InitializeAttributesRunnable( entry ); RunnableContextRunner.execute( runnable1, null, true ); RunnableContextRunner.execute( runnable2, null, true ); entryUpdated( entry ); } /** * Gets the entry. * * @param element the element * * @return the entry */ static IEntry getEntry( Object element ) { IEntry entry = null; if ( element instanceof IAdaptable ) { entry = ( IEntry ) ( ( IAdaptable ) element ).getAdapter( IEntry.class ); } return entry; } /** * Checks if is disposed. * * @return true, if is disposed */ public boolean isDisposed() { return this.dnText.isDisposed(); } /** * Gets the non-null string value. * * @param att the attribute * * @return the non-null string value */ private String getNonNullStringValue( IAttribute att ) { String value = null; if ( att != null ) { value = att.getStringValue(); } return value != null ? value : "-"; //$NON-NLS-1$ } /** * Updates the text widgets if the entry was updated. * * @param entry the entry */ private void entryUpdated( IEntry entry ) { if ( !this.dnText.isDisposed() ) { setMessage( Messages.getString( "EntryPropertyPage.Entry" ) + entry.getDn().getName() ); //$NON-NLS-1$ dnText.setText( entry.getDn().getName() ); urlText.setText( entry.getUrl().toString() ); ctText.setText( getNonNullStringValue( entry.getAttribute( SchemaConstants.CREATE_TIMESTAMP_AT ) ) ); cnText.setText( getNonNullStringValue( entry.getAttribute( SchemaConstants.CREATORS_NAME_AT ) ) ); mtText.setText( getNonNullStringValue( entry.getAttribute( SchemaConstants.MODIFY_TIMESTAMP_AT ) ) ); mnText.setText( getNonNullStringValue( entry.getAttribute( SchemaConstants.MODIFIERS_NAME_AT ) ) ); reloadCmiButton.setText( Messages.getString( "EntryPropertyPage.Refresh" ) ); //$NON-NLS-1$ int attCount = 0; int valCount = 0; int bytes = 0; IAttribute[] allAttributes = entry.getAttributes(); if ( allAttributes != null ) { for ( int attIndex = 0; attIndex < allAttributes.length; attIndex++ ) { if ( !allAttributes[attIndex].isOperationalAttribute() || includeOperationalAttributesButton.getSelection() ) { attCount++; IValue[] allValues = allAttributes[attIndex].getValues(); for ( int valIndex = 0; valIndex < allValues.length; valIndex++ ) { if ( !allValues[valIndex].isEmpty() ) { valCount++; bytes += allValues[valIndex].getBinaryValue().length; } } } } } reloadEntryButton.setText( Messages.getString( "EntryPropertyPage.Refresh" ) ); //$NON-NLS-1$ if ( !entry.isChildrenInitialized() ) { childrenText.setText( Messages.getString( "EntryPropertyPage.NotChecked" ) ); //$NON-NLS-1$ } else { childrenText.setText( ( entry.hasMoreChildren() ? NLS.bind( Messages .getString( "EntryPropertyPage.ChildrenFetched" ), new Object[] { entry.getChildrenCount() } ) //$NON-NLS-1$ : Integer.toString( entry.getChildrenCount() ) ) ); } attributesText.setText( "" + attCount ); //$NON-NLS-1$ valuesText.setText( "" + valCount ); //$NON-NLS-1$ sizeText.setText( Utils.formatBytes( bytes ) ); } } }
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/dialogs/properties/SearchPropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/SearchPropertyPage.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.dialogs.properties; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; 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.model.ISearch; import org.apache.directory.studio.ldapbrowser.core.model.impl.Search; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PropertyPage; /** * The SearchPropertyPage implements the property page for an {@link ISearch}. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, WidgetModifyListener { /** The search. */ private ISearch search; /** The search page wrapper. */ private SearchPageWrapper spw; /** * Creates a new instance of SearchPropertyPage. */ public SearchPropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ public void dispose() { spw.removeWidgetModifyListener( this ); super.dispose(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, BrowserUIConstants.PLUGIN_ID + "." + "tools_search_properties" ); //$NON-NLS-1$ //$NON-NLS-2$ // declare search ISearch search = ( ISearch ) getElement(); if ( search != null ) { this.search = search; } else { this.search = new Search(); } super.setMessage( Messages.getString( "SearchPropertyPage.Search" ) + Utils.shorten( search.getName(), 30 ) ); //$NON-NLS-1$ Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); spw = new SearchPageWrapper( SearchPageWrapper.CONNECTION_READONLY ); spw.createContents( composite ); spw.loadFromSearch( search ); spw.addWidgetModifyListener( this ); widgetModified( new WidgetModifyEvent( this ) ); return composite; } /** * {@inheritDoc} */ public boolean performOk() { boolean modified = spw.saveToSearch( search ); if ( modified && search.getBrowserConnection() != null ) { // send update event to force saving of new search parameters. EventRegistry.fireSearchUpdated( new SearchUpdateEvent( search, SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED ), this ); return spw.performSearch( search ); } return true; } /** * {@inheritDoc} */ public void widgetModified( WidgetModifyEvent event ) { setValid( spw.isValid() ); setErrorMessage( spw.getErrorMessage() ); } }
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/dialogs/properties/ValuePropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/ValuePropertyPage.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.dialogs.properties; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * This page shows some info about the selected Value. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ValuePropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** The description text. */ private Text descriptionText; /** The value text. */ private Text valueText; /** The type text. */ private Text typeText; /** The size text. */ private Text sizeText; /** * Creates a new instance of ValuePropertyPage. */ public ValuePropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { IValue value = getValue( getElement() ); Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); Composite mainGroup = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.AttributeDescription" ), 1 ); //$NON-NLS-1$ descriptionText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.ValueType" ), 1 ); //$NON-NLS-1$ typeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.ValueSize" ), 1 ); //$NON-NLS-1$ sizeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "ValuePropertyPage.Data" ), 1 ); //$NON-NLS-1$ if ( value != null && value.isString() ) { valueText = new Text( mainGroup, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY ); valueText.setFont( JFaceResources.getFont( JFaceResources.TEXT_FONT ) ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.widthHint = convertHorizontalDLUsToPixels( ( int ) ( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 ) ); gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 4 ); valueText.setLayoutData( gd ); valueText.setBackground( parent.getBackground() ); } else { valueText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ } if ( value != null ) { super.setMessage( Messages.getString( "ValuePropertyPage.Value" ) //$NON-NLS-1$ + org.apache.directory.studio.connection.core.Utils.shorten( value.toString(), 30 ) ); descriptionText.setText( value.getAttribute().getDescription() ); // valueText.setText(LdifUtils.mustEncode(value.getBinaryValue())?"Binary":value.getStringValue()); valueText.setText( value.isString() ? value.getStringValue() : Messages .getString( "ValuePropertyPage.Binary" ) ); //$NON-NLS-1$ typeText .setText( value.isString() ? Messages.getString( "ValuePropertyPage.String" ) : Messages.getString( "ValuePropertyPage.Binary" ) ); //$NON-NLS-1$ //$NON-NLS-2$ int bytes = value.getBinaryValue().length; int chars = value.isString() ? value.getStringValue().length() : 0; String size = value.isString() ? chars + ( chars > 1 ? Messages.getString( "ValuePropertyPage.Characters" ) : Messages.getString( "ValuePropertyPage.Character" ) ) : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ size += Utils.formatBytes( bytes ); sizeText.setText( size ); } return parent; } /** * Gets the value. * * @param element the element * * @return the value */ private static IValue getValue( Object element ) { IValue value = null; if ( element instanceof IAdaptable ) { value = ( IValue ) ( ( IAdaptable ) element ).getAdapter( IValue.class ); } return value; } }
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/dialogs/properties/RootDSEPropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/RootDSEPropertyPage.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.dialogs.properties; import org.apache.commons.lang3.StringUtils; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionServerType; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.jobs.ServerTypeDetector; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * This page shows some info about the Root DSE. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class RootDSEPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** The tab folder. */ private TabFolder tabFolder; /** The info tab. */ private TabItem infoTab; /** The controls tab. */ private TabItem controlsTab; /** The extensions tab. */ private TabItem extensionsTab; /** The features tab. */ private TabItem featuresTab; /** * Creates a new instance of RootDSEPropertyPage. */ public RootDSEPropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * Gets the browser connection, or null if the given element * isn't adaptable to a browser connection. * * @param element the element * * @return the browser connection */ static IBrowserConnection getConnection( Object element ) { IBrowserConnection browserConnection = null; if ( element instanceof IAdaptable ) { browserConnection = ( IBrowserConnection ) ( ( IAdaptable ) element ).getAdapter( IBrowserConnection.class ); if ( browserConnection == null ) { Connection connection = ( Connection ) ( ( IAdaptable ) element ).getAdapter( Connection.class ); browserConnection = BrowserCorePlugin.getDefault().getConnectionManager().getBrowserConnection( connection ); } } return browserConnection; } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { final IBrowserConnection connection = getConnection( getElement() ); tabFolder = new TabFolder( parent, SWT.TOP ); RowLayout mainLayout = new RowLayout(); mainLayout.fill = true; mainLayout.marginWidth = 0; mainLayout.marginHeight = 0; tabFolder.setLayout( mainLayout ); // Info tab Composite infoComposite = new Composite( tabFolder, SWT.NONE ); GridLayout gl = new GridLayout( 2, false ); infoComposite.setLayout( gl ); BaseWidgetUtils.createLabel( infoComposite, Messages.getString( "RootDSEPropertyPage.DirectoryType" ), 1 ); //$NON-NLS-1$ Text typeText = BaseWidgetUtils.createWrappedLabeledText( infoComposite, "-", 1, 150 ); //$NON-NLS-1$ if ( connection != null && connection.getRootDSE() != null ) { // Try to detect LDAP server from RootDSE ConnectionServerType serverType = ServerTypeDetector.detectServerType( connection.getRootDSE() ); if ( serverType != null ) { switch ( serverType ) { case APACHEDS: typeText.setText( Messages.getString( "RootDSEPropertyPage.ApacheDirectoryServer" ) ); //$NON-NLS-1$ break; case IBM_DIRECTORY_SERVER: typeText.setText( Messages.getString( "RootDSEPropertyPage.IBMDirectory" ) ); //$NON-NLS-1$ break; case IBM_SECUREWAY_DIRECTORY: typeText.setText( Messages.getString( "RootDSEPropertyPage.IBMSecureWay" ) ); //$NON-NLS-1$ break; case IBM_TIVOLI_DIRECTORY_SERVER: typeText.setText( Messages.getString( "RootDSEPropertyPage.IBMTivoli" ) ); //$NON-NLS-1$ break; case MICROSOFT_ACTIVE_DIRECTORY_2000: typeText.setText( Messages.getString( "RootDSEPropertyPage.MSAD2000" ) ); //$NON-NLS-1$ break; case MICROSOFT_ACTIVE_DIRECTORY_2003: typeText.setText( Messages.getString( "RootDSEPropertyPage.MSAD2003" ) ); //$NON-NLS-1$ break; case NETSCAPE: typeText.setText( Messages.getString( "RootDSEPropertyPage.NetscapeDirectoryServer" ) ); //$NON-NLS-1$ break; case NOVELL: typeText.setText( Messages.getString( "RootDSEPropertyPage.NovellEDirectory" ) ); //$NON-NLS-1$ break; case OPENLDAP: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP" ) ); //$NON-NLS-1$ break; case OPENLDAP_2_0: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP20" ) ); //$NON-NLS-1$ break; case OPENLDAP_2_1: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP21" ) ); //$NON-NLS-1$ break; case OPENLDAP_2_2: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP22" ) ); //$NON-NLS-1$ break; case OPENLDAP_2_3: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP23" ) ); //$NON-NLS-1$ break; case OPENLDAP_2_4: typeText.setText( Messages.getString( "RootDSEPropertyPage.OpenLDAP24" ) ); //$NON-NLS-1$ break; case SIEMENS_DIRX: typeText.setText( Messages.getString( "RootDSEPropertyPage.SiemensDirX" ) ); //$NON-NLS-1$ break; case SUN_DIRECTORY_SERVER: typeText.setText( Messages.getString( "RootDSEPropertyPage.SunDirectoryServer" ) ); //$NON-NLS-1$ break; } } } addInfo( connection, infoComposite, "vendorName", Messages.getString( "RootDSEPropertyPage.VendorName" ) ); //$NON-NLS-1$ //$NON-NLS-2$ addInfo( connection, infoComposite, "vendorVersion", Messages.getString( "RootDSEPropertyPage.VendorVersion" ) ); //$NON-NLS-1$ //$NON-NLS-2$ addInfo( connection, infoComposite, "supportedLDAPVersion", Messages.getString( "RootDSEPropertyPage.SupportedLDAPVersion" ) ); //$NON-NLS-1$ //$NON-NLS-2$ addInfo( connection, infoComposite, "supportedSASLMechanisms", Messages.getString( "RootDSEPropertyPage.SupportedSASL" ) ); //$NON-NLS-1$ //$NON-NLS-2$ infoTab = new TabItem( tabFolder, SWT.NONE ); infoTab.setText( Messages.getString( "RootDSEPropertyPage.Info" ) ); //$NON-NLS-1$ infoTab.setControl( infoComposite ); // Controls tab Composite controlsComposite = new Composite( tabFolder, SWT.NONE ); controlsComposite.setLayout( new GridLayout() ); Composite controlsComposite2 = BaseWidgetUtils.createColumnContainer( controlsComposite, 2, 1 ); addOidInfo( connection, controlsComposite2, "supportedControl" ); //$NON-NLS-1$ controlsTab = new TabItem( tabFolder, SWT.NONE ); controlsTab.setText( Messages.getString( "RootDSEPropertyPage.Controls" ) ); //$NON-NLS-1$ controlsTab.setControl( controlsComposite ); // Extensions tab Composite extensionComposite = new Composite( tabFolder, SWT.NONE ); extensionComposite.setLayout( new GridLayout() ); Composite extensionComposite2 = BaseWidgetUtils.createColumnContainer( extensionComposite, 2, 1 ); addOidInfo( connection, extensionComposite2, "supportedExtension" ); //$NON-NLS-1$ extensionsTab = new TabItem( tabFolder, SWT.NONE ); extensionsTab.setText( Messages.getString( "RootDSEPropertyPage.Extensions" ) ); //$NON-NLS-1$ extensionsTab.setControl( extensionComposite ); // Features tab Composite featureComposite = new Composite( tabFolder, SWT.NONE ); featureComposite.setLayout( new GridLayout() ); Composite featureComposite2 = BaseWidgetUtils.createColumnContainer( featureComposite, 2, 1 ); addOidInfo( connection, featureComposite2, "supportedFeatures" ); //$NON-NLS-1$ featuresTab = new TabItem( tabFolder, SWT.NONE ); featuresTab.setText( Messages.getString( "RootDSEPropertyPage.Features" ) ); //$NON-NLS-1$ featuresTab.setControl( featureComposite ); return tabFolder; } /** * Adds text fields to the composite. The text fields contain * the OID values of the given attribute and the OID description. * * @param browserConnection the browser connection * @param composite the composite * @param attributeType the attribute type */ private void addOidInfo( final IBrowserConnection browserConnection, Composite composite, String attributeType ) { try { String[] values = browserConnection.getRootDSE().getAttribute( attributeType ).getStringValues(); for ( String value : values ) { String description = Utils.getOidDescription( value ); if ( description == null ) { description = StringUtils.EMPTY; } BaseWidgetUtils.createLabeledText( composite, value, 1, 15 ); BaseWidgetUtils.createLabeledText( composite, description, 1, 15 ); } } catch ( Exception e ) { } } /** * Adds an text field to the composite. It contains the given label and * the values of the given attribute. * * @param browserConnection the browser connection * @param composite the composite * @param attributeType the attribute type * @param labelName the label name */ private void addInfo( final IBrowserConnection browserConnection, Composite composite, String attributeType, String labelName ) { StringBuffer sb = new StringBuffer(); try { String[] values = browserConnection.getRootDSE().getAttribute( attributeType ).getStringValues(); boolean isFirst = true; for ( String value : values ) { if ( !isFirst ) { sb.append( BrowserCoreConstants.LINE_SEPARATOR ); } sb.append( value ); isFirst = false; } } catch ( Exception e ) { sb.append( Messages.getString( "RootDSEPropertyPage.Dash" ) ); //$NON-NLS-1$ } BaseWidgetUtils.createLabel( composite, labelName, 1 ); BaseWidgetUtils.createWrappedLabeledText( composite, sb.toString(), 1, 150 ); } }
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/dialogs/properties/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/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.dialogs.properties; 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/dialogs/properties/BookmarkPropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/BookmarkPropertyPage.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.dialogs.properties; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.connection.core.Utils; import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget; import org.apache.directory.studio.ldapbrowser.core.model.IBookmark; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * This page shows some info about the selected Bookmark. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BookmarkPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** The bookmark. */ private IBookmark bookmark; /** The bookmark name text. */ private Text bookmarkNameText; /** The bookmark entry widget. */ private EntryWidget bookmarkEntryWidget; /** * Creates a new instance of BookmarkPropertyPage. */ public BookmarkPropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { if ( getElement() instanceof IAdaptable ) { bookmark = ( IBookmark ) ( ( IAdaptable ) getElement() ).getAdapter( IBookmark.class ); super .setMessage( Messages.getString( "BookmarkPropertyPage.Bookmark" ) + Utils.shorten( bookmark.getName(), 30 ) ); //$NON-NLS-1$ } else { bookmark = null; } Composite innerComposite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); BaseWidgetUtils.createLabel( innerComposite, Messages.getString( "BookmarkPropertyPage.BookmarkName" ), 1 ); //$NON-NLS-1$ bookmarkNameText = BaseWidgetUtils.createText( innerComposite, bookmark != null ? bookmark.getName() : "", 2 ); //$NON-NLS-1$ bookmarkNameText.setFocus(); bookmarkNameText.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { validate(); } } ); BaseWidgetUtils.createLabel( innerComposite, Messages.getString( "BookmarkPropertyPage.BookmarkDN" ), 1 ); //$NON-NLS-1$ bookmarkEntryWidget = new EntryWidget(); bookmarkEntryWidget.createWidget( innerComposite ); if ( bookmark != null ) { bookmarkEntryWidget.setInput( bookmark.getBrowserConnection(), bookmark.getDn() ); } bookmarkEntryWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { validate(); } } ); return innerComposite; } /** * {@inheritDoc} */ public boolean performOk() { if ( bookmark != null ) { bookmark.setName( bookmarkNameText.getText() ); bookmark.setDn( bookmarkEntryWidget.getDn() ); bookmarkEntryWidget.saveDialogSettings(); } return true; } /** * Validates the input fields. */ private void validate() { setValid( bookmarkEntryWidget.getDn() != null && !"".equals( bookmarkNameText.getText() ) ); //$NON-NLS-1$ if ( bookmark != null ) { if ( bookmarkEntryWidget.getDn() == null ) { setValid( false ); setErrorMessage( Messages.getString( "BookmarkPropertyPage.EnterDN" ) ); //$NON-NLS-1$ } else if ( "".equals( bookmarkNameText.getText() ) ) //$NON-NLS-1$ { setValid( false ); setErrorMessage( Messages.getString( "BookmarkPropertyPage.EnterName" ) ); //$NON-NLS-1$ } else if ( !bookmark.getName().equals( bookmarkNameText.getText() ) && bookmark.getBrowserConnection().getBookmarkManager().getBookmark( bookmarkNameText.getText() ) != null ) { setValid( false ); setErrorMessage( Messages.getString( "BookmarkPropertyPage.ErrorBookmarkExists" ) ); //$NON-NLS-1$ } else { setValid( true ); setErrorMessage( null ); } } else { setValid( 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/dialogs/properties/AttributePropertyPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/properties/AttributePropertyPage.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.dialogs.properties; import org.apache.directory.api.ldap.model.schema.AttributeType; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; 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.model.schema.Schema; import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils; import org.apache.directory.studio.ldapbrowser.core.utils.Utils; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; /** * This page shows some info about the selected Attribute. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class AttributePropertyPage extends PropertyPage implements IWorkbenchPropertyPage { /** The attribute name text. */ private Text attributeNameText; /** The attribute type text. */ private Text attributeTypeText; /** The attribute values text. */ private Text attributeValuesText; /** The attribute size text. */ private Text attributeSizeText; /** The atd oid text. */ private Text atdOidText; /** The atd names text. */ private Text atdNamesText; /** The atd desc text. */ private Text atdDescText; /** The atd usage text. */ private Text atdUsageText; /** The single valued flag. */ private Button singleValuedFlag; /** The collective flag. */ private Button collectiveFlag; /** The obsolete flag. */ private Button obsoleteFlag; /** The no user modification flag. */ private Button noUserModificationFlag; /** The equality matching rule text. */ private Text equalityMatchingRuleText; /** The substring matching rule text. */ private Text substringMatchingRuleText; /** The ordering matching rule text. */ private Text orderingMatchingRuleText; /** The syntax oid text. */ private Text syntaxOidText; /** The syntax desc text. */ private Text syntaxDescText; /** The syntax length text. */ private Text syntaxLengthText; /** * Creates a new instance of AttributePropertyPage. */ public AttributePropertyPage() { super(); super.noDefaultAndApplyButton(); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); Composite mainGroup = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "AttributePropertyPage.Description" ), 1 ); //$NON-NLS-1$ attributeNameText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData attributeNameTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); attributeNameTextGridData.widthHint = 300; attributeNameText.setLayoutData( attributeNameTextGridData ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "AttributePropertyPage.Type" ), 1 ); //$NON-NLS-1$ attributeTypeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData attributeTypeTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); attributeTypeTextGridData.widthHint = 300; attributeTypeText.setLayoutData( attributeTypeTextGridData ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "AttributePropertyPage.NumberOfValues" ), 1 ); //$NON-NLS-1$ attributeValuesText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData attributeValuesTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); attributeValuesTextGridData.widthHint = 300; attributeValuesText.setLayoutData( attributeValuesTextGridData ); BaseWidgetUtils.createLabel( mainGroup, Messages.getString( "AttributePropertyPage.AttributeSize" ), 1 ); //$NON-NLS-1$ attributeSizeText = BaseWidgetUtils.createLabeledText( mainGroup, "", 1 ); //$NON-NLS-1$ GridData attributeSizeTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); attributeSizeTextGridData.widthHint = 300; attributeSizeText.setLayoutData( attributeSizeTextGridData ); Group atdGroup = BaseWidgetUtils.createGroup( composite, Messages .getString( "AttributePropertyPage.AttributeType" ), 1 ); //$NON-NLS-1$ Composite atdComposite = BaseWidgetUtils.createColumnContainer( atdGroup, 2, 1 ); BaseWidgetUtils.createLabel( atdComposite, Messages.getString( "AttributePropertyPage.NubericOID" ), 1 ); //$NON-NLS-1$ atdOidText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 ); //$NON-NLS-1$ GridData atdOidTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); atdOidTextGridData.widthHint = 300; atdOidText.setLayoutData( atdOidTextGridData ); BaseWidgetUtils.createLabel( atdComposite, Messages.getString( "AttributePropertyPage.AlternativeNames" ), 1 ); //$NON-NLS-1$ atdNamesText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 ); //$NON-NLS-1$ GridData atdNamesTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); atdNamesTextGridData.widthHint = 300; atdNamesText.setLayoutData( atdNamesTextGridData ); BaseWidgetUtils.createLabel( atdComposite, Messages.getString( "AttributePropertyPage.Description" ), 1 ); //$NON-NLS-1$ atdDescText = BaseWidgetUtils.createWrappedLabeledText( atdComposite, "", 1 ); //$NON-NLS-1$ GridData atdDescTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); atdDescTextGridData.widthHint = 300; atdDescText.setLayoutData( atdDescTextGridData ); BaseWidgetUtils.createLabel( atdComposite, Messages.getString( "AttributePropertyPage.Usage" ), 1 ); //$NON-NLS-1$ atdUsageText = BaseWidgetUtils.createLabeledText( atdComposite, "", 1 ); //$NON-NLS-1$ GridData atdUsageTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); atdUsageTextGridData.widthHint = 300; atdUsageText.setLayoutData( atdUsageTextGridData ); Group flagsGroup = BaseWidgetUtils.createGroup( composite, Messages.getString( "AttributePropertyPage.Flags" ), 1 ); //$NON-NLS-1$ Composite flagsComposite = BaseWidgetUtils.createColumnContainer( flagsGroup, 4, 1 ); singleValuedFlag = BaseWidgetUtils.createCheckbox( flagsComposite, Messages .getString( "AttributePropertyPage.SingleValued" ), 1 ); //$NON-NLS-1$ singleValuedFlag.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { singleValuedFlag.setSelection( !singleValuedFlag.getSelection() ); } } ); noUserModificationFlag = BaseWidgetUtils.createCheckbox( flagsComposite, Messages .getString( "AttributePropertyPage.ReadOnly" ), 1 ); //$NON-NLS-1$ noUserModificationFlag.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { noUserModificationFlag.setSelection( !noUserModificationFlag.getSelection() ); } } ); collectiveFlag = BaseWidgetUtils.createCheckbox( flagsComposite, Messages .getString( "AttributePropertyPage.Collective" ), 1 ); //$NON-NLS-1$ collectiveFlag.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { collectiveFlag.setSelection( !collectiveFlag.getSelection() ); } } ); obsoleteFlag = BaseWidgetUtils.createCheckbox( flagsComposite, Messages .getString( "AttributePropertyPage.Obsolete" ), 1 ); //$NON-NLS-1$ obsoleteFlag.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { obsoleteFlag.setSelection( !obsoleteFlag.getSelection() ); } } ); Group syntaxGroup = BaseWidgetUtils.createGroup( composite, Messages.getString( "AttributePropertyPage.Syntax" ), 1 ); //$NON-NLS-1$ Composite syntaxComposite = BaseWidgetUtils.createColumnContainer( syntaxGroup, 2, 1 ); BaseWidgetUtils.createLabel( syntaxComposite, Messages.getString( "AttributePropertyPage.SyntaxOID" ), 1 ); //$NON-NLS-1$ syntaxOidText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 ); //$NON-NLS-1$ GridData syntaxOidTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); syntaxOidTextGridData.widthHint = 300; syntaxOidText.setLayoutData( syntaxOidTextGridData ); BaseWidgetUtils.createLabel( syntaxComposite, Messages.getString( "AttributePropertyPage.SyntaxDescription" ), 1 ); //$NON-NLS-1$ syntaxDescText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 ); //$NON-NLS-1$ GridData syntaxDescTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); syntaxDescTextGridData.widthHint = 300; syntaxDescText.setLayoutData( syntaxDescTextGridData ); BaseWidgetUtils.createLabel( syntaxComposite, Messages.getString( "AttributePropertyPage.SyntaxLength" ), 1 ); //$NON-NLS-1$ syntaxLengthText = BaseWidgetUtils.createLabeledText( syntaxComposite, "", 1 ); //$NON-NLS-1$ GridData syntaxLengthTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); syntaxLengthTextGridData.widthHint = 300; syntaxLengthText.setLayoutData( syntaxLengthTextGridData ); Group matchingGroup = BaseWidgetUtils.createGroup( composite, Messages .getString( "AttributePropertyPage.MatchingRules" ), 1 ); //$NON-NLS-1$ Composite matchingComposite = BaseWidgetUtils.createColumnContainer( matchingGroup, 2, 1 ); BaseWidgetUtils.createLabel( matchingComposite, Messages.getString( "AttributePropertyPage.EqualityMatch" ), 1 ); //$NON-NLS-1$ equalityMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 ); //$NON-NLS-1$ GridData equalityMatchingRuleTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); equalityMatchingRuleTextGridData.widthHint = 300; equalityMatchingRuleText.setLayoutData( equalityMatchingRuleTextGridData ); BaseWidgetUtils .createLabel( matchingComposite, Messages.getString( "AttributePropertyPage.SubstringMatch" ), 1 ); //$NON-NLS-1$ substringMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 ); //$NON-NLS-1$ GridData substringMatchingRuleTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); substringMatchingRuleTextGridData.widthHint = 300; substringMatchingRuleText.setLayoutData( substringMatchingRuleTextGridData ); BaseWidgetUtils.createLabel( matchingComposite, Messages.getString( "AttributePropertyPage.OrderingMatch" ), 1 ); //$NON-NLS-1$ orderingMatchingRuleText = BaseWidgetUtils.createLabeledText( matchingComposite, "", 1 ); //$NON-NLS-1$ GridData orderingMatchingRuleTextGridData = new GridData( SWT.FILL, SWT.NONE, true, false ); orderingMatchingRuleTextGridData.widthHint = 300; orderingMatchingRuleText.setLayoutData( orderingMatchingRuleTextGridData ); IAttribute attribute = getAttribute( getElement() ); if ( attribute != null ) { Schema schema = attribute.getEntry().getBrowserConnection().getSchema(); int bytes = 0; int valCount = 0; IValue[] allValues = attribute.getValues(); for ( int valIndex = 0; valIndex < allValues.length; valIndex++ ) { if ( !allValues[valIndex].isEmpty() ) { valCount++; bytes += allValues[valIndex].getBinaryValue().length; } } this.setMessage( NLS.bind( Messages.getString( "AttributePropertyPage.Attribute" ), new String[] { attribute.getDescription() } ) ); //$NON-NLS-1$ attributeNameText.setText( attribute.getDescription() ); attributeTypeText.setText( attribute.isString() ? "String" : "Binary" ); //$NON-NLS-1$ //$NON-NLS-2$ attributeValuesText.setText( "" + valCount ); //$NON-NLS-1$ attributeSizeText.setText( Utils.formatBytes( bytes ) ); if ( schema.hasAttributeTypeDescription( attribute.getDescription() ) ) { AttributeType atd = schema.getAttributeTypeDescription( attribute.getDescription() ); atdOidText.setText( atd.getOid() ); String atdNames = atd.getNames().toString(); atdNamesText.setText( atdNames.substring( 1, atdNames.length() - 1 ) ); atdDescText.setText( Utils.getNonNullString( atd.getDescription() ) ); atdUsageText.setText( Utils.getNonNullString( atd.getUsage() ) ); singleValuedFlag.setSelection( atd.isSingleValued() ); noUserModificationFlag.setSelection( !atd.isUserModifiable() ); collectiveFlag.setSelection( atd.isCollective() ); obsoleteFlag.setSelection( atd.isObsolete() ); String syntaxNumericOid = SchemaUtils.getSyntaxNumericOidTransitive( atd, schema ); long syntaxLength = SchemaUtils.getSyntaxLengthTransitive( atd, schema ); String syntaxDescription = syntaxNumericOid != null ? schema .getLdapSyntaxDescription( syntaxNumericOid ).getDescription() : null; syntaxOidText.setText( Utils.getNonNullString( syntaxNumericOid ) ); syntaxDescText.setText( Utils.getNonNullString( syntaxDescription ) ); syntaxLengthText.setText( Utils.getNonNullString( syntaxLength > 0 ? Long.toString( syntaxLength ) : null ) ); equalityMatchingRuleText.setText( Utils.getNonNullString( SchemaUtils .getEqualityMatchingRuleNameOrNumericOidTransitive( atd, schema ) ) ); substringMatchingRuleText.setText( Utils.getNonNullString( SchemaUtils .getSubstringMatchingRuleNameOrNumericOidTransitive( atd, schema ) ) ); orderingMatchingRuleText.setText( Utils.getNonNullString( SchemaUtils .getOrderingMatchingRuleNameOrNumericOidTransitive( atd, schema ) ) ); } } return parent; } /** * Gets the attribute. * * @param element the element * * @return the attribute */ private static IAttribute getAttribute( Object element ) { IAttribute attribute = null; if ( element instanceof IAdaptable ) { attribute = ( IAttribute ) ( ( IAdaptable ) element ).getAdapter( IAttribute.class ); } return attribute; } }
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/dialogs/preferences/SearchLogsPreferencePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.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.dialogs.preferences; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; /** * The search logs preference page contains settings of the * search logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchLogsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private Button enableSearchRequestLogging; private Button enableSearchResultEntryLogging; private Text logFileCountText; private Text logFileSizeText; /** * Creates a new instance of SearchResultEditorPreferencePage. */ public SearchLogsPreferencePage() { super( Messages.getString( "SearchLogsPreferencePage.SearchLogs" ) ); //$NON-NLS-1$ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() ); super.setDescription( Messages.getString( "SearchLogsPreferencePage.GeneralSettings" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void init( IWorkbench workbench ) { } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); enableSearchRequestLogging = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "SearchLogsPreferencePage.EnableRequestLogs" ), 1 ); //$NON-NLS-1$ enableSearchResultEntryLogging = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "SearchLogsPreferencePage.EnableResultLogs" ), 1 ); //$NON-NLS-1$ Group rotateGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "SearchLogsPreferencePage.LogFileRotation" ), 1 ); //$NON-NLS-1$ Composite rotateComposite = BaseWidgetUtils.createColumnContainer( rotateGroup, 5, 1 ); BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.Use" ), 1 ); //$NON-NLS-1$ logFileCountText = BaseWidgetUtils.createText( rotateComposite, "", 3, 1 ); //$NON-NLS-1$ logFileCountText.addVerifyListener( e -> { if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { e.doit = false; } if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$ { e.doit = false; } } ); logFileCountText.addModifyListener( e -> validate() ); BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.LogFilesEach" ), //$NON-NLS-1$ 1 ); logFileSizeText = BaseWidgetUtils.createText( rotateComposite, "", 5, 1 ); //$NON-NLS-1$ logFileSizeText.addVerifyListener( e -> { if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { e.doit = false; } if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$ { e.doit = false; } } ); logFileSizeText.addModifyListener( e -> validate() ); BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.KB" ), 1 ); //$NON-NLS-1$ setValues(); applyDialogFont( composite ); return composite; } private void setValues() { enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() ); enableSearchResultEntryLogging .setSelection( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() ); logFileCountText.setText( "" + ConnectionCorePlugin.getDefault().getSearchLogsFileCount() ); logFileSizeText.setText( "" + ConnectionCorePlugin.getDefault().getSearchLogsFileSize() ); } public void validate() { setValid( logFileCountText.getText().matches( "[0-9]+" ) && logFileSizeText.getText().matches( "[0-9]+" ) ); } /** * {@inheritDoc} */ public boolean performOk() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, enableSearchRequestLogging.getSelection() ); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, enableSearchResultEntryLogging.getSelection() ); instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, Integer.parseInt( logFileCountText.getText() ) ); instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, Integer.parseInt( logFileSizeText.getText() ) ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); return true; } /** * {@inheritDoc} */ protected void performDefaults() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); setValues(); super.performDefaults(); } }
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/dialogs/preferences/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/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.dialogs.preferences; 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/dialogs/preferences/SearchResultEditorPreferencePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchResultEditorPreferencePage.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.dialogs.preferences; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; /** * The search result editor preference page contains settings for the * search result editor. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchResultEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { /** The show Dn button. */ private Button showDnButton; /** The show links button. */ private Button showLinksButton; /** The sort/filter limit text */ private Text sortFilterLimitText; /** * Creates a new instance of SearchResultEditorPreferencePage. */ public SearchResultEditorPreferencePage() { super( Messages.getString( "SearchResultEditorPreferencePage.ResultEditor" ) ); //$NON-NLS-1$ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() ); super.setDescription( Messages.getString( "SearchResultEditorPreferencePage.GeneralSettings" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void init( IWorkbench workbench ) { } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 2, 1 ); BaseWidgetUtils.createSpacer( composite, 2 ); // Show Dn showDnButton = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "SearchResultEditorPreferencePage.DNAsFirst" ), 2 ); //$NON-NLS-1$ showDnButton.setSelection( getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) ); // Show DN As Link showLinksButton = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "SearchResultEditorPreferencePage.DNAsLink" ), 2 ); //$NON-NLS-1$ showLinksButton.setSelection( getPreferenceStore().getBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ) ); // Sort/Filter Limit String sortFilterLimitTooltip = Messages.getString( "SearchResultEditorPreferencePage.SortFilterLimitToolTip" ); //$NON-NLS-1$ Label sortFilterLimitLabel = BaseWidgetUtils.createLabel( composite, Messages .getString( "SearchResultEditorPreferencePage.SortFilterLimitColon" ), 1 ); //$NON-NLS-1$ sortFilterLimitLabel.setToolTipText( sortFilterLimitTooltip ); sortFilterLimitText = BaseWidgetUtils.createText( composite, "" + getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT ), 5, 1 ); //$NON-NLS-1$ sortFilterLimitText.setToolTipText( sortFilterLimitTooltip ); sortFilterLimitText.addVerifyListener( new VerifyListener() { public void verifyText( VerifyEvent e ) { if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { e.doit = false; } } } ); applyDialogFont( composite ); return composite; } /** * {@inheritDoc} */ public boolean performOk() { // Show Dn getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN, showDnButton.getSelection() ); // Show DN As Link getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS, showLinksButton.getSelection() ); // Sort/Filter Limit int sortFilterLimit = getPreferenceStore().getInt( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT ); try { sortFilterLimit = Integer.parseInt( sortFilterLimitText.getText().trim() ); } catch ( NumberFormatException nfe ) { } getPreferenceStore().setValue( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SORT_FILTER_LIMIT, sortFilterLimit ); return true; } /** * {@inheritDoc} */ protected void performDefaults() { showDnButton.setSelection( getPreferenceStore().getDefaultBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_DN ) ); showLinksButton.setSelection( getPreferenceStore().getDefaultBoolean( BrowserUIConstants.PREFERENCE_SEARCHRESULTEDITOR_SHOW_LINKS ) ); super.performDefaults(); } }
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/dialogs/preferences/EntryEditorsPreferencePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/EntryEditorsPreferencePage.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.dialogs.preferences; import java.util.ArrayList; import java.util.List; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.entryeditors.EntryEditorExtension; import org.apache.directory.studio.entryeditors.EntryEditorManager; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.dialogs.PreferencesUtil; /** * The entry editors preference page contains settings * for the Entry Editors. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class EntryEditorsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { /** A flag indicating whether or not to use the user's priority for entry editors */ private boolean useUserPriority = false; /** The open mode setting value */ private int openMode = 0; /** The ordered list of entry editors */ private List<EntryEditorExtension> sortedEntryEditorsList; // UI fields private Button historicalBehaviorButton; private Button useApplicationWideOpenModeButton; private TableViewer entryEditorsTableViewer; private Button upEntryEditorButton; private Button downEntryEditorButton; private Button restoreDefaultsEntryEditorsButton; /** * Creates a new instance of EntryEditorsPreferencePage. */ public EntryEditorsPreferencePage() { super( Messages.getString( "EntryEditorsPreferencePage.EntryEditorsPrefPageTitle" ) ); //$NON-NLS-1$ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() ); super.setDescription( Messages.getString( "EntryEditorsPreferencePage.EntryEditorsPrefPageDescription" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void init( IWorkbench workbench ) { openMode = BrowserUIPlugin.getDefault().getPluginPreferences().getInt( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE ); useUserPriority = BrowserUIPlugin.getDefault().getPluginPreferences().getBoolean( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES ); } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); // Open Mode Group BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); Group openModeGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "EntryEditorsPreferencePage.OpenMode" ), 1 ); //$NON-NLS-1$ // Historical Behavior Button historicalBehaviorButton = BaseWidgetUtils.createRadiobutton( openModeGroup, Messages .getString( "EntryEditorsPreferencePage.HistoricalBehavior" ), 1 ); //$NON-NLS-1$ Composite historicalBehaviorComposite = BaseWidgetUtils.createColumnContainer( openModeGroup, 2, 1 ); BaseWidgetUtils.createRadioIndent( historicalBehaviorComposite, 1 ); Label historicalBehaviourLabel = BaseWidgetUtils.createWrappedLabel( historicalBehaviorComposite, Messages .getString( "EntryEditorsPreferencePage.HistoricalBehaviorTooltip" ), 1 ); //$NON-NLS-1$ GridData historicalBehaviourLabelGridData = new GridData( GridData.FILL_HORIZONTAL ); historicalBehaviourLabelGridData.widthHint = 300; historicalBehaviourLabel.setLayoutData( historicalBehaviourLabelGridData ); // Use Application Wide Open Mode Button useApplicationWideOpenModeButton = BaseWidgetUtils.createRadiobutton( openModeGroup, Messages .getString( "EntryEditorsPreferencePage.ApplicationWideSetting" ), 1 ); //$NON-NLS-1$ Composite useApplicationWideOpenModeComposite = BaseWidgetUtils.createColumnContainer( openModeGroup, 2, 1 ); BaseWidgetUtils.createRadioIndent( useApplicationWideOpenModeComposite, 1 ); Link link = BaseWidgetUtils.createLink( useApplicationWideOpenModeComposite, Messages .getString( "EntryEditorsPreferencePage.ApplicationWideSettingTooltip" ), 1 ); //$NON-NLS-1$ GridData linkGridData = new GridData( GridData.FILL_HORIZONTAL ); linkGridData.widthHint = 300; link.setLayoutData( linkGridData ); link.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreferencesUtil.createPreferenceDialogOn( getShell(), "org.eclipse.ui.preferencePages.Workbench", null, null ); //$NON-NLS-1$ } } ); // Initializing the UI from the preferences value if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR ) { historicalBehaviorButton.setSelection( true ); useApplicationWideOpenModeButton.setSelection( false ); } else if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE ) { historicalBehaviorButton.setSelection( false ); useApplicationWideOpenModeButton.setSelection( true ); } // Entry Editors Group BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); Group entryEditorsGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages .getString( "EntryEditorsPreferencePage.EntryEditors" ), 1 ); //$NON-NLS-1$ // Entry Editors Label Label entryEditorsLabel = BaseWidgetUtils.createWrappedLabel( entryEditorsGroup, Messages .getString( "EntryEditorsPreferencePage.EntryEditorsLabel" ), 1 ); //$NON-NLS-1$ GridData entryEditorsLabelGridData = new GridData( GridData.FILL_HORIZONTAL ); entryEditorsLabelGridData.widthHint = 300; entryEditorsLabel.setLayoutData( entryEditorsLabelGridData ); // Entry Editors Composite Composite entryEditorsComposite = new Composite( entryEditorsGroup, SWT.NONE ); GridLayout gl = new GridLayout( 2, false ); gl.marginHeight = gl.marginWidth = 0; entryEditorsComposite.setLayout( gl ); entryEditorsComposite.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false ) ); // SchemaConnectors TableViewer entryEditorsTableViewer = new TableViewer( entryEditorsComposite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION ); GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 3 ); gridData.heightHint = 125; entryEditorsTableViewer.getTable().setLayoutData( gridData ); entryEditorsTableViewer.setContentProvider( new ArrayContentProvider() ); entryEditorsTableViewer.setLabelProvider( new LabelProvider() { public String getText( Object element ) { return ( ( EntryEditorExtension ) element ).getName(); } public Image getImage( Object element ) { return ( ( EntryEditorExtension ) element ).getIcon().createImage(); } } ); entryEditorsTableViewer.setInput( BrowserUIPlugin.getDefault().getEntryEditorManager() .getEntryEditorExtensions() ); // Up Button upEntryEditorButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages .getString( "EntryEditorsPreferencePage.Up" ), 1 ); //$NON-NLS-1$ upEntryEditorButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); upEntryEditorButton.setEnabled( false ); upEntryEditorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { moveSelectedEntryEditor( MoveEntryEditorDirectionEnum.UP ); } } ); // Down Button downEntryEditorButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages .getString( "EntryEditorsPreferencePage.Down" ), 1 ); //$NON-NLS-1$ downEntryEditorButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); downEntryEditorButton.setEnabled( false ); downEntryEditorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { moveSelectedEntryEditor( MoveEntryEditorDirectionEnum.DOWN ); } } ); // Restore Defaults Button restoreDefaultsEntryEditorsButton = BaseWidgetUtils.createButton( entryEditorsComposite, Messages .getString( "EntryEditorsPreferencePage.RestoreDefaults" ), 1 ); //$NON-NLS-1$ restoreDefaultsEntryEditorsButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); restoreDefaultsEntryEditorsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { performDefaultsEntryEditors(); } } ); // Description Label BaseWidgetUtils.createLabel( entryEditorsGroup, Messages .getString( "EntryEditorsPreferencePage.DescriptionColon" ), 1 ); //$NON-NLS-1$ // Description Text final Text descriptionText = new Text( entryEditorsGroup, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY ); descriptionText.setEditable( false ); gridData = new GridData( SWT.FILL, SWT.NONE, true, false ); gridData.heightHint = 27; gridData.widthHint = 300; descriptionText.setLayoutData( gridData ); entryEditorsTableViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged( SelectionChangedEvent event ) { // Getting the selected entry editor EntryEditorExtension entryEditor = ( EntryEditorExtension ) ( ( StructuredSelection ) entryEditorsTableViewer .getSelection() ).getFirstElement(); if ( entryEditor != null ) { // Updating the description text field descriptionText.setText( entryEditor.getDescription() ); // Updating the state of the buttons updateButtonsState( entryEditor ); } } } ); if ( useUserPriority ) { sortEntryEditorsByUserPriority(); } else { sortEntryEditorsByDefaultPriority(); } // Selecting the first entry editor if ( sortedEntryEditorsList.size() > 0 ) { entryEditorsTableViewer.setSelection( new StructuredSelection( sortedEntryEditorsList.get( 0 ) ) ); } return composite; } /** * Sorts the entry editors using the user's priority. */ private void sortEntryEditorsByUserPriority() { // Getting the entry editors sorted by user's priority sortedEntryEditorsList = new ArrayList<EntryEditorExtension>( BrowserUIPlugin.getDefault() .getEntryEditorManager().getEntryEditorExtensionsSortedByUserPriority() ); // Assigning the sorted editors to the viewer entryEditorsTableViewer.setInput( sortedEntryEditorsList ); } /** * Sorts the entry editors using the default priority. */ private void sortEntryEditorsByDefaultPriority() { // Getting the entry editors sorted by default priority sortedEntryEditorsList = new ArrayList<EntryEditorExtension>( BrowserUIPlugin.getDefault() .getEntryEditorManager().getEntryEditorExtensionsSortedByDefaultPriority() ); // Assigning the sorted editors to the viewer entryEditorsTableViewer.setInput( sortedEntryEditorsList ); } /** * Moves the currently selected entry editor. * * @param direction * the direction (up or down) */ private void moveSelectedEntryEditor( MoveEntryEditorDirectionEnum direction ) { StructuredSelection selection = ( StructuredSelection ) entryEditorsTableViewer.getSelection(); if ( selection.size() == 1 ) { EntryEditorExtension entryEditor = ( EntryEditorExtension ) selection.getFirstElement(); if ( sortedEntryEditorsList.contains( entryEditor ) ) { int oldIndex = sortedEntryEditorsList.indexOf( entryEditor ); int newIndex = 0; // Determining the new index number switch ( direction ) { case UP: newIndex = oldIndex - 1; break; case DOWN: newIndex = oldIndex + 1; break; } // Checking bounds if ( ( newIndex >= 0 ) && ( newIndex < sortedEntryEditorsList.size() ) ) { // Switching the two entry editors EntryEditorExtension newIndexEntryEditorBackup = sortedEntryEditorsList.set( newIndex, entryEditor ); sortedEntryEditorsList.set( oldIndex, newIndexEntryEditorBackup ); // Reloading the viewer entryEditorsTableViewer.refresh(); // Updating the state of the buttons updateButtonsState( entryEditor ); // Setting the "Use User Priority" to true useUserPriority = true; } } } } /** * Updates the state of the buttons. * * @param entryEditor * the selected entry editor */ private void updateButtonsState( EntryEditorExtension entryEditor ) { // Getting the index of the entry editor in the list int index = sortedEntryEditorsList.indexOf( entryEditor ); // Updating up button state upEntryEditorButton.setEnabled( index > 0 ); // Updating down button state downEntryEditorButton.setEnabled( index <= ( sortedEntryEditorsList.size() - 2 ) ); } /** * Updates the state of the buttons. */ private void updateButtonsState() { StructuredSelection selection = ( StructuredSelection ) entryEditorsTableViewer.getSelection(); if ( selection.size() == 1 ) { EntryEditorExtension entryEditor = ( EntryEditorExtension ) selection.getFirstElement(); // Updating the state of the buttons updateButtonsState( entryEditor ); } } /** * This enum is used to determine in which direction the entry editor * should be moved. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ private enum MoveEntryEditorDirectionEnum { UP, DOWN } /** * {@inheritDoc} */ public boolean performOk() { if ( historicalBehaviorButton.getSelection() ) { BrowserUIPlugin.getDefault().getPluginPreferences().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE, BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR ); } else if ( useApplicationWideOpenModeButton.getSelection() ) { BrowserUIPlugin.getDefault().getPluginPreferences().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE, BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE ); } BrowserUIPlugin.getDefault().getPluginPreferences().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES, useUserPriority ); if ( useUserPriority ) { StringBuilder sb = new StringBuilder(); for ( EntryEditorExtension entryEditor : sortedEntryEditorsList ) { sb.append( entryEditor.getId() + EntryEditorManager.PRIORITIES_SEPARATOR ); } if ( sb.length() > 0 ) { sb.deleteCharAt( sb.length() - 1 ); } BrowserUIPlugin.getDefault().getPluginPreferences().setValue( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USER_PRIORITIES, sb.toString() ); } return true; } /** * {@inheritDoc} */ protected void performDefaults() { openMode = BrowserUIPlugin.getDefault().getPluginPreferences().getDefaultInt( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE ); if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_HISTORICAL_BEHAVIOR ) { historicalBehaviorButton.setSelection( true ); useApplicationWideOpenModeButton.setSelection( false ); } else if ( openMode == BrowserUIConstants.PREFERENCE_ENTRYEDITORS_OPEN_MODE_APPLICATION_WIDE ) { historicalBehaviorButton.setSelection( false ); useApplicationWideOpenModeButton.setSelection( true ); } performDefaultsEntryEditors(); super.performDefaults(); } /** * Restore defaults to the entry editors part of the UI. */ private void performDefaultsEntryEditors() { useUserPriority = BrowserUIPlugin.getDefault().getPluginPreferences().getDefaultBoolean( BrowserUIConstants.PREFERENCE_ENTRYEDITORS_USE_USER_PRIORITIES ); if ( useUserPriority ) { sortEntryEditorsByUserPriority(); } else { sortEntryEditorsByDefaultPriority(); } updateButtonsState(); } }
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/dialogs/preferences/ModificationLogsPreferencePage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.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.dialogs.preferences; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.connection.core.ConnectionCoreConstants; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; /** * The modification logs preference page contains settings of the * modification logs view. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ModificationLogsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private Button enableModificationLogging; private Text logFileCountText; private Text logFileSizeText; private Text maskedAttributesText; /** * Creates a new instance of ModificationLogsPreferencePage. */ public ModificationLogsPreferencePage() { super( Messages.getString( "ModificationLogsPreferencePage.ModificationLogs" ) ); //$NON-NLS-1$ super.setPreferenceStore( BrowserUIPlugin.getDefault().getPreferenceStore() ); super.setDescription( Messages.getString( "ModificationLogsPreferencePage.GeneralSettingsModificationLogs" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void init( IWorkbench workbench ) { } /** * {@inheritDoc} */ protected Control createContents( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 1, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); enableModificationLogging = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "ModificationLogsPreferencePage.EnableModificationLogs" ), 1 ); //$NON-NLS-1$ BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); Group maskedAttributesGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "ModificationLogsPreferencePage.MaskedAttributes" ), 1 ); //$NON-NLS-1$ Composite maskedAttributesComposite = BaseWidgetUtils.createColumnContainer( maskedAttributesGroup, 1, 1 ); maskedAttributesText = BaseWidgetUtils.createText( maskedAttributesComposite, "", 1 ); //$NON-NLS-1$ String maskedAttributesHelp = Messages.getString( "ModificationLogsPreferencePage.CommaSeparatedList" ); //$NON-NLS-1$ BaseWidgetUtils.createWrappedLabel( maskedAttributesComposite, maskedAttributesHelp, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createSpacer( composite, 1 ); Group rotateGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ), Messages.getString( "ModificationLogsPreferencePage.LogFileRotation" ), 1 ); //$NON-NLS-1$ Composite rotateComposite = BaseWidgetUtils.createColumnContainer( rotateGroup, 5, 1 ); BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "ModificationLogsPreferencePage.Use" ), 1 ); //$NON-NLS-1$ logFileCountText = BaseWidgetUtils.createText( rotateComposite, "", 3, 1 ); //$NON-NLS-1$ logFileCountText.addVerifyListener( e -> { if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { e.doit = false; } if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$ { e.doit = false; } } ); logFileCountText.addModifyListener( e -> validate() ); BaseWidgetUtils.createLabel( rotateComposite, Messages .getString( "ModificationLogsPreferencePage.LogFilesEach" ), 1 ); //$NON-NLS-1$ logFileSizeText = BaseWidgetUtils.createText( rotateComposite, "", 5, 1 ); //$NON-NLS-1$ logFileSizeText.addVerifyListener( e -> { if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$ { e.doit = false; } if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$ { e.doit = false; } } ); logFileSizeText.addModifyListener( e -> validate() ); BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "ModificationLogsPreferencePage.KB" ), 1 ); //$NON-NLS-1$ setValues(); applyDialogFont( composite ); return composite; } private void setValues() { enableModificationLogging.setSelection( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() ); maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getMModificationLogsMaskedAttributes() ); logFileCountText.setText( "" + ConnectionCorePlugin.getDefault().getModificationLogsFileCount() ); logFileSizeText.setText( "" + ConnectionCorePlugin.getDefault().getModificationLogsFileSize() ); } public void validate() { setValid( logFileCountText.getText().matches( "[0-9]+" ) && logFileSizeText.getText().matches( "[0-9]+" ) ); } /** * {@inheritDoc} */ public boolean performOk() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, enableModificationLogging.getSelection() ); instancePreferences.put( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES, maskedAttributesText.getText() ); instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, Integer.parseInt( logFileCountText.getText() ) ); instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, Integer.parseInt( logFileSizeText.getText() ) ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); return true; } /** * {@inheritDoc} */ protected void performDefaults() { IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences(); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT ); instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE ); ConnectionCorePlugin.getDefault().flushInstanceScopePreferences(); setValues(); super.performDefaults(); } }
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/perspective/BrowserPerspective.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/perspective/BrowserPerspective.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.perspective; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.connection.ui.wizards.NewConnectionWizard; import org.apache.directory.studio.ldapbrowser.common.wizards.NewContextEntryWizard; import org.apache.directory.studio.ldapbrowser.common.wizards.NewEntryWizard; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView; import org.apache.directory.studio.ldapbrowser.ui.views.connection.ConnectionView; import org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs.ModificationLogsView; import org.apache.directory.studio.ldapbrowser.ui.views.searchlogs.SearchLogsView; import org.apache.directory.studio.ldapbrowser.ui.wizards.BatchOperationWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.NewBookmarkWizard; import org.apache.directory.studio.ldapbrowser.ui.wizards.NewSearchWizard; import org.apache.directory.studio.ldifeditor.wizards.NewLdifFileWizard; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; /** * This class implements the {@link IPerspectiveFactory} for the browser * plugin. It is responsible for creating the perspective layout. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BrowserPerspective implements IPerspectiveFactory { private static final String PROGRESS_VIEW_ID = "org.eclipse.ui.views.ProgressView"; //$NON-NLS-1$ private static final String ERROR_LOG_VIEW_ID = "org.eclipse.pde.runtime.LogView"; //$NON-NLS-1$ /** * Gets the ID of the browser perspective. * * @return the ID of the browser perspective */ public static String getId() { return BrowserUIConstants.PERSPECTIVE_LDAP; } /** * {@inheritDoc} */ public void createInitialLayout( IPageLayout layout ) { defineActions( layout ); defineLayout( layout ); layout.addPerspectiveShortcut( BrowserUIConstants.PERSPECTIVE_SCHEMA_EDITOR ); layout.addPerspectiveShortcut( BrowserUIConstants.PERSPECTIVE_LDAP ); } /** * Defines the actions in the "New..." menu and the "Show views..." menu. * * @param layout the layout */ private void defineActions( IPageLayout layout ) { // Add "new wizards". layout.addNewWizardShortcut( NewConnectionWizard.getId() ); layout.addNewWizardShortcut( NewEntryWizard.getId() ); layout.addNewWizardShortcut( NewContextEntryWizard.getId() ); layout.addNewWizardShortcut( NewSearchWizard.getId() ); layout.addNewWizardShortcut( NewBookmarkWizard.getId() ); layout.addNewWizardShortcut( BatchOperationWizard.getId() ); layout.addNewWizardShortcut( NewLdifFileWizard.getId() ); // Add "show views". layout.addShowViewShortcut( ConnectionView.getId() ); layout.addShowViewShortcut( BrowserView.getId() ); layout.addShowViewShortcut( ModificationLogsView.getId() ); layout.addShowViewShortcut( SearchLogsView.getId() ); layout.addShowViewShortcut( IPageLayout.ID_OUTLINE ); layout.addShowViewShortcut( PROGRESS_VIEW_ID ); layout.addShowViewShortcut( ERROR_LOG_VIEW_ID ); } /** * Defines the layout. * * @param layout the layout */ private void defineLayout( IPageLayout layout ) { // Editor area String editorArea = layout.getEditorArea(); // Browser folder IFolderLayout browserFolder = layout.createFolder( "browserFolder", IPageLayout.LEFT, ( float ) 0.25, //$NON-NLS-1$ editorArea ); browserFolder.addView( BrowserView.getId() ); // Connection folder IFolderLayout connectionFolder = layout.createFolder( "connectionFolder", IPageLayout.BOTTOM, ( float ) 0.75, //$NON-NLS-1$ "browserFolder" ); //$NON-NLS-1$ connectionFolder.addView( ConnectionView.getId() ); // Outline folder IFolderLayout outlineFolder = layout.createFolder( "outlineFolder", IPageLayout.RIGHT, ( float ) 0.75, //$NON-NLS-1$ editorArea ); outlineFolder.addView( IPageLayout.ID_OUTLINE ); // Progress folder IFolderLayout progessFolder = layout.createFolder( "progressFolder", IPageLayout.BOTTOM, ( float ) 0.75, //$NON-NLS-1$ "outlineFolder" ); //$NON-NLS-1$ progessFolder.addView( PROGRESS_VIEW_ID ); // Log folder IFolderLayout logFolder = layout.createFolder( "logFolder", IPageLayout.BOTTOM, ( float ) 0.75, editorArea ); //$NON-NLS-1$ logFolder.addView( ModificationLogsView.getId() ); logFolder.addView( SearchLogsView.getId() ); logFolder.addView( ERROR_LOG_VIEW_ID ); logFolder.addPlaceholder( "*" ); //$NON-NLS-1$ // non-closable? boolean isIDE = CommonUIUtils.isIDEEnvironment(); if ( !isIDE ) { layout.getViewLayout( BrowserView.getId() ).setCloseable( false ); layout.getViewLayout( ConnectionView.getId() ).setCloseable( false ); layout.getViewLayout( IPageLayout.ID_OUTLINE ).setCloseable( false ); layout.getViewLayout( PROGRESS_VIEW_ID ).setCloseable( false ); layout.getViewLayout( ModificationLogsView.getId() ).setCloseable( false ); layout.getViewLayout( SearchLogsView.getId() ).setCloseable( 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/search/SearchPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/search/SearchPage.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.search; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.search.ui.ISearchPage; import org.eclipse.search.ui.ISearchPageContainer; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.PlatformUI; /** * This class implements the {@link ISearchPage} to perform an LDAP search. * It uses the {@link SearchPageWrapper} to render all UI elements. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class SearchPage extends DialogPage implements ISearchPage, WidgetModifyListener { /** The search page container. */ private ISearchPageContainer container; /** The search. */ private ISearch search; /** The search page wrapper. */ private SearchPageWrapper spw; /** The error message label. */ private Label errorMessageLabel; /** * Gets the ID of the LDAP search page. * * @return the ID of the LDAP search page */ public static String getId() { return BrowserUIConstants.SEARCH_PAGE_LDAP_SEARCH; } /** * {@inheritDoc} */ public void dispose() { spw.removeWidgetModifyListener( this ); super.dispose(); } /** * Creates a new instance of SearchPage. */ public SearchPage() { } /** * Creates a new instance of SearchPage. * * @param title the title */ public SearchPage( String title ) { super( title ); } /** * Creates a new instance of SearchPage. * * @param title the title * @param image the image */ public SearchPage( String title, ImageDescriptor image ) { super( title, image ); } /** * {@inheritDoc} */ public boolean performAction() { spw.saveToSearch( search ); if ( search.getBrowserConnection() != null ) { search.getBrowserConnection().getSearchManager().addSearch( search ); return spw.performSearch( search ); } return false; } /** * {@inheritDoc} */ public void setContainer( ISearchPageContainer container ) { this.container = container; } /** * {@inheritDoc} */ public void createControl( Composite parent ) { // declare search search = BrowserSelectionUtils.getExampleSearch( container.getSelection() ); // create search page content GridLayout gl = new GridLayout(); parent.setLayout( gl ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); // gd.heightHint = // convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); parent.setLayoutData( gd ); Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); spw = new SearchPageWrapper( SearchPageWrapper.NONE ); spw.createContents( composite ); spw.loadFromSearch( search ); spw.addWidgetModifyListener( this ); errorMessageLabel = BaseWidgetUtils.createLabel( parent, "", 3 ); //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, BrowserUIConstants.PLUGIN_ID + "." + "tools_search_dialog" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, BrowserUIConstants.PLUGIN_ID + "." + "tools_search_dialog" ); //$NON-NLS-1$ //$NON-NLS-2$ super.setControl( parent ); } /** * {@inheritDoc} */ public void setVisible( boolean visible ) { container.setPerformActionEnabled( spw.isValid() ); super.setVisible( visible ); } /** * {@inheritDoc} */ public void widgetModified( WidgetModifyEvent event ) { container.setPerformActionEnabled( spw.isValid() ); setErrorMessage( spw.getErrorMessage() ); errorMessageLabel.setText( getErrorMessage() != null ? getErrorMessage() : "" ); //$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/wizards/NewBookmarkMainWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.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.wizards; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.search.EntryWidget; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; /** * The NewBookmarkMainWizardPage is used to specify the bookmark name * and the Dn of the target entry. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewBookmarkMainWizardPage extends WizardPage implements WidgetModifyListener { /** The entry. */ private IEntry entry; /** The bookmark name text. */ private Text bookmarkNameText; /** The bookmark entry widget. */ private EntryWidget bookmarkEntryWidget; /** * Creates a new instance of NewBookmarkMainWizardPage. * * @param pageName the page name * @param entry the entry * @param wizard the wizard */ public NewBookmarkMainWizardPage( String pageName, IEntry entry, NewBookmarkWizard wizard ) { super( pageName ); setTitle( Messages.getString( "NewBookmarkMainWizardPage.NewBookmark" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "NewBookmarkMainWizardPage.EnterNewBookmark" ) ); //$NON-NLS-1$ // setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD)); setPageComplete( false ); this.entry = entry; } /** * {@inheritDoc} */ public void dispose() { super.dispose(); bookmarkEntryWidget.removeWidgetModifyListener( this ); } /** * Validates this page. */ private void validate() { if ( bookmarkNameText != null && !bookmarkNameText.isDisposed() ) { setPageComplete( bookmarkEntryWidget.getDn() != null && !"".equals( bookmarkNameText.getText() ) ); //$NON-NLS-1$ } } /** * {@inheritDoc} */ public void setVisible( boolean visible ) { super.setVisible( visible ); if ( visible ) { validate(); } } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 3, 1 ); BaseWidgetUtils.createLabel( innerComposite, Messages.getString( "NewBookmarkMainWizardPage.BookmarkName" ), 1 ); //$NON-NLS-1$ bookmarkNameText = BaseWidgetUtils.createText( innerComposite, entry.getDn().getName(), 2 ); bookmarkNameText.setFocus(); bookmarkNameText.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { validate(); } } ); BaseWidgetUtils.createLabel( innerComposite, Messages.getString( "NewBookmarkMainWizardPage.BookmarkDN" ), 1 ); //$NON-NLS-1$ bookmarkEntryWidget = new EntryWidget(); bookmarkEntryWidget.addWidgetModifyListener( this ); bookmarkEntryWidget.createWidget( innerComposite ); bookmarkEntryWidget.setInput( entry.getBrowserConnection(), entry.getDn() ); setControl( composite ); } /** * {@inheritDoc} */ public void widgetModified( WidgetModifyEvent event ) { validate(); } /** * Gets the bookmark dn. * * @return the bookmark dn */ public Dn getBookmarkDn() { return bookmarkEntryWidget.getDn(); } /** * Gets the bookmark name. * * @return the bookmark name */ public String getBookmarkName() { return bookmarkNameText.getText(); } /** * Saves the dialog settings. */ public void saveDialogSettings() { bookmarkEntryWidget.saveDialogSettings(); } }
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/wizards/ExportExcelWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportXlsRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; /** * This class implements the Wizard for Exporting to Excel * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportExcelWizard extends ExportBaseWizard { /** The from page, used to select the exported data. */ private ExportExcelFromWizardPage fromPage; /** The to page, used to select the target file. */ private ExportExcelToWizardPage toPage; /** * Creates a new instance of ExportExcelWizard. */ public ExportExcelWizard() { super( Messages.getString( "ExportExcelWizard.ExcelExport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Export Excel Wizard * * @return The ID of the Export Excel Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_EXCEL; } /** * {@inheritDoc} */ public void addPages() { fromPage = new ExportExcelFromWizardPage( ExportExcelFromWizardPage.class.getName(), this ); addPage( fromPage ); toPage = new ExportExcelToWizardPage( ExportExcelToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem() .setHelp( fromPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_excelexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem() .setHelp( toPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_excelexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { fromPage.saveDialogSettings(); toPage.saveDialogSettings(); boolean exportDn = this.fromPage.isExportDn(); new StudioBrowserJob( new ExportXlsRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter(), exportDn ) ).execute(); 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/wizards/ExportLdifFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.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.wizards; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; /** * This class implements the page used to select the data to export to LDIF. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportLdifFromWizardPage extends ExportBaseFromWizardPage { /** * Creates a new instance of ExportLdifFromWizardPage using a * {@link SearchPageWrapper} with * <ul> * <li>hidden name * <li>visible all attributes checkbox * <li>visible operational attributes checkbox * </ul> * * @param pageName the page name * @param wizard the wizard */ public ExportLdifFromWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURN_ALLATTRIBUTES_VISIBLE | SearchPageWrapper.RETURN_OPERATIONALATTRIBUTES_VISIBLE | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch() .getReturningAttributes().length == 0 ) ? SearchPageWrapper.RETURN_ALLATTRIBUTES_CHECKED : SearchPageWrapper.NONE ) ) ); super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_LDIF_WIZARD ) ); } }
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/wizards/ExportLogsToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLogsToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.swt.widgets.Composite; /** * This class implements the page to select the target file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportLogsToWizardPage extends ExportBaseToPage { /** The extensions used by LDIF files */ private static final String[] EXTENSIONS = new String[] { "*.ldif", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** * Creates a new instance of ExportModificationLogsToWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ExportLogsToWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard ); setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_LDIF_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportLogsToWizardPage.Log" ); //$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/wizards/ExportDsmlToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.wizards.ExportDsmlWizard.ExportDsmlWizardSaveAsType; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; /** * This class implements the page to select the target DSML file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportDsmlToWizardPage extends ExportBaseToPage { /** The associated wizard */ private ExportDsmlWizard wizard; /** The extensions used by DSML files*/ private static final String[] EXTENSIONS = new String[] { "*.xml", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** * Creates a new instance of ExportDsmlToWizardPage. * * @param pageName * the name of the page * @param wizard * the wizard the page is attached to */ public ExportDsmlToWizardPage( String pageName, ExportDsmlWizard wizard ) { super( pageName, wizard ); this.wizard = wizard; super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_DSML_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); Composite saveAsOuterComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 ); Group saveAsGroup = BaseWidgetUtils.createGroup( saveAsOuterComposite, Messages .getString( "ExportDsmlToWizardPage.SaveAs" ), 1 ); //$NON-NLS-1$ Composite saveAsComposite = BaseWidgetUtils.createColumnContainer( saveAsGroup, 2, 1 ); final Button saveAsDsmlResponseButton = BaseWidgetUtils.createRadiobutton( saveAsComposite, Messages .getString( "ExportDsmlToWizardPage.DSMLResponse" ), 2 ); //$NON-NLS-1$ saveAsDsmlResponseButton.setSelection( true ); wizard.setSaveAsType( ExportDsmlWizardSaveAsType.RESPONSE ); saveAsDsmlResponseButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { if ( saveAsDsmlResponseButton.getSelection() ) { wizard.setSaveAsType( ExportDsmlWizardSaveAsType.RESPONSE ); } } } ); BaseWidgetUtils.createRadioIndent( saveAsComposite, 1 ); BaseWidgetUtils.createWrappedLabel( saveAsComposite, Messages .getString( "ExportDsmlToWizardPage.SearchSaveAsResponse" ), 1 ); //$NON-NLS-1$ final Button saveAsDsmlRequestButton = BaseWidgetUtils.createRadiobutton( saveAsComposite, Messages .getString( "ExportDsmlToWizardPage.DSMLRequest" ), 2 ); //$NON-NLS-1$ saveAsDsmlRequestButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { if ( saveAsDsmlRequestButton.getSelection() ) { wizard.setSaveAsType( ExportDsmlWizardSaveAsType.REQUEST ); } } } ); BaseWidgetUtils.createRadioIndent( saveAsComposite, 1 ); BaseWidgetUtils.createWrappedLabel( saveAsComposite, Messages .getString( "ExportDsmlToWizardPage.SearchSaveAsRequest" ), 1 ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportDsmlToWizardPage.DSML" ); //$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/wizards/ExportLdifWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportLdifRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; /** * This class implements the Wizard for Exporting to LDIF * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportLdifWizard extends ExportBaseWizard { /** The from page, used to select the exported data. */ private ExportLdifFromWizardPage fromPage; /** The to page, used to select the target file. */ private ExportLdifToWizardPage toPage; /** * Creates a new instance of ExportLdifWizard. */ public ExportLdifWizard() { super( Messages.getString( "ExportLdifWizard.LDIFExport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Export LDIF Wizard * * @return The ID of the Export LDIF Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_LDIF; } /** * {@inheritDoc} */ public void addPages() { fromPage = new ExportLdifFromWizardPage( ExportLdifFromWizardPage.class.getName(), this ); addPage( fromPage ); toPage = new ExportLdifToWizardPage( ExportLdifToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem() .setHelp( fromPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_ldifexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem() .setHelp( toPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_ldifexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { fromPage.saveDialogSettings(); toPage.saveDialogSettings(); new StudioBrowserJob( new ExportLdifRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter() ) ).execute(); 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/wizards/ImportDsmlMainWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.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.wizards; import java.io.File; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget; import org.apache.directory.studio.ldapbrowser.common.widgets.search.BrowserConnectionWidget; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; /** * This class implements the Main Page of the DSML Import Wizard * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportDsmlMainWizardPage extends WizardPage { /** The wizard the page is attached to */ private ImportDsmlWizard wizard; /** The extensions used by DSML files */ private static final String[] EXTENSIONS = new String[] { "*.xml", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** The dsml file browser widget. */ private FileBrowserWidget dsmlFileBrowserWidget; /** The browser connection widget. */ private BrowserConnectionWidget browserConnectionWidget; /** The save response button. */ private Button saveResponseButton; /** The use default response file button. */ private Button useDefaultResponseFileButton; /** The use custom response file button. */ private Button useCustomResponseFileButton; /** The response file browser widget. */ private FileBrowserWidget responseFileBrowserWidget; /** The overwrite response file button. */ private Button overwriteResponseFileButton; /** The custom response file name. */ private String customResponseFileName; /** * Creates a new instance of ImportDsmlMainWizardPage. * * @param pageName * the name of the page * @param wizard * the wizard the page is attached to */ public ImportDsmlMainWizardPage( String pageName, ImportDsmlWizard wizard ) { super( pageName ); setTitle( wizard.getWindowTitle() ); setDescription( Messages.getString( "ImportDsmlMainWizardPage.SelectConnectionAndDSMLFile" ) ); //$NON-NLS-1$ setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_DSML_WIZARD ) ); setPageComplete( false ); this.wizard = wizard; } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); // DSML file BaseWidgetUtils.createLabel( composite, Messages.getString( "ImportDsmlMainWizardPage.DSMLFile" ), 1 ); //$NON-NLS-1$ dsmlFileBrowserWidget = new FileBrowserWidget( Messages.getString( "ImportDsmlMainWizardPage.SelectDSMLFile" ), EXTENSIONS, FileBrowserWidget.TYPE_OPEN ); //$NON-NLS-1$ dsmlFileBrowserWidget.createWidget( composite ); dsmlFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { wizard.setDsmlFilename( dsmlFileBrowserWidget.getFilename() ); if ( useDefaultResponseFileButton.getSelection() ) { responseFileBrowserWidget.setFilename( dsmlFileBrowserWidget.getFilename() + ".response.xml" ); //$NON-NLS-1$ } validate(); } } ); // Connection BaseWidgetUtils.createLabel( composite, Messages.getString( "ImportDsmlMainWizardPage.ImportTo" ), 1 ); //$NON-NLS-1$ browserConnectionWidget = new BrowserConnectionWidget( wizard.getImportConnection() ); browserConnectionWidget.createWidget( composite ); browserConnectionWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { wizard.setImportConnection( browserConnectionWidget.getBrowserConnection() ); validate(); } } ); // Save Response Composite responseOuterComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 ); Group responseGroup = BaseWidgetUtils.createGroup( responseOuterComposite, Messages .getString( "ImportDsmlMainWizardPage.Response" ), 1 ); //$NON-NLS-1$ Composite responseContainer = BaseWidgetUtils.createColumnContainer( responseGroup, 3, 1 ); saveResponseButton = BaseWidgetUtils.createCheckbox( responseContainer, Messages .getString( "ImportDsmlMainWizardPage.SaveResponse" ), 3 ); //$NON-NLS-1$ saveResponseButton.setSelection( true ); wizard.setSaveResponse( saveResponseButton.getSelection() ); saveResponseButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { wizard.setSaveResponse( saveResponseButton.getSelection() ); useDefaultResponseFileButton.setEnabled( saveResponseButton.getSelection() ); useCustomResponseFileButton.setEnabled( saveResponseButton.getSelection() ); responseFileBrowserWidget.setEnabled( saveResponseButton.getSelection() && useCustomResponseFileButton.getSelection() ); overwriteResponseFileButton.setEnabled( saveResponseButton.getSelection() ); validate(); } } ); BaseWidgetUtils.createRadioIndent( responseContainer, 1 ); useDefaultResponseFileButton = BaseWidgetUtils.createRadiobutton( responseContainer, Messages .getString( "ImportDsmlMainWizardPage.UseDefaultResponse" ), 2 ); //$NON-NLS-1$ useDefaultResponseFileButton.setSelection( true ); useDefaultResponseFileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { String temp = customResponseFileName; responseFileBrowserWidget.setFilename( dsmlFileBrowserWidget.getFilename() + ".response.xml" ); //$NON-NLS-1$ responseFileBrowserWidget.setEnabled( false ); customResponseFileName = temp; validate(); } } ); BaseWidgetUtils.createRadioIndent( responseContainer, 1 ); useCustomResponseFileButton = BaseWidgetUtils.createRadiobutton( responseContainer, Messages .getString( "ImportDsmlMainWizardPage.UseCustomResponse" ), //$NON-NLS-1$ 2 ); useCustomResponseFileButton.setSelection( false ); useCustomResponseFileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { responseFileBrowserWidget.setFilename( customResponseFileName != null ? customResponseFileName : "" ); //$NON-NLS-1$ responseFileBrowserWidget.setEnabled( true ); validate(); } } ); BaseWidgetUtils.createRadioIndent( responseContainer, 1 ); responseFileBrowserWidget = new FileBrowserWidget( Messages.getString( "ImportDsmlMainWizardPage.SelectSaveFile" ), EXTENSIONS, FileBrowserWidget.TYPE_SAVE ); //$NON-NLS-1$ responseFileBrowserWidget.createWidget( responseContainer ); responseFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { customResponseFileName = responseFileBrowserWidget.getFilename(); wizard.setResponseFilename( customResponseFileName ); validate(); } } ); responseFileBrowserWidget.setEnabled( false ); BaseWidgetUtils.createRadioIndent( responseContainer, 1 ); overwriteResponseFileButton = BaseWidgetUtils.createCheckbox( responseContainer, Messages .getString( "ImportDsmlMainWizardPage.OverwriteExistingResponseFile" ), 2 ); //$NON-NLS-1$ overwriteResponseFileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { validate(); } } ); setControl( composite ); } /** * Validates the page. This method is responsible for displaying errors, as well as enabling/disabling the "Finish" button */ private void validate() { boolean ok = true; File dsmlFile = new File( dsmlFileBrowserWidget.getFilename() ); if ( "".equals( dsmlFileBrowserWidget.getFilename() ) ) //$NON-NLS-1$ { setErrorMessage( null ); ok = false; } else if ( !dsmlFile.isFile() || !dsmlFile.exists() ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorSelectedDSMLNotExist" ) ); //$NON-NLS-1$ ok = false; } else if ( !dsmlFile.canRead() ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorSelectedDSMLNotReadable" ) ); //$NON-NLS-1$ ok = false; } else if ( saveResponseButton.getSelection() ) { File responseFile = new File( responseFileBrowserWidget.getFilename() ); File responseFileDirectory = responseFile.getParentFile(); if ( responseFile.equals( dsmlFile ) ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorDSMLFileAndResponseFileEqual" ) ); //$NON-NLS-1$ ok = false; } else if ( responseFile.isDirectory() ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorSelectedResponseFileNotFile" ) ); //$NON-NLS-1$ ok = false; } else if ( responseFile.exists() && !overwriteResponseFileButton.getSelection() ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorSelecedResponseFileExist" ) ); //$NON-NLS-1$ ok = false; } else if ( responseFile.exists() && !responseFile.canWrite() ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.ErrorSelectedResponseFileNotWritable" ) ); //$NON-NLS-1$ ok = false; } else if ( responseFile.getParentFile() == null ) { setErrorMessage( Messages .getString( "ImportDsmlMainWizardPage.ErrorSelectedResponseFileDirectoryNotWritable" ) ); //$NON-NLS-1$ ok = false; } else if ( !responseFile.exists() && ( responseFileDirectory == null || !responseFileDirectory.canWrite() ) ) { setErrorMessage( Messages .getString( "ImportDsmlMainWizardPage.ErrorSelectedResponseFileDirectoryNotWritable" ) ); //$NON-NLS-1$ ok = false; } } if ( ( wizard.getImportConnection() == null ) || ( browserConnectionWidget.getBrowserConnection() == null ) ) { setErrorMessage( Messages.getString( "ImportDsmlMainWizardPage.PleaseSelectConnection" ) ); //$NON-NLS-1$ ok = false; } if ( ok ) { setErrorMessage( null ); } setPageComplete( ok ); getContainer().updateButtons(); } /** * Saves the Dialog Settings of the Page */ public void saveDialogSettings() { dsmlFileBrowserWidget.saveDialogSettings(); } }
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/wizards/BatchOperationWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationWizard.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.wizards; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileWriter; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.CommonUIUtils; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.ui.RunnableContextRunner; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.common.actions.CopyAction; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; 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.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.core.model.IValue; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldifeditor.editor.LdifEditor; import org.apache.directory.studio.ldifeditor.editor.NonExistingLdifEditorInput; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.texteditor.IDocumentProvider; public class BatchOperationWizard extends Wizard implements INewWizard { /** The connection */ private IBrowserConnection connection; // Wizard pages private BatchOperationApplyOnWizardPage applyOnPage; private BatchOperationTypeWizardPage typePage; private BatchOperationLdifWizardPage ldifPage; private BatchOperationModifyWizardPage modifyPage; private BatchOperationFinishWizardPage finishPage; /** * Creates a new instance of BatchOperationWizard. */ public BatchOperationWizard() { super.setWindowTitle( Messages.getString( "BatchOperationWizard.BatchOperation" ) ); //$NON-NLS-1$ super.setNeedsProgressMonitor( true ); } /** * Gets the id. * * @return the id */ public static String getId() { return BrowserUIConstants.WIZARD_BATCH_OPERATION; } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection() } /** * {@inheritDoc} */ public void addPages() { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); Connection[] connections = BrowserSelectionUtils.getConnections( selection ); ISearch[] searches = BrowserSelectionUtils.getSearches( selection ); IEntry[] entries = BrowserSelectionUtils.getEntries( selection ); ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection ); IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection ); IAttribute[] attributes = BrowserSelectionUtils.getAttributes( selection ); IValue[] values = BrowserSelectionUtils.getValues( selection ); // if(searches.length + entries.length + searchResults.length + // bookmarks.length > 0) { if ( connections.length > 0 && connections[0].getConnectionWrapper().isConnected() || searches.length + entries.length + searchResults.length + bookmarks.length + attributes.length + values.length > 0 ) { ISearch search = BrowserSelectionUtils.getExampleSearch( selection ); search.setName( null ); this.connection = search.getBrowserConnection(); applyOnPage = new BatchOperationApplyOnWizardPage( BatchOperationApplyOnWizardPage.class.getName(), this ); addPage( applyOnPage ); typePage = new BatchOperationTypeWizardPage( BatchOperationTypeWizardPage.class.getName(), this ); addPage( typePage ); ldifPage = new BatchOperationLdifWizardPage( BatchOperationLdifWizardPage.class.getName(), this ); addPage( ldifPage ); modifyPage = new BatchOperationModifyWizardPage( BatchOperationModifyWizardPage.class.getName(), this ); addPage( modifyPage ); finishPage = new BatchOperationFinishWizardPage( BatchOperationFinishWizardPage.class.getName() ); addPage( finishPage ); } else { IWizardPage page = new DummyWizardPage(); addPage( page ); } } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem().setHelp( applyOnPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( typePage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( ldifPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( modifyPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( finishPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_batchoperation_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * This private class implements a dummy wizard page that is displayed when no connection is selected. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class DummyWizardPage extends WizardPage { /** * Creates a new instance of DummyWizardPage. */ protected DummyWizardPage() { super( "" ); //$NON-NLS-1$ super.setTitle( Messages.getString( "BatchOperationWizard.NoConnectionSelected" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationWizard.SelectOpenConnection" ) ); //$NON-NLS-1$ // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD)); super.setPageComplete( true ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); setControl( composite ); } } /** * {@inheritDoc} */ public IWizardPage getNextPage( IWizardPage page ) { if ( this.applyOnPage != null ) { if ( page == this.applyOnPage ) { return this.typePage; } else if ( page == this.typePage && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF ) { return this.ldifPage; } else if ( page == this.typePage && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY ) { return this.modifyPage; } else if ( page == this.typePage && this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_DELETE ) { return this.finishPage; } else if ( page == this.modifyPage ) { return this.finishPage; } else if ( page == this.ldifPage ) { return this.finishPage; } } return null; } /** * {@inheritDoc} */ public boolean canFinish() { if ( this.applyOnPage != null ) { if ( !this.applyOnPage.isPageComplete() ) { return false; } if ( !this.typePage.isPageComplete() ) { return false; } if ( this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF && !this.ldifPage.isPageComplete() ) { return false; } if ( this.typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY && !this.modifyPage.isPageComplete() ) { return false; } if ( !this.finishPage.isPageComplete() ) { return false; } } return true; } /** * {@inheritDoc} */ public boolean performCancel() { return true; } /** * {@inheritDoc} */ public boolean performFinish() { if ( this.applyOnPage != null ) { this.applyOnPage.saveDialogSettings(); this.finishPage.saveDialogSettings(); // get LDIF String ldifFragment = ""; //$NON-NLS-1$ if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF ) { ldifFragment = this.ldifPage.getLdifFragment(); } else if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_MODIFY ) { ldifFragment = this.modifyPage.getLdifFragment(); } if ( typePage.getOperationType() == BatchOperationTypeWizardPage.OPERATION_TYPE_DELETE ) { ldifFragment = "changetype: delete" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$ } // get DNs Dn[] dns = applyOnPage.getApplyOnDns(); if ( dns == null ) { if ( applyOnPage.getApplyOnSearch() != null ) { ISearch search = applyOnPage.getApplyOnSearch(); if ( search.getBrowserConnection() != null ) { search.setSearchResults( null ); SearchRunnable runnable = new SearchRunnable( new ISearch[] { search } ); IStatus status = RunnableContextRunner.execute( runnable, getContainer(), true ); if ( status.isOK() ) { ISearchResult[] srs = search.getSearchResults(); dns = new Dn[srs.length]; for ( int i = 0; i < srs.length; i++ ) { dns[i] = srs[i].getDn(); } } } } } if ( dns != null ) { StringBuffer ldif = new StringBuffer(); for ( int i = 0; i < dns.length; i++ ) { ldif.append( "dn: " ); //$NON-NLS-1$ ldif.append( dns[i].getName() ); ldif.append( BrowserCoreConstants.LINE_SEPARATOR ); ldif.append( ldifFragment ); ldif.append( BrowserCoreConstants.LINE_SEPARATOR ); } if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_EDITOR ) { // Opening an LDIF Editor with the LDIF content try { IEditorInput input = new NonExistingLdifEditorInput(); IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .openEditor( input, LdifEditor.getId() ); IDocumentProvider documentProvider = ( ( LdifEditor ) editor ).getDocumentProvider(); if ( documentProvider != null ) { IDocument document = documentProvider.getDocument( input ); if ( document != null ) { document.set( ldif.toString() ); } } } catch ( PartInitException e ) { return false; } return true; } else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_FILE ) // TODO { // Saving the LDIF to a file // Getting the shell Shell shell = Display.getDefault().getActiveShell(); // detect IDE or RCP: // check if perspective org.eclipse.ui.resourcePerspective is available boolean isIDE = CommonUIUtils.isIDEEnvironment(); if ( isIDE ) { // Asking the user for the location where to 'save as' the file SaveAsDialog dialog = new SaveAsDialog( shell ); if ( dialog.open() != Dialog.OK ) { return false; } // Getting if the resulting file IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( dialog.getResult() ); try { // Creating the file if it does not exist if ( !file.exists() ) { file.create( new ByteArrayInputStream( "".getBytes() ), true, null ); //$NON-NLS-1$ } // Saving the LDIF to the file in the workspace file.setContents( new ByteArrayInputStream( ldif.toString().getBytes() ), true, true, new NullProgressMonitor() ); } catch ( Exception e ) { return false; } } else { boolean canOverwrite = false; String path = null; while ( !canOverwrite ) { // Open FileDialog FileDialog dialog = new FileDialog( shell, SWT.SAVE ); path = dialog.open(); if ( path == null ) { return false; } // Check whether file exists and if so, confirm overwrite final File externalFile = new File( path ); if ( externalFile.exists() ) { String question = NLS.bind( Messages .getString( "BatchOperationWizard.TheFileAlreadyExistsReplace" ), path ); //$NON-NLS-1$ MessageDialog overwriteDialog = new MessageDialog( shell, Messages .getString( "BatchOperationWizard.Question" ), null, question, //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 ); int overwrite = overwriteDialog.open(); switch ( overwrite ) { case 0: // Yes canOverwrite = true; break; case 1: // No break; case 2: // Cancel default: return false; } } else { canOverwrite = true; } } // Saving the LDIF to the file on disk try { BufferedWriter outFile = new BufferedWriter( new FileWriter( path ) ); outFile.write( ldif.toString() ); outFile.close(); } catch ( Exception e ) { return false; } } return true; } else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_LDIF_CLIPBOARD ) { // Copying the LDIF to the clipboard CopyAction.copyToClipboard( new Object[] { ldif.toString() }, new Transfer[] { TextTransfer.getInstance() } ); return true; } else if ( finishPage.getExecutionMethod() == BatchOperationFinishWizardPage.EXECUTION_METHOD_ON_CONNECTION ) { // Executing the LDIF on the connection ExecuteLdifRunnable runnable = new ExecuteLdifRunnable( getConnection(), ldif.toString(), true, finishPage.getContinueOnError() ); StudioBrowserJob job = new StudioBrowserJob( runnable ); job.execute(); return true; } } return false; } return true; } /** * Gets the type of the page. * * @return the type of the page */ public BatchOperationTypeWizardPage getTypePage() { return typePage; } /** * Gets the connection. * * @return the connection */ public IBrowserConnection getConnection() { return this.connection; } }
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/wizards/BatchOperationTypeWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationTypeWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; public class BatchOperationTypeWizardPage extends WizardPage { public final static int OPERATION_TYPE_NONE = -1; public final static int OPERATION_TYPE_MODIFY = 0; public final static int OPERATION_TYPE_DELETE = 1; public final static int OPERATION_TYPE_CREATE_LDIF = 2; private final static String[] OPERATION_TYPES = { Messages.getString( "BatchOperationTypeWizardPage.ModifyEntries" ), Messages.getString( "BatchOperationTypeWizardPage.DeleteEntries" ), Messages.getString( "BatchOperationTypeWizardPage.ExecuteLDIFChangetype" ) }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ private Button[] operationTypeButtons; public BatchOperationTypeWizardPage( String pageName, BatchOperationWizard wizard ) { super( pageName ); super.setTitle( Messages.getString( "BatchOperationTypeWizardPage.SelectOperationType" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationTypeWizardPage.PleaseSelectBatch" ) ); //$NON-NLS-1$ super.setPageComplete( false ); } private void validate() { setPageComplete( getOperationType() != OPERATION_TYPE_NONE ); } public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); operationTypeButtons = new Button[OPERATION_TYPES.length]; for ( int i = 0; i < operationTypeButtons.length; i++ ) { operationTypeButtons[i] = BaseWidgetUtils.createRadiobutton( composite, OPERATION_TYPES[i], 1 ); operationTypeButtons[i].addSelectionListener( new SelectionListener() { public void widgetDefaultSelected( SelectionEvent e ) { validate(); } public void widgetSelected( SelectionEvent e ) { validate(); } } ); } operationTypeButtons[0].setSelection( true ); validate(); setControl( composite ); } public int getOperationType() { for ( int i = 0; i < operationTypeButtons.length; i++ ) { if ( operationTypeButtons[i].getSelection() ) { return i; } } return OPERATION_TYPE_NONE; } }
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/wizards/BatchOperationLdifWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationLdifWizardPage.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.wizards; import java.util.List; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldifeditor.widgets.LdifEditorWidget; import org.apache.directory.studio.ldifparser.model.LdifFile; import org.apache.directory.studio.ldifparser.model.container.LdifContainer; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.events.VerifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; public class BatchOperationLdifWizardPage extends WizardPage implements WidgetModifyListener { private static final String LDIF_DN_PREFIX = "dn: cn=dummy" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$ private static final String LDIF_INITIAL = "changetype: modify" + BrowserCoreConstants.LINE_SEPARATOR; //$NON-NLS-1$ private BatchOperationWizard wizard; private LdifEditorWidget ldifEditorWidget; public BatchOperationLdifWizardPage( String pageName, BatchOperationWizard wizard ) { super( pageName ); super.setTitle( Messages.getString( "BatchOperationLdifWizardPage.LDIFFragment" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationLdifWizardPage.PleaseEnterLDIFFragment" ) ); //$NON-NLS-1$ // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD)); super.setPageComplete( false ); this.wizard = wizard; } public void dispose() { ldifEditorWidget.dispose(); super.dispose(); } private void validate() { LdifFile model = ldifEditorWidget.getLdifModel(); List<LdifContainer> containers = model.getContainers(); if ( containers.size() == 0 ) { setPageComplete( false ); return; } for ( LdifContainer ldifContainer : containers ) { if ( !ldifContainer.isValid() ) { setPageComplete( false ); return; } } setPageComplete( true ); } public boolean isPageComplete() { if ( wizard.getTypePage().getOperationType() != BatchOperationTypeWizardPage.OPERATION_TYPE_CREATE_LDIF ) { return true; } return super.isPageComplete(); } public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); ldifEditorWidget = new LdifEditorWidget( null, LDIF_DN_PREFIX + LDIF_INITIAL, true ); ldifEditorWidget.createWidget( composite ); ldifEditorWidget.addWidgetModifyListener( this ); ldifEditorWidget.getSourceViewer().getTextWidget().addVerifyListener( new VerifyListener() { public void verifyText( VerifyEvent e ) { if ( e.start < LDIF_DN_PREFIX.length() || e.end < LDIF_DN_PREFIX.length() ) { e.doit = false; } } } ); validate(); setControl( composite ); } public String getLdifFragment() { return ldifEditorWidget.getLdifModel().toRawString().replaceAll( LDIF_DN_PREFIX, "" ); //$NON-NLS-1$ } public void widgetModified( WidgetModifyEvent event ) { validate(); } }
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/wizards/ImportDsmlWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.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.wizards; import java.io.File; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserCategory; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.jobs.ImportDsmlRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; 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.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; 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.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; /** * This class implements the Import DSML Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportDsmlWizard extends Wizard implements IImportWizard { /** The connection attached to the import */ private IBrowserConnection importConnection; /** The main page of the wizard */ private ImportDsmlMainWizardPage mainPage; /** The DSML Filename */ private String dsmlFilename; /** The Save Filename */ private String responseFilename; /** The Save Response flag */ private boolean saveResponse; /** * Creates a new instance of ImportDsmlWizard. */ public ImportDsmlWizard() { super(); setWindowTitle( Messages.getString( "ImportDsmlWizard.DSMLImport" ) ); //$NON-NLS-1$ } /** * Creates a new instance of ImportDsmlWizard. * @param selectedConnection * The connection to use */ public ImportDsmlWizard( IBrowserConnection selectedConnection ) { setWindowTitle( Messages.getString( "ImportDsmlWizard.DSMLImport" ) ); //$NON-NLS-1$ this.importConnection = selectedConnection; } /** * Gets the ID of the Import DSML Wizard * @return The ID of the Import DSML Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_IMPORT_DSML; } /** * {@inheritDoc} */ public boolean performFinish() { mainPage.saveDialogSettings(); if ( dsmlFilename != null && !"".equals( dsmlFilename ) ) //$NON-NLS-1$ { File dsmlFile = new File( dsmlFilename ); if ( saveResponse ) { File responseFile = new File( responseFilename ); new StudioBrowserJob( new ImportDsmlRunnable( importConnection, dsmlFile, responseFile ) ).execute(); } else { new StudioBrowserJob( new ImportDsmlRunnable( importConnection, dsmlFile ) ).execute(); } return true; } return false; } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { Object o = selection.getFirstElement(); if ( o instanceof IEntry ) { importConnection = ( ( IEntry ) o ).getBrowserConnection(); } else if ( o instanceof ISearchResult ) { importConnection = ( ( ISearchResult ) o ).getEntry().getBrowserConnection(); } else if ( o instanceof IBookmark ) { importConnection = ( ( IBookmark ) o ).getBrowserConnection(); } else if ( o instanceof IAttribute ) { importConnection = ( ( IAttribute ) o ).getEntry().getBrowserConnection(); } else if ( o instanceof IValue ) { importConnection = ( ( IValue ) o ).getAttribute().getEntry().getBrowserConnection(); } else if ( o instanceof IBrowserConnection ) { importConnection = ( IBrowserConnection ) o; } else if ( o instanceof Connection ) { importConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( ( Connection ) o ); } else if ( o instanceof BrowserCategory ) { importConnection = ( ( BrowserCategory ) o ).getParent(); } else { importConnection = null; } } /** * {@inheritDoc} */ public void addPages() { mainPage = new ImportDsmlMainWizardPage( ImportDsmlMainWizardPage.class.getName(), this ); addPage( mainPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem() .setHelp( mainPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_dsmlimport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Get the connection attached to the Import * @return The connection attached to the Import */ public IBrowserConnection getImportConnection() { return importConnection; } /** * Sets the connection attached to the Import * @param connection * The connection attached to the Import */ public void setImportConnection( IBrowserConnection connection ) { this.importConnection = connection; } /** * Sets the DSML Filename * @param dsmlFilename * The DSML Filename */ public void setDsmlFilename( String dsmlFilename ) { this.dsmlFilename = dsmlFilename; } /** * Sets the Save Filename * @param saveFilename * The Save Filename */ public void setResponseFilename( String saveFilename ) { this.responseFilename = saveFilename; } /** * Sets the SaveResponse flag * @param b * The SaveResponse flag */ public void setSaveResponse( boolean b ) { this.saveResponse = b; } }
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/wizards/ExportConnectionsWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportConnectionsWizardPage.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.wizards; import java.io.File; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; /** * This class implements the page used to select the connections to export. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportConnectionsWizardPage extends WizardPage { // UI widgets // private CheckboxTreeViewer connectionsTreeViewer; // private ConnectionContentProvider contentProvider; private FileBrowserWidget fileBrowserWidget; private Button overwriteFileButton; /** * Creates a new instance of ExportConnectionsWizardPage. */ protected ExportConnectionsWizardPage() { super( ExportConnectionsWizardPage.class.getName() ); setTitle( Messages.getString( "ExportConnectionsWizardPage.ExportConnections" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "ExportConnectionsWizardPage.DefineConnectionsExport" ) ); //$NON-NLS-1$ setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CONNECTIONS_WIZARD ) ); setPageComplete( false ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { // Main Composite Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); // // Connections Group // Group connectionsGroup = BaseWidgetUtils.createGroup( composite, "Connections", 1 ); // Composite connectionsGroupComposite = BaseWidgetUtils.createColumnContainer( connectionsGroup, 2, 1 ); // // // Connections Label // BaseWidgetUtils.createLabel( connectionsGroupComposite, "Select the connections to export: ", 1 ); // BaseWidgetUtils.createSpacer( connectionsGroupComposite, 1 ); // // // Connections TreeViewer // connectionsTreeViewer = new CheckboxTreeViewer( new Tree( connectionsGroupComposite, SWT.BORDER | SWT.CHECK // | SWT.FULL_SELECTION ) ); // GridData connectionsTableViewerGridData = new GridData( SWT.FILL, SWT.NONE, true, false, 1, 2 ); // connectionsTableViewerGridData.heightHint = 125; // connectionsTreeViewer.getTree().setLayoutData( connectionsTableViewerGridData ); // contentProvider = new ConnectionContentProvider(); // connectionsTreeViewer.setContentProvider( contentProvider ); // connectionsTreeViewer.setLabelProvider( new ConnectionLabelProvider() ); // connectionsTreeViewer.setInput( ConnectionCorePlugin.getDefault().getConnectionFolderManager() ); // connectionsTreeViewer.addCheckStateListener( new ICheckStateListener() // { // public void checkStateChanged( CheckStateChangedEvent event ) // { // Object checkedElement = event.getElement(); // Object[] children = contentProvider.getChildren( checkedElement ); // if ( ( children != null ) && ( children.length > 0 ) ) // { // for ( Object child : children ) // { // connectionsTreeViewer.setChecked( child, event.getChecked() ); // } // } // } // } ); // // // Selection Buttons // Button selectAllButton = BaseWidgetUtils.createButton( connectionsGroupComposite, "Select All", 1 ); // selectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); // selectAllButton.addSelectionListener( new SelectionAdapter() // { // public void widgetSelected( SelectionEvent e ) // { // connectionsTreeViewer.setAllChecked( true ); // validate(); // } // } ); // Button deselectAllButton = BaseWidgetUtils.createButton( connectionsGroupComposite, "Deselect All", 1 ); // deselectAllButton.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, false, false ) ); // deselectAllButton.addSelectionListener( new SelectionAdapter() // { // public void widgetSelected( SelectionEvent e ) // { // connectionsTreeViewer.setAllChecked( false ); // validate(); // } // } ); // Destination Group // Group destinationGroup = BaseWidgetUtils.createGroup( composite, "Destination", 1 ); // Composite destinationGroupComposite = BaseWidgetUtils.createColumnContainer( destinationGroup, 3, 1 ); // Destination File BaseWidgetUtils.createLabel( composite, Messages.getString( "ExportConnectionsWizardPage.ToFile" ), 1 ); //$NON-NLS-1$ fileBrowserWidget = new FileBrowserWidget( Messages.getString( "ExportConnectionsWizardPage.ChooseFile" ), new String[] //$NON-NLS-1$ { "*.lbc", "*" }, FileBrowserWidget.TYPE_SAVE ); //$NON-NLS-1$ fileBrowserWidget.createWidget( composite ); fileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { validate(); } } ); BaseWidgetUtils.createRadioIndent( composite, 1 ); overwriteFileButton = BaseWidgetUtils.createCheckbox( composite, Messages .getString( "ExportConnectionsWizardPage.OverwriteExistingFile" ), 2 ); //$NON-NLS-1$ overwriteFileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { validate(); } } ); setControl( composite ); } /** * Validates this page. This method is responsible for displaying errors, * as well as enabling/disabling the "Finish" button */ private void validate() { boolean ok = true; File file = new File( fileBrowserWidget.getFilename() ); if ( "".equals( fileBrowserWidget.getFilename() ) ) //$NON-NLS-1$ { setErrorMessage( null ); ok = false; } else if ( file.isDirectory() ) { setErrorMessage( Messages.getString( "ExportConnectionsWizardPage.ErrorFileNotAFile" ) ); //$NON-NLS-1$ ok = false; } else if ( file.exists() && !overwriteFileButton.getSelection() ) { setErrorMessage( Messages.getString( "ExportConnectionsWizardPage.ErrorFileAlreadyExists" ) ); //$NON-NLS-1$ ok = false; } else if ( file.exists() && !file.canWrite() ) { setErrorMessage( Messages.getString( "ExportConnectionsWizardPage.ErrorFileNotWritable" ) ); //$NON-NLS-1$ ok = false; } else if ( file.getParentFile() == null ) { setErrorMessage( Messages.getString( "ExportConnectionsWizardPage.ErrorFileDirectoryNotWritable" ) ); //$NON-NLS-1$ ok = false; } if ( ok ) { setErrorMessage( null ); } setPageComplete( ok ); } /** * Gets the export file name. * * @return * the export file name */ public String getExportFileName() { return fileBrowserWidget.getFilename(); } /** * Saves the dialog settings. */ public void saveDialogSettings() { fileBrowserWidget.saveDialogSettings(); } }
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/wizards/ExportCsvFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvFromWizardPage.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.wizards; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; /** * This class implements the page used to select the data to export to CSV. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportCsvFromWizardPage extends ExportBaseFromWizardPage { /** * Creates a new instance of ExportExcelFromWizardPage using a * {@link SearchPageWrapper} with * <ul> * <li>hidden name * <li>visible and checked return Dn checkbox * <li>invisible all attributes checkbox * <li>invisible operational attributes checkbox * </ul> * * @param pageName the page name * @param wizard the wizard */ public ExportCsvFromWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURN_DN_VISIBLE | SearchPageWrapper.RETURN_DN_CHECKED ) ); super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) ); } /** * Checks if the DNs should be exported. * * @return true, if the DNs should be exported */ public boolean isExportDn() { return spw.isReturnDn(); } }
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/wizards/ExportModificationLogsWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportModificationLogsWizard.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.wizards; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.directory.api.util.FileUtils; import org.apache.directory.api.util.IOUtils; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifModificationLogger; import org.apache.directory.studio.connection.ui.ConnectionUIPlugin; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; /** * This class implements the wizard for exporting the modification logs. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportModificationLogsWizard extends ExportBaseWizard { /** The to page, used to select the target file. */ private ExportLogsToWizardPage toPage; /** * Creates a new instance of ExportModificationLogsWizard. */ public ExportModificationLogsWizard() { super( Messages.getString( "ExportModificationLogsWizard.ExportModificationLogs" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void addPages() { toPage = new ExportLogsToWizardPage( ExportLogsToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public boolean performFinish() { toPage.saveDialogSettings(); if ( search.getBrowserConnection().getConnection() != null ) { try { File targetFile = new File( exportFilename ); OutputStream os = FileUtils.openOutputStream( targetFile ); LdifModificationLogger modificationLogger = ConnectionCorePlugin.getDefault() .getLdifModificationLogger(); File[] files = modificationLogger.getFiles( search.getBrowserConnection().getConnection() ); // need to go backward through the files as the 1st file contains the newest entry for ( int i = files.length - 1; i >= 0; i-- ) { File file = files[i]; if ( file != null && file.exists() && file.canRead() ) { InputStream is = FileUtils.openInputStream( file ); IOUtils.copy( is, os ); is.close(); } } os.close(); } catch ( IOException e ) { ConnectionUIPlugin.getDefault().getExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserCommonConstants.PLUGIN_ID, IStatus.ERROR, Messages .getString( "ExportModificationLogsWizard.CantExportModificationLogs" ), e ) ); //$NON-NLS-1$ } } 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/wizards/ExportExcelFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.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.wizards; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; /** * This class implements the page used to select the data to export to Excel. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportExcelFromWizardPage extends ExportBaseFromWizardPage { /** * Creates a new instance of ExportExcelFromWizardPage using a * {@link SearchPageWrapper} with * <ul> * <li>hidden name * <li>visible and checked return Dn checkbox * <li>visible all attributes checkbox * <li>visible operational attributes checkbox * </ul> * * @param pageName the page name * @param wizard the wizard */ public ExportExcelFromWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURN_DN_VISIBLE | SearchPageWrapper.RETURN_DN_CHECKED | SearchPageWrapper.RETURN_ALLATTRIBUTES_VISIBLE | SearchPageWrapper.RETURN_OPERATIONALATTRIBUTES_VISIBLE | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch() .getReturningAttributes().length == 0 ) ? SearchPageWrapper.RETURN_ALLATTRIBUTES_CHECKED : SearchPageWrapper.NONE ) ) ); super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_XLS_WIZARD ) ); } /** * Checks if the DNs should be exported. * * @return true, if the DNs should be exported */ public boolean isExportDn() { return spw.isReturnDn(); } }
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/wizards/ImportConnectionsWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportConnectionsWizard.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.wizards; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.ConnectionFolder; import org.apache.directory.studio.connection.core.ConnectionFolderManager; import org.apache.directory.studio.connection.core.ConnectionManager; import org.apache.directory.studio.connection.core.ConnectionParameter; import org.apache.directory.studio.connection.core.io.ConnectionIO; import org.apache.directory.studio.connection.core.io.ConnectionIOException; import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionIO; import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.impl.BrowserConnection; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; /** * This class implements the Wizard for Importing connections. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportConnectionsWizard extends ExportBaseWizard { /** The wizard page */ private ImportConnectionsWizardPage page; /** * Creates a new instance of ImportConnectionsWizard. */ public ImportConnectionsWizard() { super( Messages.getString( "ImportConnectionsWizard.ConnectionsImport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Import Connections Wizard * * @return The ID of the Import Connections Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_IMPORT_CONNECTIONS; } /** * {@inheritDoc} */ public void addPages() { page = new ImportConnectionsWizardPage(); addPage( page ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID // PlatformUI.getWorkbench().getHelpSystem().setHelp( fromPage.getControl(), // BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifexport_wizard" ); //TODO: Add Help Context } /** * {@inheritDoc} */ public boolean performFinish() { page.saveDialogSettings(); String importFileName = page.getImportFileName(); try { ZipFile importFile = new ZipFile( new File( importFileName ) ); // Loading the Connections ZipEntry connectionsEntry = importFile.getEntry( "connections.xml" ); //$NON-NLS-1$ if ( connectionsEntry != null ) { InputStream connectionsInputStream = importFile.getInputStream( connectionsEntry ); ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager(); Set<ConnectionParameter> connectionParametersSet = ConnectionIO.load( connectionsInputStream ); for ( ConnectionParameter connectionParameter : connectionParametersSet ) { connectionManager.addConnection( new Connection( connectionParameter ) ); } } // Loading the ConnectionFolders ZipEntry connectionFoldersEntry = importFile.getEntry( "connectionFolders.xml" ); //$NON-NLS-1$ ConnectionFolder rootConnectionFolder = null; if ( connectionFoldersEntry != null ) { InputStream connectionFoldersInputStream = importFile.getInputStream( connectionFoldersEntry ); ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault() .getConnectionFolderManager(); Set<ConnectionFolder> connectionFoldersSet = ConnectionIO .loadConnectionFolders( connectionFoldersInputStream ); for ( ConnectionFolder connectionFolder : connectionFoldersSet ) { if ( !"0".equals( connectionFolder.getId() ) ) //$NON-NLS-1$ { connectionFolderManager.addConnectionFolder( connectionFolder ); } else { rootConnectionFolder = connectionFolder; } } // Root ConnectionFolder must be the last one to be loaded if ( rootConnectionFolder != null ) { ConnectionFolder realRootConnectionFolder = connectionFolderManager.getRootConnectionFolder(); // Adding subfolders List<String> realSubFolderIds = realRootConnectionFolder.getSubFolderIds(); for ( String subFolderId : rootConnectionFolder.getSubFolderIds() ) { if ( !realSubFolderIds.contains( subFolderId ) ) { realRootConnectionFolder.addSubFolderId( subFolderId ); } } // Adding connections List<String> realConnectionIds = realRootConnectionFolder.getConnectionIds(); for ( String connectionId : rootConnectionFolder.getConnectionIds() ) { if ( !realConnectionIds.contains( connectionId ) ) { realRootConnectionFolder.addConnectionId( connectionId ); } } } } // Loading the BrowserConnections ZipEntry browserConnectionsEntry = importFile.getEntry( "browserconnections.xml" ); //$NON-NLS-1$ if ( browserConnectionsEntry != null ) { InputStream browserConnectionsInputStream = importFile.getInputStream( browserConnectionsEntry ); Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections(); Map<String, IBrowserConnection> connectionsMap = new HashMap<String, IBrowserConnection>(); for ( int i = 0; i < connections.length; i++ ) { Connection connection = connections[i]; BrowserConnection browserConnection = new BrowserConnection( connection ); connectionsMap.put( connection.getId(), browserConnection ); } BrowserConnectionIO.load( browserConnectionsInputStream, connectionsMap ); } } catch ( ZipException e ) { // TODO Auto-generated catch block e.printStackTrace(); } catch ( IOException e ) { // TODO Auto-generated catch block e.printStackTrace(); } catch ( ConnectionIOException e ) { // TODO Auto-generated catch block e.printStackTrace(); } 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/wizards/ExportCsvToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.common.dialogs.preferences.TextFormatsPreferencePage; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Link; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This class implements the page to select the target CSV file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportCsvToWizardPage extends ExportBaseToPage { /** The extensions used by CSV files */ private static final String[] EXTENSIONS = new String[] { "*.csv", "*.txt", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /** * Creates a new instance of ExportCsvToWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ExportCsvToWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard ); setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_CSV_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); String text = Messages.getString( "ExportCsvToWizardPage.SeeTextFormats" ); //$NON-NLS-1$ Link link = BaseWidgetUtils.createLink( composite, text, 2 ); link.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreferencesUtil.createPreferenceDialogOn( getShell(), BrowserUIConstants.PREFERENCEPAGEID_TEXTFORMATS, null, TextFormatsPreferencePage.CSV_TAB ).open(); } } ); } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportCsvToWizardPage.CVS" ); //$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/wizards/BatchOperationFinishWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationFinishWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; /** * This class implements the Finish page of the Batch Operation Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BatchOperationFinishWizardPage extends WizardPage { /** The continue on error flag key */ public static final String EXECUTE_METHOD_DIALOGSETTING_KEY = BatchOperationFinishWizardPage.class.getName() + ".executeMethod"; //$NON-NLS-1$ /** The continue on error flag key */ public static final String CONTINUE_ON_ERROR_DIALOGSETTING_KEY = BatchOperationFinishWizardPage.class.getName() + ".continueOnError"; //$NON-NLS-1$ // Execution Method Values public final static int EXECUTION_METHOD_NONE = -1; public final static int EXECUTION_METHOD_ON_CONNECTION = 0; public final static int EXECUTION_METHOD_LDIF_EDITOR = 1; public final static int EXECUTION_METHOD_LDIF_FILE = 2; public final static int EXECUTION_METHOD_LDIF_CLIPBOARD = 3; // UI widgets private Button executeOnConnectionButton; private Button continueOnErrorButton; private Button generateLdifButton; private Button generateInLDIFEditorButton; private Button generateInFileButton; private Button generateInClipboardButton; // Listeners private SelectionListener validateSelectionListener = new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { validate(); } }; /** * Creates a new instance of BatchOperationFinishWizardPage. * * @param pageName the page name */ public BatchOperationFinishWizardPage( String pageName ) { super( pageName ); super.setTitle( Messages.getString( "BatchOperationFinishWizardPage.SelectExecutionMethod" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationFinishWizardPage.PleaseSelectBatchOperation" ) ); //$NON-NLS-1$ super.setPageComplete( false ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { // Composite Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout(); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); // Execute On Connection Button executeOnConnectionButton = BaseWidgetUtils.createRadiobutton( composite, Messages .getString( "BatchOperationFinishWizardPage.ExecuteOnConnection" ), 1 ); //$NON-NLS-1$ // Execute On Connection Composite Composite executeOnConnectionComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); // Continue On Error Radio Button BaseWidgetUtils.createRadioIndent( executeOnConnectionComposite, 1 ); continueOnErrorButton = BaseWidgetUtils.createCheckbox( executeOnConnectionComposite, Messages .getString( "ImportLdifMainWizardPage.ContinueOnError" ), 1 ); //$NON-NLS-1$ // Generate LDIF Button generateLdifButton = BaseWidgetUtils.createRadiobutton( composite, Messages .getString( "BatchOperationFinishWizardPage.GenerateLDIF" ), 1 ); //$NON-NLS-1$ // Generate LDIF Button Composite Composite generateLdifButtonComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 ); // In The LDIF Editor Button BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 ); generateInLDIFEditorButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite, Messages .getString( "BatchOperationFinishWizardPage.GenerateLDIFInLDIFEditor" ), 1 ); //$NON-NLS-1$ // In A File Button BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 ); generateInFileButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite, Messages .getString( "BatchOperationFinishWizardPage.GenerateLDIFInFile" ), 1 ); //$NON-NLS-1$ // In The Clipboard Button BaseWidgetUtils.createRadioIndent( generateLdifButtonComposite, 1 ); generateInClipboardButton = BaseWidgetUtils.createRadiobutton( generateLdifButtonComposite, Messages .getString( "BatchOperationFinishWizardPage.GenerateLDIFInClipBoard" ), 1 ); //$NON-NLS-1$ init(); validate(); addListeners(); setControl( composite ); } /** * Initializes the UI. */ private void init() { try { // Default value for the 'Execute Method' dialog setting if ( BrowserUIPlugin.getDefault().getDialogSettings().get( EXECUTE_METHOD_DIALOGSETTING_KEY ) == null ) { BrowserUIPlugin.getDefault().getDialogSettings() .put( EXECUTE_METHOD_DIALOGSETTING_KEY, EXECUTION_METHOD_ON_CONNECTION ); } // Default value for the 'Continue On Error' dialog setting if ( BrowserUIPlugin.getDefault().getDialogSettings().get( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) == null ) { BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, true ); } // Getting the 'Execute Method' dialog setting int executeMethod = BrowserUIPlugin.getDefault().getDialogSettings() .getInt( EXECUTE_METHOD_DIALOGSETTING_KEY ); switch ( executeMethod ) { case EXECUTION_METHOD_ON_CONNECTION: executeOnConnectionButton.setSelection( true ); generateInLDIFEditorButton.setSelection( true ); break; case EXECUTION_METHOD_LDIF_EDITOR: generateLdifButton.setSelection( true ); generateInLDIFEditorButton.setSelection( true ); break; case EXECUTION_METHOD_LDIF_FILE: generateLdifButton.setSelection( true ); generateInFileButton.setSelection( true ); break; case EXECUTION_METHOD_LDIF_CLIPBOARD: generateLdifButton.setSelection( true ); generateInClipboardButton.setSelection( true ); break; } // Getting the 'Continue On Error' dialog setting continueOnErrorButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings() .getBoolean( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) ); } catch ( Exception e ) { // Nothing to do } } /** * Validates the page. */ private void validate() { continueOnErrorButton.setEnabled( executeOnConnectionButton.getSelection() ); generateInLDIFEditorButton.setEnabled( generateLdifButton.getSelection() ); generateInFileButton.setEnabled( generateLdifButton.getSelection() ); generateInClipboardButton.setEnabled( generateLdifButton.getSelection() ); setPageComplete( getExecutionMethod() != EXECUTION_METHOD_NONE ); } /** * Adds listeners. */ private void addListeners() { executeOnConnectionButton.addSelectionListener( validateSelectionListener ); generateLdifButton.addSelectionListener( validateSelectionListener ); } /** * Gets the execution method. * * @return the execution method */ public int getExecutionMethod() { if ( executeOnConnectionButton.getSelection() ) { return EXECUTION_METHOD_ON_CONNECTION; } else if ( generateLdifButton.getSelection() ) { if ( generateInLDIFEditorButton.getSelection() ) { return EXECUTION_METHOD_LDIF_EDITOR; } else if ( generateInFileButton.getSelection() ) { return EXECUTION_METHOD_LDIF_FILE; } else if ( generateInClipboardButton.getSelection() ) { return EXECUTION_METHOD_LDIF_CLIPBOARD; } } return EXECUTION_METHOD_NONE; } /** * Gets the continue on error flag. * * @return the continue on error flag */ public boolean getContinueOnError() { return continueOnErrorButton.getSelection(); } /** * Saves the dialog settings. */ public void saveDialogSettings() { BrowserUIPlugin.getDefault().getDialogSettings().put( EXECUTE_METHOD_DIALOGSETTING_KEY, getExecutionMethod() ); BrowserUIPlugin.getDefault().getDialogSettings() .put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, getContinueOnError() ); } }
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/wizards/ExportOdfToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportOdfToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.common.dialogs.preferences.TextFormatsPreferencePage; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Link; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This class implements the page to select the target ODF file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportOdfToWizardPage extends ExportBaseToPage { /** The extensions used by ODF files */ private static final String[] EXTENSIONS = new String[] { "*.ods", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** * Creates a new instance of ExportOdfToWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ExportOdfToWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard ); setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_ODF_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); String text = Messages.getString( "ExportOdfToWizardPage.SeeTextFormats" ); //$NON-NLS-1$ Link link = BaseWidgetUtils.createLink( composite, text, 2 ); link.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreferencesUtil.createPreferenceDialogOn( getShell(), BrowserUIConstants.PREFERENCEPAGEID_TEXTFORMATS, null, TextFormatsPreferencePage.ODF_TAB ).open(); } } ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createWrappedLabel( composite, Messages.getString( "ExportOdfToWizardPage.WarningOdf" ), 2 ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportOdfToWizardPage.Odf" ); //$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/wizards/ExportBaseWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.core.model.ISearch; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.IExportWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; /** * This class is a base implementation of the export wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class ExportBaseWizard extends Wizard implements IExportWizard { /** The export filename. */ protected String exportFilename = ""; //$NON-NLS-1$ /** The search. */ protected ISearch search; /** * Creates a new instance of ExportBaseWizard. * * @param title the title */ public ExportBaseWizard( String title ) { super(); setWindowTitle( title ); init( null, ( IStructuredSelection ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection() ); } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { search = BrowserSelectionUtils.getExampleSearch( selection ); search.setName( null ); exportFilename = ""; //$NON-NLS-1$ } /** * Sets the export filename. * * @param exportFilename the export filename */ public void setExportFilename( String exportFilename ) { this.exportFilename = exportFilename; } /** * Gets the export filename. * * @return the export filename */ public String getExportFilename() { return exportFilename; } /** * Gets the search. * * @return the search */ public ISearch getSearch() { return search; } /** * Sets the search. * * @param search the search */ public void setSearch( ISearch search ) { this.search = search; } }
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/wizards/ExportOdfFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportOdfFromWizardPage.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.wizards; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; /** * This class implements the page used to select the data to export to ODF. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportOdfFromWizardPage extends ExportBaseFromWizardPage { /** * Creates a new instance of ExportOdfFromWizardPage using a * {@link SearchPageWrapper} with * <ul> * <li>hidden name * <li>visible and checked return Dn checkbox * <li>visible all attributes checkbox * <li>visible operational attributes checkbox * </ul> * * @param pageName the page name * @param wizard the wizard */ public ExportOdfFromWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURN_DN_VISIBLE | SearchPageWrapper.RETURN_DN_CHECKED | SearchPageWrapper.RETURN_ALLATTRIBUTES_VISIBLE | SearchPageWrapper.RETURN_OPERATIONALATTRIBUTES_VISIBLE | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch() .getReturningAttributes().length == 0 ) ? SearchPageWrapper.RETURN_ALLATTRIBUTES_CHECKED : SearchPageWrapper.NONE ) ) ); super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_ODF_WIZARD ) ); } /** * Checks if the DNs should be exported. * * @return true, if the DNs should be exported */ public boolean isExportDn() { return spw.isReturnDn(); } }
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/wizards/ImportConnectionsWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportConnectionsWizardPage.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.wizards; import java.io.File; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.widgets.Composite; /** * This class implements the page used to select the data to export to LDIF. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportConnectionsWizardPage extends WizardPage { private FileBrowserWidget fileBrowserWidget; protected ImportConnectionsWizardPage() { super( ImportConnectionsWizardPage.class.getName() ); setTitle( Messages.getString( "ImportConnectionsWizardPage.ImportConnections" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "ImportConnectionsWizardPage.ImportConnectionsFromFilesystem" ) ); //$NON-NLS-1$ setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_CONNECTIONS_WIZARD ) ); setPageComplete( false ); } public void createControl( Composite parent ) { // Main Composite Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); // From File BaseWidgetUtils.createLabel( composite, Messages.getString( "ImportConnectionsWizardPage.FromFile" ), 1 ); //$NON-NLS-1$ fileBrowserWidget = new FileBrowserWidget( Messages.getString( "ImportConnectionsWizardPage.ChooseFile" ), new String[] //$NON-NLS-1$ { "*.lbc", "*" }, FileBrowserWidget.TYPE_OPEN ); //$NON-NLS-1$ fileBrowserWidget.createWidget( composite ); fileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { validate(); } } ); setControl( composite ); } /** * Validates this page. This method is responsible for displaying errors, * as well as enabling/disabling the "Finish" button */ private void validate() { boolean ok = true; File file = new File( fileBrowserWidget.getFilename() ); if ( "".equals( fileBrowserWidget.getFilename() ) ) //$NON-NLS-1$ { setErrorMessage( null ); ok = false; } else if ( !file.exists() ) { setErrorMessage( Messages.getString( "ImportConnectionsWizardPage.ErrorFileNotExists" ) ); //$NON-NLS-1$ ok = false; } else if ( file.isDirectory() ) { setErrorMessage( Messages.getString( "ImportConnectionsWizardPage.ErrorFileNotFile" ) ); //$NON-NLS-1$ ok = false; } else if ( file.exists() && !file.canRead() ) { setErrorMessage( Messages.getString( "ImportConnectionsWizardPage.ErrorFileNotReadable" ) ); //$NON-NLS-1$ ok = false; } if ( ok ) { setErrorMessage( null ); } setPageComplete( ok ); } /** * Gets the export file name. * * @return * the export file name */ public String getImportFileName() { return fileBrowserWidget.getFilename(); } /** * Saves the dialog settings. */ public void saveDialogSettings() { fileBrowserWidget.saveDialogSettings(); } }
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/wizards/Messages.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/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.wizards; 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/wizards/NewSearchWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewSearchWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.search.SearchPage; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchWindow; /** * The NewSearchWizard is used to add a "New Search" action to the platforms * "New..." menu. It just opens the platform's search dialog. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewSearchWizard extends Wizard implements INewWizard { /** The window. */ private IWorkbenchWindow window; /** * Creates a new instance of NewSearchWizard. */ public NewSearchWizard() { // Nothing to do } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { window = workbench.getActiveWorkbenchWindow(); } /** * {@inheritDoc} */ public void dispose() { window = null; } /** * Gets the id. * * @return the id */ public static String getId() { return BrowserUIConstants.WIZARD_NEW_SEARCH; } /** * {@inheritDoc} */ public boolean performFinish() { NewSearchUI.openSearchDialog( window, SearchPage.getId() ); 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/wizards/BatchOperationApplyOnWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationApplyOnWizardPage.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.wizards; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; 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.eclipse.jface.viewers.ISelection; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; public class BatchOperationApplyOnWizardPage extends WizardPage { private String[] initCurrentSelectionTexts; private Dn[][] initCurrentSelectionDns; private ISearch initSearch; private Button currentSelectionButton; private Combo currentSelectionCombo; private Button searchButton; private SearchPageWrapper spw; public BatchOperationApplyOnWizardPage( String pageName, BatchOperationWizard wizard ) { super( pageName ); super.setTitle( Messages.getString( "BatchOperationApplyOnWizardPage.SelectApplicationEntries" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationApplyOnWizardPage.PleaseSelectEntries" ) ); //$NON-NLS-1$ super.setPageComplete( false ); this.prepareCurrentSelection(); this.prepareSearch(); } private void validate() { setPageComplete( getApplyOnDns() != null || spw.isValid() ); setErrorMessage( searchButton.getSelection() ? spw.getErrorMessage() : null ); } public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); Composite applyOnGroup = composite; this.currentSelectionButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, Messages .getString( "BatchOperationApplyOnWizardPage.CurrentSelection" ), 1 ); //$NON-NLS-1$ this.currentSelectionButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { enableCurrentSelectionWidgets( currentSelectionButton.getSelection() ); validate(); } } ); Composite currentSelectionComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 ); BaseWidgetUtils.createRadioIndent( currentSelectionComposite, 1 ); this.currentSelectionCombo = BaseWidgetUtils.createReadonlyCombo( currentSelectionComposite, this.initCurrentSelectionTexts, 0, 1 ); this.currentSelectionCombo.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) { validate(); } } ); BaseWidgetUtils.createSpacer( applyOnGroup, 1 ); BaseWidgetUtils.createSpacer( applyOnGroup, 1 ); this.searchButton = BaseWidgetUtils.createRadiobutton( applyOnGroup, Messages .getString( "BatchOperationApplyOnWizardPage.ResultsOfSearch" ), 1 ); //$NON-NLS-1$ this.searchButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { enableSearchWidgets( searchButton.getSelection() ); validate(); } } ); Composite searchComposite = BaseWidgetUtils.createColumnContainer( applyOnGroup, 2, 1 ); BaseWidgetUtils.createRadioIndent( searchComposite, 1 ); Composite innerSearchComposite = BaseWidgetUtils.createColumnContainer( searchComposite, 3, 1 ); this.spw = new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURNINGATTRIBUTES_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_READONLY ); this.spw.createContents( innerSearchComposite ); this.spw.loadFromSearch( this.initSearch ); this.spw.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { validate(); } } ); this.currentSelectionButton.setSelection( this.currentSelectionCombo.getItemCount() > 0 ); this.currentSelectionButton.setEnabled( this.currentSelectionCombo.getItemCount() > 0 ); this.searchButton.setSelection( this.currentSelectionCombo.getItemCount() == 0 ); this.enableCurrentSelectionWidgets( this.currentSelectionButton.getSelection() ); this.enableSearchWidgets( this.searchButton.getSelection() ); validate(); setControl( composite ); } public Dn[] getApplyOnDns() { if ( currentSelectionButton.getSelection() ) { int index = currentSelectionCombo.getSelectionIndex(); return initCurrentSelectionDns[index]; } else { return null; } } public ISearch getApplyOnSearch() { if ( searchButton.getSelection() ) { return this.initSearch; } else { return null; } } private void enableCurrentSelectionWidgets( boolean b ) { currentSelectionCombo.setEnabled( b ); } private void enableSearchWidgets( boolean b ) { spw.setEnabled( b ); } private void prepareSearch() { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); this.initSearch = BrowserSelectionUtils.getExampleSearch( selection ); this.initSearch.setName( null ); // never follow referrals for a batch operation! this.initSearch.setReferralsHandlingMethod( Connection.ReferralHandlingMethod.IGNORE ); } private void prepareCurrentSelection() { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); ISearch[] searches = BrowserSelectionUtils.getSearches( selection ); IEntry[] entries = BrowserSelectionUtils.getEntries( selection ); ISearchResult[] searchResults = BrowserSelectionUtils.getSearchResults( selection ); IBookmark[] bookmarks = BrowserSelectionUtils.getBookmarks( selection ); IAttribute[] attributes = BrowserSelectionUtils.getAttributes( selection ); IValue[] values = BrowserSelectionUtils.getValues( selection ); List<String> textList = new ArrayList<String>(); List<Dn[]> dnsList = new ArrayList<Dn[]>(); if ( attributes.length + values.length > 0 ) { Set<Dn> internalDnSet = new LinkedHashSet<Dn>(); for ( int v = 0; v < values.length; v++ ) { if ( values[v].isString() ) { try { Dn dn = new Dn( values[v].getStringValue() ); internalDnSet.add( dn ); } catch ( LdapInvalidDnException e ) { } } } for ( int a = 0; a < attributes.length; a++ ) { IValue[] vals = attributes[a].getValues(); for ( int v = 0; v < vals.length; v++ ) { if ( vals[v].isString() ) { try { Dn dn = new Dn( vals[v].getStringValue() ); internalDnSet.add( dn ); } catch ( LdapInvalidDnException e ) { } } } } if ( !internalDnSet.isEmpty() ) { dnsList.add( internalDnSet.toArray( new Dn[internalDnSet.size()] ) ); textList .add( NLS .bind( Messages.getString( "BatchOperationApplyOnWizardPage.DNsOfSelectedAttributes" ), new Object[] { internalDnSet.size() } ) ); //$NON-NLS-1$ } } if ( searches.length == 1 && searches[0].getSearchResults() != null ) { Set<Dn> internalDnSet = new LinkedHashSet<Dn>(); ISearchResult[] srs = searches[0].getSearchResults(); for ( int i = 0; i < srs.length; i++ ) { internalDnSet.add( srs[i].getDn() ); } dnsList.add( internalDnSet.toArray( new Dn[internalDnSet.size()] ) ); textList .add( NLS .bind( Messages.getString( "BatchOperationApplyOnWizardPage.SearchResultOf" ), new Object[] { searches[0].getName(), searches[0].getSearchResults().length } ) ); //$NON-NLS-1$ } if ( entries.length + searchResults.length + bookmarks.length > 0 ) { Set<Dn> internalDnSet = new LinkedHashSet<Dn>(); for ( int i = 0; i < entries.length; i++ ) { internalDnSet.add( entries[i].getDn() ); } for ( int i = 0; i < searchResults.length; i++ ) { internalDnSet.add( searchResults[i].getDn() ); } for ( int i = 0; i < bookmarks.length; i++ ) { internalDnSet.add( bookmarks[i].getDn() ); } dnsList.add( internalDnSet.toArray( new Dn[internalDnSet.size()] ) ); textList .add( NLS .bind( Messages.getString( "BatchOperationApplyOnWizardPage.SelectedEntries" ), new Object[] { internalDnSet.size() } ) ); //$NON-NLS-1$ } this.initCurrentSelectionTexts = textList.toArray( new String[textList.size()] ); this.initCurrentSelectionDns = dnsList.toArray( new Dn[0][0] ); } /** * Saves the dialog settings. */ public void saveDialogSettings() { this.spw.saveToSearch( initSearch ); } }
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/wizards/BatchOperationModifyWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/BatchOperationModifyWizardPage.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.wizards; import java.util.List; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.ModWidget; import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants; import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema; import org.apache.directory.studio.ldifparser.model.LdifFile; import org.apache.directory.studio.ldifparser.model.container.LdifContainer; import org.apache.directory.studio.ldifparser.parser.LdifParser; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; /** * This class implements the "Modify" page for the Batch Operation Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class BatchOperationModifyWizardPage extends WizardPage implements WidgetModifyListener { /** The wizard */ private BatchOperationWizard wizard; /** The ModWidget */ private ModWidget modWidget; /** * Creates a new instance of BatchOperationModifyWizardPage. * * @param pageName the name of the page * @param wizard the wizard */ public BatchOperationModifyWizardPage( String pageName, BatchOperationWizard wizard ) { super( pageName ); super.setTitle( Messages.getString( "BatchOperationModifyWizardPage.DefineModification" ) ); //$NON-NLS-1$ super.setDescription( Messages.getString( "BatchOperationModifyWizardPage.PleaseDefineModifications" ) ); //$NON-NLS-1$ // super.setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ENTRY_WIZARD)); super.setPageComplete( false ); this.wizard = wizard; } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); modWidget = new ModWidget( wizard.getConnection() != null ? wizard.getConnection().getSchema() : Schema.DEFAULT_SCHEMA ); modWidget.createContents( composite ); modWidget.addWidgetModifyListener( this ); validate(); setControl( composite ); } /** * Gets the LDIF fragment. * * @return the LDIF fragment */ public String getLdifFragment() { return modWidget.getLdifFragment(); } /** * {@inheritDoc} */ public void widgetModified( WidgetModifyEvent event ) { validate(); } /** * Validates the page */ private void validate() { String dummyLdif = "dn: cn=dummy" + BrowserCoreConstants.LINE_SEPARATOR + modWidget.getLdifFragment(); //$NON-NLS-1$ LdifFile model = new LdifParser().parse( dummyLdif ); List<LdifContainer> containers = model.getContainers(); if ( containers.size() == 0 ) { setPageComplete( false ); return; } for ( LdifContainer ldifContainer : containers ) { if ( !ldifContainer.isValid() ) { setPageComplete( false ); return; } } setPageComplete( 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/wizards/ExportDsmlWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportDsmlRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportDsmlRunnable.ExportDsmlJobType; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; /** * This class implements the Wizard for Exporting to DSML * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportDsmlWizard extends ExportBaseWizard { /** The title. */ public static final String WIZARD_TITLE = Messages.getString( "ExportDsmlWizard.DSMLExport" ); //$NON-NLS-1$ /** The from page, used to select the exported data. */ private ExportDsmlFromWizardPage fromPage; /** The to page, used to select the target file. */ private ExportDsmlToWizardPage toPage; private ExportDsmlWizardSaveAsType saveAsType = ExportDsmlWizardSaveAsType.RESPONSE; /** * This enum contains the two possible export types. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public enum ExportDsmlWizardSaveAsType { RESPONSE, REQUEST }; /** * Creates a new instance of ExportDsmlWizard. */ public ExportDsmlWizard() { super( WIZARD_TITLE ); } /** * Gets the ID of the Export DSML Wizard * @return The ID of the Export DSML Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_DSML; } /** * {@inheritDoc} */ public void addPages() { fromPage = new ExportDsmlFromWizardPage( ExportDsmlFromWizardPage.class.getName(), this ); addPage( fromPage ); toPage = new ExportDsmlToWizardPage( ExportDsmlToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem().setHelp( fromPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_dsmlexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem().setHelp( toPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_dsmlexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { fromPage.saveDialogSettings(); toPage.saveDialogSettings(); switch ( saveAsType ) { case RESPONSE: new StudioBrowserJob( new ExportDsmlRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter(), ExportDsmlJobType.RESPONSE ) ).execute(); break; case REQUEST: new StudioBrowserJob( new ExportDsmlRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter(), ExportDsmlJobType.REQUEST ) ).execute(); break; } return true; } /** * Gets the "Save as" type. * * @return * the "Save as" type */ public ExportDsmlWizardSaveAsType getSaveAsType() { return saveAsType; } /** * Sets the "Save as" type. * * @param saveAsType * the "Save as" type */ public void setSaveAsType( ExportDsmlWizardSaveAsType saveAsType ) { this.saveAsType = saveAsType; } }
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/wizards/ExportSearchLogsWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportSearchLogsWizard.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.wizards; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.directory.api.util.FileUtils; import org.apache.directory.api.util.IOUtils; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.io.api.LdifSearchLogger; import org.apache.directory.studio.connection.ui.ConnectionUIPlugin; import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; /** * This class implements the wizard for exporting the search logs. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportSearchLogsWizard extends ExportBaseWizard { /** The to page, used to select the target file. */ private ExportLogsToWizardPage toPage; /** * Creates a new instance of ExportSearchLogsWizard. */ public ExportSearchLogsWizard() { super( Messages.getString( "ExportSearchLogsWizard.ExportSearchLogs" ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void addPages() { toPage = new ExportLogsToWizardPage( ExportLogsToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public boolean performFinish() { toPage.saveDialogSettings(); if ( search.getBrowserConnection().getConnection() != null ) { try { File targetFile = new File( exportFilename ); OutputStream os = FileUtils.openOutputStream( targetFile ); LdifSearchLogger searchLogger = ConnectionCorePlugin.getDefault().getLdifSearchLogger(); File[] files = searchLogger.getFiles( search.getBrowserConnection().getConnection() ); // need to go backward through the files as the 1st file contains the newest entry for ( int i = files.length - 1; i >= 0; i-- ) { File file = files[i]; if ( file != null && file.exists() && file.canRead() ) { InputStream is = FileUtils.openInputStream( file ); IOUtils.copy( is, os ); is.close(); } } os.close(); } catch ( IOException e ) { ConnectionUIPlugin.getDefault().getExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserCommonConstants.PLUGIN_ID, IStatus.ERROR, Messages .getString( "ExportSearchLogsWizard.CantExportSearchLogs" ), e ) ); //$NON-NLS-1$ } } 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/wizards/ImportLdifMainWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.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.wizards; import java.io.File; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget; import org.apache.directory.studio.ldapbrowser.common.widgets.search.BrowserConnectionWidget; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; /** * This class implements the Main Page of the LDIF Import Wizard * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportLdifMainWizardPage extends WizardPage { /** The continue on error flag key */ public static final String CONTINUE_ON_ERROR_DIALOGSETTING_KEY = ImportLdifMainWizardPage.class.getName() + ".continueOnError"; //$NON-NLS-1$ /** The update if entry exists flag key */ public static final String UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY = ImportLdifMainWizardPage.class.getName() + ".updateIfEntryExists"; //$NON-NLS-1$ /** The valid extension. */ private static final String[] EXTENSIONS = new String[] { "*.ldif", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** The valid log extension. */ private static final String[] LOG_EXTENSIONS = new String[] { "*.ldif.log", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** The wizard. */ private ImportLdifWizard wizard; /** The ldif file browser widget. */ private FileBrowserWidget ldifFileBrowserWidget; /** The browser connection widget. */ private BrowserConnectionWidget browserConnectionWidget; /** The enable logging button. */ private Button enableLoggingButton; /** The use default logfile button. */ private Button useDefaultLogfileButton; /** The use custom logfile button. */ private Button useCustomLogfileButton; /** The custom logfile name. */ private String customLogfileName; /** The log file browser widget. */ private FileBrowserWidget logFileBrowserWidget; /** The overwrite logfile button. */ private Button overwriteLogfileButton; /** The update if entry exists button. */ private Button updateIfEntryExistsButton; /** The continue on error button. */ private Button continueOnErrorButton; /** * Creates a new instance of ImportLdifMainWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ImportLdifMainWizardPage( String pageName, ImportLdifWizard wizard ) { super( pageName ); setTitle( Messages.getString( "ImportLdifMainWizardPage.LDIFImport" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "ImportLdifMainWizardPage.PleaseSelectConnectionAndLDIF" ) ); //$NON-NLS-1$ setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_IMPORT_LDIF_WIZARD ) ); setPageComplete( false ); this.wizard = wizard; } /** * Validates the page. This method is responsible for displaying errors, * as well as enabling/disabling the "Finish" button */ private void validate() { boolean ok = true; File ldifFile = new File( ldifFileBrowserWidget.getFilename() ); if ( "".equals( ldifFileBrowserWidget.getFilename() ) ) //$NON-NLS-1$ { setErrorMessage( null ); ok = false; } else if ( !ldifFile.isFile() || !ldifFile.exists() ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorSelectedLDIFNotExist" ) ); //$NON-NLS-1$ ok = false; } else if ( !ldifFile.canRead() ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorSelectedLDIFNotReadable" ) ); //$NON-NLS-1$ ok = false; } else if ( enableLoggingButton.getSelection() ) { File logFile = new File( logFileBrowserWidget.getFilename() ); File logFileDirectory = logFile.getParentFile(); if ( logFile.equals( ldifFile ) ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorLDIFAndLogEqual" ) ); //$NON-NLS-1$ ok = false; } else if ( logFile.isDirectory() ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorSelectedLogFileNotFile" ) ); //$NON-NLS-1$ ok = false; } else if ( logFile.exists() && !overwriteLogfileButton.getSelection() ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorSelectedLogFileExist" ) ); //$NON-NLS-1$ ok = false; } else if ( logFile.exists() && !logFile.canWrite() ) { setErrorMessage( Messages.getString( "ImportLdifMainWizardPage.ErrorSelectedLogFileNotWritable" ) ); //$NON-NLS-1$ ok = false; } else if ( logFile.getParentFile() == null ) { setErrorMessage( Messages .getString( "ImportLdifMainWizardPage.ErrorSelectedLogFileDirectoryNotWritable" ) ); //$NON-NLS-1$ ok = false; } else if ( !logFile.exists() && ( logFileDirectory == null || !logFileDirectory.canWrite() ) ) { setErrorMessage( Messages .getString( "ImportLdifMainWizardPage.ErrorSelectedLogFileDirectoryNotWritable" ) ); //$NON-NLS-1$ ok = false; } } if ( wizard.getImportConnection() == null ) { setErrorMessage( Messages .getString( "ImportLdifMainWizardPage.ErrorNoConnectionSelected" ) ); //$NON-NLS-1$ ok = false; } if ( ok ) { setErrorMessage( null ); } setPageComplete( ok ); getContainer().updateButtons(); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); // LDIF file BaseWidgetUtils.createLabel( composite, Messages.getString( "ImportLdifMainWizardPage.LDIFFile" ), 1 ); //$NON-NLS-1$ ldifFileBrowserWidget = new FileBrowserWidget( Messages.getString( "ImportLdifMainWizardPage.SelectLDIFFile" ), EXTENSIONS, FileBrowserWidget.TYPE_OPEN ); //$NON-NLS-1$ ldifFileBrowserWidget.createWidget( composite ); ldifFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { wizard.setLdifFilename( ldifFileBrowserWidget.getFilename() ); if ( useDefaultLogfileButton.getSelection() ) { logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" ); //$NON-NLS-1$ } validate(); } } ); // Connection BaseWidgetUtils.createLabel( composite, Messages.getString( "ImportLdifMainWizardPage.ImportTo" ), 1 ); //$NON-NLS-1$ browserConnectionWidget = new BrowserConnectionWidget( wizard.getImportConnection() ); browserConnectionWidget.createWidget( composite ); browserConnectionWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { wizard.setImportConnection( browserConnectionWidget.getBrowserConnection() ); validate(); } } ); // Logging Composite loggingOuterComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 ); Group loggingGroup = BaseWidgetUtils.createGroup( loggingOuterComposite, Messages .getString( "ImportLdifMainWizardPage.Logging" ), 1 ); //$NON-NLS-1$ Composite loggingContainer = BaseWidgetUtils.createColumnContainer( loggingGroup, 3, 1 ); enableLoggingButton = BaseWidgetUtils.createCheckbox( loggingContainer, Messages .getString( "ImportLdifMainWizardPage.EnableLogging" ), 3 ); //$NON-NLS-1$ enableLoggingButton.setSelection( true ); wizard.setEnableLogging( enableLoggingButton.getSelection() ); enableLoggingButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { wizard.setEnableLogging( enableLoggingButton.getSelection() ); useDefaultLogfileButton.setEnabled( enableLoggingButton.getSelection() ); useCustomLogfileButton.setEnabled( enableLoggingButton.getSelection() ); logFileBrowserWidget.setEnabled( enableLoggingButton.getSelection() && useCustomLogfileButton.getSelection() ); overwriteLogfileButton.setEnabled( enableLoggingButton.getSelection() ); validate(); } } ); BaseWidgetUtils.createRadioIndent( loggingContainer, 1 ); useDefaultLogfileButton = BaseWidgetUtils.createRadiobutton( loggingContainer, Messages .getString( "ImportLdifMainWizardPage.UseDefaultLogFile" ), 2 ); //$NON-NLS-1$ useDefaultLogfileButton.setSelection( true ); useDefaultLogfileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { String temp = customLogfileName; logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" ); //$NON-NLS-1$ logFileBrowserWidget.setEnabled( false ); customLogfileName = temp; validate(); } } ); BaseWidgetUtils.createRadioIndent( loggingContainer, 1 ); useCustomLogfileButton = BaseWidgetUtils.createRadiobutton( loggingContainer, Messages .getString( "ImportLdifMainWizardPage.UseCustomLogFile" ), 2 ); //$NON-NLS-1$ useCustomLogfileButton.setSelection( false ); useCustomLogfileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { logFileBrowserWidget.setFilename( customLogfileName != null ? customLogfileName : "" ); //$NON-NLS-1$ logFileBrowserWidget.setEnabled( true ); validate(); } } ); BaseWidgetUtils.createRadioIndent( loggingContainer, 1 ); logFileBrowserWidget = new FileBrowserWidget( Messages.getString( "ImportLdifMainWizardPage.SelectLogFile" ), LOG_EXTENSIONS, FileBrowserWidget.TYPE_SAVE ); //$NON-NLS-1$ logFileBrowserWidget.createWidget( loggingContainer ); logFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { customLogfileName = logFileBrowserWidget.getFilename(); wizard.setLogFilename( customLogfileName ); validate(); } } ); logFileBrowserWidget.setEnabled( false ); BaseWidgetUtils.createRadioIndent( loggingContainer, 1 ); overwriteLogfileButton = BaseWidgetUtils.createCheckbox( loggingContainer, Messages .getString( "ImportLdifMainWizardPage.OverwriteExistingLogFile" ), 2 ); //$NON-NLS-1$ overwriteLogfileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { validate(); } } ); // Options Composite optionsOuterComposite = BaseWidgetUtils.createColumnContainer( composite, 1, 3 ); Group optionsGroup = BaseWidgetUtils.createGroup( optionsOuterComposite, Messages .getString( "ImportLdifMainWizardPage.Options" ), 1 ); //$NON-NLS-1$ Composite optionsContainer = BaseWidgetUtils.createColumnContainer( optionsGroup, 3, 1 ); updateIfEntryExistsButton = BaseWidgetUtils.createCheckbox( optionsContainer, Messages .getString( "ImportLdifMainWizardPage.UpdateExistingEntires" ), //$NON-NLS-1$ 3 ); updateIfEntryExistsButton .setToolTipText( Messages.getString( "ImportLdifMainWizardPage.OptionsAppliesForLdif" ) ); //$NON-NLS-1$ if ( BrowserUIPlugin.getDefault().getDialogSettings().get( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY ) == null ) { BrowserUIPlugin.getDefault().getDialogSettings().put( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY, false ); } updateIfEntryExistsButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings().getBoolean( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY ) ); wizard.setUpdateIfEntryExists( updateIfEntryExistsButton.getSelection() ); updateIfEntryExistsButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { wizard.setUpdateIfEntryExists( updateIfEntryExistsButton.getSelection() ); validate(); } } ); continueOnErrorButton = BaseWidgetUtils.createCheckbox( optionsContainer, Messages .getString( "ImportLdifMainWizardPage.ContinueOnError" ), 3 ); //$NON-NLS-1$ if ( BrowserUIPlugin.getDefault().getDialogSettings().get( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) == null ) { BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, false ); } continueOnErrorButton.setSelection( BrowserUIPlugin.getDefault().getDialogSettings().getBoolean( CONTINUE_ON_ERROR_DIALOGSETTING_KEY ) ); wizard.setContinueOnError( continueOnErrorButton.getSelection() ); continueOnErrorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { wizard.setContinueOnError( continueOnErrorButton.getSelection() ); validate(); } } ); setControl( composite ); } /** * Saves the dialog settings. */ public void saveDialogSettings() { ldifFileBrowserWidget.saveDialogSettings(); BrowserUIPlugin.getDefault().getDialogSettings().put( UPDATE_IF_ENTRY_EXISTS_DIALOGSETTING_KEY, updateIfEntryExistsButton.getSelection() ); BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY, continueOnErrorButton.getSelection() ); } }
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/wizards/ExportConnectionsWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportConnectionsWizard.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.wizards; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.ConnectionCorePlugin; import org.apache.directory.studio.connection.core.ConnectionFolder; import org.apache.directory.studio.connection.core.ConnectionParameter; import org.apache.directory.studio.connection.core.io.ConnectionIO; import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionIO; 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.eclipse.swt.widgets.Composite; /** * This class implements the Wizard for Exporting connections. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportConnectionsWizard extends ExportBaseWizard { /** The wizard page */ private ExportConnectionsWizardPage page; /** * Creates a new instance of ExportConnectionsWizard. */ public ExportConnectionsWizard() { super( Messages.getString( "ExportConnectionsWizard.ConnectionsExport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Export Connections Wizard * * @return The ID of the Export Connections Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_CONNECTIONS; } /** * {@inheritDoc} */ public void addPages() { page = new ExportConnectionsWizardPage(); addPage( page ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID // PlatformUI.getWorkbench().getHelpSystem().setHelp( fromPage.getControl(), // BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifexport_wizard" ); //TODO: Add Help Context } /** * {@inheritDoc} */ public boolean performFinish() { page.saveDialogSettings(); String exportFileName = page.getExportFileName(); try { // Creating the ZipOutputStream ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( new File( exportFileName ) ) ); // Writing the Connections file. zos.putNextEntry( new ZipEntry( "connections.xml" ) ); //$NON-NLS-1$ Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections(); Set<ConnectionParameter> connectionParameters = new HashSet<ConnectionParameter>(); for ( Connection connection : connections ) { connectionParameters.add( connection.getConnectionParameter() ); } ConnectionIO.save( connectionParameters, zos ); zos.closeEntry(); // Writing the Connection Folders file. zos.putNextEntry( new ZipEntry( "connectionFolders.xml" ) ); //$NON-NLS-1$ ConnectionFolder[] connectionFolders = ConnectionCorePlugin.getDefault().getConnectionFolderManager() .getConnectionFolders(); Set<ConnectionFolder> connectionFoldersSet = new HashSet<ConnectionFolder>(); for ( ConnectionFolder connectionFolder : connectionFolders ) { connectionFoldersSet.add( connectionFolder ); } ConnectionIO.saveConnectionFolders( connectionFoldersSet, zos ); zos.closeEntry(); // Writing the Browser Connections file. zos.putNextEntry( new ZipEntry( "browserconnections.xml" ) ); //$NON-NLS-1$ IBrowserConnection[] browserConnections = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnections(); Map<String, IBrowserConnection> browserConnectionsMap = new HashMap<String, IBrowserConnection>(); for ( IBrowserConnection browserConnection : browserConnections ) { browserConnectionsMap.put( browserConnection.getConnection().getId(), browserConnection ); } BrowserConnectionIO.save( zos, browserConnectionsMap ); zos.closeEntry(); // Closing the ZipOutputStream zos.close(); } catch ( FileNotFoundException e ) { // TODO Auto-generated catch block e.printStackTrace(); } catch ( IOException e ) { // TODO Auto-generated catch block e.printStackTrace(); } 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/wizards/ExportOdfWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportOdfWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportOdfRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; /** * This class implements the Wizard for Exporting to ODF. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportOdfWizard extends ExportBaseWizard { /** The from page, used to select the exported data. */ private ExportOdfFromWizardPage fromPage; /** The to page, used to select the target file. */ private ExportOdfToWizardPage toPage; /** * Creates a new instance of ExportOdfWizard. */ public ExportOdfWizard() { super( Messages.getString( "ExportOdfWizard.OdfExport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Export ODF Wizard * * @return The ID of the Export ODF Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_ODF; } /** * {@inheritDoc} */ public void addPages() { fromPage = new ExportOdfFromWizardPage( ExportOdfFromWizardPage.class.getName(), this ); addPage( fromPage ); toPage = new ExportOdfToWizardPage( ExportOdfToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem() .setHelp( fromPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_odfexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem() .setHelp( toPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_odfexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { fromPage.saveDialogSettings(); toPage.saveDialogSettings(); boolean exportDn = this.fromPage.isExportDn(); new StudioBrowserJob( new ExportOdfRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter(), exportDn ) ).execute(); 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/wizards/NewBookmarkWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.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.wizards; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserCategory; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserEntryPage; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserSearchResultPage; 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.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.core.model.IValue; import org.apache.directory.studio.ldapbrowser.core.model.impl.Bookmark; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardPage; 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.INewWizard; import org.eclipse.ui.IWorkbench; /** * The NewConnectionWizard is used to create a new bookmark. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class NewBookmarkWizard extends Wizard implements INewWizard { /** The main page. */ private NewBookmarkMainWizardPage mainPage; /** The selected entry. */ private IEntry selectedEntry; /** * Creates a new instance of NewBookmarkWizard. */ public NewBookmarkWizard() { setWindowTitle( Messages.getString( "NewBookmarkWizard.NewBookmark" ) ); //$NON-NLS-1$ setNeedsProgressMonitor( false ); } /** * Gets the id. * * @return the id */ public static String getId() { return BrowserUIConstants.WIZARD_NEW_BOOKMARK; } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { // determine the currently selected entry, used // to preset the bookmark target Dn Object o = selection.getFirstElement(); if ( o instanceof IEntry ) { selectedEntry = ( ( IEntry ) o ); } else if ( o instanceof ISearchResult ) { selectedEntry = ( ( ISearchResult ) o ).getEntry(); } else if ( o instanceof IBookmark ) { selectedEntry = ( ( IBookmark ) o ).getEntry(); } else if ( o instanceof IAttribute ) { selectedEntry = ( ( IAttribute ) o ).getEntry(); } else if ( o instanceof IValue ) { selectedEntry = ( ( IValue ) o ).getAttribute().getEntry(); } else if ( o instanceof IBrowserConnection ) { selectedEntry = ( ( IBrowserConnection ) o ).getRootDSE(); } else if ( o instanceof ISearch ) { selectedEntry = ( ( ISearch ) o ).getBrowserConnection().getRootDSE(); } else if ( o instanceof BrowserCategory ) { selectedEntry = ( ( BrowserCategory ) o ).getParent().getRootDSE(); } else if ( o instanceof BrowserSearchResultPage ) { selectedEntry = ( ( BrowserSearchResultPage ) o ).getSearch().getBrowserConnection().getRootDSE(); } else if ( o instanceof BrowserEntryPage ) { selectedEntry = ( ( BrowserEntryPage ) o ).getEntry(); } else { selectedEntry = null; } } /** * {@inheritDoc} */ public void addPages() { if ( selectedEntry != null ) { mainPage = new NewBookmarkMainWizardPage( NewBookmarkMainWizardPage.class.getName(), selectedEntry, this ); addPage( mainPage ); } else { IWizardPage page = new DummyWizardPage(); addPage( page ); } } /** * Just a dummy page. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ class DummyWizardPage extends WizardPage { /** * Creates a new instance of DummyWizardPage. */ protected DummyWizardPage() { super( "" ); //$NON-NLS-1$ setTitle( Messages.getString( "NewBookmarkWizard.NoEntrySelected" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "NewBookmarkWizard.InOrderToUse" ) ); //$NON-NLS-1$ // setImageDescriptor(BrowserUIPlugin.getDefault().getImageDescriptor(BrowserUIConstants.IMG_ATTRIBUTE_WIZARD)); setPageComplete( true ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = new Composite( parent, SWT.NONE ); GridLayout gl = new GridLayout( 1, false ); composite.setLayout( gl ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); setControl( composite ); } } /** * {@inheritDoc} */ public boolean performFinish() { if ( selectedEntry != null ) { String name = mainPage.getBookmarkName(); Dn dn = mainPage.getBookmarkDn(); IBookmark bookmark = new Bookmark( selectedEntry.getBrowserConnection(), dn, name ); selectedEntry.getBrowserConnection().getBookmarkManager().addBookmark( bookmark ); } mainPage.saveDialogSettings(); 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/wizards/ExportDsmlFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportDsmlFromWizardPage.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.wizards; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; /** * This class implements the page used to select the data to export to DSML. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportDsmlFromWizardPage extends ExportBaseFromWizardPage { /** * Creates a new instance of ExportDsmlFromWizardPage using a * {@link SearchPageWrapper} with * <ul> * <li>hidden name * <li>visible all attributes checkbox * <li>visible operational attributes checkbox * </ul> * * @param pageName * the name of the page * @param wizard * the wizard the page is attached to */ public ExportDsmlFromWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard, new SearchPageWrapper( SearchPageWrapper.NAME_INVISIBLE | SearchPageWrapper.REFERRALOPTIONS_FOLLOW_MANUAL_INVISIBLE | SearchPageWrapper.RETURN_ALLATTRIBUTES_VISIBLE | SearchPageWrapper.RETURN_OPERATIONALATTRIBUTES_VISIBLE | ( ( wizard.getSearch().getReturningAttributes() == null || wizard.getSearch() .getReturningAttributes().length == 0 ) ? SearchPageWrapper.RETURN_ALLATTRIBUTES_CHECKED : SearchPageWrapper.NONE ) ) ); super.setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_DSML_WIZARD ) ); } }
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/wizards/ImportLdifWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.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.wizards; import java.io.File; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.ldapbrowser.common.widgets.browser.BrowserCategory; import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin; import org.apache.directory.studio.ldapbrowser.core.jobs.ImportLdifRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; 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.IBrowserConnection; import org.apache.directory.studio.ldapbrowser.core.model.IEntry; 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.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; /** * This class implements the Import LDIF Wizard. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ImportLdifWizard extends Wizard implements IImportWizard { /** The main page. */ private ImportLdifMainWizardPage mainPage; /** The ldif filename. */ private String ldifFilename; /** The import connection. */ private IBrowserConnection importConnection; /** The enable logging flag. */ private boolean enableLogging; /** The log filename. */ private String logFilename; /** The update if entry exists flag. */ private boolean updateIfEntryExists; /** The continue on error flag. */ private boolean continueOnError; /** * Creates a new instance of ImportLdifWizard. */ public ImportLdifWizard() { super(); setWindowTitle( Messages.getString( "ImportLdifWizard.LDIFImport" ) ); //$NON-NLS-1$ } /** * Creates a new instance of ImportLdifWizard. * * @param importConnection the import connection */ public ImportLdifWizard( IBrowserConnection importConnection ) { super.setWindowTitle( Messages.getString( "ImportLdifWizard.LDIFImport" ) ); //$NON-NLS-1$ this.importConnection = importConnection; } /** * Gets the ID of the Import LDIF Wizard * * @return The ID of the Import LDIF Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_IMPORT_LDIF; } /** * {@inheritDoc} */ public void init( IWorkbench workbench, IStructuredSelection selection ) { Object o = selection.getFirstElement(); if ( o instanceof IEntry ) { importConnection = ( ( IEntry ) o ).getBrowserConnection(); } else if ( o instanceof ISearchResult ) { importConnection = ( ( ISearchResult ) o ).getEntry().getBrowserConnection(); } else if ( o instanceof IBookmark ) { importConnection = ( ( IBookmark ) o ).getBrowserConnection(); } else if ( o instanceof IAttribute ) { importConnection = ( ( IAttribute ) o ).getEntry().getBrowserConnection(); } else if ( o instanceof IValue ) { importConnection = ( ( IValue ) o ).getAttribute().getEntry().getBrowserConnection(); } else if ( o instanceof IBrowserConnection ) { importConnection = ( IBrowserConnection ) o; } else if ( o instanceof Connection ) { importConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( ( Connection ) o ); } else if ( o instanceof BrowserCategory ) { importConnection = ( ( BrowserCategory ) o ).getParent(); } else { importConnection = null; } } /** * {@inheritDoc} */ public void addPages() { mainPage = new ImportLdifMainWizardPage( ImportLdifMainWizardPage.class.getName(), this ); addPage( mainPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); PlatformUI.getWorkbench().getHelpSystem() .setHelp( mainPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_ldifimport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { mainPage.saveDialogSettings(); if ( ldifFilename != null && !"".equals( ldifFilename ) ) //$NON-NLS-1$ { File ldifFile = new File( ldifFilename ); if ( enableLogging ) { File logFile = new File( logFilename ); new StudioBrowserJob( new ImportLdifRunnable( importConnection, ldifFile, logFile, updateIfEntryExists, continueOnError ) ).execute(); } else { new StudioBrowserJob( new ImportLdifRunnable( importConnection, ldifFile, updateIfEntryExists, continueOnError ) ).execute(); } return true; } return false; } /** * Gets the import connection. * * @return the import connection */ public IBrowserConnection getImportConnection() { return importConnection; } /** * Sets the import connection. * * @param importConnection the import connection */ public void setImportConnection( IBrowserConnection importConnection ) { this.importConnection = importConnection; } /** * Sets the ldif filename. * * @param ldifFilename the ldif filename */ public void setLdifFilename( String ldifFilename ) { this.ldifFilename = ldifFilename; } /** * Sets the update if entry exists flag. * * @param updateIfEntryExists the update if entry exists flag */ public void setUpdateIfEntryExists( boolean updateIfEntryExists ) { this.updateIfEntryExists = updateIfEntryExists; } /** * Sets the continue on error flag. * * @param continueOnError the continue on error flag */ public void setContinueOnError( boolean continueOnError ) { this.continueOnError = continueOnError; } /** * Sets the log filename. * * @param logFilename the log filename */ public void setLogFilename( String logFilename ) { this.logFilename = logFilename; } /** * Sets the enable logging flag. * * @param b the enable logging flag */ public void setEnableLogging( boolean b ) { this.enableLogging = b; } }
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/wizards/ExportBaseToPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseToPage.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.wizards; import java.io.File; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; /** * This class is a base implementation of the page to select the target export file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class ExportBaseToPage extends WizardPage { /** The wizard. */ protected ExportBaseWizard wizard; /** The file browser widget. */ protected FileBrowserWidget fileBrowserWidget; /** The overwrite file button. */ protected Button overwriteFileButton; /** * Creates a new instance of ExportBaseToPage. * * @param pageName the page name * @param wizard the wizard */ public ExportBaseToPage( String pageName, ExportBaseWizard wizard ) { super( pageName ); setPageComplete( false ); setTitle( NLS.bind( Messages.getString( "ExportBaseToPage.FileType" ), getFileType() ) ); //$NON-NLS-1$ setDescription( NLS.bind( Messages.getString( "ExportBaseToPage.PleaseEnterTargetFile" ), getFileType() ) ); //$NON-NLS-1$ this.wizard = wizard; } /** * Validates this page. This method is responsible for displaying errors, * as well as enabling/disabling the "Finish" button */ protected void validate() { boolean ok = true; File file = new File( fileBrowserWidget.getFilename() ); if ( "".equals( fileBrowserWidget.getFilename() ) ) //$NON-NLS-1$ { setErrorMessage( null ); ok = false; } else if ( file.isDirectory() ) { setErrorMessage( NLS.bind( Messages.getString( "ExportBaseToPage.ErrorNotAFile" ), new String[] { getFileType() } ) ); //$NON-NLS-1$ ok = false; } else if ( file.exists() && !overwriteFileButton.getSelection() ) { setErrorMessage( NLS .bind( Messages.getString( "ExportBaseToPage.ErrorFileExists" ), new String[] { getFileType(), getFileType(), getFileType() } ) ); //$NON-NLS-1$ ok = false; } else if ( file.exists() && !file.canWrite() ) { setErrorMessage( NLS.bind( Messages.getString( "ExportBaseToPage.ErrorFileNotWritable" ), new String[] { getFileType() } ) ); //$NON-NLS-1$ ok = false; } else if ( file.getParentFile() == null ) { setErrorMessage( NLS.bind( Messages.getString( "ExportBaseToPage.ErrorDirectoryNotWritable" ), new String[] { getFileType() } ) ); //$NON-NLS-1$ ok = false; } if ( ok ) { setErrorMessage( null ); } setPageComplete( ok && wizard.getExportFilename() != null && !"".equals( wizard.getExportFilename() ) ); //$NON-NLS-1$ } /** * {@inheritDoc} */ public void createControl( Composite composite ) { // Export file BaseWidgetUtils.createLabel( composite, NLS.bind( Messages.getString( "ExportBaseToPage.FileTypeColon" ), getFileType() ), 1 ); //$NON-NLS-1$ fileBrowserWidget = new FileBrowserWidget( NLS.bind( Messages.getString( "ExportBaseToPage.SelectFileType" ), new String[] { getFileType() } ), //$NON-NLS-1$ getExtensions(), FileBrowserWidget.TYPE_SAVE ); fileBrowserWidget.createWidget( composite ); fileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener() { public void widgetModified( WidgetModifyEvent event ) { wizard.setExportFilename( fileBrowserWidget.getFilename() ); validate(); } } ); BaseWidgetUtils.createRadioIndent( composite, 1 ); overwriteFileButton = BaseWidgetUtils.createCheckbox( composite, NLS.bind( Messages .getString( "ExportBaseToPage.OverwriteExistingFile" ), new String[] { getFileType() } ), 2 ); //$NON-NLS-1$ overwriteFileButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent event ) { validate(); } } ); fileBrowserWidget.setFocus(); setControl( composite ); validate(); } /** * Gets the valid file extensions. * * @return the valid file extensions */ protected abstract String[] getExtensions(); /** * Gets the file type. * * @return the file type */ protected abstract String getFileType(); /** * Saves the dialog settings. */ public void saveDialogSettings() { fileBrowserWidget.saveDialogSettings(); } }
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/wizards/ExportExcelToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.common.dialogs.preferences.TextFormatsPreferencePage; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Link; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This class implements the page to select the target Excel file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportExcelToWizardPage extends ExportBaseToPage { /** The extensions used by Excel files */ private static final String[] EXTENSIONS = new String[] { "*.xls", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** * Creates a new instance of ExportExcelToWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ExportExcelToWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard ); setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_XLS_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); String text = Messages.getString( "ExportExcelToWizardPage.SeeTextFormats" ); //$NON-NLS-1$ Link link = BaseWidgetUtils.createLink( composite, text, 2 ); link.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreferencesUtil.createPreferenceDialogOn( getShell(), BrowserUIConstants.PREFERENCEPAGEID_TEXTFORMATS, null, TextFormatsPreferencePage.XLS_TAB ).open(); } } ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); BaseWidgetUtils.createWrappedLabel( composite, Messages.getString( "ExportExcelToWizardPage.WarningExcel" ), 2 ); //$NON-NLS-1$ } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportExcelToWizardPage.Excel" ); //$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/wizards/ExportBaseFromWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportBaseFromWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.common.ui.widgets.WidgetModifyEvent; import org.apache.directory.studio.common.ui.widgets.WidgetModifyListener; import org.apache.directory.studio.ldapbrowser.common.widgets.search.SearchPageWrapper; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.widgets.Composite; /** * This class is a base implementation of the page to select the data to export. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public abstract class ExportBaseFromWizardPage extends WizardPage implements WidgetModifyListener { /** The wizard. */ protected ExportBaseWizard wizard; /** The search page wrapper. */ protected SearchPageWrapper spw; /** * Creates a new instance of ExportBaseFromWizardPage. * * @param spw the search page wrapper * @param pageName the page name * @param wizard the wizard */ public ExportBaseFromWizardPage( String pageName, ExportBaseWizard wizard, SearchPageWrapper spw ) { super( pageName ); setTitle( Messages.getString( "ExportBaseFromWizardPage.DataToExport" ) ); //$NON-NLS-1$ setDescription( Messages.getString( "ExportBaseFromWizardPage.PleaseDefineSearchParameters" ) ); //$NON-NLS-1$ setPageComplete( true ); this.wizard = wizard; this.spw = spw; } /** * {@inheritDoc} */ public void createControl( Composite parent ) { Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); spw.createContents( composite ); spw.loadFromSearch( wizard.getSearch() ); spw.addWidgetModifyListener( this ); setControl( composite ); } /** * Validates this page and sets the error message * if this page is not valid. */ protected void validate() { setPageComplete( spw.isValid() ); setErrorMessage( spw.getErrorMessage() ); } /** * {@inheritDoc} */ public void widgetModified( WidgetModifyEvent event ) { validate(); } /** * Saves the dialog settings. */ public void saveDialogSettings() { spw.saveToSearch( wizard.getSearch() ); } }
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/wizards/ExportLdifToWizardPage.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.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.wizards; import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils; import org.apache.directory.studio.ldapbrowser.common.dialogs.preferences.TextFormatsPreferencePage; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Link; import org.eclipse.ui.dialogs.PreferencesUtil; /** * This class implements the page to select the target LDIF file. * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportLdifToWizardPage extends ExportBaseToPage { /** The extensions used by LDIF files */ private static final String[] EXTENSIONS = new String[] { "*.ldif", "*" }; //$NON-NLS-1$ //$NON-NLS-2$ /** * Creates a new instance of ExportLdifToWizardPage. * * @param pageName the page name * @param wizard the wizard */ public ExportLdifToWizardPage( String pageName, ExportBaseWizard wizard ) { super( pageName, wizard ); setImageDescriptor( BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_EXPORT_LDIF_WIZARD ) ); } /** * {@inheritDoc} */ public void createControl( Composite parent ) { final Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); super.createControl( composite ); BaseWidgetUtils.createSpacer( composite, 3 ); BaseWidgetUtils.createSpacer( composite, 1 ); String text = Messages.getString( "ExportLdifToWizardPage.SeeTextFormats" ); //$NON-NLS-1$ Link link = BaseWidgetUtils.createLink( composite, text, 2 ); link.addSelectionListener( new SelectionAdapter() { public void widgetSelected( SelectionEvent e ) { PreferencesUtil.createPreferenceDialogOn( getShell(), BrowserUIConstants.PREFERENCEPAGEID_TEXTFORMATS, null, TextFormatsPreferencePage.LDIF_TAB ).open(); } } ); } /** * {@inheritDoc} */ protected String[] getExtensions() { return EXTENSIONS; } /** * {@inheritDoc} */ protected String getFileType() { return Messages.getString( "ExportLdifToWizardPage.LDIF" ); //$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/wizards/ExportCsvWizard.java
plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportCsvWizard.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.wizards; import org.apache.directory.studio.ldapbrowser.core.jobs.ExportCsvRunnable; import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; /** * This class implements the Wizard for Exporting to CSV * * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> */ public class ExportCsvWizard extends ExportBaseWizard { /** The from page, used to select the exported data. */ private ExportCsvFromWizardPage fromPage; /** The to page, used to select the target file. */ private ExportCsvToWizardPage toPage; /** * Creates a new instance of ExportCsvWizard. */ public ExportCsvWizard() { super( Messages.getString( "ExportCsvWizard.CSVExport" ) ); //$NON-NLS-1$ } /** * Gets the ID of the Export CSV Wizard * * @return The ID of the Export CSV Wizard */ public static String getId() { return BrowserUIConstants.WIZARD_EXPORT_CSV; } /** * {@inheritDoc} */ public void addPages() { fromPage = new ExportCsvFromWizardPage( ExportCsvFromWizardPage.class.getName(), this ); addPage( fromPage ); toPage = new ExportCsvToWizardPage( ExportCsvToWizardPage.class.getName(), this ); addPage( toPage ); } /** * {@inheritDoc} */ public void createPageControls( Composite pageContainer ) { super.createPageControls( pageContainer ); // set help context ID PlatformUI.getWorkbench().getHelpSystem() .setHelp( fromPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_csvexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ PlatformUI.getWorkbench().getHelpSystem() .setHelp( toPage.getControl(), BrowserUIConstants.PLUGIN_ID + "." + "tools_csvexport_wizard" ); //$NON-NLS-1$ //$NON-NLS-2$ } /** * {@inheritDoc} */ public boolean performFinish() { fromPage.saveDialogSettings(); toPage.saveDialogSettings(); boolean exportDn = this.fromPage.isExportDn(); new StudioBrowserJob( new ExportCsvRunnable( exportFilename, search.getBrowserConnection(), search.getSearchParameter(), exportDn ) ).execute(); return true; } }
java
Apache-2.0
e55b93d729a60c986fc93e52f9519f4bbdf51252
2026-01-05T02:32:00.866394Z
false