1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

initial contribution of dstore examples plugin

This commit is contained in:
David McKnight 2009-03-20 20:21:42 +00:00
parent 5e97c0b56d
commit 36f6b25e71
26 changed files with 1356 additions and 0 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="miners"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.examples.dstore</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,12 @@
#Mon Mar 16 11:50:09 EDT 2009
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error

View file

@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Dstore Plug-in
Bundle-SymbolicName: org.eclipse.rse.examples.dstore;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.rse.examples.dstore.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.rse.core;bundle-version="3.1.0",
org.eclipse.dstore.core;bundle-version="3.1.0",
org.eclipse.dstore.extra;bundle-version="2.1.100",
org.eclipse.rse.services.dstore;bundle-version="3.0.100",
org.eclipse.rse.services;bundle-version="3.1.0",
org.eclipse.rse.ui;bundle-version="3.1.0",
org.eclipse.rse.connectorservice.dstore;bundle-version="3.0.1",
org.eclipse.swt;bundle-version="3.4.0",
org.eclipse.jface;bundle-version="3.4.0",
org.eclipse.ui.views;bundle-version="3.3.0",
org.eclipse.ui;bundle-version="3.4.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,8 @@
source.. = src/,\
miners/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
plugin.properties,\
icons/

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

View file

@ -0,0 +1,123 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.miners;
import org.eclipse.dstore.core.miners.Miner;
import org.eclipse.dstore.core.model.DE;
import org.eclipse.dstore.core.model.DataElement;
import org.eclipse.dstore.core.model.DataStoreResources;
public class SampleMiner extends Miner {
public String getVersion() {
return "1.0.0";
}
protected void load() {
}
public DataElement handleCommand(DataElement theElement) throws Exception {
String name = getCommandName(theElement);
DataElement status = getCommandStatus(theElement);
DataElement subject = getCommandArgument(theElement, 0);
if (name.equals("C_SAMPLE_QUERY")){ //$NON-NLS-1$
return handleSampleQuery(subject, status);
}
else if (name.equals("C_SAMPLE_ACTION")){//$NON-NLS-1$
return handleSampleAction(subject, status);
}
else if (name.equals("C_RENAME")){
return handleRename(subject, getCommandArgument(theElement, 1), status);
}
else if (name.equals("C_DELETE")){
return handleDelete(subject, status);
}
else if (name.equals("C_CREATE_SAMPLE_OBJECT")){
return handleCreateSampleObject(subject, status);
}
else if (name.equals("C_CREATE_SAMPLE_CONTAINER")){
return handleCreateSampleContainer(subject, status);
}
return status;
}
public void extendSchema(DataElement schemaRoot) {
DataElement sampleContainer = _dataStore.createObjectDescriptor(schemaRoot, "Sample Container"); //$NON-NLS-1$
DataElement sampleObject = _dataStore.createObjectDescriptor(schemaRoot, "Sample Object"); //$NON-NLS-1$
_dataStore.createReference(sampleObject, sampleContainer, DataStoreResources.model_abstracts, DataStoreResources.model_abstracted_by);
createCommandDescriptor(sampleContainer, "Query", "C_SAMPLE_QUERY", false); //$NON-NLS-1$ //$NON-NLS-2$
createCommandDescriptor(sampleObject, "Do Something", "C_SAMPLE_ACTION", false); //$NON-NLS-1$ //$NON-NLS-2$
createCommandDescriptor(sampleObject, "Rename", "C_RENAME", false); //$NON-NLS-1$ //$NON-NLS-2$
createCommandDescriptor(sampleObject, "Delete", "C_DELETE", false); //$NON-NLS-1$ //$NON-NLS-2$
createCommandDescriptor(sampleObject, "Create Object", "C_CREATE_SAMPLE_OBJECT", false);
createCommandDescriptor(sampleObject, "Create Container", "C_CREATE_SAMPLE_CONTAINER", false);
_dataStore.refresh(schemaRoot);
}
private DataElement handleSampleQuery(DataElement parent, DataElement status){
String value = parent.getValue();
if (!value.equals("queried")){
_dataStore.createObject(parent, "Sample Object", "New Object 1"); //$NON-NLS-1$ //$NON-NLS-2$
_dataStore.createObject(parent, "Sample Object", "New Object 2"); //$NON-NLS-1$ //$NON-NLS-2$
_dataStore.createObject(parent, "Sample Container", "New Container 3"); //$NON-NLS-1$ //$NON-NLS-2$
parent.setAttribute(DE.A_VALUE, "queried");
_dataStore.refresh(parent);
}
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
private DataElement handleSampleAction(DataElement parent, DataElement status){
parent.setAttribute(DE.A_NAME, parent.getName() + " - modified");
_dataStore.refresh(parent.getParent());
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
private DataElement handleRename(DataElement parent, DataElement newName, DataElement status){
parent.setAttribute(DE.A_NAME, newName.getName());
_dataStore.refresh(parent.getParent());
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
private DataElement handleDelete(DataElement subject, DataElement status){
DataElement parent = subject.getParent();
_dataStore.deleteObject(parent, subject);
_dataStore.refresh(parent);
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
private DataElement handleCreateSampleObject(DataElement parent, DataElement status){
_dataStore.createObject(parent, "Sample Object", "Untitled"); //$NON-NLS-1$ //$NON-NLS-2$
_dataStore.refresh(parent);
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
private DataElement handleCreateSampleContainer(DataElement parent, DataElement status){
_dataStore.createObject(parent, "Sample Container", "Untitled Container"); //$NON-NLS-1$ //$NON-NLS-2$
_dataStore.refresh(parent);
status.setAttribute(DE.A_NAME, "done"); //$NON-NLS-1$
return status;
}
}

View file

@ -0,0 +1,17 @@
################################################################################
# Copyright (c) 2009 IBM, 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:
# David McKnight - initial API and implementation
################################################################################
pluginName = DataStore Example
providerName = Eclipse.org
SampleSubsystemName=DStore Sample SubSystem
SampleSubsystemDescription=This subsystem allows the user to remotely query a parent node to return children.

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009 IBM Corporation 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
Initial Contributors:
The following IBM employees contributed to the Remote System Explorer
component that contains this file: David McKnight
Contributors:
David McKnight (IBM) - Initial contribution
-->
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.rse.core.subsystemConfigurations">
<configuration
systemTypeIds="org.eclipse.rse.systemtype.linux;org.eclipse.rse.systemtype.unix"
name="DStore Sample SubSystem"
description="his subsystem allows the user to remotely query a parent node to return children."
iconlive="icons/full/obj16/samplesubsystemlive_obj.gif"
icon="icons/full/obj16/samplesubsystem_obj.gif"
category="dstore.sample"
class="org.eclipse.rse.examples.dstore.subsystems.SampleSubSystemConfiguration"
vendor="%providerName"
priority="200"
id="dstore.sample"/>
</extension>
</plugin>

View file

@ -0,0 +1,62 @@
package org.eclipse.rse.examples.dstore;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.rse.examples.dstore.subsystems.RemoteSampleObject;
import org.eclipse.rse.examples.dstore.ui.RemoteSampleObjectAdapterFactory;
import org.eclipse.rse.examples.dstore.ui.SampleSubSystemConfigurationAdapterFactory;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rse.examples.dstore";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
IAdapterManager manager = Platform.getAdapterManager();
RemoteSampleObjectAdapterFactory factory = new RemoteSampleObjectAdapterFactory();
manager.registerAdapters(factory, RemoteSampleObject.class);
SampleSubSystemConfigurationAdapterFactory sscaf = new SampleSubSystemConfigurationAdapterFactory();
sscaf.registerWithManager(manager);
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,25 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.services;
import org.eclipse.dstore.core.model.DataElement;
public class HostSampleContainer extends HostSampleObject implements IHostSampleContainer {
public HostSampleContainer(DataElement element){
super(element);
}
}

View file

@ -0,0 +1,36 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.services;
import org.eclipse.dstore.core.model.DataElement;
public class HostSampleObject implements IHostSampleObject {
private DataElement _element;
public HostSampleObject(DataElement element){
_element = element;
}
public DataElement getDataElement() {
return _element;
}
public String getName(){
return _element.getName();
}
public String getType(){
return _element.getType();
}
}

View file

@ -0,0 +1,18 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.services;
public interface IHostSampleContainer extends IHostSampleObject {
}

View file

@ -0,0 +1,22 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.services;
import org.eclipse.dstore.core.model.DataElement;
public interface IHostSampleObject {
public DataElement getDataElement();
public String getName();
public String getType();
}

View file

@ -0,0 +1,102 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.services;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.dstore.core.model.DataElement;
import org.eclipse.dstore.core.model.IDataStoreProvider;
import org.eclipse.rse.services.dstore.AbstractDStoreService;
public class SampleService extends AbstractDStoreService {
public SampleService(IDataStoreProvider dataStoreProvider) {
super(dataStoreProvider);
}
@Override
protected String getMinerId() {
return "org.eclipse.rse.examples.dstore.miners.SampleMiner";
}
public IHostSampleContainer getContainer(String name, IProgressMonitor monitor){
DataElement universalTemp = getMinerElement();
DataElement containerElement = getDataStore().createObject(universalTemp, "Sample Container", name,"", "", false); //$NON-NLS-1$
return new HostSampleContainer(containerElement);
}
public IHostSampleObject[] query(IHostSampleContainer container, IProgressMonitor monitor){
DataElement containerElement = container.getDataElement();
if (!isInitialized())
{
waitForInitialize(monitor);
}
DataElement[] results = dsQueryCommand(containerElement, "C_SAMPLE_QUERY", monitor);
List<IHostSampleObject> returned = new ArrayList<IHostSampleObject>();
for (int i = 0; i < results.length; i++){
DataElement result = results[i];
if (result.isDeleted()){
// don't add deleted items
}
else if (result.getType().equals("Sample Container")){
returned.add(new HostSampleContainer(result));
}
else {
returned.add(new HostSampleObject(result));
}
}
return (IHostSampleObject[])returned.toArray(new IHostSampleObject[returned.size()]);
}
public void doAction(IHostSampleObject object, IProgressMonitor monitor){
DataElement subject = object.getDataElement();
dsStatusCommand(subject, "C_SAMPLE_ACTION", monitor);
}
public void createSampleObject(IHostSampleObject object, IProgressMonitor monitor){
DataElement subject = object.getDataElement();
dsStatusCommand(subject, "C_CREATE_SAMPLE_OBJECT", monitor);
}
public void createSampleContainer(IHostSampleObject object, IProgressMonitor monitor){
DataElement subject = object.getDataElement();
dsStatusCommand(subject, "C_CREATE_SAMPLE_CONTAINER", monitor);
}
public boolean rename(IHostSampleObject object, String newName, IProgressMonitor monitor){
DataElement subject = object.getDataElement();
ArrayList<DataElement> args = new ArrayList<DataElement>();
DataElement newNameArg = getDataStore().createObject(null, "Name", newName);
args.add(newNameArg);
dsStatusCommand(subject, args, "C_RENAME", monitor);
return true;
}
public boolean delete(IHostSampleObject object, IProgressMonitor monitor){
DataElement subject = object.getDataElement();
dsStatusCommand(subject, "C_DELETE", monitor);
return true;
}
}

View file

@ -0,0 +1,70 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.subsystems;
import org.eclipse.rse.core.subsystems.AbstractResource;
import org.eclipse.rse.examples.dstore.services.IHostSampleContainer;
import org.eclipse.rse.examples.dstore.services.IHostSampleObject;
public class RemoteSampleObject extends AbstractResource {
protected IHostSampleObject _hostObject;
private RemoteSampleObject[] _contents;
private RemoteSampleObject _parent;
public RemoteSampleObject(RemoteSampleObject parent, IHostSampleObject hostObject, SampleSubSystem ss){
_hostObject = hostObject;
_parent = parent;
setSubSystem(ss);
}
public IHostSampleObject getHostSampleObject(){
return _hostObject;
}
public boolean isContainer(){
if (_hostObject instanceof IHostSampleContainer){
return true;
}
return false;
}
public String getName(){
return _hostObject.getName();
}
public String getType(){
return _hostObject.getType();
}
public RemoteSampleObject getParent(){
return _parent;
}
public String getAbsolutePath(){
if (_parent != null){
return _parent.getAbsolutePath() + "." + getName();
}
else {
return getName();
}
}
public void setContents(RemoteSampleObject[] contents){
_contents = contents;
}
public RemoteSampleObject[] getContents(){
return _contents;
}
}

View file

@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.subsystems;
import org.eclipse.rse.examples.dstore.services.IHostSampleObject;
public class SampleRootResource extends RemoteSampleObject {
public SampleRootResource(SampleSubSystem ss) {
super(null, null, ss);
}
public boolean isContainer(){
return true;
}
public String getName(){
return "Root";
}
public String getType(){
return "Root";
}
public RemoteSampleObject getParent(){
return null;
}
public String getAbsolutePath(){
return getName();
}
public IHostSampleObject getHostSampleObject(){
return _hostObject;
}
public void setHostSampleObject(IHostSampleObject hostObject){
_hostObject = hostObject;
}
}

View file

@ -0,0 +1,125 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.subsystems;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.SubSystem;
import org.eclipse.rse.examples.dstore.services.IHostSampleContainer;
import org.eclipse.rse.examples.dstore.services.IHostSampleObject;
import org.eclipse.rse.examples.dstore.services.SampleService;
public class SampleSubSystem extends SubSystem {
private SampleService _sampleService;
private SampleRootResource _root;
protected SampleSubSystem(IHost host, IConnectorService connectorService, SampleService sampleService) {
super(host, connectorService);
_sampleService = sampleService;
}
public boolean hasChildren() {
return true;
}
public Object[] getChildren() {
if (_root == null){
_root = new SampleRootResource(this);
}
return new Object[] {_root};
}
public Object[] list(RemoteSampleObject containerObj, IProgressMonitor monitor){
try {
checkIsConnected(monitor);
}
catch (Exception e){
e.printStackTrace();
}
RemoteSampleObject[] contents = containerObj.getContents();
if (contents == null){
IHostSampleContainer container = (IHostSampleContainer)containerObj.getHostSampleObject();
if (container == null && containerObj instanceof SampleRootResource){
container = getSampleService().getContainer(containerObj.getName(), monitor);
((SampleRootResource)containerObj).setHostSampleObject(container);
}
IHostSampleObject[] hostResults = getSampleService().query(container, monitor);
contents = new RemoteSampleObject[hostResults.length];
for (int i = 0; i < hostResults.length; i++){
IHostSampleObject hobj = hostResults[i];
contents[i] = new RemoteSampleObject(containerObj, hobj, this);
}
containerObj.setContents(contents);
}
return contents;
}
public void doRemoteAction(RemoteSampleObject object, IProgressMonitor monitor){
IHostSampleObject hostObject = object.getHostSampleObject();
getSampleService().doAction(hostObject, monitor);
}
public void createSampleContainer(RemoteSampleObject parentObject, IProgressMonitor monitor){
parentObject.setContents(null); // clear contents so that fresh contents arrive after refresh
IHostSampleObject hostObject = parentObject.getHostSampleObject();
getSampleService().createSampleContainer(hostObject, monitor);
}
public void createSampleObject(RemoteSampleObject parentObject, IProgressMonitor monitor){
parentObject.setContents(null); // clear contents so that fresh contents arrive after refresh
IHostSampleObject hostObject = parentObject.getHostSampleObject();
getSampleService().createSampleObject(hostObject, monitor);
}
public boolean rename(RemoteSampleObject object, String newName, IProgressMonitor monitor){
IHostSampleObject hostObject = object.getHostSampleObject();
return getSampleService().rename(hostObject, newName, monitor);
}
public boolean delete(RemoteSampleObject object, IProgressMonitor monitor){
object.getParent().setContents(null); // clear contents so that fresh contents arrive after refresh
IHostSampleObject hostObject = object.getHostSampleObject();
return getSampleService().delete(hostObject, monitor);
}
protected SampleService getSampleService(){
return _sampleService;
}
@Override
public void initializeSubSystem(IProgressMonitor monitor) {
super.initializeSubSystem(monitor);
getSampleService().initService(monitor);
}
@Override
public void uninitializeSubSystem(IProgressMonitor monitor) {
_root.setHostSampleObject(null);
_root.setContents(null);
super.uninitializeSubSystem(monitor);
getSampleService().uninitService(monitor);
}
}

View file

@ -0,0 +1,63 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.subsystems;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.rse.connectorservice.dstore.DStoreConnectorService;
import org.eclipse.rse.connectorservice.dstore.DStoreConnectorServiceManager;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
import org.eclipse.rse.examples.dstore.services.SampleService;
import org.eclipse.rse.services.dstore.IDStoreService;
public class SampleSubSystemConfiguration extends SubSystemConfiguration {
protected Map _services = new HashMap();
public ISubSystem createSubSystemInternal(IHost conn) {
return new SampleSubSystem(conn, getConnectorService(conn), getSampleService(conn));
}
public IConnectorService getConnectorService(IHost host) {
return DStoreConnectorServiceManager.getInstance().getConnectorService(host, getServiceImplType());
}
public SampleService getSampleService(IHost host) {
SampleService service = (SampleService)_services.get(host);
if (service == null)
{
DStoreConnectorService connectorService = (DStoreConnectorService)getConnectorService(host);
service = new SampleService(connectorService);
_services.put(host, service);
}
return service;
}
public boolean supportsFilters() {
return false;
}
public Class getServiceImplType(){
return IDStoreService.class;
}
}

View file

@ -0,0 +1,55 @@
/********************************************************************************
* Copyright (c) 2006 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.rse.examples.dstore.subsystems.RemoteSampleObject;
import org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.ui.views.properties.IPropertySource;
/**
* This factory maps requests for an adapter object from a given remote object.
*/
public class RemoteSampleObjectAdapterFactory extends AbstractSystemRemoteAdapterFactory
implements IAdapterFactory
{
private SampleAdapter sampleAdapter = new SampleAdapter();
/**
* Constructor for DeveloperAdapterFactory.
*/
public RemoteSampleObjectAdapterFactory() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
public Object getAdapter(Object adaptableObject, Class adapterType) {
ISystemViewElementAdapter adapter = null;
if (adaptableObject instanceof RemoteSampleObject)
adapter = sampleAdapter;
// these lines are very important!
if ((adapter != null) && (adapterType == IPropertySource.class))
adapter.setPropertySourceInput(adaptableObject);
return adapter;
}
}

View file

@ -0,0 +1,248 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.examples.dstore.subsystems.RemoteSampleObject;
import org.eclipse.rse.examples.dstore.subsystems.SampleRootResource;
import org.eclipse.rse.examples.dstore.subsystems.SampleSubSystem;
import org.eclipse.rse.examples.dstore.ui.actions.NewSampleObjectAction;
import org.eclipse.rse.examples.dstore.ui.actions.SampleAction;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
public class SampleAdapter extends AbstractSystemViewAdapter implements
ISystemRemoteElementAdapter {
private SampleAction _sampleAction;
private NewSampleObjectAction _newSampleObjectAction;
private NewSampleObjectAction _newSampleContainerAction;
@Override
public Object[] getChildren(IAdaptable element, IProgressMonitor monitor) {
RemoteSampleObject object = getSampleObject(element);
if (object != null){
if (object.isContainer()){
SampleSubSystem ss = (SampleSubSystem)object.getSubSystem();
return ss.list(object, monitor);
}
}
return null;
}
@Override
public Object getParent(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getParent();
}
return null;
}
@Override
public String getType(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getType();
}
return null;
}
@Override
public boolean hasChildren(IAdaptable element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.isContainer();
}
return false;
}
@Override
protected Object internalGetPropertyValue(Object key) {
// TODO Auto-generated method stub
return null;
}
public String getAbsoluteParentName(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getParent().getAbsolutePath();
}
return null;
}
public Object getRemoteParent(Object element, IProgressMonitor monitor)
throws Exception {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getParent();
}
return null;
}
public String[] getRemoteParentNamesInUse(Object element,
IProgressMonitor monitor) throws Exception {
// TODO Auto-generated method stub
return null;
}
public boolean refreshRemoteObject(Object oldElement, Object newElement) {
// TODO Auto-generated method stub
return false;
}
public String getRemoteSubType(Object element) {
// TODO Auto-generated method stub
return null;
}
public String getRemoteType(Object element) {
// TODO Auto-generated method stub
return null;
}
public String getRemoteTypeCategory(Object element) {
// TODO Auto-generated method stub
return null;
}
public String getSubSystemConfigurationId(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getSubSystem().getSubSystemConfiguration().getId();
}
return null;
}
public String getText(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getName();
}
return null;
}
public String getAbsoluteName(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
return obj.getAbsolutePath();
}
return null;
}
@Override
public void addActions(SystemMenuManager menu,
IStructuredSelection selection, Shell parent, String menuGroup) {
Object firstSelection = selection.getFirstElement();
if (firstSelection instanceof RemoteSampleObject){
if (!(firstSelection instanceof SampleRootResource)){
if (_sampleAction == null){
_sampleAction = new SampleAction(parent);
}
menu.add(ISystemContextMenuConstants.GROUP_CHANGE, _sampleAction);
}
if (_newSampleObjectAction == null){
_newSampleObjectAction = new NewSampleObjectAction(shell, false);
}
if (_newSampleContainerAction == null){
_newSampleContainerAction = new NewSampleObjectAction(shell, true);
}
if (((RemoteSampleObject)firstSelection).isContainer()){
menu.add(ISystemContextMenuConstants.GROUP_NEW, _newSampleObjectAction);
menu.add(ISystemContextMenuConstants.GROUP_NEW, _newSampleContainerAction);
}
}
}
private RemoteSampleObject getSampleObject(Object element){
if (element instanceof RemoteSampleObject){
return (RemoteSampleObject)element;
}
return null;
}
@Override
public ImageDescriptor getImageDescriptor(Object element) {
RemoteSampleObject obj = getSampleObject(element);
if (obj != null){
if (obj.isContainer()){
return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
}
else {
return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ELEMENT);
}
}
return null;
}
@Override
protected IPropertyDescriptor[] internalGetPropertyDescriptors() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean canRename(Object element) {
if (element instanceof SampleRootResource){
return false;
}
return true;
}
@Override
public boolean doRename(Shell shell, Object element, String name,
IProgressMonitor monitor) throws Exception {
SampleSubSystem ss = (SampleSubSystem)getSubSystem(element);
return ss.rename((RemoteSampleObject)element, name, monitor);
}
@Override
public boolean canDelete(Object element) {
if (element instanceof SampleRootResource){
return false;
}
return true;
}
@Override
public boolean doDelete(Shell shell, Object element,
IProgressMonitor monitor) throws Exception {
SampleSubSystem ss = (SampleSubSystem)getSubSystem(element);
boolean result = ss.delete((RemoteSampleObject)element, monitor);
if (result){
ss.list(((RemoteSampleObject)element).getParent(), monitor);
}
return result;
}
@Override
public boolean supportsDeferredQueries(ISubSystem subSys) {
return true;
}
}

View file

@ -0,0 +1,21 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui;
import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter;
public class SampleSubSystemConfigurationAdapter extends
SubSystemConfigurationAdapter {
}

View file

@ -0,0 +1,64 @@
/********************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
* Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.rse.examples.dstore.subsystems.SampleSubSystemConfiguration;
import org.eclipse.rse.ui.subsystems.ISubSystemConfigurationAdapter;
/**
* @see IAdapterFactory
*/
public class SampleSubSystemConfigurationAdapterFactory implements
IAdapterFactory {
private ISubSystemConfigurationAdapter ssConfigAdapter = new SampleSubSystemConfigurationAdapter();
/**
* @see IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList()
{
return new Class[] {ISubSystemConfigurationAdapter.class};
}
/**
* Called by our plugin's startup method to register our adaptable object types
* with the platform. We prefer to do it here to isolate/encapsulate all factory
* logic in this one place.
* @param manager Platform adapter manager
*/
public void registerWithManager(IAdapterManager manager)
{
manager.registerAdapters(this, SampleSubSystemConfiguration.class);
}
/**
* @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
public Object getAdapter(Object adaptableObject, Class adapterType)
{
Object adapter = null;
if (adaptableObject instanceof SampleSubSystemConfiguration)
adapter = ssConfigAdapter;
return adapter;
}
}

View file

@ -0,0 +1,71 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui.actions;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.examples.dstore.subsystems.RemoteSampleObject;
import org.eclipse.rse.examples.dstore.subsystems.SampleSubSystem;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
public class NewSampleObjectAction extends SystemBaseAction {
public class NewSampleObjectJob extends Job {
private RemoteSampleObject _selectedObject;
public NewSampleObjectJob(RemoteSampleObject selectedObject){
super("Create Sample Object");
_selectedObject = selectedObject;
}
public IStatus run(IProgressMonitor monitor){
SampleSubSystem ss = (SampleSubSystem)_selectedObject.getSubSystem();
// do remote action
if (_container){
ss.createSampleContainer(_selectedObject, monitor);
}
else {
ss.createSampleObject(_selectedObject, monitor);
}
// refresh view
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
sr.fireEvent(new SystemResourceChangeEvent(_selectedObject, ISystemResourceChangeEvents.EVENT_REFRESH, _selectedObject));
return Status.OK_STATUS;
}
}
private boolean _container;
public NewSampleObjectAction(Shell shell, boolean container) {
super(container? "Sample Container" : "Sample Object", shell);
_container = container;
}
@Override
public void run() {
RemoteSampleObject obj = (RemoteSampleObject)getSelection().getFirstElement();
if (obj != null){
NewSampleObjectJob job = new NewSampleObjectJob(obj);
job.schedule();
}
}
}

View file

@ -0,0 +1,70 @@
/********************************************************************************
* Copyright (c) 2009 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* {Name} (company) - description of contribution.
********************************************************************************/
package org.eclipse.rse.examples.dstore.ui.actions;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemResourceChangeEvents;
import org.eclipse.rse.core.events.SystemResourceChangeEvent;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.examples.dstore.subsystems.RemoteSampleObject;
import org.eclipse.rse.examples.dstore.subsystems.SampleSubSystem;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.swt.widgets.Shell;
public class SampleAction extends SystemBaseAction {
public class SampleJob extends Job {
private RemoteSampleObject _selectedObject;
public SampleJob(RemoteSampleObject selectedObject){
super("Sample Job");
_selectedObject = selectedObject;
}
public IStatus run(IProgressMonitor monitor){
SampleSubSystem ss = (SampleSubSystem)_selectedObject.getSubSystem();
// do remote action
ss.doRemoteAction(_selectedObject, monitor);
// refresh view
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
sr.fireEvent(new SystemResourceChangeEvent(_selectedObject.getParent(), ISystemResourceChangeEvents.EVENT_REFRESH, _selectedObject.getParent()));
return Status.OK_STATUS;
}
}
public SampleAction(Shell shell) {
super("Do Remote Operation", shell);
}
@Override
public void run() {
RemoteSampleObject obj = (RemoteSampleObject)getSelection().getFirstElement();
if (obj != null){
SampleJob job = new SampleJob(obj);
job.schedule();
}
}
}