Package de.innovationgate.eclipse.wgadesigner.team

Source Code of de.innovationgate.eclipse.wgadesigner.team.WGAPluginResourceSyncInfo

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* 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:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/

package de.innovationgate.eclipse.wgadesigner.team;

import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.IResourceVariantComparator;

import de.innovationgate.eclipse.wgadesigner.models.WGARemoteServer;
import de.innovationgate.eclipse.wgadesigner.natures.WGARuntime;
import de.innovationgate.eclipse.wgadesigner.tomcat.TomcatUtils;
import de.innovationgate.wgaservices.types.PluginInfo;
import de.innovationgate.wgaservices.types.Version;



public class WGAPluginResourceSyncInfo extends SyncInfo {

    private WGARemoteServer _server;
    private WGARuntime _runtime;
    private PluginInfo _localPluginInfo;

    private Version _remoteWGAVersion;

    public WGAPluginResourceSyncInfo(WGARuntime runtime, WGARemoteServer server, IResource local, PluginInfo localPluginInfo, IResourceVariant remote, Version remoteWGAVersion) {     
        super(local, remote, remote, new IResourceVariantComparator() {           
            public boolean isThreeWay() {
                return false;
            }           
            public boolean compare(IResourceVariant base, IResourceVariant remote) {
                return false;
            }           
            public boolean compare(IResource local, IResourceVariant remote) {
                return false;
            }
        });
        _server = server;
        _runtime = runtime;
        _localPluginInfo = localPluginInfo;
        _remoteWGAVersion = remoteWGAVersion;
    }

    public WGARemoteServer getServer() {
        return _server;
    }

    public void setServer(WGARemoteServer server) {
        _server = server;
    }

    public WGARuntime getRuntime() {
        return _runtime;
    }

    public void setRuntime(WGARuntime runtime) {
        _runtime = runtime;
    }   
   
    @Override
    protected int calculateKind() throws TeamException {
        if (getLocal() instanceof IProject) {
            return IN_SYNC;
        } else if (getLocal().equals(WGARemoteServerSubscriber.retrieveVirtualPluginRoot(_runtime))) {
            return IN_SYNC;
        }  
        if (_localPluginInfo != null && getRemote() != null) {
            PluginInfo remotePluginInfo = ((WGAPluginResourceVariant)getRemote()).getPluginInfo();           
            if (_localPluginInfo.getVersion().equals(remotePluginInfo.getVersion())) {
                return IN_SYNC;
            } else {
                return DELETION | OUTGOING;
            }
        } else if (_localPluginInfo != null && getRemote() == null) {
            // compare only up to patch level - ignore build version
            _remoteWGAVersion.setBuildVersion(0);
            _localPluginInfo.getMinimumWGAVersion().setBuildVersion(0);
           
            int comp =_remoteWGAVersion.compareTo(_localPluginInfo.getMinimumWGAVersion());
            if (comp == 0 || comp > 0) {
                return OUTGOING | ADDITION;
            } else {
                return OUTGOING | CONFLICTING | ADDITION;
            }
        } else if (_localPluginInfo == null && getRemote() != null) {
            return DELETION | OUTGOING;
        }
        return IN_SYNC;
    }
   
   
    public PluginInfo getLocalPluginInfo() {
        return _localPluginInfo;
    }


}
TOP

Related Classes of de.innovationgate.eclipse.wgadesigner.team.WGAPluginResourceSyncInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.