Package de.innovationgate.eclipse.wgadesigner.team

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

/*******************************************************************************
* 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 org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.team.ui.synchronize.SynchronizeModelAction;
import org.eclipse.team.ui.synchronize.SynchronizeModelOperation;
import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup;

public class WGARemoteServerSynchronizationActionContribution extends SynchronizePageActionGroup
 
  public static final String CONTEXT_MENU_CONTRIBUTION_GROUP = "context_group_1";
 
  public void initialize(ISynchronizePageConfiguration configuration) {
    super.initialize(configuration);
    appendToGroup(
        ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP,
        new SynchronizeModelAction("Commit", configuration) {
          protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) {
            return new CommitOperation(configuration, elements);            
          }

          @Override
          public void selectionChanged(ISelection selection) {             
            super.selectionChanged(selection);
            boolean enabled = true;
            if (selection instanceof IStructuredSelection) {
              IStructuredSelection structSelection = (IStructuredSelection) selection;
              Object selectedElement = structSelection.getFirstElement();
              if (selectedElement instanceof ISynchronizeModelElement) {
                if ((((ISynchronizeModelElement)selectedElement).getKind() & SyncInfo.CONFLICTING) == SyncInfo.CONFLICTING) {
                  enabled = false;                  
                }
              }
            }
            setEnabled(enabled);
          }
        });
  }
}
TOP

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

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.