~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to rpm/org.eclipse.linuxtools.rpm.ui/src/org/eclipse/linuxtools/internal/rpm/ui/RPMExportWizard.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2004-2009 Red Hat, Inc.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 *     Red Hat - initial API and implementation
10
 
 *******************************************************************************/
11
 
package org.eclipse.linuxtools.internal.rpm.ui;
12
 
 
13
 
import org.eclipse.core.resources.IProject;
14
 
import org.eclipse.core.resources.IResource;
15
 
import org.eclipse.core.runtime.CoreException;
16
 
import org.eclipse.jface.viewers.IStructuredSelection;
17
 
import org.eclipse.jface.wizard.Wizard;
18
 
import org.eclipse.linuxtools.rpm.core.IRPMConstants;
19
 
import org.eclipse.ui.IExportWizard;
20
 
import org.eclipse.ui.IWorkbench;
21
 
 
22
 
/**
23
 
 * Wizard to handle rpm exports.
24
 
 *
25
 
 */
26
 
public class RPMExportWizard extends Wizard implements IExportWizard {
27
 
        private RPMExportPage mainPage;
28
 
        private IStructuredSelection selection;
29
 
 
30
 
        /**
31
 
         * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench,
32
 
         *      IStructuredSelection)
33
 
         * 
34
 
         *      Basic constructor. Don't do much, just print out debug, and set
35
 
         *      progress monitor status to true
36
 
         */
37
 
        public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
38
 
                setNeedsProgressMonitor(true);
39
 
                setWindowTitle(Messages.getString("RPMExportWizard.Export_an_SRPM")); //$NON-NLS-1$
40
 
                selection = currentSelection;
41
 
        }
42
 
 
43
 
        @Override
44
 
        public boolean performFinish() {
45
 
                // Create a new instance of the RPMExportOperation runnable
46
 
                final RPMExportOperation rpmExport = new RPMExportOperation(mainPage
47
 
                                .getSelectedRPMProject(), mainPage.getExportType());
48
 
                // Run the export
49
 
                rpmExport.setUser(true);
50
 
                rpmExport.schedule();
51
 
                
52
 
                // Need to return some meaningful status. Should only return true if the
53
 
                // wizard completed successfully.
54
 
                return true;
55
 
        }
56
 
 
57
 
        @Override
58
 
        public boolean canFinish() {
59
 
                return mainPage.canFinish();
60
 
        }
61
 
 
62
 
        // Add the RPMExportPage as the only page in this wizard.
63
 
        @Override
64
 
        public void addPages() {
65
 
                IProject project = null;
66
 
                if (selection.isEmpty()) {
67
 
 
68
 
                } else if (!(selection.getFirstElement() instanceof IProject)) {
69
 
                        if (selection.getFirstElement() instanceof IResource) {
70
 
                                IResource resource = (IResource) selection.getFirstElement();
71
 
                                IProject parentProject = resource.getProject();
72
 
                                try {
73
 
                                        if (parentProject.hasNature(IRPMConstants.RPM_NATURE_ID)) {
74
 
                                                project = parentProject;
75
 
                                        }
76
 
                                } catch (CoreException e) {
77
 
                                        // nothing we can do
78
 
                                }
79
 
                        }
80
 
                } else if (selection.getFirstElement() instanceof IProject) {
81
 
                        IProject tempProject = (IProject) selection.getFirstElement();
82
 
                        try {
83
 
                                if (tempProject.hasNature(IRPMConstants.RPM_NATURE_ID)) {
84
 
                                        project = tempProject;
85
 
                                }
86
 
                        } catch (CoreException e) {
87
 
                                // nothing we can do
88
 
                        }
89
 
                }
90
 
                if (project != null) {
91
 
                        mainPage = new RPMExportPage(project);
92
 
                        addPage(mainPage);
93
 
                }
94
 
        }
95
 
}