Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f7463ead739958a5958dbd519991e373c74800ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (c) 2015 Eike Stepper (Berlin, Germany) 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:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.explorer.ui.repositories.wizards;

import org.eclipse.emf.cdo.explorer.repositories.CDORepository.IDGeneration;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository.VersioningMode;
import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.ValidationProblem;
import org.eclipse.emf.cdo.internal.explorer.repositories.RemoteCDORepository;

import org.eclipse.net4j.util.StringUtil;

import org.eclipse.swt.widgets.Composite;

import java.util.Properties;

/**
 * @author Eike Stepper
 */
public class RepositoryRemotePage extends AbstractRepositoryPage
{
  private MasterRepositoryController controller;

  public RepositoryRemotePage()
  {
    super("remote", "Remote Repository");
    setTitle("New Remote Repository");
    setMessage("Enter label and connection parameters of the new remote location.");
  }

  @Override
  protected void fillPage(Composite container)
  {
    controller = new MasterRepositoryController(container)
    {
      @Override
      protected void validateController()
      {
        super.validateController();
        validate();
      }
    };
  }

  @Override
  protected void doValidate(Properties properties) throws Exception
  {
    super.doValidate(properties);

    String connectorDescription = controller.getConnectorDescription();
    if (StringUtil.isEmpty(connectorDescription))
    {
      // TODO Port could be empty/invalid!
      throw new Exception("Host is empty.");
    }

    String repositoryName = controller.getRepositoryName();
    if (StringUtil.isEmpty(repositoryName))
    {
      throw new ValidationProblem("Repository name is empty.");
    }

    properties.setProperty(RemoteCDORepository.PROP_CONNECTOR_TYPE, "tcp");
    properties.setProperty(RemoteCDORepository.PROP_CONNECTOR_DESCRIPTION, connectorDescription);
    properties.setProperty(RemoteCDORepository.PROP_NAME, repositoryName);

    VersioningMode versioningMode = controller.getVersioningMode();
    if (versioningMode != null)
    {
      properties.setProperty(RemoteCDORepository.PROP_VERSIONING_MODE, versioningMode.toString());
    }

    IDGeneration idGeneration = controller.getIDGeneration();
    if (idGeneration != null)
    {
      properties.setProperty(RemoteCDORepository.PROP_ID_GENERATION, idGeneration.toString());
    }
  }
}

Back to the top