/*******************************************************************************
* 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.editors.design.wizards;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.IStructuredSelection;
import de.innovationgate.eclipse.editors.Plugin;
import de.innovationgate.eclipse.editors.helpers.TMLModulFolderSelectionViewFilter;
import de.innovationgate.eclipse.utils.FolderSelectionViewFilter;
import de.innovationgate.eclipse.utils.ui.DesignResourceSelectionPage;
import de.innovationgate.eclipse.utils.wga.WGADesignStructureHelper;
public class NewTMLModuleFolderSelectionPage extends DesignResourceSelectionPage {
public NewTMLModuleFolderSelectionPage(String title, String description, IStructuredSelection preSelection) {
super(title, description, preSelection);
setTitle(title);
}
@Override
protected FolderSelectionViewFilter getFilter() {
return new TMLModulFolderSelectionViewFilter();
}
@Override
public List<IStatus> validate() {
List<IStatus> list = new ArrayList<IStatus>();
if (!(getTreeViewer().getTree().getSelectionCount() > 0)) {
list.add(new Status(Status.ERROR, Plugin.PLUGIN_ID, "There is no designfolder in workspace."));
} else {
IContainer treeSelection = (IContainer) getTreeViewer().getTree().getSelection()[0].getData();
if (!WGADesignStructureHelper.isValidTMLLocation(treeSelection)) {
list.add(new Status(Status.ERROR, Plugin.PLUGIN_ID, "You cannot create a TML module here. Please select a folder below the tml folder."));
}
}
return list;
}
@Override
protected String getPathNameUnderDesign() {
return "tml";
}
}