~ubuntu-branches/ubuntu/utopic/eclipse-eclox/utopic

« back to all changes in this revision

Viewing changes to eclox.ui/src/eclox/ui/wizard/NewDoxyfileWizardPage.java

  • Committer: Package Import Robot
  • Author(s): Graham Inggs
  • Date: 2013-07-07 20:33:10 UTC
  • Revision ID: package-import@ubuntu.com-20130707203310-a44yw80gqtc2s9ob
Tags: upstream-0.10.0
ImportĀ upstreamĀ versionĀ 0.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (C) 2003-2008, 2013, Guillaume Brocker
 
3
 * 
 
4
 * All rights reserved. This program and the accompanying materials
 
5
 * are made available under the terms of the Eclipse Public License v1.0
 
6
 * which accompanies this distribution, and is available at
 
7
 * http://www.eclipse.org/legal/epl-v10.html
 
8
 *
 
9
 * Contributors:
 
10
 *     Guillaume Brocker - Initial API and implementation
 
11
 *
 
12
 ******************************************************************************/ 
 
13
 
 
14
package eclox.ui.wizard;
 
15
 
 
16
import org.eclipse.core.resources.IResource;
 
17
import org.eclipse.jface.viewers.IStructuredSelection;
 
18
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
 
19
 
 
20
import eclox.ui.Images;
 
21
import eclox.ui.Plugin;
 
22
 
 
23
/**
 
24
 * @author gbrocker
 
25
 *
 
26
 * To change the template for this generated type comment go to
 
27
 * Window - Preferences - Java - Code Generation - Code and Comments
 
28
 */
 
29
public class NewDoxyfileWizardPage extends WizardNewFileCreationPage {
 
30
        
 
31
        /**
 
32
         * Retrieves the initial doxyfile name relative to the given object that
 
33
         * is supposed to be a resource.
 
34
         * 
 
35
         * If the object is not an IResourec instance, and adapter is searched for it.
 
36
         */
 
37
        private static String getInitialFileName( Object object ) {
 
38
                IResource resource;
 
39
                
 
40
                // Skip null objects
 
41
                if( object == null ) {
 
42
                        resource = null;
 
43
                }
 
44
                // Try the direct convertion to a IResource 
 
45
                else if( object instanceof IResource ) {
 
46
                        resource = (IResource) object;
 
47
                }
 
48
                // Try to find an adapter
 
49
                else {
 
50
                        resource = (IResource) org.eclipse.core.runtime.Platform.getAdapterManager().getAdapter(object, IResource.class);                               
 
51
                }
 
52
 
 
53
                // Finally, gets the project name for the resource (if one has been found).
 
54
                return (resource != null) ? (resource.getProject().getName() + ".doxyfile") : new String();
 
55
        }
 
56
        
 
57
        /**
 
58
         * Constructor.
 
59
         * 
 
60
         * @param selection     The current selection object.
 
61
         */
 
62
        public NewDoxyfileWizardPage(IStructuredSelection selection) {
 
63
                super("page", selection);
 
64
                setTitle("Doxygen Configuration");
 
65
                setDescription("Creates a new Doxygen configuration file.");
 
66
                setFileName( selection != null ? getInitialFileName(selection.getFirstElement()) : new String() );
 
67
                setImageDescriptor( Plugin.getImageDescriptor(Images.DOXYFILE_WIZARD));         
 
68
        }
 
69
 
 
70
        /**
 
71
         * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#getNewFileLabel()
 
72
         */
 
73
        protected String getNewFileLabel() {
 
74
                return "Doxyfile &name:";
 
75
        }
 
76
        
 
77
}