Package de.innovationgate.eclipse.editors.design.wizards

Source Code of de.innovationgate.eclipse.editors.design.wizards.NewScriptModuleFolderSelectionPage

/*******************************************************************************
* 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.ScriptModuleFolderSelectionViewFilter;
import de.innovationgate.eclipse.utils.FolderSelectionViewFilter;
import de.innovationgate.eclipse.utils.ui.DesignResourceSelectionPage;
import de.innovationgate.eclipse.utils.wga.WGADesignStructureHelper;

public class NewScriptModuleFolderSelectionPage extends DesignResourceSelectionPage {

  public NewScriptModuleFolderSelectionPage(String title, String description, IStructuredSelection preSelection) {
    super(title, description, preSelection);
    setTitle(title);
  }

  @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.isValidScriptLocation(treeSelection)) {
        list.add(new Status(Status.ERROR, Plugin.PLUGIN_ID, "You cannot create a script module here. Please select a folder below the scripts folder."));
      }
    }

    return list;
  }

  @Override
  protected FolderSelectionViewFilter getFilter() {
    return new ScriptModuleFolderSelectionViewFilter();
  }

  @Override
  protected String getPathNameUnderDesign() {
    // TODO Auto-generated method stub
    return "scripts";
  }
}
TOP

Related Classes of de.innovationgate.eclipse.editors.design.wizards.NewScriptModuleFolderSelectionPage

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.