Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2015-06-10 11:58:46 +0000
committerVincent Lorenzo2015-06-10 16:36:50 +0000
commitbaf3e23fe043af3b1b691ef18ce61d3d12809283 (patch)
tree51cbcc349b4146806fe3df4f48e95a73c6e79b50
parentda05af7cd982f59ee563b614277ef4d7dfffb158 (diff)
downloadorg.eclipse.papyrus-baf3e23fe043af3b1b691ef18ce61d3d12809283.tar.gz
org.eclipse.papyrus-baf3e23fe043af3b1b691ef18ce61d3d12809283.tar.xz
org.eclipse.papyrus-baf3e23fe043af3b1b691ef18ce61d3d12809283.zip
bug 469829: [Tree Table] Paste is broken in TreeTable https://bugs.eclipse.org/bugs/show_bug.cgi?id=469829 : a first commit to avoid the invalid thread access for the user
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java11
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java9
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java9
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java9
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/EventListHelper.java116
5 files changed, 63 insertions, 91 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index eeb37565572..834598b91c2 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -470,16 +470,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
// we refresh the table after each command, only when it is visible
// its allows to refresh the text and the appearance of the table
// this refresh doesn't manage the add/remove axis
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (nattable != null && !nattable.isDisposed() && nattable.isVisible()) {
- nattable.doCommand(new VisualRefreshCommand());
- }
- }
- });
-
+ refreshNatTable();
}
};
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java
index 4e8909cfabf..6d2150d6445 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java
@@ -79,6 +79,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
+import org.eclipse.ui.progress.UIJob;
/**
* Paste command manager for the paste in the table
@@ -289,10 +290,10 @@ public class PasteEObjectAxisInNattableCommandProvider {
sharedMap.clear();
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, monitor, sharedMap);
if (pasteCommand == null) {
@@ -335,10 +336,10 @@ public class PasteEObjectAxisInNattableCommandProvider {
}
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromStringCommandInAttachedMode(contextEditingDomain, tableEditingDomain, monitor);
if (pasteCommand == null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
index 9a6403abb72..fbf9e4e54d3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
@@ -65,6 +65,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
+import org.eclipse.ui.progress.UIJob;
/**
* Paste command manager for the paste in the table
@@ -216,10 +217,10 @@ public class PasteEObjectAxisInTableCommandProvider {
sharedMap.clear();
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, monitor, sharedMap);
if (pasteCommand == null) {
@@ -267,10 +268,10 @@ public class PasteEObjectAxisInTableCommandProvider {
}
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromFromStringCommand(contextEditingDomain, tableEditingDomain, monitor);
if (pasteCommand == null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
index a887da6c11e..c9b5cf626b8 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
@@ -94,6 +94,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
+import org.eclipse.ui.progress.UIJob;
/**
* Paste command manager for the paste in the table
@@ -378,10 +379,10 @@ public class PasteEObjectTreeAxisInNattableCommandProvider {
sharedMap.clear();
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, monitor, sharedMap);
if (pasteCommand == null) {
@@ -424,10 +425,10 @@ public class PasteEObjectTreeAxisInNattableCommandProvider {
}
} else {
// we create a job in order to don't freeze the UI
- final Job job = new Job(pasteJobName) {
+ final UIJob job = new UIJob(pasteJobName) {
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
final ICommand pasteCommand = getPasteFromStringCommandInAttachedMode(contextEditingDomain, tableEditingDomain, monitor);
if (pasteCommand == null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/EventListHelper.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/EventListHelper.java
index 5b6dca05517..264c47271fe 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/EventListHelper.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/EventListHelper.java
@@ -37,13 +37,40 @@ public class EventListHelper {
* an object to add to the event list
*/
public static final void addToEventList(final EventList<Object> list, final Object object) {
- // since the bug fix for 463764: [Tree Table] Impossible to sort columns, we use SortedList. so the order is given by the comparator
- // it is not yet required to check the parent location to add object to the list.
- // I remove the check to know if object was already in the list, because if true, there is a bug to manage in another location
+ list.getReadWriteLock().readLock().lock();
+ try {
+ if (list.contains(object)) {
+ return;
+ }
+ } catch (Exception e1) {
+ Activator.log.error(e1);
+ } finally {
+ list.getReadWriteLock().readLock().unlock();
+ }
+ int parentIndex = -1;
+ // 1. get the index to add the element
+ if (object instanceof ITreeItemAxis) {
+ IAxis parent = ((ITreeItemAxis) object).getParent();
+ if (parent != null) {
+ try {
+ list.getReadWriteLock().readLock().lock();
+ parentIndex = list.indexOf(parent);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ } finally {
+ list.getReadWriteLock().readLock().unlock();
+ }
+ }
+ }
+
list.getReadWriteLock().writeLock().lock();
try {
- list.add(object);
+ if (parentIndex != -1) {
+ list.add(parentIndex + 1, object);
+ } else {
+ list.add(object);
+ }
} catch (Exception e) {
Activator.log.error(e);
} finally {
@@ -51,58 +78,6 @@ public class EventListHelper {
}
}
-
-
- // /**
- // * the previous version of the method! Currently we keep it in case of new bug due its rewriting
- // *
- // * @param list
- // * an event list to edit
- // * @param object
- // * an object to add to the event list
- // */
- // public static final void addToEventList(final EventList<Object> list, final Object object) {
- // list.getReadWriteLock().readLock().lock();
- // try {
- // if (list.contains(object)) {
- // return;
- // }
- // } catch (Exception e1) {
- // Activator.log.error(e1);
- // } finally {
- // list.getReadWriteLock().readLock().unlock();
- // }
- // int parentIndex = -1;
- // // 1. get the index to add the element
- // if (object instanceof ITreeItemAxis) {
- // IAxis parent = ((ITreeItemAxis) object).getParent();
- // if (parent != null) {
- // try {
- // list.getReadWriteLock().readLock().lock();
- // parentIndex = list.indexOf(parent);
- // } catch (Exception e) {
- // Activator.log.error(e);
- // } finally {
- // list.getReadWriteLock().readLock().unlock();
- // }
- // }
- // }
- //
- //
- // list.getReadWriteLock().writeLock().lock();
- // try {
- // if (parentIndex != -1) {
- // list.add(parentIndex + 1, object);
- // } else {
- // list.add(object);
- // }
- // } catch (Exception e) {
- // Activator.log.error(e);
- // } finally {
- // list.getReadWriteLock().writeLock().unlock();
- // }
- // }
-
/**
*
* @param list
@@ -111,22 +86,25 @@ public class EventListHelper {
* an object to remove from the list
*/
public static final void removeFromEventList(final EventList<Object> list, final Object object) {
-
- //the containment test is already done by the remove method itself
- // list.getReadWriteLock().readLock().lock();
- // try {
- // if (!list.contains(object)) {
- // return;
- // }
- // } catch (Exception e1) {
- // Activator.log.error(e1);
- // } finally {
- // list.getReadWriteLock().readLock().unlock();
- // }
+ list.getReadWriteLock().readLock().lock();
+ try {
+ if (!list.contains(object)) {
+ return;
+ }
+ } catch (Exception e1) {
+ Activator.log.error(e1);
+ } finally {
+ list.getReadWriteLock().readLock().unlock();
+ }
list.getReadWriteLock().writeLock().lock();
try {
- list.remove(object);
+
+ if (object instanceof ITreeItemAxis) {
+ list.remove(object);
+ } else {
+ list.remove(object);
+ }
} catch (Exception e) {
Activator.log.error(e);
} finally {

Back to the top