EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.resultdecorator.resourceenvironmentdecorator.presentation]

COVERAGE SUMMARY FOR SOURCE FILE [ResourceenvironmentdecoratorModelWizard.java]

nameclass, %method, %block, %line, %
ResourceenvironmentdecoratorModelWizard.java0%   (0/6)0%   (0/25)0%   (0/807)0%   (0/173)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceenvironmentdecoratorModelWizard0%   (0/1)0%   (0/8)0%   (0/336)0%   (0/70)
<static initializer> 0%   (0/1)0%   (0/16)0%   (0/5)
ResourceenvironmentdecoratorModelWizard (): void 0%   (0/1)0%   (0/11)0%   (0/3)
addPages (): void 0%   (0/1)0%   (0/149)0%   (0/24)
createInitialModel (): EObject 0%   (0/1)0%   (0/15)0%   (0/3)
getInitialObjectNames (): Collection 0%   (0/1)0%   (0/44)0%   (0/9)
getModelFile (): IFile 0%   (0/1)0%   (0/4)0%   (0/1)
init (IWorkbench, IStructuredSelection): void 0%   (0/1)0%   (0/19)0%   (0/5)
performFinish (): boolean 0%   (0/1)0%   (0/78)0%   (0/21)
     
class ResourceenvironmentdecoratorModelWizard$10%   (0/1)0%   (0/2)0%   (0/66)0%   (0/17)
ResourceenvironmentdecoratorModelWizard$1 (ResourceenvironmentdecoratorModelW... 0%   (0/1)0%   (0/9)0%   (0/2)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/57)0%   (0/15)
     
class ResourceenvironmentdecoratorModelWizard$20%   (0/1)0%   (0/2)0%   (0/19)0%   (0/4)
ResourceenvironmentdecoratorModelWizard$2 (ResourceenvironmentdecoratorModelW... 0%   (0/1)0%   (0/12)0%   (0/2)
run (): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage0%   (0/1)0%   (0/8)0%   (0/315)0%   (0/71)
ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWiza... 0%   (0/1)0%   (0/13)0%   (0/5)
createControl (Composite): void 0%   (0/1)0%   (0/185)0%   (0/42)
getEncoding (): String 0%   (0/1)0%   (0/4)0%   (0/1)
getEncodings (): Collection 0%   (0/1)0%   (0/28)0%   (0/5)
getInitialObjectName (): String 0%   (0/1)0%   (0/27)0%   (0/5)
getLabel (String): String 0%   (0/1)0%   (0/18)0%   (0/4)
setVisible (boolean): void 0%   (0/1)0%   (0/26)0%   (0/8)
validatePage (): boolean 0%   (0/1)0%   (0/14)0%   (0/1)
     
class ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/4)
ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWiza... 0%   (0/1)0%   (0/6)0%   (0/2)
modifyText (ModifyEvent): void 0%   (0/1)0%   (0/7)0%   (0/2)
     
class ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWizardNewFileCreationPage0%   (0/1)0%   (0/3)0%   (0/58)0%   (0/12)
ResourceenvironmentdecoratorModelWizard$ResourceenvironmentdecoratorModelWiza... 0%   (0/1)0%   (0/8)0%   (0/3)
getModelFile (): IFile 0%   (0/1)0%   (0/9)0%   (0/1)
validatePage (): boolean 0%   (0/1)0%   (0/41)0%   (0/8)

1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package de.uka.ipd.sdq.pcm.resultdecorator.resourceenvironmentdecorator.presentation;
8 
9 
10import java.util.ArrayList;
11import java.util.Arrays;
12import java.util.Collection;
13import java.util.Collections;
14import java.util.HashMap;
15import java.util.List;
16import java.util.Map;
17import java.util.MissingResourceException;
18import java.util.StringTokenizer;
19 
20import org.eclipse.core.resources.IContainer;
21import org.eclipse.core.resources.IFile;
22import org.eclipse.core.resources.IFolder;
23import org.eclipse.core.resources.IProject;
24import org.eclipse.core.resources.IResource;
25import org.eclipse.core.resources.ResourcesPlugin;
26import org.eclipse.core.runtime.IProgressMonitor;
27import org.eclipse.core.runtime.Path;
28import org.eclipse.emf.common.CommonPlugin;
29import org.eclipse.emf.common.util.URI;
30import org.eclipse.emf.ecore.EClass;
31import org.eclipse.emf.ecore.EClassifier;
32import org.eclipse.emf.ecore.EObject;
33import org.eclipse.emf.ecore.resource.Resource;
34import org.eclipse.emf.ecore.resource.ResourceSet;
35import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
36import org.eclipse.emf.ecore.xmi.XMLResource;
37import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
38import org.eclipse.jface.dialogs.MessageDialog;
39import org.eclipse.jface.viewers.ISelection;
40import org.eclipse.jface.viewers.IStructuredSelection;
41import org.eclipse.jface.viewers.StructuredSelection;
42import org.eclipse.jface.wizard.Wizard;
43import org.eclipse.jface.wizard.WizardPage;
44import org.eclipse.swt.SWT;
45import org.eclipse.swt.events.ModifyEvent;
46import org.eclipse.swt.events.ModifyListener;
47import org.eclipse.swt.layout.GridData;
48import org.eclipse.swt.layout.GridLayout;
49import org.eclipse.swt.widgets.Combo;
50import org.eclipse.swt.widgets.Composite;
51import org.eclipse.swt.widgets.Label;
52import org.eclipse.ui.INewWizard;
53import org.eclipse.ui.IWorkbench;
54import org.eclipse.ui.IWorkbenchPage;
55import org.eclipse.ui.IWorkbenchPart;
56import org.eclipse.ui.IWorkbenchWindow;
57import org.eclipse.ui.PartInitException;
58import org.eclipse.ui.actions.WorkspaceModifyOperation;
59import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
60import org.eclipse.ui.part.FileEditorInput;
61import org.eclipse.ui.part.ISetSelectionTarget;
62 
63import de.uka.ipd.sdq.pcm.resultdecorator.presentation.ResultdecoratorEditorPlugin;
64import de.uka.ipd.sdq.pcm.resultdecorator.provider.ResultdecoratorEditPlugin;
65import de.uka.ipd.sdq.pcm.resultdecorator.resourceenvironmentdecorator.ResourceenvironmentdecoratorFactory;
66import de.uka.ipd.sdq.pcm.resultdecorator.resourceenvironmentdecorator.ResourceenvironmentdecoratorPackage;
67 
68 
69/**
70 * This is a simple wizard for creating a new model file.
71 * <!-- begin-user-doc -->
72 * <!-- end-user-doc -->
73 * @generated
74 */
75public class ResourceenvironmentdecoratorModelWizard extends Wizard implements INewWizard {
76        /**
77         * The supported extensions for created files.
78         * <!-- begin-user-doc -->
79         * <!-- end-user-doc -->
80         * @generated
81         */
82        public static final List<String> FILE_EXTENSIONS =
83                Collections.unmodifiableList(Arrays.asList(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorEditorFilenameExtensions").split("\\s*,\\s*")));
84 
85        /**
86         * A formatted list of supported file extensions, suitable for display.
87         * <!-- begin-user-doc -->
88         * <!-- end-user-doc -->
89         * @generated
90         */
91        public static final String FORMATTED_FILE_EXTENSIONS =
92                ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
93 
94        /**
95         * This caches an instance of the model package.
96         * <!-- begin-user-doc -->
97         * <!-- end-user-doc -->
98         * @generated
99         */
100        protected ResourceenvironmentdecoratorPackage resourceenvironmentdecoratorPackage = ResourceenvironmentdecoratorPackage.eINSTANCE;
101 
102        /**
103         * This caches an instance of the model factory.
104         * <!-- begin-user-doc -->
105         * <!-- end-user-doc -->
106         * @generated
107         */
108        protected ResourceenvironmentdecoratorFactory resourceenvironmentdecoratorFactory = resourceenvironmentdecoratorPackage.getResourceenvironmentdecoratorFactory();
109 
110        /**
111         * This is the file creation page.
112         * <!-- begin-user-doc -->
113         * <!-- end-user-doc -->
114         * @generated
115         */
116        protected ResourceenvironmentdecoratorModelWizardNewFileCreationPage newFileCreationPage;
117 
118        /**
119         * This is the initial object creation page.
120         * <!-- begin-user-doc -->
121         * <!-- end-user-doc -->
122         * @generated
123         */
124        protected ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage initialObjectCreationPage;
125 
126        /**
127         * Remember the selection during initialization for populating the default container.
128         * <!-- begin-user-doc -->
129         * <!-- end-user-doc -->
130         * @generated
131         */
132        protected IStructuredSelection selection;
133 
134        /**
135         * Remember the workbench during initialization.
136         * <!-- begin-user-doc -->
137         * <!-- end-user-doc -->
138         * @generated
139         */
140        protected IWorkbench workbench;
141 
142        /**
143         * Caches the names of the types that can be created as the root object.
144         * <!-- begin-user-doc -->
145         * <!-- end-user-doc -->
146         * @generated
147         */
148        protected List<String> initialObjectNames;
149 
150        /**
151         * This just records the information.
152         * <!-- begin-user-doc -->
153         * <!-- end-user-doc -->
154         * @generated
155         */
156        public void init(IWorkbench workbench, IStructuredSelection selection) {
157                this.workbench = workbench;
158                this.selection = selection;
159                setWindowTitle(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
160                setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(ResultdecoratorEditorPlugin.INSTANCE.getImage("full/wizban/NewResourceenvironmentdecorator")));
161        }
162 
163        /**
164         * Returns the names of the types that can be created as the root object.
165         * <!-- begin-user-doc -->
166         * <!-- end-user-doc -->
167         * @generated
168         */
169        protected Collection<String> getInitialObjectNames() {
170                if (initialObjectNames == null) {
171                        initialObjectNames = new ArrayList<String>();
172                        for (EClassifier eClassifier : resourceenvironmentdecoratorPackage.getEClassifiers()) {
173                                if (eClassifier instanceof EClass) {
174                                        EClass eClass = (EClass)eClassifier;
175                                        if (!eClass.isAbstract()) {
176                                                initialObjectNames.add(eClass.getName());
177                                        }
178                                }
179                        }
180                        Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
181                }
182                return initialObjectNames;
183        }
184 
185        /**
186         * Create a new model.
187         * <!-- begin-user-doc -->
188         * <!-- end-user-doc -->
189         * @generated
190         */
191        protected EObject createInitialModel() {
192                EClass eClass = (EClass)resourceenvironmentdecoratorPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
193                EObject rootObject = resourceenvironmentdecoratorFactory.create(eClass);
194                return rootObject;
195        }
196 
197        /**
198         * Do the work after everything is specified.
199         * <!-- begin-user-doc -->
200         * <!-- end-user-doc -->
201         * @generated
202         */
203        @Override
204        public boolean performFinish() {
205                try {
206                        // Remember the file.
207                        //
208                        final IFile modelFile = getModelFile();
209 
210                        // Do the work within an operation.
211                        //
212                        WorkspaceModifyOperation operation =
213                                new WorkspaceModifyOperation() {
214                                        @Override
215                                        protected void execute(IProgressMonitor progressMonitor) {
216                                                try {
217                                                        // Create a resource set
218                                                        //
219                                                        ResourceSet resourceSet = new ResourceSetImpl();
220 
221                                                        // Get the URI of the model file.
222                                                        //
223                                                        URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
224 
225                                                        // Create a resource for this file.
226                                                        //
227                                                        Resource resource = resourceSet.createResource(fileURI);
228 
229                                                        // Add the initial model object to the contents.
230                                                        //
231                                                        EObject rootObject = createInitialModel();
232                                                        if (rootObject != null) {
233                                                                resource.getContents().add(rootObject);
234                                                        }
235 
236                                                        // Save the contents of the resource to the file system.
237                                                        //
238                                                        Map<Object, Object> options = new HashMap<Object, Object>();
239                                                        options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
240                                                        resource.save(options);
241                                                }
242                                                catch (Exception exception) {
243                                                        ResultdecoratorEditorPlugin.INSTANCE.log(exception);
244                                                }
245                                                finally {
246                                                        progressMonitor.done();
247                                                }
248                                        }
249                                };
250 
251                        getContainer().run(false, false, operation);
252 
253                        // Select the new file resource in the current view.
254                        //
255                        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
256                        IWorkbenchPage page = workbenchWindow.getActivePage();
257                        final IWorkbenchPart activePart = page.getActivePart();
258                        if (activePart instanceof ISetSelectionTarget) {
259                                final ISelection targetSelection = new StructuredSelection(modelFile);
260                                getShell().getDisplay().asyncExec
261                                        (new Runnable() {
262                                                 public void run() {
263                                                         ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
264                                                 }
265                                         });
266                        }
267 
268                        // Open an editor on the new file.
269                        //
270                        try {
271                                page.openEditor
272                                        (new FileEditorInput(modelFile),
273                                         workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
274                        }
275                        catch (PartInitException exception) {
276                                MessageDialog.openError(workbenchWindow.getShell(), ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
277                                return false;
278                        }
279 
280                        return true;
281                }
282                catch (Exception exception) {
283                        ResultdecoratorEditorPlugin.INSTANCE.log(exception);
284                        return false;
285                }
286        }
287 
288        /**
289         * This is the one page of the wizard.
290         * <!-- begin-user-doc -->
291         * <!-- end-user-doc -->
292         * @generated
293         */
294        public class ResourceenvironmentdecoratorModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
295                /**
296                 * Pass in the selection.
297                 * <!-- begin-user-doc -->
298                 * <!-- end-user-doc -->
299                 * @generated
300                 */
301                public ResourceenvironmentdecoratorModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
302                        super(pageId, selection);
303                }
304 
305                /**
306                 * The framework calls this to see if the file is correct.
307                 * <!-- begin-user-doc -->
308                 * <!-- end-user-doc -->
309                 * @generated
310                 */
311                @Override
312                protected boolean validatePage() {
313                        if (super.validatePage()) {
314                                String extension = new Path(getFileName()).getFileExtension();
315                                if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
316                                        String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
317                                        setErrorMessage(ResultdecoratorEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
318                                        return false;
319                                }
320                                return true;
321                        }
322                        return false;
323                }
324 
325                /**
326                 * <!-- begin-user-doc -->
327                 * <!-- end-user-doc -->
328                 * @generated
329                 */
330                public IFile getModelFile() {
331                        return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
332                }
333        }
334 
335        /**
336         * This is the page where the type of object to create is selected.
337         * <!-- begin-user-doc -->
338         * <!-- end-user-doc -->
339         * @generated
340         */
341        public class ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage extends WizardPage {
342                /**
343                 * <!-- begin-user-doc -->
344                 * <!-- end-user-doc -->
345                 * @generated
346                 */
347                protected Combo initialObjectField;
348 
349                /**
350                 * @generated
351                 * <!-- begin-user-doc -->
352                 * <!-- end-user-doc -->
353                 */
354                protected List<String> encodings;
355 
356                /**
357                 * <!-- begin-user-doc -->
358                 * <!-- end-user-doc -->
359                 * @generated
360                 */
361                protected Combo encodingField;
362 
363                /**
364                 * Pass in the selection.
365                 * <!-- begin-user-doc -->
366                 * <!-- end-user-doc -->
367                 * @generated
368                 */
369                public ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage(String pageId) {
370                        super(pageId);
371                }
372 
373                /**
374                 * <!-- begin-user-doc -->
375                 * <!-- end-user-doc -->
376                 * @generated
377                 */
378                public void createControl(Composite parent) {
379                        Composite composite = new Composite(parent, SWT.NONE); {
380                                GridLayout layout = new GridLayout();
381                                layout.numColumns = 1;
382                                layout.verticalSpacing = 12;
383                                composite.setLayout(layout);
384 
385                                GridData data = new GridData();
386                                data.verticalAlignment = GridData.FILL;
387                                data.grabExcessVerticalSpace = true;
388                                data.horizontalAlignment = GridData.FILL;
389                                composite.setLayoutData(data);
390                        }
391 
392                        Label containerLabel = new Label(composite, SWT.LEFT);
393                        {
394                                containerLabel.setText(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ModelObject"));
395 
396                                GridData data = new GridData();
397                                data.horizontalAlignment = GridData.FILL;
398                                containerLabel.setLayoutData(data);
399                        }
400 
401                        initialObjectField = new Combo(composite, SWT.BORDER);
402                        {
403                                GridData data = new GridData();
404                                data.horizontalAlignment = GridData.FILL;
405                                data.grabExcessHorizontalSpace = true;
406                                initialObjectField.setLayoutData(data);
407                        }
408 
409                        for (String objectName : getInitialObjectNames()) {
410                                initialObjectField.add(getLabel(objectName));
411                        }
412 
413                        if (initialObjectField.getItemCount() == 1) {
414                                initialObjectField.select(0);
415                        }
416                        initialObjectField.addModifyListener(validator);
417 
418                        Label encodingLabel = new Label(composite, SWT.LEFT);
419                        {
420                                encodingLabel.setText(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_XMLEncoding"));
421 
422                                GridData data = new GridData();
423                                data.horizontalAlignment = GridData.FILL;
424                                encodingLabel.setLayoutData(data);
425                        }
426                        encodingField = new Combo(composite, SWT.BORDER);
427                        {
428                                GridData data = new GridData();
429                                data.horizontalAlignment = GridData.FILL;
430                                data.grabExcessHorizontalSpace = true;
431                                encodingField.setLayoutData(data);
432                        }
433 
434                        for (String encoding : getEncodings()) {
435                                encodingField.add(encoding);
436                        }
437 
438                        encodingField.select(0);
439                        encodingField.addModifyListener(validator);
440 
441                        setPageComplete(validatePage());
442                        setControl(composite);
443                }
444 
445                /**
446                 * <!-- begin-user-doc -->
447                 * <!-- end-user-doc -->
448                 * @generated
449                 */
450                protected ModifyListener validator =
451                        new ModifyListener() {
452                                public void modifyText(ModifyEvent e) {
453                                        setPageComplete(validatePage());
454                                }
455                        };
456 
457                /**
458                 * <!-- begin-user-doc -->
459                 * <!-- end-user-doc -->
460                 * @generated
461                 */
462                protected boolean validatePage() {
463                        return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
464                }
465 
466                /**
467                 * <!-- begin-user-doc -->
468                 * <!-- end-user-doc -->
469                 * @generated
470                 */
471                @Override
472                public void setVisible(boolean visible) {
473                        super.setVisible(visible);
474                        if (visible) {
475                                if (initialObjectField.getItemCount() == 1) {
476                                        initialObjectField.clearSelection();
477                                        encodingField.setFocus();
478                                }
479                                else {
480                                        encodingField.clearSelection();
481                                        initialObjectField.setFocus();
482                                }
483                        }
484                }
485 
486                /**
487                 * <!-- begin-user-doc -->
488                 * <!-- end-user-doc -->
489                 * @generated
490                 */
491                public String getInitialObjectName() {
492                        String label = initialObjectField.getText();
493 
494                        for (String name : getInitialObjectNames()) {
495                                if (getLabel(name).equals(label)) {
496                                        return name;
497                                }
498                        }
499                        return null;
500                }
501 
502                /**
503                 * <!-- begin-user-doc -->
504                 * <!-- end-user-doc -->
505                 * @generated
506                 */
507                public String getEncoding() {
508                        return encodingField.getText();
509                }
510 
511                /**
512                 * Returns the label for the specified type name.
513                 * <!-- begin-user-doc -->
514                 * <!-- end-user-doc -->
515                 * @generated
516                 */
517                protected String getLabel(String typeName) {
518                        try {
519                                return ResultdecoratorEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
520                        }
521                        catch(MissingResourceException mre) {
522                                ResultdecoratorEditorPlugin.INSTANCE.log(mre);
523                        }
524                        return typeName;
525                }
526 
527                /**
528                 * <!-- begin-user-doc -->
529                 * <!-- end-user-doc -->
530                 * @generated
531                 */
532                protected Collection<String> getEncodings() {
533                        if (encodings == null) {
534                                encodings = new ArrayList<String>();
535                                for (StringTokenizer stringTokenizer = new StringTokenizer(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
536                                        encodings.add(stringTokenizer.nextToken());
537                                }
538                        }
539                        return encodings;
540                }
541        }
542 
543        /**
544         * The framework calls this to create the contents of the wizard.
545         * <!-- begin-user-doc -->
546         * <!-- end-user-doc -->
547         * @generated
548         */
549                @Override
550        public void addPages() {
551                // Create a page, set the title, and the initial model file name.
552                //
553                newFileCreationPage = new ResourceenvironmentdecoratorModelWizardNewFileCreationPage("Whatever", selection);
554                newFileCreationPage.setTitle(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorModelWizard_label"));
555                newFileCreationPage.setDescription(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorModelWizard_description"));
556                newFileCreationPage.setFileName(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
557                addPage(newFileCreationPage);
558 
559                // Try and get the resource selection to determine a current directory for the file dialog.
560                //
561                if (selection != null && !selection.isEmpty()) {
562                        // Get the resource...
563                        //
564                        Object selectedElement = selection.iterator().next();
565                        if (selectedElement instanceof IResource) {
566                                // Get the resource parent, if its a file.
567                                //
568                                IResource selectedResource = (IResource)selectedElement;
569                                if (selectedResource.getType() == IResource.FILE) {
570                                        selectedResource = selectedResource.getParent();
571                                }
572 
573                                // This gives us a directory...
574                                //
575                                if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
576                                        // Set this for the container.
577                                        //
578                                        newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
579 
580                                        // Make up a unique new name here.
581                                        //
582                                        String defaultModelBaseFilename = ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorEditorFilenameDefaultBase");
583                                        String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
584                                        String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
585                                        for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
586                                                modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
587                                        }
588                                        newFileCreationPage.setFileName(modelFilename);
589                                }
590                        }
591                }
592                initialObjectCreationPage = new ResourceenvironmentdecoratorModelWizardInitialObjectCreationPage("Whatever2");
593                initialObjectCreationPage.setTitle(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_ResourceenvironmentdecoratorModelWizard_label"));
594                initialObjectCreationPage.setDescription(ResultdecoratorEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
595                addPage(initialObjectCreationPage);
596        }
597 
598        /**
599         * Get the file from the page.
600         * <!-- begin-user-doc -->
601         * <!-- end-user-doc -->
602         * @generated
603         */
604        public IFile getModelFile() {
605                return newFileCreationPage.getModelFile();
606        }
607 
608}

[all classes][de.uka.ipd.sdq.pcm.resultdecorator.resourceenvironmentdecorator.presentation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov