1
/*******************************************************************************
2
* Copyright (C) 2003, 2004, 2007, 2008, 2013, Guillaume Brocker
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
10
* Guillaume Brocker - Initial API and implementation
12
******************************************************************************/
14
package eclox.ui.wizard;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.wizard.Wizard;
22
import org.eclipse.ui.INewWizard;
23
import org.eclipse.ui.IWorkbench;
25
import eclox.core.doxygen.Doxygen;
26
import eclox.core.doxygen.InvokeException;
27
import eclox.core.doxygen.RunException;
28
import eclox.ui.Plugin;
31
* Implement the new file wizard extension to provide a way to create
36
public class NewDoxyfileWizard extends Wizard implements INewWizard {
38
private IFile m_doxyfile; ///< The created doxyfile.
39
private NewDoxyfileWizardPage m_page; ///< The wizard page used to get the file name.
42
* Retrieves the created doxyfile.
44
* @return the created doxyfile, null if none
46
public IFile getDoxyfile() {
51
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
53
public void init( IWorkbench workbench, IStructuredSelection selection ) {
54
m_page = new NewDoxyfileWizardPage( selection );
56
setWindowTitle( "New Doxygen Configuration" );
60
* @see org.eclipse.jface.wizard.Wizard#performFinish()
62
public boolean performFinish() {
64
// Creates the doxyfile resource.
65
IFile doxyfile = createFile( m_page.getContainerFullPath(), m_page.getFileName() );
67
// Warn user if the doxyfile exists.
68
if( doxyfile.exists() ) {
69
MessageDialog.openWarning(getShell(), "Resource Exists", "The resource " + doxyfile.getFullPath().toString() + " already exists !" );
73
// Creates the effective resource file.
75
Doxygen.getDefault().generate( doxyfile );
76
m_doxyfile = doxyfile;
79
// Doxygen returned an error.
80
catch( RunException runException ) {
81
MessageDialog.openError(getShell(), "Doxygen Error", "An error occured while running doxygen. " + runException.toString());
84
// Doxygen was impossible to run.
85
catch( InvokeException invokeException ) {
86
if( Plugin.editPreferencesAfterDoxygenInvocationFailed() ) {
97
* Create the resource file.
99
* @param containerPath The path to the container for the resource to create.
100
* @param fileName A string containnig the name of the file resource to create.
102
* @return The created file resource. The file system's file hasn't been created at this step.
104
private IFile createFile( IPath containerPath, String fileName ) {
107
String fileExtension;
109
filePath = containerPath.append( fileName );
110
fileExtension = filePath.getFileExtension();
111
if( (fileExtension == null || fileExtension.compareToIgnoreCase( "Doxyfile" ) != 0) && fileName.compareToIgnoreCase("Doxyfile") != 0 ) {
112
filePath = filePath.addFileExtension( "Doxyfile" );
114
result = ResourcesPlugin.getWorkspace().getRoot().getFile( filePath );