You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2012/05/04 16:17:54 UTC

svn commit: r1333981 - in /directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem: CopyOfPathEditorInput.java PathEditorInput.java

Author: pamarcelot
Date: Fri May  4 14:17:54 2012
New Revision: 1333981

URL: http://svn.apache.org/viewvc?rev=1333981&view=rev
Log:
Part of a fix for DIRSTUDIO-811 (Review and remove any source file under Eclipse Public License (EPL) v 1.0).

Added:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/CopyOfPathEditorInput.java
Removed:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/PathEditorInput.java

Added: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/CopyOfPathEditorInput.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/CopyOfPathEditorInput.java?rev=1333981&view=auto
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/CopyOfPathEditorInput.java (added)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/filesystem/CopyOfPathEditorInput.java Fri May  4 14:17:54 2012
@@ -0,0 +1,183 @@
+/*
+ *  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.common.ui.filesystem;
+
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.ILocationProvider;
+
+
+/**
+ * This class defines an editor input based on the local file system path of a file.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CopyOfPathEditorInput implements IPathEditorInput, ILocationProvider
+{
+    /** The path */
+    private IPath path;
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean exists()
+    {
+        if ( path != null )
+        {
+            return path.toFile().exists();
+        }
+
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getAdapter( Class adapter )
+    {
+        if ( ILocationProvider.class.equals( adapter ) )
+        {
+            return this;
+        }
+
+        return Platform.getAdapterManager().getAdapter( this, adapter );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ImageDescriptor getImageDescriptor()
+    {
+        return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor( path.toString() );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName()
+    {
+        if ( path != null )
+        {
+            return path.toFile().getName();
+        }
+
+        return "";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPath getPath()
+    {
+        if ( path != null )
+        {
+            return path;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPath getPath( Object element )
+    {
+        if ( element instanceof CopyOfPathEditorInput )
+        {
+            return ( ( CopyOfPathEditorInput ) element ).getPath();
+        }
+
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public IPersistableElement getPersistable()
+    {
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getToolTipText()
+    {
+        if ( path != null )
+        {
+            return path.makeRelative().toOSString();
+        }
+
+        return "";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int hashCode()
+    {
+        if ( path != null )
+        {
+            return path.hashCode();
+        }
+
+        return super.hashCode();
+    }
+
+
+    /** 
+     * {@inheritDoc}
+     */
+    public boolean equals( Object o )
+    {
+        if ( path != null )
+        {
+            // Shortcut
+            if ( this == o )
+            {
+                return true;
+            }
+
+            if ( o instanceof CopyOfPathEditorInput )
+            {
+                CopyOfPathEditorInput input = ( CopyOfPathEditorInput ) o;
+
+                return path.equals( input.path );
+            }
+        }
+
+        return super.equals( o );
+    }
+}