KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2ecore > action > AddOutputRootAction


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004-2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: AddOutputRootAction.java,v 1.4 2005/06/08 06:23:41 nickb Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2ecore.action;
18
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 import org.eclipse.core.resources.IResource;
24 import org.eclipse.core.resources.ResourcesPlugin;
25 import org.eclipse.emf.common.util.URI;
26 import org.eclipse.emf.mapping.action.AddRootBottomAction;
27 import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditor;
28 import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditorPlugin;
29 import org.eclipse.ui.dialogs.ResourceSelectionDialog;
30
31
32 /**
33  *
34  */

35 public class AddOutputRootAction extends AddRootBottomAction
36 {
37   /**
38    *
39    */

40   public AddOutputRootAction()
41   {
42     super();
43   }
44
45   /*
46    * (non-Javadoc)
47    *
48    * @see org.eclipse.emf.mapping.action.AddRootBottomAction#getBottomsToAdd()
49    */

50   protected Collection JavaDoc getBottomsToAdd()
51   {
52     Collection JavaDoc bottomsToAdd = new ArrayList JavaDoc();
53
54     ResourceSelectionDialog resourceSelectionDialog = new ResourceSelectionDialog(
55       workbenchPart.getSite().getShell(),
56       ResourcesPlugin.getWorkspace().getRoot(),
57       Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_SelectOutputEcoreModels_label")); //$NON-NLS-1$
58
resourceSelectionDialog.open();
59
60     Object JavaDoc[] result = resourceSelectionDialog.getResult();
61
62     if (result != null)
63     {
64
65       for (int i = 0; i < result.length; i++)
66       {
67         IResource resource = (IResource)result[i];
68
69         if (resource.getType() == IResource.FILE && "ecore".equals(resource.getFullPath().getFileExtension())) //$NON-NLS-1$
70
{
71           bottomsToAdd.addAll(((Ecore2EcoreEditor)workbenchPart).getEditingDomain().getResourceSet().getResource(
72             URI.createPlatformResourceURI(resource.getFullPath().toString()),
73             true).getContents());
74         }
75       }
76     }
77
78     return bottomsToAdd;
79   }
80 }
Popular Tags