Anonymous avatar Anonymous committed b386a7c

fixed the DND bug for items with spaces or other special characters

Comments (0)

Files changed (5)

org.openscada.da.ui.connection/META-INF/MANIFEST.MF

 Bundle-ManifestVersion: 2
 Bundle-Name: openSCADA DA Connection UI
 Bundle-SymbolicName: org.openscada.da.ui.connection;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
 Bundle-Activator: org.openscada.da.ui.connection.Activator
 Bundle-Vendor: openSCADA.org
 Export-Package: org.openscada.da.ui.connection;version="1.1.0";uses:="org.eclipse.core.runtime,org.eclipse.ui.plugin,org.osgi.framework",

org.openscada.da.ui.connection/src/org/openscada/da/ui/connection/dnd/CommonDragAdapterAssistant.java

 /*
  * This file is part of the OpenSCADA project
+ * 
  * Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
+ * Copyright (C) 2013 IBH SYSTEMS GmbH (http://ibh-systems.com)
  *
  * OpenSCADA is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License version 3
 
 package org.openscada.da.ui.connection.dnd;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.Collection;
 
 import org.eclipse.jface.viewers.IStructuredSelection;
             {
                 sb.append ( NL );
             }
-            sb.append ( item.getConnectionString () + "#" + item.getId () );
+            sb.append ( item.getConnectionString () );
+            sb.append ( '#' );
+            try
+            {
+                sb.append ( URLEncoder.encode ( item.getId (), "UTF-8" ) );
+            }
+            catch ( final UnsupportedEncodingException e )
+            {
+                sb.append ( item.getId () );
+            }
 
             i++;
         }

org.openscada.da.ui.widgets/META-INF/MANIFEST.MF

 Bundle-ManifestVersion: 2
 Bundle-Name: openSCADA DA UI Widgets
 Bundle-SymbolicName: org.openscada.da.ui.widgets;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
 Bundle-Activator: org.openscada.da.ui.widgets.Activator
 Bundle-Vendor: openSCADA.org
 Export-Package: org.openscada.da.ui.widgets.realtime;version="1.1.0";

org.openscada.da.ui.widgets/src/org/openscada/da/ui/widgets/realtime/ItemDropAdapter.java

 /*
  * This file is part of the OpenSCADA project
+ * 
  * Copyright (C) 2006-2012 TH4 SYSTEMS GmbH (http://th4-systems.com)
+ * Copyright (C) 2013 IBH SYSTEMS GmbH (http://ibh-systems.com)
  *
  * OpenSCADA is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License version 3
 
 package org.openscada.da.ui.widgets.realtime;
 
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLDecoder;
 
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
                 if ( uri.getScheme () == null )
                 {
                     final String[] stoks = tok.split ( "#" );
-                    final Item item = new Item ( stoks[0], stoks[1], Type.ID );
+                    final Item item = new Item ( stoks[0], decodeItemId ( stoks[1] ), Type.ID );
                     dropItem ( item, viewer );
                 }
                 else if ( uri.getFragment () != null )
                 {
                     final String[] stoks = tok.split ( "#", 2 );
-                    final Item item = new Item ( stoks[0], uri.getFragment (), Type.URI );
+                    final Item item = new Item ( stoks[0], decodeItemId ( uri.getFragment () ), Type.URI );
                     dropItem ( item, viewer );
                 }
 
             catch ( final URISyntaxException e )
             {
                 final String[] stoks = tok.split ( "#" );
-                final Item item = new Item ( stoks[0], stoks[1], Type.ID );
+                final Item item = new Item ( stoks[0], decodeItemId ( stoks[1] ), Type.ID );
                 dropItem ( item, viewer );
             }
         }
     }
 
+    private String decodeItemId ( final String itemId )
+    {
+        try
+        {
+            return URLDecoder.decode ( itemId, "UTF-8" );
+        }
+        catch ( final UnsupportedEncodingException e )
+        {
+            return itemId;
+        }
+    }
+
     private void dropItems ( final Item[] items )
     {
         final TreeViewer viewer = (TreeViewer)getViewer ();

org.openscada.da.ui.widgets/src/org/openscada/da/ui/widgets/realtime/RealtimeListDragSourceListener.java

 /*
  * This file is part of the OpenSCADA project
+ * 
  * Copyright (C) 2006-2010 TH4 SYSTEMS GmbH (http://th4-systems.com)
+ * Copyright (C) 2013 IBH SYSTEMS GmbH (http://ibh-systems.com)
  *
  * OpenSCADA is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License version 3
 
 package org.openscada.da.ui.widgets.realtime;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
         this.viewer = viewer;
     }
 
+    @Override
     public void dragFinished ( final DragSourceEvent event )
     {
     }
 
+    @Override
     public void dragSetData ( final DragSourceEvent event )
     {
         try
         {
             event.doit = false;
         }
-
     }
 
     protected void setItemUriData ( final DragSourceEvent event, final IStructuredSelection selection )
 
             sb.append ( item.getConnectionString () );
             sb.append ( "#" ); //$NON-NLS-1$
-            sb.append ( item.getId () );
+            try
+            {
+                sb.append ( URLEncoder.encode ( item.getId (), "UTF-8" ) );
+            }
+            catch ( final UnsupportedEncodingException e )
+            {
+                sb.append ( item.getId () );
+            }
 
             cnt++;
         }
         event.data = sb.toString ();
     }
 
+    @Override
     public void dragStart ( final DragSourceEvent event )
     {
         event.doit = false;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.