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 16:05:02 UTC
svn commit: r592029 [1/2] - in
/directory/sandbox/felixk/studio-valueeditors: ./ 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/mai...
Author: felixk
Date: Mon Nov 5 07:04:58 2007
New Revision: 592029
URL: http://svn.apache.org/viewvc?rev=592029&view=rev
Log:
Initial studio maven-build
Added:
directory/sandbox/felixk/studio-valueeditors/ (with props)
directory/sandbox/felixk/studio-valueeditors/META-INF/
directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF (with props)
directory/sandbox/felixk/studio-valueeditors/plugin.properties (with props)
directory/sandbox/felixk/studio-valueeditors/plugin.xml (with props)
directory/sandbox/felixk/studio-valueeditors/pom.xml (with props)
directory/sandbox/felixk/studio-valueeditors/src/
directory/sandbox/felixk/studio-valueeditors/src/main/
directory/sandbox/felixk/studio-valueeditors/src/main/java/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/integer/IntegerValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/objectclass/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/objectclass/ObjectClassDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/objectclass/ObjectClassValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/password/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/password/PasswordDialog.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/password/PasswordValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/
directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/addresseditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/administrativeroleeditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/dneditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/generalizedtimeeditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/imageeditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/inplace_oceditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/integereditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/objectclasseditor.png (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/passwordeditor.gif (with props)
directory/sandbox/felixk/studio-valueeditors/src/main/resources/resources/icons/texteditor.gif (with props)
Propchange: directory/sandbox/felixk/studio-valueeditors/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Nov 5 07:04:58 2007
@@ -0,0 +1,2 @@
+.settings
+target
Added: directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF (added)
+++ directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF Mon Nov 5 07:04:58 2007
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache Directory Studio Value Editors
+Bundle-SymbolicName: org.apache.directory.studio.valueeditors;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.directory.studio.valueeditors.ValueEditorsActivator
+Bundle-Vendor: Apache Software Foundation
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.apache.directory.studio.jars,
+ org.apache.directory.studio.connection.core,
+ org.apache.directory.studio.connection.ui,
+ org.apache.directory.studio.ldapbrowser.core,
+ org.apache.directory.studio.ldapbrowser.common
+Eclipse-LazyStart: true
+Export-Package: org.apache.directory.studio.valueeditors,
+ org.apache.directory.studio.valueeditors.address,
+ org.apache.directory.studio.valueeditors.dn,
+ org.apache.directory.studio.valueeditors.image,
+ org.apache.directory.studio.valueeditors.integer,
+ org.apache.directory.studio.valueeditors.objectclass,
+ org.apache.directory.studio.valueeditors.password,
+ org.apache.directory.studio.valueeditors.time
Propchange: directory/sandbox/felixk/studio-valueeditors/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/plugin.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/plugin.properties?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/plugin.properties (added)
+++ directory/sandbox/felixk/studio-valueeditors/plugin.properties Mon Nov 5 07:04:58 2007
@@ -0,0 +1,19 @@
+# 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.
+project.name=Apache Directory Studio Value Editors
+project.version=1.0.0
+project.id=org.apache.directory.studio.valueeditors
Propchange: directory/sandbox/felixk/studio-valueeditors/plugin.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/plugin.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/plugin.xml?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/plugin.xml (added)
+++ directory/sandbox/felixk/studio-valueeditors/plugin.xml Mon Nov 5 07:04:58 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.apache.directory.studio.valueeditors">
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.password.PasswordValueEditor"
+ icon="resources/icons/passwordeditor.gif"
+ name="Password Editor">
+ <attribute attributeType="userPassword"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.image.ImageValueEditor"
+ icon="resources/icons/imageeditor.gif"
+ name="Image Editor">
+ <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.28"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.time.InPlaceGeneralizedTimeValueEditor"
+ icon="resources/icons/generalizedtimeeditor.gif"
+ name="In-Place Generalized Time Editor">
+ <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.24"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.objectclass.ObjectClassValueEditor"
+ icon="resources/icons/objectclasseditor.png"
+ name="Object Class Editor">
+ <attribute attributeType="objectClass"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.dn.DnValueEditor"
+ icon="resources/icons/dneditor.gif"
+ name="DN Editor">
+ <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.12"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.address.AddressValueEditor"
+ icon="resources/icons/addresseditor.gif"
+ name="Address Editor">
+ <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.41"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.integer.IntegerValueEditor"
+ icon="resources/icons/integereditor.gif"
+ name="Integer Editor">
+ <syntax syntaxOID="1.3.6.1.4.1.1466.115.121.1.27"/>
+ </valueEditor>
+ <valueEditor
+ class="org.apache.directory.studio.valueeditors.administrativerole.AdministrativeRoleValueEditor"
+ icon="resources/icons/administrativeroleeditor.gif"
+ name="Administrative Role Editor">
+ <attribute attributeType="administrativeRole"/>
+ </valueEditor>
+ </extension>
+
+</plugin>
Propchange: directory/sandbox/felixk/studio-valueeditors/plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/pom.xml?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/pom.xml (added)
+++ directory/sandbox/felixk/studio-valueeditors/pom.xml Mon Nov 5 07:04:58 2007
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<!--
+ @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ @version $Id: pom.xml 353 2007-10-28 14:59:35Z felix $
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ </parent>
+ <artifactId>${groupId}.valueeditors</artifactId>
+ <name>Apache Directory Studio Value Editors</name>
+ <packaging>jar</packaging>
+
+ <description></description>
+
+ <!-- Set path for local repository -->
+ <properties>
+ <local-repo>${project.basedir}/../local-repository</local-repo>
+ </properties>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>plugin.properties</include>
+ <include>plugin.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>META-INF/MANIFEST.MF</manifestFile>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.directory.studio</groupId>
+ <artifactId>${pom.groupId}.ldapbrowser.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>org.eclipse.core.runtime</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Propchange: directory/sandbox/felixk/studio-valueeditors/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,138 @@
+/*
+ * 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.valueeditors;
+
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ValueEditorsActivator extends AbstractUIPlugin
+{
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.apache.directory.studio.valueeditors";
+
+ /** The shared instance */
+ private static ValueEditorsActivator plugin;
+
+
+ /**
+ * The constructor
+ */
+ public ValueEditorsActivator()
+ {
+ plugin = this;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start( BundleContext context ) throws Exception
+ {
+ super.start( context );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop( BundleContext context ) throws Exception
+ {
+ plugin = null;
+ super.stop( context );
+ }
+
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ValueEditorsActivator getDefault()
+ {
+ return plugin;
+ }
+
+
+ /**
+ * Use this method to get SWT images. Use the IMG_ constants from
+ * ValueEditorConstants for the key.
+ *
+ * @param key
+ * The key (relative path to the image im filesystem)
+ * @return The image discriptor or null
+ */
+ public ImageDescriptor getImageDescriptor( String key )
+ {
+ if ( key != null )
+ {
+ URL url = FileLocator.find( getBundle(), new Path( key ), null );
+ if ( url != null )
+ return ImageDescriptor.createFromURL( url );
+ else
+ return null;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Use this method to get SWT images. Use the IMG_ constants from
+ * ValueEditorConstants for the key. A ImageRegistry is used to manage the
+ * the key->Image mapping.
+ * <p>
+ * Note: Don't dispose the returned SWT Image. It is disposed
+ * automatically when the plugin is stopped.
+ *
+ * @param key
+ * The key (relative path to the image im filesystem)
+ * @return The SWT Image or null
+ * @see ValueEditorsConstants
+ */
+ public Image getImage( String key )
+ {
+ Image image = getImageRegistry().get( key );
+ if ( image == null )
+ {
+ ImageDescriptor id = getImageDescriptor( key );
+ if ( id != null )
+ {
+ image = id.createImage();
+ getImageRegistry().put( key, image );
+ }
+ }
+ return image;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,55 @@
+/*
+ * 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.valueeditors;
+
+/**
+ * Contains constants for the value editors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ValueEditorsConstants
+{
+
+ /** The relative path to the image editor icon */
+ public static final String IMG_IMAGEEDITOR = "resources/icons/imageeditor.gif";
+
+ /** The relative path to the address editor icon */
+ public static final String IMG_ADDRESSEDITOR = "resources/icons/addresseditor.gif";
+
+ /** The relative path to the DN editor icon */
+ public static final String IMG_DNEDITOR = "resources/icons/dneditor.gif";
+
+ /** The relative path to the password editor icon */
+ public static final String IMG_PASSWORDEDITOR = "resources/icons/passwordeditor.gif";
+
+ /** The relative path to the generalized time editor icon */
+ public static final String IMG_INPLACE_GENERALIZEDTIMEEDITOR = "resources/icons/inplace_generalizedtimeeditor.gif";
+
+ /** The relative path to the object class editor icon */
+ public static final String IMG_OCDEDITOR = "resources/icons/objectclasseditor.png";
+
+ /** The relative path to the integer editor icon */
+ public static final String IMG_INTEGEREDITOR = "resources/icons/integereditor.gif";
+
+ /** The relative path to the administrative role editor icon */
+ public static final String IMG_ADMINISTRATIVEROLEEDITOR = "resources/icons/administrativeroleeditor.gif";
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/ValueEditorsConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,140 @@
+/*
+ * 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.valueeditors.address;
+
+
+import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.valueeditors.ValueEditorsActivator;
+import org.apache.directory.studio.valueeditors.ValueEditorsConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * The AddressDialog is used from the address value editor to edit an address.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddressDialog extends Dialog
+{
+
+ /** The initial address. */
+ private String initialAddress;
+
+ /** The return address. */
+ private String returnAddress;
+
+ /** The text widget. */
+ private Text text;
+
+
+ /**
+ * Creates a new instance of AddressDialog.
+ *
+ * @param parentShell the parent shell
+ * @param initialAddress the initial address
+ */
+ public AddressDialog( Shell parentShell, String initialAddress )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialAddress = initialAddress;
+ this.returnAddress = null;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( "Address Editor" );
+ shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_ADDRESSEDITOR ) );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ returnAddress = text.getText();
+ returnAddress = returnAddress.replaceAll( "\n", "\\$" );
+ returnAddress = returnAddress.replaceAll( "\r", "\\$" );
+ returnAddress = returnAddress.replaceAll( "\\$\\$", "\\$" );
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ // create composite
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ composite.setLayoutData( gd );
+
+ // text widget
+ text = new Text( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
+ text.setText( initialAddress.replaceAll( "\\$", BrowserCoreConstants.LINE_SEPARATOR ) );
+ // GridData gd = new GridData(GridData.GRAB_HORIZONTAL |
+ // GridData.HORIZONTAL_ALIGN_FILL);
+ gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ gd.heightHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH / 2 );
+ text.setLayoutData( gd );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the address.
+ *
+ * @return the address
+ */
+ public String getAddress()
+ {
+ return returnAddress;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.valueeditors.address;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for syntax 1.3.6.1.4.1.1466.115.121.1.41
+ * (Postal Address). In the displayed value the $ separators are replaced
+ * by commas. In the opened AddressDialog the $ separators are recplaced by
+ * line breaks.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddressValueEditor extends AbstractDialogStringValueEditor
+{
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the AddressDialog.
+ */
+ protected boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof String )
+ {
+ AddressDialog dialog = new AddressDialog( shell, ( String ) value );
+ if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getAddress() ) )
+ {
+ setValue( dialog.getAddress() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementatiosn replaces the $ separators by commas.
+ */
+ public String getDisplayValue( IValue value )
+ {
+ String displayValue = super.getDisplayValue( value );
+
+ if ( !showRawValues() )
+ {
+ displayValue = displayValue.replaceAll( "\\$", ", " );
+ }
+
+ return displayValue;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/address/AddressValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,174 @@
+/*
+ * 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.valueeditors.administrativerole;
+
+
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
+import org.apache.directory.studio.valueeditors.ValueEditorsActivator;
+import org.apache.directory.studio.valueeditors.ValueEditorsConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.DecoratedField;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IControlCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * This class provides a dialog to enter or select an administrative role.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AdministrativeRoleDialog extends Dialog
+{
+
+ /** The dialog title */
+ public static final String DIALOG_TITLE = "Administrative Role Editor";
+
+ /** The possible administrative role values. */
+ private static final String[] administrativeRoleValues = new String[]
+ { "autonomousArea", "accessControlSpecificArea", "accessControlInnerArea", "subschemaAdminSpecificArea",
+ "collectiveAttributeSpecificArea", "collectiveAttributeInnerArea", "triggerExecutionSpecificArea",
+ "triggerExecutionInnerArea" };
+
+ /** The initial value. */
+ private String initialValue;
+
+ /** The administrative role combo field. */
+ private DecoratedField administrativeRoleComboField;
+
+ /** The administrative role combo. */
+ private Combo administrativeRoleCombo;
+
+ /** The administrative role content proposal adapter */
+ private ContentProposalAdapter administrativeRoleCPA;
+
+ /** The return value. */
+ private String returnValue;
+
+
+ /**
+ * Creates a new instance of AdministrativeRoleDialog.
+ *
+ * @param parentShell the parent shell
+ * @param initialValue the initial value
+ */
+ public AdministrativeRoleDialog( Shell parentShell, String initialValue )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.initialValue = initialValue;
+ this.returnValue = null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( DIALOG_TITLE );
+ shell.setImage( ValueEditorsActivator.getDefault()
+ .getImage( ValueEditorsConstants.IMG_ADMINISTRATIVEROLEEDITOR ) );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ super.createButtonsForButtonBar( parent );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void okPressed()
+ {
+ returnValue = administrativeRoleCombo.getText();
+ super.okPressed();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ // create composite
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH );
+ composite.setLayoutData( gd );
+
+ // combo widget
+ final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+ administrativeRoleComboField = new DecoratedField( composite, SWT.NONE, new IControlCreator()
+ {
+ public Control createControl( Composite parent, int style )
+ {
+ Combo combo = BaseWidgetUtils.createCombo( parent, new String[0], -1, 1 );
+ combo.setVisibleItemCount( 20 );
+ return combo;
+ }
+ } );
+ administrativeRoleComboField.addFieldDecoration( fieldDecoration, SWT.TOP | SWT.LEFT, true );
+ administrativeRoleComboField.getLayoutControl()
+ .setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+ administrativeRoleCombo = ( Combo ) administrativeRoleComboField.getControl();
+ administrativeRoleCombo.setItems( administrativeRoleValues );
+ administrativeRoleCombo.setText( initialValue );
+
+ // content proposal adapter
+ administrativeRoleCPA = new ContentProposalAdapter( administrativeRoleCombo, new ComboContentAdapter(),
+ new ListContentProposalProvider( administrativeRoleCombo.getItems() ), null, null );
+ administrativeRoleCPA.setFilterStyle( ContentProposalAdapter.FILTER_NONE );
+ administrativeRoleCPA.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Gets the administrative role.
+ *
+ * @return the administrative role
+ */
+ public String getAdministrativeRole()
+ {
+ return returnValue;
+ }
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.valueeditors.administrativerole;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for attribute administrativeRole.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AdministrativeRoleValueEditor extends AbstractDialogStringValueEditor
+{
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the AdministrativeRoleDialog.
+ */
+ public boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof String )
+ {
+ AdministrativeRoleDialog dialog = new AdministrativeRoleDialog( shell, ( String ) value );
+ if ( dialog.open() == TextDialog.OK && !"".equals( dialog.getAdministrativeRole() ) )
+ {
+ setValue( dialog.getAdministrativeRole() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/administrativerole/AdministrativeRoleValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,160 @@
+/*
+ * 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.valueeditors.dn;
+
+
+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.IBrowserConnection;
+import org.apache.directory.studio.valueeditors.ValueEditorsActivator;
+import org.apache.directory.studio.valueeditors.ValueEditorsConstants;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+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.Shell;
+
+
+/**
+ * The DnDialog is used from the DN value editor to edit and select a DN.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+
+public class DnDialog extends Dialog
+{
+
+ /** The entry widget. */
+ private EntryWidget entryWidget;
+
+ /** The connection. */
+ private IBrowserConnection connection;
+
+ /** The dn. */
+ private LdapDN dn;
+
+
+ /**
+ * Creates a new instance of DnDialog.
+ *
+ * @param parentShell the parent shell
+ * @param connection the connection
+ * @param dn the dn
+ */
+ public DnDialog( Shell parentShell, IBrowserConnection connection, LdapDN dn )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.connection = connection;
+ this.dn = dn;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( "DN Editor" );
+ shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_DNEDITOR ) );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed()
+ {
+ dn = entryWidget.getDn();
+ entryWidget.saveDialogSettings();
+ super.okPressed();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createButtonBar( Composite parent )
+ {
+ Control control = super.createButtonBar( parent );
+ updateWidgets();
+ return control;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+
+ Composite composite = ( Composite ) super.createDialogArea( parent );
+ GridData gd = new GridData( GridData.FILL_BOTH );
+ gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ) * 3 / 2;
+ composite.setLayoutData( gd );
+
+ Composite innerComposite = BaseWidgetUtils.createColumnContainer( composite, 2, 1 );
+ entryWidget = new EntryWidget( connection, dn );
+ entryWidget.addWidgetModifyListener( new WidgetModifyListener()
+ {
+ public void widgetModified( WidgetModifyEvent event )
+ {
+ updateWidgets();
+ }
+ } );
+ entryWidget.createWidget( innerComposite );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Updates the widgets.
+ */
+ private void updateWidgets()
+ {
+ if ( getButton( IDialogConstants.OK_ID ) != null )
+ {
+ getButton( IDialogConstants.OK_ID ).setEnabled(
+ entryWidget.getDn() != null && !"".equals( entryWidget.getDn().toString() ) );
+ }
+ }
+
+
+ /**
+ * Gets the dn.
+ *
+ * @return the dn
+ */
+ public LdapDN getDn()
+ {
+ return dn;
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.valueeditors.dn;
+
+
+import javax.naming.InvalidNameException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.AbstractDialogStringValueEditor;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for syntax 1.3.6.1.4.1.1466.115.121.1.12
+ * (Distinguished Name).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DnValueEditor extends AbstractDialogStringValueEditor
+{
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the DnDialog.
+ */
+ protected boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+ if ( value != null && value instanceof DnValueEditorRawValueWrapper )
+ {
+ DnValueEditorRawValueWrapper wrapper = ( DnValueEditorRawValueWrapper ) value;
+ LdapDN dn;
+ try
+ {
+ dn = wrapper.dn != null ? new LdapDN( wrapper.dn ) : null;
+ }
+ catch ( InvalidNameException e )
+ {
+ dn = null;
+ }
+ DnDialog dialog = new DnDialog( shell, wrapper.connection, dn );
+ if ( dialog.open() == TextDialog.OK && dialog.getDn() != null )
+ {
+ setValue( dialog.getDn().toString() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns a DnValueEditorRawValueWrapper with the connection of
+ * the attribute hierarchy and a null DN if there are no values
+ * in attributeHierarchy.
+ *
+ * Returns a DnValueEditorRawValueWrapper with the connection of
+ * the attribute hierarchy and a DN if there is one value
+ * in attributeHierarchy.
+ */
+ public Object getRawValue( AttributeHierarchy attributeHierarchy )
+ {
+ if ( attributeHierarchy == null )
+ {
+ return null;
+ }
+ else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
+ {
+ IBrowserConnection connection = attributeHierarchy.getAttribute().getEntry().getBrowserConnection();
+ return new DnValueEditorRawValueWrapper( connection, null );
+ }
+ else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 )
+ {
+ IBrowserConnection connection = attributeHierarchy.getAttribute().getEntry().getBrowserConnection();
+ return new DnValueEditorRawValueWrapper( connection, getDisplayValue( attributeHierarchy ) );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns a DnValueEditorRawValueWrapper with the connection of
+ * the value and a DN build from the given value.
+ */
+ public Object getRawValue( IValue value )
+ {
+ Object o = super.getRawValue( value );
+ if ( o != null && o instanceof String )
+ {
+ IBrowserConnection connection = value.getAttribute().getEntry().getBrowserConnection();
+ return new DnValueEditorRawValueWrapper( connection, ( String ) o );
+ }
+
+ return null;
+ }
+
+
+ /**
+ * The DnValueEditorRawValueWrapper is used to pass contextual
+ * information to the opened DnDialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ private class DnValueEditorRawValueWrapper
+ {
+ /** The connection, used in DnDialog to browse for an entry */
+ private IBrowserConnection connection;
+
+ /** The DN, used as initial value in DnDialog */
+ private String dn;
+
+
+ /**
+ * Creates a new instance of DnValueEditorRawValueWrapper.
+ *
+ * @param connection the connection
+ * @param dn the DN
+ */
+ private DnValueEditorRawValueWrapper( IBrowserConnection connection, String dn )
+ {
+ this.connection = connection;
+ this.dn = dn;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return dn == null ? "" : dn;
+ }
+
+ }
+
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/dn/DnValueEditor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,782 @@
+/*
+ * 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.valueeditors.image;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
+import org.apache.directory.studio.ldapbrowser.common.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.valueeditors.ValueEditorsActivator;
+import org.apache.directory.studio.valueeditors.ValueEditorsConstants;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+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.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The ImageDialog is used from the image value editor to view the current image
+ * and to select a new image.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImageDialog extends Dialog
+{
+
+ private static final int MAX_WIDTH = 250;
+
+ private static final int MAX_HEIGHT = 250;
+
+ private static final int CURRENT_TAB = 0;
+
+ private static final int NEW_TAB = 1;
+
+ private static final String SELECTED_TAB_DIALOGSETTINGS_KEY = ImageDialog.class.getName() + ".tab";
+
+ private TabFolder tabFolder;
+
+ private TabItem currentTab;
+
+ private TabItem newTab;
+
+ private byte[] currentImageRawData;
+
+ private Image currentImage;
+
+ private Composite currentImageContainer;
+
+ private Label currentImageLabel;
+
+ private Text currentImageTypeText;
+
+ private Text currentImageWidthText;
+
+ private Text currentImageHeightText;
+
+ private Text currentImageSizeText;
+
+ private Button currentImageSaveButton;
+
+ private byte[] newImageRawData;
+
+ private Image newImage;
+
+ private Composite newImageContainer;
+
+ private Label newImageLabel;
+
+ private Text newImageTypeText;
+
+ private Text newImageWidthText;
+
+ private Text newImageHeightText;
+
+ private Text newImageSizeText;
+
+ private Text newImageFilenameText;
+
+ private Button newImageBrowseButton;
+
+ private int requiredImageType;
+
+ private byte[] newImageRawDataInRequiredFormat;
+
+ private Button okButton;
+
+
+ /**
+ * Creates a new instance of ImageDialog.
+ *
+ * @param parentShell the parent shell
+ * @param currentImageRawData the current image raw data
+ * @param requiredImageType the required image type
+ */
+ public ImageDialog( Shell parentShell, byte[] currentImageRawData, int requiredImageType )
+ {
+ super( parentShell );
+ super.setShellStyle( super.getShellStyle() | SWT.RESIZE );
+ this.currentImageRawData = currentImageRawData;
+ this.requiredImageType = requiredImageType;
+
+ newImageRawDataInRequiredFormat = null;
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ public boolean close()
+ {
+ if ( currentImage != null && !currentImage.isDisposed() )
+ {
+ currentImage.dispose();
+ }
+ if ( newImage != null && !newImage.isDisposed() )
+ {
+ newImage.dispose();
+ }
+
+ // save selected tab to dialog settings
+ ValueEditorsActivator.getDefault().getDialogSettings().put( SELECTED_TAB_DIALOGSETTINGS_KEY,
+ tabFolder.getSelectionIndex() );
+
+ return super.close();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed( int buttonId )
+ {
+ if ( buttonId == IDialogConstants.OK_ID )
+ {
+ if ( newImageRawData != null )
+ {
+ try
+ {
+ ImageData imageData = new ImageData( new ByteArrayInputStream( newImageRawData ) );
+ if ( imageData.type != requiredImageType )
+ {
+ ImageLoader imageLoader = new ImageLoader();
+ imageLoader.data = new ImageData[]
+ { imageData };
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ imageLoader.save( baos, requiredImageType );
+ newImageRawDataInRequiredFormat = baos.toByteArray();
+ }
+ else
+ {
+ newImageRawDataInRequiredFormat = newImageRawData;
+ }
+ }
+ catch ( SWTException swte )
+ {
+ newImageRawDataInRequiredFormat = null;
+ }
+ }
+ }
+ else
+ {
+ newImageRawDataInRequiredFormat = null;
+ }
+
+ super.buttonPressed( buttonId );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell shell )
+ {
+ super.configureShell( shell );
+ shell.setText( "Image Editor" );
+ shell.setImage( ValueEditorsActivator.getDefault().getImage( ValueEditorsConstants.IMG_IMAGEEDITOR ) );
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar( Composite parent )
+ {
+ okButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+ createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+
+ // load dialog settings
+ try
+ {
+ int tabIndex = ValueEditorsActivator.getDefault().getDialogSettings().getInt( SELECTED_TAB_DIALOGSETTINGS_KEY );
+ tabFolder.setSelection( tabIndex );
+ }
+ catch ( Exception e )
+ {
+ }
+
+ // update on load
+ updateTabFolder();
+ }
+
+
+ /**
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent )
+ {
+ Composite composite = ( 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 );
+ composite.setLayoutData( gd1 );
+
+ tabFolder = new TabFolder( composite, SWT.TOP );
+ GridLayout mainLayout = new GridLayout();
+ mainLayout.marginWidth = 0;
+ mainLayout.marginHeight = 0;
+ tabFolder.setLayout( mainLayout );
+ tabFolder.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ tabFolder.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent e )
+ {
+ updateTabFolder();
+ }
+ } );
+
+ // current image
+ if ( currentImageRawData != null && currentImageRawData.length > 0 )
+ {
+ currentImageContainer = new Composite( tabFolder, SWT.NONE );
+ GridLayout currentLayout = new GridLayout( 1, false );
+ currentLayout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
+ currentLayout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
+ currentLayout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
+ currentLayout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING );
+ currentImageContainer.setLayout( currentLayout );
+ currentImageContainer.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ currentImageLabel = createImageLabel( currentImageContainer );
+
+ Composite currentImageInfoContainer = createImageInfoContainer( currentImageContainer );
+ currentImageTypeText = createImageInfo( currentImageInfoContainer, "Image Type:" );
+ currentImageSizeText = createImageInfo( currentImageInfoContainer, "Image Size:" );
+ currentImageWidthText = createImageInfo( currentImageInfoContainer, "Image Width:" );
+ currentImageHeightText = createImageInfo( currentImageInfoContainer, "Image Height:" );
+
+ Composite currentImageSaveContainer = createImageInfoContainer( currentImageContainer );
+ Label dummyLabel = BaseWidgetUtils.createLabel( currentImageSaveContainer, "", 1 );
+ GridData gd = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+ dummyLabel.setLayoutData( gd );
+ currentImageSaveButton = createButton( currentImageSaveContainer, "Save..." );
+ currentImageSaveButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ FileDialog fileDialog = new FileDialog( ImageDialog.this.getShell(), SWT.SAVE );
+ fileDialog.setText( "Save Image" );
+ fileDialog.setFilterExtensions( new String[]
+ { "*.jpg" } );
+ String returnedFileName = fileDialog.open();
+ if ( returnedFileName != null )
+ {
+ try
+ {
+ File file = new File( returnedFileName );
+ FileOutputStream out = new FileOutputStream( file );
+ out.write( currentImageRawData );
+ out.flush();
+ out.close();
+ }
+ catch ( FileNotFoundException e )
+ {
+
+ BrowserCommonActivator.getDefault()
+ .getExceptionHandler().handleException(
+ new Status( IStatus.ERROR, ValueEditorsActivator.PLUGIN_ID, IStatus.ERROR,
+ "Can't write to file", e ) );
+ }
+ catch ( IOException e )
+ {
+ BrowserCommonActivator.getDefault()
+ .getExceptionHandler().handleException(
+ new Status( IStatus.ERROR, ValueEditorsActivator.PLUGIN_ID, IStatus.ERROR,
+ "Can't write to file", e ) );
+ }
+ }
+ }
+ } );
+
+ currentTab = new TabItem( tabFolder, SWT.NONE );
+ currentTab.setText( "Current Image" );
+ currentTab.setControl( currentImageContainer );
+ }
+
+ // new image
+ newImageContainer = new Composite( tabFolder, SWT.NONE );
+ GridLayout newLayout = new GridLayout( 1, false );
+ newLayout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
+ newLayout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
+ newLayout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
+ newLayout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING );
+ newImageContainer.setLayout( newLayout );
+ newImageContainer.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+
+ newImageLabel = createImageLabel( newImageContainer );
+
+ Composite newImageInfoContainer = createImageInfoContainer( newImageContainer );
+ newImageTypeText = createImageInfo( newImageInfoContainer, "Image Type:" );
+ newImageSizeText = createImageInfo( newImageInfoContainer, "Image Size:" );
+ newImageWidthText = createImageInfo( newImageInfoContainer, "Image Width:" );
+ newImageHeightText = createImageInfo( newImageInfoContainer, "Image Height:" );
+
+ Composite newImageSelectContainer = createImageInfoContainer( newImageContainer );
+ newImageFilenameText = new Text( newImageSelectContainer, SWT.SINGLE | SWT.BORDER );
+ GridData gd = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+ newImageFilenameText.setLayoutData( gd );
+ newImageFilenameText.addModifyListener( new ModifyListener()
+ {
+ public void modifyText( ModifyEvent e )
+ {
+ updateNewImageGroup();
+ }
+ } );
+ newImageBrowseButton = createButton( newImageSelectContainer, "Browse..." );
+ newImageBrowseButton.addSelectionListener( new SelectionAdapter()
+ {
+ public void widgetSelected( SelectionEvent event )
+ {
+ FileDialog fileDialog = new FileDialog( ImageDialog.this.getShell(), SWT.OPEN );
+ fileDialog.setText( "Select Image" );
+ // fileDialog.setFilterExtensions(IMAGE_FILE_EXTENSIONS);
+ fileDialog.setFileName( new File( newImageFilenameText.getText() ).getName() );
+ fileDialog.setFilterPath( new File( newImageFilenameText.getText() ).getParent() );
+ String returnedFileName = fileDialog.open();
+ if ( returnedFileName != null )
+ {
+ newImageFilenameText.setText( returnedFileName );
+ }
+ }
+ } );
+
+ newTab = new TabItem( tabFolder, SWT.NONE );
+ newTab.setText( "New Image" );
+ newTab.setControl( newImageContainer );
+
+ applyDialogFont( composite );
+ return composite;
+ }
+
+
+ /**
+ * Update current image tab.
+ */
+ private void updateCurrentImageGroup()
+ {
+ if ( currentTab != null )
+ {
+ if ( currentImage != null && !currentImage.isDisposed() )
+ {
+ currentImage.dispose();
+ currentImage = null;
+ }
+
+ if ( currentImageRawData != null && currentImageRawData.length > 0 )
+ {
+ try
+ {
+ ImageData imageData = new ImageData( new ByteArrayInputStream( currentImageRawData ) );
+ currentImage = new Image( getShell().getDisplay(), resizeImage( imageData ) );
+ currentImageLabel.setText( "" );
+ currentImageLabel.setImage( currentImage );
+ currentImageTypeText.setText( getImageType( imageData.type ) );
+ currentImageSizeText.setText( getSizeString( currentImageRawData.length ) );
+ currentImageWidthText.setText( imageData.width + " Pixel" );
+ currentImageHeightText.setText( imageData.height + " Pixel" );
+ }
+ catch ( SWTException swte )
+ {
+ currentImageLabel.setImage( null );
+ currentImageLabel.setText( " Unsupported format " );
+ currentImageTypeText.setText( "Unsupported format" );
+ currentImageSizeText.setText( getSizeString( currentImageRawData.length ) );
+ currentImageWidthText.setText( "-" );
+ currentImageHeightText.setText( "-" );
+ }
+ }
+ else
+ {
+ currentImageLabel.setImage( null );
+ currentImageLabel.setText( " No Image " );
+ currentImageTypeText.setText( "No Image" );
+ currentImageSizeText.setText( "-" );
+ currentImageWidthText.setText( "-" );
+ currentImageHeightText.setText( "-" );
+ }
+
+ currentImageSaveButton.setEnabled( currentImageRawData != null && currentImageRawData.length > 0 );
+ }
+ }
+
+
+ /**
+ * Update new image tab.
+ */
+ private void updateNewImageGroup()
+ {
+ if ( newImage != null && !newImage.isDisposed() )
+ {
+ newImage.dispose();
+ newImage = null;
+ }
+
+ if ( !"".equals( newImageFilenameText.getText() ) )
+ {
+ try
+ {
+ File file = new File( newImageFilenameText.getText() );
+ FileInputStream in = new FileInputStream( file );
+ ByteArrayOutputStream out = new ByteArrayOutputStream( ( int ) file.length() );
+ byte[] buf = new byte[4096];
+ int len;
+ while ( ( len = in.read( buf ) ) > 0 )
+ {
+ out.write( buf, 0, len );
+ }
+ newImageRawData = out.toByteArray();
+ out.close();
+ in.close();
+ }
+ catch ( FileNotFoundException e )
+ {
+ newImageRawData = null;
+ newImageLabel.setImage( null );
+ newImageLabel.setText( " Error: File not found " );
+ newImageTypeText.setText( "-" );
+ newImageSizeText.setText( "-" );
+ newImageWidthText.setText( "-" );
+ newImageHeightText.setText( "-" );
+ }
+ catch ( IOException e )
+ {
+ newImageRawData = null;
+ newImageLabel.setImage( null );
+ newImageLabel.setText( " Error: Can't read file (" + e.getMessage() + ") " );
+ newImageTypeText.setText( "-" );
+ newImageSizeText.setText( "-" );
+ newImageWidthText.setText( "-" );
+ newImageHeightText.setText( "-" );
+ }
+ }
+ else
+ {
+ newImageRawData = null;
+ newImageLabel.setImage( null );
+ newImageLabel.setText( " No image selected " );
+ newImageTypeText.setText( "-" );
+ newImageSizeText.setText( "-" );
+ newImageWidthText.setText( "-" );
+ newImageHeightText.setText( "-" );
+ }
+
+ if ( newImageRawData != null && newImageRawData.length > 0 )
+ {
+ try
+ {
+ ImageData imageData = new ImageData( new ByteArrayInputStream( newImageRawData ) );
+ newImage = new Image( getShell().getDisplay(), resizeImage( imageData ) );
+ newImageLabel.setImage( newImage );
+ newImageTypeText.setText( getImageType( imageData.type ) );
+ if ( imageData.type != requiredImageType )
+ {
+ newImageTypeText.setText( newImageTypeText.getText() + " (will be converted to "
+ + getImageType( requiredImageType ) + ")" );
+ }
+ newImageSizeText.setText( getSizeString( newImageRawData.length ) );
+ newImageWidthText.setText( imageData.width + " Pixel" );
+ newImageHeightText.setText( imageData.height + " Pixel" );
+ }
+ catch ( SWTException swte )
+ {
+ newImageLabel.setImage( null );
+ newImageLabel.setText( " Unsupported format " );
+ newImageTypeText.setText( "Unsupported format" );
+ newImageSizeText.setText( getSizeString( newImageRawData.length ) );
+ newImageWidthText.setText( "-" );
+ newImageHeightText.setText( "-" );
+ }
+ }
+
+ if ( okButton != null )
+ {
+ okButton.setEnabled( newImage != null );
+ }
+
+ newImageLabel.getParent().layout();
+ newImageTypeText.getParent().layout();
+ }
+
+
+ /**
+ * Update tab folder and the tabs.
+ */
+ private void updateTabFolder()
+ {
+ if ( currentImageSaveButton != null )
+ {
+ if ( tabFolder.getSelectionIndex() == CURRENT_TAB )
+ {
+ currentImageSaveButton.setFocus();
+ }
+ updateCurrentImageGroup();
+ }
+
+ if ( newImageBrowseButton != null )
+ {
+ if ( tabFolder.getSelectionIndex() == NEW_TAB || currentImageSaveButton == null )
+ {
+ newImageBrowseButton.setFocus();
+ }
+ updateNewImageGroup();
+ }
+ }
+
+
+ /**
+ * Resizes the image.
+ *
+ * @param imageData the image data to resize
+ *
+ * @return the resized image data
+ */
+ private ImageData resizeImage( ImageData imageData )
+ {
+ double widthScaleFactor = 1.0;
+ if ( imageData.width > MAX_WIDTH )
+ {
+ widthScaleFactor = ( double ) MAX_WIDTH / imageData.width;
+ }
+ double heightScaleFactor = 1.0;
+ if ( imageData.height > MAX_HEIGHT )
+ {
+ heightScaleFactor = ( double ) MAX_HEIGHT / imageData.height;
+ }
+
+ if ( heightScaleFactor < widthScaleFactor )
+ {
+ imageData = imageData.scaledTo(
+ convertHorizontalDLUsToPixels( ( int ) ( imageData.width * heightScaleFactor ) ),
+ convertHorizontalDLUsToPixels( ( int ) ( imageData.height * heightScaleFactor ) ) );
+ }
+ else
+ {
+ imageData = imageData.scaledTo(
+ convertHorizontalDLUsToPixels( ( int ) ( imageData.width * widthScaleFactor ) ),
+ convertHorizontalDLUsToPixels( ( int ) ( imageData.height * widthScaleFactor ) ) );
+ }
+
+ return imageData;
+ }
+
+
+ /**
+ * Creates the image label.
+ *
+ * @param parent the parent
+ *
+ * @return the image label
+ */
+ private Label createImageLabel( Composite parent )
+ {
+ Composite labelComposite = new Composite( parent, SWT.BORDER );
+ GridLayout gl = new GridLayout( 1, true );
+ labelComposite.setLayout( gl );
+ GridData gd = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+ gd.widthHint = MAX_WIDTH;
+ gd.heightHint = MAX_HEIGHT;
+ labelComposite.setLayoutData( gd );
+ labelComposite.setBackground( getShell().getDisplay().getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW ) );
+
+ Label imageLabel = new Label( labelComposite, SWT.CENTER );
+ gd = new GridData( SWT.CENTER, SWT.CENTER, true, true );
+ imageLabel.setLayoutData( gd );
+ return imageLabel;
+ }
+
+
+ /**
+ * Creates the image info container.
+ *
+ * @param parent the parent
+ *
+ * @return the image info container
+ */
+ private Composite createImageInfoContainer( Composite parent )
+ {
+ Composite imageInfoContainer = new Composite( parent, SWT.NONE );
+ GridLayout gl = new GridLayout( 2, false );
+ gl.marginHeight = gl.marginWidth = 0;
+ imageInfoContainer.setLayout( gl );
+ imageInfoContainer.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ return imageInfoContainer;
+ }
+
+
+ /**
+ * Creates the image info.
+ *
+ * @param label the label
+ * @param parent the parent
+ *
+ * @return the image info
+ */
+ private Text createImageInfo( Composite parent, String label )
+ {
+ BaseWidgetUtils.createLabel( parent, label, 1 );
+ Text text = BaseWidgetUtils.createLabeledText( parent, "", 1 );
+ return text;
+ }
+
+
+ /**
+ * Creates the button.
+ *
+ * @param label the label
+ * @param parent the parent
+ *
+ * @return the button
+ */
+ private Button createButton( Composite parent, String label )
+ {
+ Button button = BaseWidgetUtils.createButton( parent, label, 1 );
+ return button;
+ }
+
+
+ /**
+ * Gets the size string.
+ *
+ * @param length the length
+ *
+ * @return the size string
+ */
+ private static String getSizeString( int length )
+ {
+ if ( length > 1000000 )
+ {
+ return ( length / 1000000 ) + " MB (" + length + " bytes)";
+ }
+ else if ( length > 1000 )
+ {
+ return ( length / 1000 ) + " KB (" + length + " bytes)";
+ }
+ else
+ {
+ return length + " bytes";
+ }
+ }
+
+
+ /**
+ * Gets the image info.
+ *
+ * @param imageRawData the image raw data
+ *
+ * @return the image info
+ */
+ public static String getImageInfo( byte[] imageRawData )
+ {
+
+ if ( imageRawData == null )
+ {
+ return "NULL";
+ }
+
+ String text = "Image (" + imageRawData.length + " Bytes)";
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream( imageRawData );
+ ImageData imageData = new ImageData( bais );
+
+ String typePrefix = getImageType( imageData.type );
+ if ( !"".equals( typePrefix ) )
+ typePrefix += "-";
+
+ text = typePrefix + "Image (" + imageData.width + "x" + imageData.height + " Pixel, " + imageRawData.length
+ + " Bytes)";
+ }
+ catch ( SWTException swte )
+ {
+ text = "Invalid Image (" + imageRawData.length + " Bytes)";
+ }
+ return text;
+ }
+
+
+ /**
+ * Gets the image type.
+ *
+ * @param swtCode the swt code
+ *
+ * @return the image type
+ */
+ private static String getImageType( int swtCode )
+ {
+ String type = "";
+
+ if ( swtCode == SWT.IMAGE_JPEG )
+ {
+ type = "JPEG";
+ }
+ else if ( swtCode == SWT.IMAGE_GIF )
+ {
+ type = "GIF";
+ }
+ else if ( swtCode == SWT.IMAGE_PNG )
+ {
+ type = "PNG";
+ }
+ else if ( swtCode == SWT.IMAGE_BMP || swtCode == SWT.IMAGE_BMP_RLE )
+ {
+ type = "BMP";
+ }
+
+ return type;
+ }
+
+
+ /**
+ * Gets the iimage data in required format.
+ *
+ * @return Returns the image data in required format or null.
+ */
+ public byte[] getNewImageRawData()
+ {
+ return newImageRawDataInRequiredFormat;
+ }
+}
Propchange: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageDialog.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageValueEditor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageValueEditor.java?rev=592029&view=auto
==============================================================================
--- directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageValueEditor.java (added)
+++ directory/sandbox/felixk/studio-valueeditors/src/main/java/org/apache/directory/studio/valueeditors/image/ImageValueEditor.java Mon Nov 5 07:04:58 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.valueeditors.image;
+
+
+import org.apache.directory.studio.ldapbrowser.common.dialogs.TextDialog;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.AbstractDialogBinaryValueEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Implementation of IValueEditor for syntax 1.3.6.1.4.1.1466.115.121.1.28
+ * (JPEG).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ImageValueEditor extends AbstractDialogBinaryValueEditor
+{
+
+ /**
+ * {@inheritDoc}
+ *
+ * This implementation opens the ImageDialog.
+ */
+ protected boolean openDialog( Shell shell )
+ {
+ Object value = getValue();
+
+ if ( value != null && value instanceof byte[] )
+ {
+ byte[] currentImageData = ( byte[] ) value;
+
+ ImageDialog dialog = new ImageDialog( shell, currentImageData, SWT.IMAGE_JPEG );
+ if ( dialog.open() == TextDialog.OK && dialog.getNewImageRawData() != null )
+ {
+ setValue( dialog.getNewImageRawData() );
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * Returns the image info text created by
+ * ImageDialog.getImageInfo().
+ */
+ public String getDisplayValue( IValue value )
+ {
+ if ( showRawValues() )
+ {
+ return getPrintableString( value );
+ }
+ else
+ {
+ if ( value == null )
+ {
+ return "NULL";
+ }
+ else if ( value.isBinary() )
+ {
+ byte[] data = value.getBinaryValue();
+ String text = ImageDialog.getImageInfo( data );
+ return text;
+ }
+ else
+ {
+ return "Invalid Image Data";
+ }
+ }
+ }
+
+}