View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2006</p>
22   * <p>Company: OntoText Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.repository.ui.wizards;
26  
27  import java.util.Iterator;
28  
29  import org.eclipse.core.resources.IFile;
30  import org.eclipse.jface.viewers.IStructuredSelection;
31  import org.eclipse.jface.viewers.StructuredSelection;
32  import org.eclipse.jface.wizard.Wizard;
33  import org.eclipse.ui.IEditorPart;
34  import org.eclipse.ui.PlatformUI;
35  import org.wsmostudio.repository.ui.RepositoryEditor;
36  
37  /***
38   * This wizard supports exporting wsml resources from the workspace to a certain
39   * repository.
40   *
41   * @author not attributable
42   * @version $Revision: 469 $ $Date: 2006-01-09 14:51:14 +0200 $
43   */
44  
45  public class ExportEntitiesWizard extends Wizard {
46      
47      ExportEntitiesWizardPage mainPage;
48      
49      public ExportEntitiesWizard() {
50          super();
51          setWindowTitle("Import Resources in Repository");
52      }
53      
54      public void addPages() {
55          mainPage = new ExportEntitiesWizardPage(new StructuredSelection());
56          addPage(mainPage);
57      }
58  
59      public boolean performFinish() {
60          IStructuredSelection sel = mainPage.getFileSelection();
61          if (sel == null 
62                  || sel.size() == 0) {
63              return false; // invalid seleciton
64          }
65          
66          IEditorPart part = PlatformUI.getWorkbench()
67                                 .getActiveWorkbenchWindow()
68                                     .getActivePage()
69                                         .getActiveEditor();
70          if (false == part instanceof RepositoryEditor) {
71              return false; // invalid editor on top
72          }
73          RepositoryEditor repEditor = (RepositoryEditor)part;
74          for (Iterator it = sel.iterator(); it.hasNext();) {
75              if (false == repEditor.addResourceFromFile((IFile)it.next())) {
76                  return false;
77              }
78          }
79          return true;
80      }
81  }
82  
83  /*
84   * $Log$
85   * Revision 1.4  2006/01/09 12:51:11  alex_simov
86   * Copyright message in header updated
87   *
88   * Revision 1.3  2005/07/21 11:46:32  alex_simov
89   * added javadoc: class description, footer
90   *
91   */