Package de.innovationgate.eclipse.wgadesigner.team

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

/*******************************************************************************
* 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.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import de.innovationgate.eclipse.utils.ui.ValidatedWizardPage;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.natures.WGARuntime;

public class ChooseWGARuntimePage extends ValidatedWizardPage {

  private String _invalidMessage = "Please select a runtime for the synchronization.";

    protected ChooseWGARuntimePage() {
    super("WGA runtime");
    setTitle("WGA runtime");
  }

  public ChooseWGARuntimePage(String title, String invalidMessage) {
      super(title);
      setTitle(title);
      _invalidMessage  = invalidMessage;
  }
 
  private WGARuntime _runtime;
  private Map<String, WGARuntime> _runtimes;
  private org.eclipse.swt.widgets.List _lstRuntimes;

  @Override
  public void computeResponse() {
    _runtime = _runtimes.get(_lstRuntimes.getSelection()[0]);
  }

  @Override
  public List<IStatus> validate() {
    List<IStatus> messages = new ArrayList<IStatus>();
   
    if (_lstRuntimes.getSelectionCount() <= 0) {
      messages.add(new Status(Status.WARNING, WGADesignerPlugin.PLUGIN_ID, _invalidMessage));
    }
   
    return messages;
  }

  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);
   
    Label label = new Label(container, SWT.NONE);
    label.setText("Available runtimes:");
   
    _lstRuntimes = new org.eclipse.swt.widgets.List(container, SWT.BORDER|SWT.SINGLE);
    _lstRuntimes.setLayoutData(new GridData(GridData.FILL_BOTH));
    _lstRuntimes.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetDefaultSelected(SelectionEvent e) {
        performValidation();
      }

      @Override
      public void widgetSelected(SelectionEvent e) {
        performValidation();
      }
     
    });
    _runtimes = WGADesignerPlugin.getAllRuntimes();
    List<String> runtimeNames = new ArrayList<String>();
    runtimeNames.addAll(_runtimes.keySet());
    Collections.sort(runtimeNames);
    for (String runtime : runtimeNames) {
      _lstRuntimes.add(runtime);
    }
    setControl(container);
    performValidation();
  }

  public WGARuntime getRuntime() {
    return _runtime;
  }

}
TOP

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

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.