| /******************************************************************************* |
| * Copyright (c) 2016 Fundación Tecnalia Research & Innovation. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Huascar Espinoza - initial API and implementation |
| * Alejandra Ruíz - initial API and implementation |
| * Idoya Del Río - initial API and implementation |
| * Mari Carmen Palacios - initial API and implementation |
| * Angel López - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.opencert.apm.assurproj.wizards.ui.wizards; |
| |
| import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite; |
| import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ResourceChooserValidator; |
| import org.eclipse.emf.cdo.dawn.ui.composites.CDOResourceNodeChooserComposite.ValidationListener; |
| import org.eclipse.emf.cdo.dawn.ui.messages.Messages; |
| import org.eclipse.emf.cdo.view.CDOView; |
| import org.eclipse.emf.common.util.URI; |
| import org.eclipse.jface.wizard.WizardPage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Button; |
| import org.eclipse.swt.widgets.Composite; |
| |
| /** |
| * @author Martin Fluegge |
| */ |
| public class SelectProjectWizardPage extends WizardPage |
| { |
| private Composite container; |
| |
| private boolean showResources; |
| |
| private final String fileExtension; |
| |
| private int resourceValidationType = ResourceChooserValidator.VALIDATION_ERROR; |
| |
| private Button generateArgModel; |
| /** |
| * left for backward compatibility with the generated editors. This field might soon be removed. Use |
| * <b>org.eclipse.emf.cdo.dawn.ui.composites.ResourceChooserValidator.VALIDATION_WARN</b> instead. |
| */ |
| @Deprecated |
| public static final int VALIDATION_WARN = ResourceChooserValidator.VALIDATION_WARN; |
| |
| private final CDOView view; |
| |
| //private String resourceNamePrefix = "default"; //$NON-NLS-1$ |
| |
| private boolean createAutomaticResourceName; |
| |
| /** |
| * @since 1.0 |
| */ |
| protected CDOResourceNodeChooserComposite chooserComposite; |
| |
| |
| public SelectProjectWizardPage(String fileExtension, boolean showResources, CDOView view) |
| { |
| super("Create or upate Project Baseline"); |
| this.view = view; |
| setTitle("Select the Assurance project to update"); |
| setDescription("Select the Assurance project to create new baseline"); |
| this.showResources = showResources; |
| this.fileExtension = fileExtension; |
| } |
| |
| public void createControl(Composite parent) |
| { |
| container = new Composite(parent, SWT.NULL); |
| GridLayout layout = new GridLayout(); |
| container.setLayout(layout); |
| layout.numColumns = 1; |
| chooserComposite = new CDOResourceNodeChooserComposite(container, SWT.NONE, fileExtension, view); |
| chooserComposite.showResources(showResources); |
| ResourceChooserValidator validator = chooserComposite.getValidator(); |
| validator.setResourceValidationType(resourceValidationType); |
| validator.setValidationListener(new ValidationListener() |
| { |
| public void validationFinished() |
| { |
| validatePage(); |
| } |
| }); |
| |
| /* if (createAutomaticResourceName) |
| { |
| chooserComposite.createAutomaticResourceName(); |
| }*/ |
| |
| GridData gd = new GridData(GridData.FILL_BOTH); |
| chooserComposite.setLayoutData(gd); |
| |
| generateArgModel= new Button(container, SWT.CHECK); |
| generateArgModel.setText("Generate Argumentation model and diagram"); |
| generateArgModel.setSelection(false); |
| |
| setControl(container); |
| //validator.validate(); |
| } |
| |
| private void validatePage() |
| { |
| ResourceChooserValidator validator = chooserComposite.getValidator(); |
| boolean valid = validator.isValid(); |
| |
| if(validator.getMessage().equals(Messages.DawnCreateNewResourceWizardPage_12)){ |
| //If the error is that the resource exists, in this case is not an error an avoid the message an continue the wizard |
| valid=true; |
| } |
| |
| if (!valid) |
| { |
| int type = validator.getMessageType(); |
| setMessage(validator.getMessage(), type); |
| } |
| else |
| { |
| setMessage(""); |
| } |
| setPageComplete(valid); |
| } |
| |
| public URI getURI() |
| { |
| return chooserComposite.getURI(); |
| } |
| |
| public void setShowResources(boolean showResources) |
| { |
| this.showResources = showResources; |
| } |
| |
| public boolean isShowResources() |
| { |
| return showResources; |
| } |
| |
| public void setResourceNamePrefix(String resourceNamePrefix) |
| { |
| // this.resourceNamePrefix = resourceNamePrefix; |
| chooserComposite.setResourceNamePrefix(resourceNamePrefix); |
| chooserComposite.setResourceName(resourceNamePrefix); |
| } |
| |
| public String getResourceNamePrefix() |
| { |
| return chooserComposite.getResourceNamePrefix(); |
| } |
| |
| public void setResourcePath(String text) |
| { |
| if (!text.endsWith("/") || !!text.endsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$ |
| { |
| text += "/"; //$NON-NLS-1$ |
| } |
| chooserComposite.setResourcePath(text); |
| } |
| |
| public String getResourcePath() |
| { |
| return chooserComposite.getResourcePath(); |
| } |
| |
| public void setCreateAutomaticResourceName(boolean createAutomaticResourceName) |
| { |
| this.createAutomaticResourceName = createAutomaticResourceName; |
| } |
| |
| public boolean isCreateAutomaticResourceName() |
| { |
| return createAutomaticResourceName; |
| } |
| |
| public void setResourceValidationType(int resourceValidationType) |
| { |
| this.resourceValidationType = resourceValidationType; |
| } |
| |
| public int getResourceValidationType() |
| { |
| return resourceValidationType; |
| } |
| |
| public String getDefaultName() |
| { |
| return chooserComposite.getDefaultName(); |
| } |
| |
| public boolean generateArgumentation() { |
| |
| return generateArgModel.getSelection(); |
| |
| } |
| } |