Package org.eclipse.egit.ui.internal.actions

Source Code of org.eclipse.egit.ui.internal.actions.SimpleFetchActionHandler

/*******************************************************************************
* Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
*
* 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
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.fetch.FetchOperationUI;
import org.eclipse.egit.ui.internal.fetch.SimpleConfigureFetchDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RemoteConfig;

/**
* Action for "Simple fetch"
*/
public class SimpleFetchActionHandler extends RepositoryActionHandler {
  public Object execute(ExecutionEvent event) throws ExecutionException {
    final Repository repository = getRepository(true, event);
    if (repository == null)
      return null;
    RemoteConfig config = SimpleConfigureFetchDialog
        .getConfiguredRemote(repository);
    if (config == null) {
      MessageDialog
          .openInformation(
              getShell(event),
              UIText.SimpleFetchActionHandler_NothingToFetchDialogTitle,
              UIText.SimpleFetchActionHandler_NothingToFetchDialogMessage);
      return null;
    }

    new FetchOperationUI(repository, config, Activator.getDefault().getPreferenceStore()
            .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT), false).start();
    return null;
  }

  @Override
  public boolean isEnabled() {
    final Repository repository = getRepository();
    return repository != null
        && SimpleConfigureFetchDialog
            .getConfiguredRemote(repository) != null;
  }
}
TOP

Related Classes of org.eclipse.egit.ui.internal.actions.SimpleFetchActionHandler

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.