You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2007/11/05 18:01:46 UTC
svn commit: r592087 [14/16] - in
/directory/sandbox/felixk/studio-ldapbrowser-ui: ./ META-INF/ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/directory/
src/main/java/org/apache/directory/studio/ src...
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,77 @@
+/*
+ * 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>
+ * @version $Rev$, $Date$
+ */
+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.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();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelFromWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,108 @@
+/*
+ * 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.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+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>
+ * @version $Rev$, $Date$
+ */
+public class ExportExcelToWizardPage extends ExportBaseToPage
+{
+
+ /** The extensions used by Excel files */
+ private static final String[] EXTENSIONS = new String[]
+ { "*.xls", "*.*" };
+
+
+ /**
+ * 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 = "See <a>Text Formats</a> for Excel file format preferences.";
+ Link link = BaseWidgetUtils.createLink( composite, text, 2 );
+ link.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ PreferencesUtil.createPreferenceDialogOn( getShell(), TextFormatsPreferencePage.class.getName(), null,
+ TextFormatsPreferencePage.XLS_TAB ).open();
+ }
+ } );
+
+ BaseWidgetUtils.createSpacer( composite, 3 );
+ BaseWidgetUtils.createSpacer( composite, 1 );
+ BaseWidgetUtils.createWrappedLabel( composite,
+ "Warning: Excel export is memory intensive! Maximum number of exportable entries is limited to 65000!", 2 );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String[] getExtensions()
+ {
+ return EXTENSIONS;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String getFileType()
+ {
+ return "Excel";
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelToWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,109 @@
+/*
+ * 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.ExportXlsJob;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+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>
+ * @version $Rev$, $Date$
+ */
+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( "Excel Export" );
+ }
+
+
+ /**
+ * Gets the ID of the Export Excel Wizard
+ *
+ * @return The ID of the Export Excel Wizard
+ */
+ public static String getId()
+ {
+ return ExportExcelWizard.class.getName();
+ }
+
+
+ /**
+ * {@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(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_excelexport_wizard" );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( toPage.getControl(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_excelexport_wizard" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean performFinish()
+ {
+ fromPage.saveDialogSettings();
+ toPage.saveDialogSettings();
+ boolean exportDn = this.fromPage.isExportDn();
+
+ ExportXlsJob eej = new ExportXlsJob( exportFilename, search.getBrowserConnection(), search.getSearchParameter(),
+ exportDn );
+ eej.execute();
+
+ return true;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportExcelWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,63 @@
+/*
+ * 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>
+ * @version $Rev$, $Date$
+ */
+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.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 ) );
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifFromWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.dialogs.preferences.TextFormatsPreferencePage;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+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>
+ * @version $Rev$, $Date$
+ */
+public class ExportLdifToWizardPage extends ExportBaseToPage
+{
+
+ /** The extensions used by LDIF files */
+ private static final String[] EXTENSIONS = new String[]
+ { "*.ldif", "*.*" };
+
+
+ /**
+ * 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 = "See <a>Text Formats</a> for LDIF file format preferences.";
+ Link link = BaseWidgetUtils.createLink( composite, text, 2 );
+ link.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ PreferencesUtil.createPreferenceDialogOn( getShell(), TextFormatsPreferencePage.class.getName(), null,
+ TextFormatsPreferencePage.LDIF_TAB ).open();
+ }
+ } );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String[] getExtensions()
+ {
+ return EXTENSIONS;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected String getFileType()
+ {
+ return "LDIF";
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifToWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,107 @@
+/*
+ * 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.ExportLdifJob;
+import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+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>
+ * @version $Rev$, $Date$
+ */
+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( "LDIF Export" );
+ }
+
+
+ /**
+ * Gets the ID of the Export LDIF Wizard
+ *
+ * @return The ID of the Export LDIF Wizard
+ */
+ public static String getId()
+ {
+ return ExportLdifWizard.class.getName();
+ }
+
+
+ /**
+ * {@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(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifexport_wizard" );
+ PlatformUI.getWorkbench().getHelpSystem().setHelp( toPage.getControl(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifexport_wizard" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean performFinish()
+ {
+ fromPage.saveDialogSettings();
+ toPage.saveDialogSettings();
+
+ ExportLdifJob elj = new ExportLdifJob( exportFilename, search.getBrowserConnection(), search.getSearchParameter() );
+ elj.execute();
+
+ return true;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ExportLdifWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,300 @@
+/*
+ * 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.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+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>
+ * @version $Rev$, $Date$
+ */
+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", "*.*" };
+
+ /** 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( ImportDsmlWizard.WIZARD_TITLE );
+ setDescription( "Please select a connection and the DSML file to import" );
+ 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, "DSML file:", 1 );
+ dsmlFileBrowserWidget = new FileBrowserWidget( "Select a DSML File", EXTENSIONS, FileBrowserWidget.TYPE_OPEN );
+ 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" );
+ }
+ validate();
+ }
+ } );
+
+ // Connection
+ BaseWidgetUtils.createLabel( composite, "Import into:", 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, "Response", 1 );
+ Composite responseContainer = BaseWidgetUtils.createColumnContainer( responseGroup, 3, 1 );
+
+ saveResponseButton = BaseWidgetUtils.createCheckbox( responseContainer, "Save response", 3 );
+ 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,
+ "Use default response file", 2 );
+ useDefaultResponseFileButton.setSelection( true );
+ useDefaultResponseFileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ String temp = customResponseFileName;
+ responseFileBrowserWidget.setFilename( dsmlFileBrowserWidget.getFilename() + ".response.xml" );
+ responseFileBrowserWidget.setEnabled( false );
+ customResponseFileName = temp;
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( responseContainer, 1 );
+ useCustomResponseFileButton = BaseWidgetUtils.createRadiobutton( responseContainer, "Use custom response file",
+ 2 );
+ useCustomResponseFileButton.setSelection( false );
+ useCustomResponseFileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ responseFileBrowserWidget.setFilename( customResponseFileName != null ? customResponseFileName : "" );
+ responseFileBrowserWidget.setEnabled( true );
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( responseContainer, 1 );
+ responseFileBrowserWidget = new FileBrowserWidget( "Select save file", null, FileBrowserWidget.TYPE_SAVE );
+ 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,
+ "Overwrite existing response file", 2 );
+ 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() ) )
+ {
+ setErrorMessage( null );
+ ok = false;
+ }
+ else if ( !dsmlFile.isFile() || !dsmlFile.exists() )
+ {
+ setErrorMessage( "Selected DSML file doesn't exist." );
+ ok = false;
+ }
+ else if ( !dsmlFile.canRead() )
+ {
+ setErrorMessage( "Selected DSML file is not readable." );
+ ok = false;
+ }
+ else if ( saveResponseButton.getSelection() )
+ {
+ File responseFile = new File( responseFileBrowserWidget.getFilename() );
+ File responseFileDirectory = responseFile.getParentFile();
+
+ if ( responseFile.equals( dsmlFile ) )
+ {
+ setErrorMessage( "DSML file and response file must not be equal." );
+ ok = false;
+ }
+ else if ( responseFile.isDirectory() )
+ {
+ setErrorMessage( "Selected response file is not a file." );
+ ok = false;
+ }
+ else if ( responseFile.exists() && !overwriteResponseFileButton.getSelection() )
+ {
+ setErrorMessage( "Selected response file already exists. Select option 'Overwrite existing response file' if you want to overwrite the response file." );
+ ok = false;
+ }
+ else if ( responseFile.exists() && !responseFile.canWrite() )
+ {
+ setErrorMessage( "Selected response file is not writeable." );
+ ok = false;
+ }
+ else if ( responseFile.getParentFile() == null )
+ {
+ setErrorMessage( "Selected response file directory is not writeable." );
+ ok = false;
+ }
+ else if ( !responseFile.exists() && ( responseFileDirectory == null || !responseFileDirectory.canWrite() ) )
+ {
+ setErrorMessage( "Selected response file directory is not writeable." );
+ ok = false;
+ }
+ }
+
+ if ( ( wizard.getImportConnection() == null ) || ( browserConnectionWidget.getBrowserConnection() == null ) )
+ {
+ setErrorMessage( "Please select a Connection." );
+ ok = false;
+ }
+
+ if ( ok )
+ {
+ setErrorMessage( null );
+ }
+ setPageComplete( ok );
+ getContainer().updateButtons();
+ }
+
+
+ /**
+ * Saves the Dialog Settings of the Page
+ */
+ public void saveDialogSettings()
+ {
+ dsmlFileBrowserWidget.saveDialogSettings();
+ }
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlMainWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,240 @@
+/*
+ * 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.ldapbrowser.core.jobs.ImportDsmlJob;
+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.BrowserUIPlugin;
+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>
+ * @version $Rev$, $Date$
+ */
+public class ImportDsmlWizard extends Wizard implements IImportWizard
+{
+ /** Page Title */
+ public static final String WIZARD_TITLE = "DSML Import";
+
+ /** 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( WIZARD_TITLE );
+ }
+
+
+ /**
+ * Creates a new instance of ImportDsmlWizard.
+ * @param selectedConnection
+ * The connection to use
+ */
+ public ImportDsmlWizard( IBrowserConnection selectedConnection )
+ {
+ setWindowTitle( WIZARD_TITLE );
+ this.importConnection = selectedConnection;
+ }
+
+
+ /**
+ * Gets the ID of the Import DSML Wizard
+ * @return The ID of the Import DSML Wizard
+ */
+ public static String getId()
+ {
+ return ImportDsmlWizard.class.getName();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean performFinish()
+ {
+ mainPage.saveDialogSettings();
+
+ if ( dsmlFilename != null && !"".equals( dsmlFilename ) )
+ {
+ File dsmlFile = new File( dsmlFilename );
+
+ if ( saveResponse )
+ {
+ File responseFile = new File( responseFilename );
+ new ImportDsmlJob( importConnection, dsmlFile, responseFile ).execute();
+ }
+ else
+ {
+ new ImportDsmlJob( 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
+ {
+ 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(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_dsmlimport_wizard" );
+ }
+
+
+ /**
+ * 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;
+ }
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportDsmlWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,326 @@
+/*
+ * 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.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.FileBrowserWidget;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
+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>
+ * @version $Rev$, $Date$
+ */
+public class ImportLdifMainWizardPage extends WizardPage
+{
+
+ /** The continue on error flag key */
+ public static final String CONTINUE_ON_ERROR_DIALOGSETTING_KEY = ImportLdifMainWizardPage.class.getName()
+ + ".continueOnError";
+
+ /** The valid extension. */
+ private static final String[] EXTENSIONS = new String[]
+ { "*.ldif", "*.*" };
+
+ /** 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 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( "LDIF Import" );
+ setDescription( "Please select a connection and the LDIF to import" );
+ 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() ) )
+ {
+ setErrorMessage( null );
+ ok = false;
+ }
+ else if ( !ldifFile.isFile() || !ldifFile.exists() )
+ {
+ setErrorMessage( "Selected LDIF file doesn't exist." );
+ ok = false;
+ }
+ else if ( !ldifFile.canRead() )
+ {
+ setErrorMessage( "Selected LDIF file is not readable." );
+ ok = false;
+ }
+ else if ( enableLoggingButton.getSelection() )
+ {
+ File logFile = new File( logFileBrowserWidget.getFilename() );
+ File logFileDirectory = logFile.getParentFile();
+
+ if ( logFile.equals( ldifFile ) )
+ {
+ setErrorMessage( "LDIF file and Logfile must not be equal." );
+ ok = false;
+ }
+ else if ( logFile.isDirectory() )
+ {
+ setErrorMessage( "Selected logfile is no file." );
+ ok = false;
+ }
+ else if ( logFile.exists() && !overwriteLogfileButton.getSelection() )
+ {
+ setErrorMessage( "Selected logfile already exists. Select option 'Overwrite existing logfile' if you want to overwrite the logfile." );
+ ok = false;
+ }
+ else if ( logFile.exists() && !logFile.canWrite() )
+ {
+ setErrorMessage( "Selected logfile is not writeable." );
+ ok = false;
+ }
+ else if ( logFile.getParentFile() == null )
+ {
+ setErrorMessage( "Selected logfile directory is not writeable." );
+ ok = false;
+ }
+ else if ( !logFile.exists() && ( logFileDirectory == null || !logFileDirectory.canWrite() ) )
+ {
+ setErrorMessage( "Selected logfile directory is not writeable." );
+ ok = false;
+ }
+ }
+
+ if ( wizard.getImportConnection() == null )
+ {
+ 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, "LDIF file:", 1 );
+ ldifFileBrowserWidget = new FileBrowserWidget( "Select LDIF File", EXTENSIONS, FileBrowserWidget.TYPE_OPEN );
+ ldifFileBrowserWidget.createWidget( composite );
+ ldifFileBrowserWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ wizard.setLdifFilename( ldifFileBrowserWidget.getFilename() );
+ if ( useDefaultLogfileButton.getSelection() )
+ {
+ logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" );
+ }
+ validate();
+ }
+ } );
+
+ // Connection
+ BaseWidgetUtils.createLabel( composite, "Import into:", 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, "Logging", 1 );
+ Composite loggingContainer = BaseWidgetUtils.createColumnContainer( loggingGroup, 3, 1 );
+
+ enableLoggingButton = BaseWidgetUtils.createCheckbox( loggingContainer, "Enable logging", 3 );
+ 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, "Use default logfile", 2 );
+ useDefaultLogfileButton.setSelection( true );
+ useDefaultLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ String temp = customLogfileName;
+ logFileBrowserWidget.setFilename( ldifFileBrowserWidget.getFilename() + ".log" );
+ logFileBrowserWidget.setEnabled( false );
+ customLogfileName = temp;
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ useCustomLogfileButton = BaseWidgetUtils.createRadiobutton( loggingContainer, "Use custom logfile", 2 );
+ useCustomLogfileButton.setSelection( false );
+ useCustomLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ logFileBrowserWidget.setFilename( customLogfileName != null ? customLogfileName : "" );
+ logFileBrowserWidget.setEnabled( true );
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createRadioIndent( loggingContainer, 1 );
+ logFileBrowserWidget = new FileBrowserWidget( "Select Logfile", null, FileBrowserWidget.TYPE_SAVE );
+ 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, "Overwrite existing logfile", 2 );
+ overwriteLogfileButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ validate();
+ }
+ } );
+
+ // Continue
+ continueOnErrorButton = BaseWidgetUtils.createCheckbox( composite, "Continue on error", 3 );
+ 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 );
+ // nameText.setFocus();
+ }
+
+
+ /**
+ * Saves the dialog settings.
+ */
+ public void saveDialogSettings()
+ {
+ ldifFileBrowserWidget.saveDialogSettings();
+ BrowserUIPlugin.getDefault().getDialogSettings().put( CONTINUE_ON_ERROR_DIALOGSETTING_KEY,
+ continueOnErrorButton.getSelection() );
+ }
+
+}
\ No newline at end of file
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifMainWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,255 @@
+/*
+ * 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.ldapbrowser.core.jobs.ImportLdifJob;
+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.BrowserUIPlugin;
+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>
+ * @version $Rev$, $Date$
+ */
+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 continue on error flag. */
+ private boolean continueOnError;
+
+
+ /**
+ * Creates a new instance of ImportLdifWizard.
+ */
+ public ImportLdifWizard()
+ {
+ super();
+ setWindowTitle( "LDIF Import" );
+ }
+
+
+ /**
+ * Creates a new instance of ImportLdifWizard.
+ *
+ * @param importConnection the import connection
+ */
+ public ImportLdifWizard( IBrowserConnection importConnection )
+ {
+ super.setWindowTitle( "LDIF Import" );
+ this.importConnection = importConnection;
+ }
+
+
+ /**
+ * Gets the ID of the Import LDIF Wizard
+ *
+ * @return The ID of the Import LDIF Wizard
+ */
+ public static String getId()
+ {
+ return ImportLdifWizard.class.getName();
+ }
+
+
+ /**
+ * {@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
+ {
+ 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(),
+ BrowserUIPlugin.PLUGIN_ID + "." + "tools_ldifimport_wizard" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean performFinish()
+ {
+
+ mainPage.saveDialogSettings();
+
+ if ( ldifFilename != null && !"".equals( ldifFilename ) )
+ {
+ File ldifFile = new File( ldifFilename );
+
+ if ( enableLogging )
+ {
+ File logFile = new File( logFilename );
+ new ImportLdifJob( importConnection, ldifFile, logFile, continueOnError ).execute();
+ }
+ else
+ {
+ new ImportLdifJob( importConnection, ldifFile, 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 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;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/ImportLdifWizard.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,186 @@
+/*
+ * 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.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
+import org.apache.directory.studio.ldapbrowser.common.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>
+ * @version $Rev$, $Date$
+ */
+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( "New Bookmark" );
+ setDescription( "Please enter the bookmark parameters." );
+ // 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() ) );
+ }
+ }
+
+
+ /**
+ * {@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, "Bookmark Name:", 1 );
+ bookmarkNameText = BaseWidgetUtils.createText( innerComposite, entry.getDn().getUpName(), 2 );
+ bookmarkNameText.setFocus();
+ bookmarkNameText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ validate();
+ }
+ } );
+
+ BaseWidgetUtils.createLabel( innerComposite, "Bookmark DN:", 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 LdapDN 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();
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkMainWizardPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.java?rev=592087&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.java (added)
+++ directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.java Mon Nov 5 09:01:21 2007
@@ -0,0 +1,211 @@
+/*
+ * 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.shared.ldap.name.LdapDN;
+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.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>
+ * @version $Rev$, $Date$
+ */
+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( "New Bookmark" );
+ setNeedsProgressMonitor( false );
+ }
+
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public static String getId()
+ {
+ return NewBookmarkWizard.class.getName();
+ }
+
+
+ /**
+ * {@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>
+ * @version $Rev$, $Date$
+ */
+ class DummyWizardPage extends WizardPage
+ {
+
+ /**
+ * Creates a new instance of DummyWizardPage.
+ */
+ protected DummyWizardPage()
+ {
+ super( "" );
+ setTitle( "No entry selected" );
+ setDescription( "In order to use the bookmark creation wizard please select an entry or connection." );
+ // 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();
+ LdapDN dn = mainPage.getBookmarkDn();
+ IBookmark bookmark = new Bookmark( selectedEntry.getBrowserConnection(), dn, name );
+ selectedEntry.getBrowserConnection().getBookmarkManager().addBookmark( bookmark );
+ }
+ mainPage.saveDialogSettings();
+ return true;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/wizards/NewBookmarkWizard.java
------------------------------------------------------------------------------
svn:eol-style = native