Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-04-03 10:10:22 +0000
committerUwe Stieber2012-04-03 10:10:22 +0000
commit2ec926c3b0baf3ef2a8ab3d4d29249c7e2c6158c (patch)
treefcc287a1c7d3b83048d8400546704cb839e5f1c6 /target_explorer/plugins/org.eclipse.tcf.te.launch.core
parent6283a4cd9d4b7f3fd8a096261f3bd47fef5faa83 (diff)
downloadorg.eclipse.tcf-2ec926c3b0baf3ef2a8ab3d4d29249c7e2c6158c.tar.gz
org.eclipse.tcf-2ec926c3b0baf3ef2a8ab3d4d29249c7e2c6158c.tar.xz
org.eclipse.tcf-2ec926c3b0baf3ef2a8ab3d4d29249c7e2c6158c.zip
Target Explorer: CHANGE persistence to GSON
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml72
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java78
3 files changed, 228 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
index 037f62900..3b8add180 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml
@@ -43,4 +43,76 @@
</step>
</extension>
+<!-- Persistence delegate contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.persistence.delegates">
+ <delegate
+ id="org.eclipse.tcf.te.launch.core.persistence.gson.fileTransferItem"
+ class="org.eclipse.tcf.te.launch.core.internal.GsonFileTransferItemPersistenceDelegate">
+ </delegate>
+ <delegate
+ id="org.eclipse.tcf.te.launch.core.persistence.gson.referencedProjectItem"
+ class="org.eclipse.tcf.te.launch.core.internal.GsonReferencedProjectItemPersistenceDelegate">
+ </delegate>
+ </extension>
+
+<!-- Persistence delegate bindings contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.persistence.bindings">
+ <binding
+ delegateId="org.eclipse.tcf.te.launch.core.persistence.gson.fileTransferItem"
+ id="org.eclipse.tcf.te.launch.core.binding.gson.fileTransferItem">
+ <enablement>
+ <with variable="container">
+ <or>
+ <instanceof value="java.lang.String"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="containerClass">
+ <equals value="java.lang.String"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ <with variable="context">
+ <or>
+ <instanceof value="org.eclipse.tcf.te.launch.core.interfaces.IFileTransferItem"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="contextClass">
+ <equals value="org.eclipse.tcf.te.launch.core.interfaces.IFileTransferItem"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ </enablement>
+ </binding>
+ <binding
+ delegateId="org.eclipse.tcf.te.launch.core.persistence.gson.referencedProjectItem"
+ id="org.eclipse.tcf.te.launch.core.binding.gson.referencedProjectItem">
+ <enablement>
+ <with variable="container">
+ <or>
+ <instanceof value="java.lang.String"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="containerClass">
+ <equals value="java.lang.String"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ <with variable="context">
+ <or>
+ <instanceof value="org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem"/>
+ <and>
+ <instanceof value="java.lang.Class"/>
+ <with variable="contextClass">
+ <equals value="org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem"/>
+ </with>
+ </and>
+ </or>
+ </with>
+ </enablement>
+ </binding>
+ </extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java
new file mode 100644
index 000000000..0bcfbe75c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonFileTransferItemPersistenceDelegate.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.internal;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.tcf.te.launch.core.interfaces.IFileTransferItem;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransferItem;
+import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
+
+/**
+ * File transfer item to string delegate implementation.
+ */
+public class GsonFileTransferItemPersistenceDelegate extends AbstractGsonMapPersistenceDelegate {
+
+ /**
+ * Constructor.
+ */
+ public GsonFileTransferItemPersistenceDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return IFileTransferItem.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#toMap(java.lang.Object)
+ */
+ @Override
+ protected Map<String, Object> toMap(final Object context) throws IOException {
+ IFileTransferItem item = getFileTransferItem(context);
+ if (item != null) {
+ return super.toMap(item.getProperties());
+ }
+
+ return new HashMap<String, Object>();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#fromMap(java.util.Map, java.lang.Object)
+ */
+ @Override
+ protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
+ IFileTransferItem item = new FileTransferItem();
+ item.setProperties(map);
+ return item;
+ }
+
+ /**
+ * Get a file transfer item from the given context.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @return The file transfer item or <code>null</code>.
+ */
+ protected IFileTransferItem getFileTransferItem(Object context) {
+ IFileTransferItem item = null;
+
+ if (context instanceof IFileTransferItem) {
+ item = (IFileTransferItem)context;
+ }
+
+ return item;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java
new file mode 100644
index 000000000..be03f0a3c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/internal/GsonReferencedProjectItemPersistenceDelegate.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.core.internal;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectItem;
+import org.eclipse.tcf.te.runtime.persistence.AbstractGsonMapPersistenceDelegate;
+
+/**
+ * Referenced project item to string delegate implementation.
+ */
+public class GsonReferencedProjectItemPersistenceDelegate extends AbstractGsonMapPersistenceDelegate {
+
+ /**
+ * Constructor.
+ */
+ public GsonReferencedProjectItemPersistenceDelegate() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#getPersistedClass(java.lang.Object)
+ */
+ @Override
+ public Class<?> getPersistedClass(Object context) {
+ return IReferencedProjectItem.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#toMap(java.lang.Object)
+ */
+ @Override
+ protected Map<String, Object> toMap(final Object context) throws IOException {
+ IReferencedProjectItem item = getReferencedProjectItem(context);
+ if (item != null) {
+ return super.toMap(item.getProperties());
+ }
+
+ return new HashMap<String, Object>();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#fromMap(java.util.Map, java.lang.Object)
+ */
+ @Override
+ protected Object fromMap(Map<String, Object> map, Object context) throws IOException {
+ IReferencedProjectItem item = new ReferencedProjectItem();
+ item.setProperties(map);
+ return item;
+ }
+
+ /**
+ * Get a referenced project item from the given context.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @return The referenced project item or <code>null</code>.
+ */
+ protected IReferencedProjectItem getReferencedProjectItem(Object context) {
+ IReferencedProjectItem item = null;
+
+ if (context instanceof IReferencedProjectItem) {
+ item = (IReferencedProjectItem)context;
+ }
+
+ return item;
+ }
+}

Back to the top