| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * 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: |
| * Pierre Allard, |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.ui.wizards; |
| |
| import org.eclipse.apogy.core.Activator; |
| import org.eclipse.apogy.core.WorksiteContributor; |
| import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFacade; |
| import org.eclipse.apogy.core.ui.composites.WorksiteContributorsListComposite; |
| import org.eclipse.jface.dialogs.IDialogPage; |
| import org.eclipse.jface.wizard.WizardPage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class ApogyWorksiteSelectionWizardPage extends WizardPage { |
| private final static String WIZARD_PAGE_ID = "org.eclipse.apogy.core.ui.wizards.ApogyWorksiteSelectionWizardPage"; |
| private WorksiteContributorsListComposite listComposite; |
| private final static String ERROR_MSG = "You must select one worksite"; |
| |
| /** |
| * Constructor for SampleNewWizardPage. |
| * |
| * @param pageName |
| */ |
| public ApogyWorksiteSelectionWizardPage() { |
| super(WIZARD_PAGE_ID); |
| setTitle("Select Registered Apogy Worksite"); |
| setDescription("This wizard allows to select a registered Apogy Worksite."); |
| validate(); |
| } |
| |
| /** |
| * @see IDialogPage#createControl(Composite) |
| */ |
| @Override |
| public void createControl(Composite parent) { |
| this.listComposite = new WorksiteContributorsListComposite(parent, SWT.NONE, |
| Activator.getRegisteredWorksiteProviders()) { |
| @Override |
| protected void newWorksiteContributorSelected(WorksiteContributor selectedWorksiteContributor) { |
| validate(); |
| } |
| }; |
| setControl(this.listComposite); |
| } |
| |
| protected void validate() { |
| String message = null; |
| if (ApogyCoreInvocatorFacade.INSTANCE.getActiveInvocatorSession() == null) { |
| message = "There is no active Apogy Session. Activate a session first."; |
| } else { |
| if (getWorksiteContributor() == null) { |
| message = ERROR_MSG; |
| } |
| } |
| setErrorMessage(message); |
| setPageComplete(message == null); |
| } |
| |
| public WorksiteContributor getWorksiteContributor() { |
| return this.listComposite == null ? null : this.listComposite.getSelectedWorksiteContributor(); |
| } |
| } |