View | Details | Raw Unified | Return to bug 82195 | Differences between
and this patch

Collapse All | Expand All

(-)build.properties (-1 / +11 lines)
Lines 10-13 Link Here
10
bin.includes = plugin.xml,\
10
bin.includes = plugin.xml,\
11
               *.jar,\
11
               *.jar,\
12
               RpmUi.jar,\
12
               RpmUi.jar,\
13
               icons/
13
               icons/,\
14
               about.html
15
src.includes = .classpath,\
16
               .project,\
17
               .template,\
18
               ChangeLog,\
19
               about.html,\
20
               build.properties,\
21
               icons/,\
22
               plugin.xml,\
23
               src/
(-)plugin.xml (-14 / +7 lines)
Lines 5-22 Link Here
5
   name="RPM UI Plug-in"
5
   name="RPM UI Plug-in"
6
   version="1.2"
6
   version="1.2"
7
   provider-name="Eclipse.org"
7
   provider-name="Eclipse.org"
8
   >
8
   class="org.eclipse.cdt.rpm.ui.RPMUIPlugin">
9
   
9
   
10
10
11
   <runtime>
11
   <runtime>
12
      <library name="RpmUi.jar"/>
12
      <library name="RpmUi.jar"/>
13
   <library name="RPMCore.jar">        
14
   		<export name="*"/>      
15
   </library>      
16
   
13
   
17
   <library name="RPMPluginPreferencesPage.jar">        
18
   		<export name="*"/>      
19
   </library>
20
   </runtime>
14
   </runtime>
21
   
15
   
22
   <requires>
16
   <requires>
Lines 28-34 Link Here
28
      <import plugin="org.eclipse.swt"/>
22
      <import plugin="org.eclipse.swt"/>
29
      <import plugin="org.eclipse.jface"/>
23
      <import plugin="org.eclipse.jface"/>
30
      <import plugin="org.eclipse.text"/>
24
      <import plugin="org.eclipse.text"/>
31
      <import plugin="org.eclipse.cdt.core" />
32
      <import plugin="org.eclipse.cdt.rpm.core"/>
25
      <import plugin="org.eclipse.cdt.rpm.core"/>
33
   </requires>
26
   </requires>
34
27
Lines 41-47 Link Here
41
            class="org.eclipse.cdt.rpm.ui.RPMExportWizard"
34
            class="org.eclipse.cdt.rpm.ui.RPMExportWizard"
42
            id="org.eclipse.cdt.rpm.ui.RPMExportWizard">
35
            id="org.eclipse.cdt.rpm.ui.RPMExportWizard">
43
         <description>
36
         <description>
44
            Export C/C++ projects to RPM format
37
            Export an RPM
45
         </description>
38
         </description>
46
         <selection
39
         <selection
47
               class="org.eclipse.core.resources.IResource">
40
               class="org.eclipse.core.resources.IResource">
Lines 53-60 Link Here
53
      <wizard
46
      <wizard
54
            name="Source RPM"
47
            name="Source RPM"
55
            icon="icons/rpm.gif"
48
            icon="icons/rpm.gif"
56
            class="org.eclipse.cdt.rpm.ui.SRPMImportwizard"
49
            class="org.eclipse.cdt.rpm.ui.SRPMImportWizard"
57
            id="org.eclipse.cdt.rpm.ui.SRPMImportwizard">
50
            id="org.eclipse.cdt.rpm.ui.SRPMImportWizard">
58
         <description>
51
         <description>
59
            Imports a Source RPM to a project
52
            Imports a Source RPM to a project
60
         </description>
53
         </description>
Lines 66-76 Link Here
66
   <extension
59
   <extension
67
   				point="org.eclipse.ui.views">
60
   				point="org.eclipse.ui.views">
68
   		<category
61
   		<category
69
   				name="RPM Plugin Log File"
62
   				name="RPM Log File"
70
   				id="org.eclipse.cdt.rpm.ui.logviewer">
63
   				id="org.eclipse.cdt.rpm.ui.logviewer">
71
   		</category>
64
   		</category>
72
   <view
65
   <view
73
   			name="RPM Plugin Log Viewer"
66
   			name="RPM Log Viewer"
74
   			icon="icons/rpm.gif"
67
   			icon="icons/rpm.gif"
75
   			class="org.eclipse.cdt.rpm.ui.logviewer.RPMLogViewer"
68
   			class="org.eclipse.cdt.rpm.ui.logviewer.RPMLogViewer"
76
   			id="org.eclipse.cdt.rpm.ui.logviewer.RPMLogViewer"
69
   			id="org.eclipse.cdt.rpm.ui.logviewer.RPMLogViewer"
Lines 82-88 Link Here
82
      point = "org.eclipse.ui.preferencePages">
75
      point = "org.eclipse.ui.preferencePages">
83
       <page id="org.eclipse.cdt.rpm.ui.preferences.Page1"
76
       <page id="org.eclipse.cdt.rpm.ui.preferences.Page1"
84
	      class="org.eclipse.cdt.rpm.ui.preferences.RPMPluginPreferencesPage"
77
	      class="org.eclipse.cdt.rpm.ui.preferences.RPMPluginPreferencesPage"
85
            name="RPM Plugin">
78
            name="RPM">
86
       </page>
79
       </page>
87
	</extension>
80
	</extension>
88
</plugin>
81
</plugin>
(-)src/org/eclipse/cdt/rpm/ui/RPMExportOperation.java (-165 / +37 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the
4
 * This program is open source software licensed under the
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
Lines 7-18 Link Here
7
7
8
package org.eclipse.cdt.rpm.ui;
8
package org.eclipse.cdt.rpm.ui;
9
9
10
import org.eclipse.cdt.rpm.core.*;
10
import org.eclipse.cdt.rpm.core.IRPMProject;
11
11
import org.eclipse.cdt.rpm.core.RPMExportDelta;
12
import org.eclipse.core.resources.IProject;
13
import org.eclipse.core.resources.IWorkspaceRoot;
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
12
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.MultiStatus;
14
import org.eclipse.core.runtime.MultiStatus;
Lines 27-117 Link Here
27
import java.util.ArrayList;
23
import java.util.ArrayList;
28
import java.util.Iterator;
24
import java.util.Iterator;
29
25
30
/**
31
 * @author pmuldoon
32
 *
33
 * Export Class for RPM plug-in. This allows us to abstract the operations to
34
 * a utility class which also inherits IRunnableWithProgress that allows use of
35
 * progress bar
36
 */
37
public class RPMExportOperation implements IRunnableWithProgress {
26
public class RPMExportOperation implements IRunnableWithProgress {
38
	// Class variables that are use for storage
39
	// as they are passed into the constrcutor
40
	private String project_name;
41
	private String actual_proj_name;
42
	private boolean preserve_env;
43
	private boolean keep_log;
44
	private String spec_file;
45
	private String patch_name = ""; //$NON-NLS-1$
46
	private String patch_tag = ""; //$NON-NLS-1$
47
	private String patch_changelog = ""; //$NON-NLS-1$
48
	private String patch_version = ""; //$NON-NLS-1$
49
	private String patch_release = ""; //$NON-NLS-1$
50
	private boolean gen_patch;
51
	private String exportType;
52
53
	// Progressmonitor
54
	private IProgressMonitor monitor;
27
	private IProgressMonitor monitor;
55
28
	private ArrayList rpm_errorTable;
56
	public ArrayList rpm_errorTable;
29
	private IRPMProject rpmProject;
57
30
	private RPMExportDelta exportDelta;
58
	/**
31
	private int exportType;
59
	 * Method RPMExportOperation.
32
	
60
	 * @param a_proj_name - actual project name
33
	public RPMExportOperation(IRPMProject rpmProject, int exportType,
61
	 * @param work_path - path to workspace of project
34
			RPMExportDelta exportDelta) {
62
	 * @param pSpec_File - path to spec file
35
		this.rpmProject = rpmProject;
63
	 * @param pPatchName - patch file name to use
36
		this.exportDelta = exportDelta;
64
	 * @param pPatchComment - Comment for patch entry
37
		this.exportType = exportType;
65
	 * @param pPatchChangeLog - ChangeLog header entry
66
	 * @param pPatchVersion - Version Number to use
67
	 * @param pPatchRelease- Release Number to use
68
	 * @param pexportType - -ba, -bs or -bp (all, source, binary)
69
	 * @param pGenPatch - Patch Generation toggle
70
	 *
71
	 */
72
	public RPMExportOperation(
73
		String a_proj_name,
74
		String work_path,
75
		String pSpec_File,
76
		String pPatchName,
77
		String pPatchComment,
78
		String pPatchChangeLog,
79
		String pPatchVersion,
80
		String pPatchRelease,
81
		String pexportType,
82
		boolean pGenPatch) {
83
84
		// Copy passed variables to constructor, to class variables	
85
		project_name = work_path;
86
		actual_proj_name = a_proj_name;
87
		spec_file = pSpec_File;
88
		patch_name = pPatchName;
89
		patch_tag = pPatchComment;
90
		patch_changelog = pPatchChangeLog;
91
		patch_version = pPatchVersion;
92
		patch_release = pPatchRelease;
93
		exportType = pexportType;
94
		gen_patch = pGenPatch;
95
	}
38
	}
96
39
97
	/**
40
	/**
98
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(IProgressMonitor)
41
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(IProgressMonitor)
99
	 *
42
	 *
100
	 * Perform the incremental build of the S/RPM export. 
101
	 */
43
	 */
102
	public void run(IProgressMonitor progressMonitor)
44
	public void run(IProgressMonitor progressMonitor)
103
		throws InvocationTargetException {
45
		throws InvocationTargetException {
104
46
		int totalWork = 2;
105
		int totalWork = 0;
106
		ArrayList PatchInfo = null;
107
		RPMExport rpmexport;
108
		SRPMExport srpmexport;
109
110
		// Total number of work steps needed
111
		if (exportType.equals("-ba")) //$NON-NLS-1$
112
			totalWork = 4;
113
		else
114
			totalWork = 2;
115
47
116
		monitor = progressMonitor;
48
		monitor = progressMonitor;
117
49
Lines 120-217 Link Here
120
52
121
		// Start progress
53
		// Start progress
122
		monitor.beginTask(Messages.getString("RPMExportOperation.Starting"), //$NON-NLS-1$
54
		monitor.beginTask(Messages.getString("RPMExportOperation.Starting"), //$NON-NLS-1$
123
		totalWork); //$NON-NLS-1$
55
		totalWork);
124
56
		monitor.worked(1);
125
		// If the export type is all  (-ba) or export type is source (-bs)
57
		
126
		if (exportType.equals("-bs") || exportType.equals("-ba")) { //$NON-NLS-1$ //$NON-NLS-2$
58
		switch(exportType) {
127
59
		case IRPMUIConstants.BUILD_ALL:
128
			monitor.setTaskName(Messages.getString("RPMExportOperation.Starting_SRPM_Export")); //$NON-NLS-1$
129
130
			// Try to create an instance of the srpm export class
131
			try {
60
			try {
132
				srpmexport = new SRPMExport(project_name);
61
				monitor.setTaskName(Messages.getString("RPMExportOperation.Executing_RPM_Export"));
133
			} catch (Exception e) {
62
				rpmProject.buildAll(exportDelta);
63
			} catch(Exception e) {
134
				rpm_errorTable.add(e);
64
				rpm_errorTable.add(e);
135
				refreshWorkspace();
136
				return;
137
			}
65
			}
138
			// set the various properties of a SRPM export
66
			break;
139
			srpmexport.setChangelog_entry(patch_changelog);
67
		
140
			srpmexport.setUi_ver_no(patch_version);
68
		case IRPMUIConstants.BUILD_BINARY:
141
			srpmexport.setUi_rel_no(patch_release);
69
			monitor.setTaskName(Messages.getString("RPMExportOperation.Executing_RPM_Export")); //$NON-NLS-1$
142
			srpmexport.setUi_spec_file(spec_file);
143
			srpmexport.setPatch_tag(patch_tag);
144
145
			monitor.worked(1);
146
			monitor.setTaskName(Messages.getString("RPMExportOperation.Executing_SRPM_Export")); //$NON-NLS-1$
147
148
			// execue the srpm export
149
			try {
150
				srpmexport.run();
151
			} catch (CoreException e) {
152
				rpm_errorTable.add(e.getStatus());
153
				refreshWorkspace();
154
				return;
155
			}
156
			monitor.worked(1);
157
158
		}
159
		// If the export type is all  (-ba) or export type is binary (-bb)
160
		if (exportType.equals("-bb") || exportType.equals("-ba")) { //$NON-NLS-1$ //$NON-NLS-2$
161
162
			monitor.setTaskName(Messages.getString("RPMExportOperation.Starting_RPM_Export")); //$NON-NLS-1$
163
164
			// Try to create an instance of the rpm export class
165
			try {
70
			try {
166
				rpmexport = new RPMExport(project_name);
71
				rpmProject.buildBinaryRPM(exportDelta);
167
			} catch (Exception e) {
72
			} catch(Exception e) {
168
				rpm_errorTable.add(e);
73
				rpm_errorTable.add(e);
169
				refreshWorkspace();
170
				return;
171
			}
74
			}
172
75
			break;
173
			// set the various properties of an RPM export
76
		
174
			rpmexport.setUi_ver_no(patch_version);
77
		case IRPMUIConstants.BUILD_SOURCE:
175
			rpmexport.setUi_rel_no(patch_release);
78
			monitor.setTaskName(Messages.getString("RPMExportOperation.Executing_SRPM_Export")); //$NON-NLS-1$
176
			rpmexport.setUi_spec_file(spec_file);
177
			if (exportType.equals("-bb")) { //$NON-NLS-1$
178
				rpmexport.setPatch_tag(patch_tag);
179
				rpmexport.setChangelog_entry(patch_changelog);
180
			}
181
182
			monitor.worked(1);
183
			monitor.setTaskName(Messages.getString("RPMExportOperation.Executing_RPM_Export")); //$NON-NLS-1$
184
185
			// execue the rpm export
186
			try {
79
			try {
187
				rpmexport.run();
80
				rpmProject.buildSourceRPM(exportDelta);
188
			} catch (CoreException e) {
81
			} catch(Exception e) {
189
				rpm_errorTable.add(e.getStatus());
82
				rpm_errorTable.add(e);
190
				refreshWorkspace();
191
				return;
192
			}
83
			}
193
84
			break;
194
			monitor.worked(1);
195
		}
196
197
		refreshWorkspace();
198
199
	}
200
201
202
	public void refreshWorkspace()
203
	{
204
		// Refresh the workspace
205
		IWorkspaceRoot myWorkspaceRoot =
206
		ResourcesPlugin.getWorkspace().getRoot();
207
		IProject myProject = myWorkspaceRoot.getProject(actual_proj_name);
208
209
		try {
210
			myWorkspaceRoot.refreshLocal(2, null);
211
			myProject.refreshLocal(2, null);
212
		} catch (CoreException e1) {
213
			rpm_errorTable.add(e1.getStatus());
214
		}
85
		}
86
		monitor.worked(1);
215
	}
87
	}
216
	
88
	
217
	public MultiStatus getStatus() {
89
	public MultiStatus getStatus() {
(-)src/org/eclipse/cdt/rpm/ui/RPMExportPage.java (-477 / +159 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 ** (c) 2004 Red Hat, Inc.
2
 ** (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
Lines 15-36 Link Here
15
 */
15
 */
16
package org.eclipse.cdt.rpm.ui;
16
package org.eclipse.cdt.rpm.ui;
17
17
18
import org.eclipse.cdt.rpm.core.*;
18
import java.util.Iterator;
19
19
20
import org.eclipse.cdt.core.CProjectNature;
20
import org.eclipse.cdt.rpm.core.IRPMProject;
21
import org.eclipse.cdt.rpm.core.RPMProjectFactory;
22
import org.eclipse.cdt.rpm.core.RPMProjectNature;
23
import org.eclipse.cdt.rpm.ui.util.ExceptionHandler;
24
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IProjectNature;
23
import org.eclipse.core.resources.IResource;
26
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.resources.IWorkspaceRoot;
27
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.ResourcesPlugin;
28
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.MultiStatus;
31
import org.eclipse.core.runtime.Path;
29
30
import org.eclipse.jface.dialogs.ErrorDialog;
31
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.wizard.WizardPage;
33
import org.eclipse.jface.wizard.WizardPage;
33
34
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.events.KeyEvent;
35
import org.eclipse.swt.events.KeyEvent;
36
import org.eclipse.swt.events.KeyListener;
36
import org.eclipse.swt.events.KeyListener;
Lines 56-96 Link Here
56
import org.eclipse.swt.widgets.Listener;
56
import org.eclipse.swt.widgets.Listener;
57
import org.eclipse.swt.widgets.Text;
57
import org.eclipse.swt.widgets.Text;
58
58
59
import java.io.FileNotFoundException;
60
import java.lang.reflect.InvocationTargetException;
61
62
import java.util.ArrayList;
63
import java.util.Iterator;
64
65
59
66
/**
60
/**
67
 * @author pmuldoon
68
 *
61
 *
69
 * RPMExportPage. Called by RPMExportWizard.  Class can not be subclassed
62
 * RPMExportPage. Called by RPMExportWizard.  Class can not be subclassed
70
 *extends WizardPage for the RPM export wizard, implements Listener
63
 *extends WizardPage for the RPM export wizard, implements Listener
71
 *
64
 *
72
 */
65
 */
73
public class RPMExportPage extends WizardPage implements Listener {
66
public class RPMExportPage extends WizardPage implements Listener {
74
	private RPMExportOperation rpmExport;
75
	private RPMCore rpmExportCore;
76
77
	// Checkbox Buttons
67
	// Checkbox Buttons
78
79
	private Button generatePatch;
68
	private Button generatePatch;
80
	private Button exportBinary;
69
	private Button exportBinary;
81
	private Button exportSource;
70
	private Button exportSource;
71
	
72
	// Version and release fields
82
	private Text rpmVersion;
73
	private Text rpmVersion;
83
	private Text rpmRelease;
74
	private Text rpmRelease;
75
	
76
	// The current selection
84
	private IStructuredSelection selection;
77
	private IStructuredSelection selection;
85
78
86
	//Composite Project Listbox control	
79
	//Composite Project Listbox control	
87
	private List projectList;
80
	private List projectList;
81
	
82
	//Spec file combo box
88
	private Combo specFileCombo;
83
	private Combo specFileCombo;
89
	private boolean patchNeeded = false;
84
	
85
	//Patch grid
90
	private Group patchNeedHintGrid;
86
	private Group patchNeedHintGrid;
91
	private static String path_to_specfile;
87
	
92
	static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
88
	//The currently selected RPM project
93
	static final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
89
	private IRPMProject rpmProject;
90
	
91
	//Is a patch needed?
92
	private boolean patchNeeded = false;
94
	
93
	
95
	public RPMExportPage(IStructuredSelection currentSelection) {
94
	public RPMExportPage(IStructuredSelection currentSelection) {
96
		super(Messages.getString("RPMExportPage.Export_SRPM"), //$NON-NLS-1$
95
		super(Messages.getString("RPMExportPage.Export_SRPM"), //$NON-NLS-1$
Lines 99-252 Link Here
99
		setPageComplete(true);
98
		setPageComplete(true);
100
		selection = currentSelection;
99
		selection = currentSelection;
101
	}
100
	}
101
	
102
	public IRPMProject getSelectedRPMProject() {
103
		return rpmProject;
104
	}
105
	
106
	public IFile getSelectedSpecFile() {
107
		Path newSpecFilePath = 
108
			new Path(specFileCombo.getItem(specFileCombo.getSelectionIndex()));
109
		return rpmProject.getProject().getFile(newSpecFilePath);
110
	}
111
	
112
	public String getSelectedVersion() {
113
		return rpmVersion.getText();
114
	}
115
	
116
	public String getSelectedRelease() {
117
		return rpmRelease.getText();
118
	}
102
119
103
	/**
120
	public int getExportType() {
104
	 * Method returnProject.
121
		int exportType = 0;
105
	 * @return String - returned selected project
122
		if(exportBinary.getSelection() && exportSource.getSelection()) {
106
	 *
123
			exportType = IRPMUIConstants.BUILD_ALL;
107
	 * Returns a string from the selected project
124
		} else if(exportBinary.getSelection()) {
108
	 * in the control list box.
125
			exportType = IRPMUIConstants.BUILD_BINARY; 
109
	 */
126
		} else if(exportSource.getSelection()) {
110
	public String returnProject() {
127
			exportType = IRPMUIConstants.BUILD_SOURCE;
111
		String projSelect;
128
		}
129
		return exportType;
130
	}
131
	
132
	private String getSelectedProjectName() {
133
		String projSelect = null;
112
		String[] projDetails = projectList.getSelection();
134
		String[] projDetails = projectList.getSelection();
113
135
114
		if (projDetails.length > 0) {
136
		if (projDetails.length > 0) {
115
			projSelect = projDetails[0];
137
			projSelect = projDetails[0];
116
		} else {
117
			projSelect = ""; //$NON-NLS-1$
118
		}
138
		}
119
120
		return projSelect;
139
		return projSelect;
121
	}
140
	}
122
141
	
123
	/**
142
	private void setPatchNeeded(boolean patchDelta) {
124
	 * Method returnProjectPath
125
	 * @return returns the path of the currently selected project in 
126
	 * projectList
127
	 */
128
	public String returnProjectPath() {
129
		String[] projectSelection = projectList.getSelection();
130
		IProject projectDetail;
131
132
		// As we only allow a single selection in the listbox, and the listbox
133
		// always comes with the first element selected, we can assume
134
		// the first element in the returned array is valid.
135
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
136
		try {
137
			projectDetail = workspaceRoot.getProject(projectSelection[0]);
138
		} catch (Exception e) {
139
			return null;
140
		}
141
142
		return projectDetail.getLocation().toOSString();
143
	}
144
145
	/**
146
	 * Method setPatchModifier
147
	 * @param patchDelta - sets whether patch is required in a project
148
	 */
149
	private void setPatchModifier(boolean patchDelta) {
150
		patchNeeded = patchDelta;
143
		patchNeeded = patchDelta;
151
	}
144
	}
152
145
	
153
	/**
146
	private boolean isPatchNeeded() {
154
	 * Method patchNeeded
155
	 * @return boolean - is a patch needed?
156
	 */
157
	public boolean patchNeeded() {
158
		return patchNeeded;
147
		return patchNeeded;
159
	}
148
	}
160
149
161
	/**
150
	/**
162
	 * Method returnSpecFiles
163
	 *
164
	 * @param projname - Name of the project to mine for spec files
165
	 * @return ArrayList - ArrayList of found spec files
166
	 *
167
	 * Method that mines a selected project for spec files
168
	 * Will return an ArrayList of returned spec files
169
	 *
170
	 */
171
	public ArrayList returnSpecFiles(String givenProjectName) {
172
		IProject[] internalProjects;
173
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
174
		internalProjects = workspaceRoot.getProjects();
175
176
		String projectName;
177
		ArrayList specFileList = new ArrayList();
178
179
		for (int numberOfProjects = 0; numberOfProjects < internalProjects.length; numberOfProjects++) {
180
			projectName = internalProjects[numberOfProjects].getName();
181
182
			if (projectName.equals(givenProjectName)) {
183
				try {
184
					final IResource[] projectResourceList = internalProjects[numberOfProjects].members();
185
186
					for (int numberOfResources = 0; numberOfResources < projectResourceList.length; numberOfResources++) {
187
						String filenameExtension = projectResourceList[numberOfResources].getFileExtension();
188
189
						if (filenameExtension != null) {
190
							if (filenameExtension.equals("spec")) { //$NON-NLS-1$
191
								specFileList.add(projectResourceList[numberOfResources].getName().toString());
192
							}
193
						}
194
					}
195
				} catch (CoreException e) {
196
				}
197
			}
198
		}
199
200
		return specFileList;
201
	}
202
203
	/**
204
	 * Method hasMakefile.
205
	 * @param givenProjectName - project name to check
206
	 * @return boolean - true if project has makefile, false if not
207
	 *
208
	 *  Returns boolean on whether the currently selected project
209
	 *  has a Makefile that is visible and can be sourced
210
	 */
211
	public boolean hasMakefile(String givenProjectName) {
212
		IProject[] internalProjectList;
213
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
214
		internalProjectList = workspaceRoot.getProjects();
215
216
		String projectName;
217
		IResource resourceList;
218
219
		for (int a = 0; a < internalProjectList.length; a++) {
220
			projectName = internalProjectList[a].getName();
221
222
			if (projectName.equals(givenProjectName)) {
223
				resourceList = internalProjectList[a].findMember(Messages.getString(
224
							"RPMExportPage.Makefile_pc")); //$NON-NLS-1$
225
226
				if (resourceList != null) {
227
					return true;
228
				}
229
230
				resourceList = internalProjectList[a].findMember(Messages.getString(
231
							"RPMExportPage.makefile_lc")); //$NON-NLS-1$
232
233
				if (resourceList != null) {
234
					return true;
235
				}
236
			}
237
		}
238
239
		return false;
240
	}
241
242
	/**
243
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
151
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
244
	 *
152
	 *
245
	 * Parent control. Creates the listbox, Destination box, and options box
153
	 * Parent control. Creates the listbox, Destination box, and options box
246
	 *
154
	 *
247
	 */
155
	 */
248
	public void createControl(Composite parent) {
156
	public void createControl(Composite parent) {
249
		
250
		Composite composite = new Composite(parent, SWT.NULL);
157
		Composite composite = new Composite(parent, SWT.NULL);
251
158
252
		// Create a layout for the wizard page
159
		// Create a layout for the wizard page
Lines 256-442 Link Here
256
163
257
		// Create contols on the page
164
		// Create contols on the page
258
		createProjectBox(composite);
165
		createProjectBox(composite);
259
		createSpecFileField(composite);
166
		createSpecFileFields(composite);
260
		setSpecFileComboData();
261
		createSpacer(composite);
167
		createSpacer(composite);
262
		createExportType(composite);
168
		createExportTypeControls(composite);
263
		setPatchHint(composite);
169
		createPatchHint(composite);
170
		
171
		// Fill in the fields
172
		setSpecFileComboData();
173
		setVersionReleaseFields();
264
174
265
		// Check if the project checksums are different
175
		// Check if the project has changed
266
		// and therefore the project needs a path
176
		// and therefore the project needs a patch
267
		if (compareCheckSum(returnProjectPath()).equals("patch")) //$NON-NLS-1$
177
		boolean projectChanged = false;
268
		 {
178
		try {
179
			if(rpmProject != null) {
180
				projectChanged = rpmProject.isChanged();
181
			}
182
		} catch(CoreException e) {
183
			ExceptionHandler.handle(e, getShell(), Messages.getString("ErrorDialog.title"),
184
					e.getMessage());
185
		}
186
		if(projectChanged) {
269
			patchNeedHintGrid.setVisible(true);
187
			patchNeedHintGrid.setVisible(true);
270
			setPatchModifier(true);
188
			setPatchNeeded(true);
271
			setPageComplete(true);
189
			setPageComplete(true);
272
		} else {
190
		} else {
273
			setPatchModifier(false);
191
			setPatchNeeded(false);
274
			setPageComplete(false);
192
			setPageComplete(false);
275
		}
193
		}
276
	}
194
	}
277
195
278
	/**
196
	private void createExportTypeControls(Composite parent) { 
279
	 * Method compareCheckSum
197
		//Create a group for the control and set up the layout.
280
	 * 
281
	 * @param givenProject - project to check
282
	 * @return = match
283
	 * @return = legacy
284
	 * @return = patch
285
	 * @return = error
286
	 * 
287
	 * Returns one of the above status depending on project status
288
	 * 
289
	 */
290
	public String compareCheckSum(String givenProject) {
291
		try {
292
			// Create an instance of the RPMExport class
293
			rpmExportCore = new RPMCore();
294
			
295
			// Mine the .srpmInfo file if there is one
296
			if (rpmExportCore.firstSRPM(givenProject)) {
297
				return "legacy";
298
			}
299
			ArrayList srpmProjectInfo = rpmExportCore.getSRPMexportinfo(givenProject);
300
301
			// If the generated checksum, and the one in the srpmInfo file are the same
302
			// then the project has not changed since last import and does not need a patch
303
			if (rpmExportCore.generateChecksum(givenProject, 0) == Long.parseLong(
304
						(String) srpmProjectInfo.get(6))) {
305
				setPatchModifier(false);
306
307
				return "match"; //$NON-NLS-1$
308
						
309
				
310
				// If we cannot find an srpmInfo file, this is a legacy project
311
			} else if (Long.parseLong((String) srpmProjectInfo.get(6)) == -1) {
312
				setPatchModifier(false);
313
314
				return "legacy"; //$NON-NLS-1$
315
			// Otherwise they don't match and we need to patch
316
				} else {
317
					setPatchModifier(true);
318
319
					return "patch";  //$NON-NLS-1$
320
				}
321
		} catch (CoreException e) {
322
				return "error"; //$NON-NLS-1$
323
		}
324
	}
325
326
	/**
327
	 * Method checkPageComplete.
328
	 * @return boolean
329
	 *
330
	 * Check if export rpm name is valid
331
	 * Check if project has makefile
332
	 * Check a valid project has been selected
333
	 */
334
	public boolean checkPageComplete() {
335
		// Method invoked to check we have all the required data from the user
336
		// before we  allow the wizard to execute. However they can cancel at 
337
		// anytime.
338
		// Check the contents of the RPM destination filename
339
		// Needs work, least of all the variable name ;)
340
		// Check to ensure that the selected project has a makefile
341
		if (hasMakefile(returnProject()) == false) {
342
			setErrorMessage(Messages.getString(
343
					"RPMExportPage.project_does_not_have_Makefile")); //$NON-NLS-1$
344
345
			return false;
346
		}
347
348
		// Check to ensure the select project is actually a project        
349
		String projDetails = returnProject();
350
351
		if (projDetails.equals(Messages.getString(
352
						"RPMExportPage.No_c/c++_projects_found")) == true) { //$NON-NLS-1$
353
			setErrorMessage(Messages.getString(
354
					"RPMExportPage.Invald_project_specified")); //$NON-NLS-1$
355
356
			return false;
357
		}
358
   
359
		// If all tests pass, then we are okay to go.        
360
		return true;
361
	}
362
363
	/**
364
	 * Method finish. Performs the actual work.
365
	 * @return boolean
366
	 * @throws CoreException
367
	 * @throws CoreException
368
	 */
369
	public boolean finish(String[] givenPatchData) throws CoreException {
370
		// Selected project location
371
		String projectLocation = null;
372
373
		// Check that we can finish the export operation	
374
		if (checkPageComplete() == false) {
375
			return false;
376
		}
377
378
		// As we only allow a single selection in the listbox, and the listbox always
379
		// comes with the first element selected, we can assume the first element
380
		// in the returned array is valid. Need to add a try/catch group to check for
381
		// null though
382
		projectLocation = returnProjectPath();
383
384
		String exportType = null;
385
386
		// Calculate the export source type
387
		// -ba = build all
388
		// -bs = build source
389
		// -bb = build binary
390
		if ((exportSource.getSelection() == true) &&
391
				(exportBinary.getSelection() == true)) {
392
			exportType = "-ba"; //$NON-NLS-1$
393
		} else if (exportSource.getSelection() == true) {
394
			exportType = "-bs"; //$NON-NLS-1$
395
		} else if (exportBinary.getSelection() == true) {
396
			exportType = "-bb"; //$NON-NLS-1$
397
		}
398
399
		// Create a new instance of rpmExportOperation build class
400
		try {
401
			rpmExport = new RPMExportOperation(returnProject(),
402
					projectLocation, specFileCombo.getText(), "", givenPatchData[0], //$NON-NLS-1$
403
					givenPatchData[1] + line_sep + 
404
					givenPatchData[2] + line_sep + line_sep, rpmVersion.getText(),
405
					rpmRelease.getText(), exportType, patchNeeded);
406
		} catch (Exception e) {
407
			 setErrorMessage(e.toString());
408
			 return false;
409
		 }
410
		 
411
		 // Run the export
412
		  try {
413
				getContainer().run(true, true, rpmExport);
414
			} catch (InvocationTargetException e1) {
415
				setErrorMessage(e1.toString());
416
				return false;
417
			} catch (InterruptedException e1) {		
418
				setErrorMessage(e1.toString());
419
			}
420
421
		MultiStatus status = rpmExport.getStatus();
422
423
		if (!status.isOK()) {
424
			ErrorDialog.openError(getContainer().getShell(),
425
				Messages.getString(
426
					"RPMExportPage.Errors_encountered_importing_SRPM"), //$NON-NLS-1$
427
				null, // no special message
428
				status);
429
430
			return false;
431
		}
432
433
		// Need to return some meaninful status. Should only return true if the wizard completed
434
		// successfully.
435
		return true;
436
	}
437
438
	private void createExportType(Composite parent) { //Create a group for the control and set up the layout.
439
440
		Group group = new Group(parent, SWT.NONE);
198
		Group group = new Group(parent, SWT.NONE);
441
		group.setLayout(new GridLayout());
199
		group.setLayout(new GridLayout());
442
		group.setText(Messages.getString("RPMExportPage.Composite_Export_Type")); //$NON-NLS-1$
200
		group.setText(Messages.getString("RPMExportPage.Composite_Export_Type")); //$NON-NLS-1$
Lines 479-491 Link Here
479
	 * Create a list box and populate it with
237
	 * Create a list box and populate it with
480
	 * the list of current projects in the workspace
238
	 * the list of current projects in the workspace
481
	 */
239
	 */
482
	protected void createProjectBox(Composite parent) {
240
	private void createProjectBox(Composite parent) {
483
		// Creates a control that enumerates all the projects in the current 
241
		// Creates a control that enumerates all the projects in the current 
484
		// Workspace and places them in a listbox. 
242
		// Workspace and places them in a listbox. 
485
		// Need to check what to do if the user chooses to export an RPM
486
		// when there are no current projects in the workspace. Right now 
487
		// the other export wizard just open, with empty treeviews (?)
488
		// Declare an array of IProject;
489
		IProject[] internalProjectList;
243
		IProject[] internalProjectList;
490
		String Proj_Enum;
244
		String Proj_Enum;
491
245
Lines 521-590 Link Here
521
275
522
		if (internalProjectList.length < 1) {
276
		if (internalProjectList.length < 1) {
523
			projectList.add(Messages.getString(
277
			projectList.add(Messages.getString(
524
					"RPMPage.No_c/c++_projects_found_2")); //$NON-NLS-1$
278
					"RPMPage.No_RPM_projects_found")); //$NON-NLS-1$
525
			return;
279
			return;
526
		}
280
		}
527
281
528
		// Stuff the listbox with the text name of the projects 
529
		// using the getName() method
530
		// Find the first selected project in the workspace
282
		// Find the first selected project in the workspace
531
532
		Iterator iter = selection.iterator();
283
		Iterator iter = selection.iterator();
533
		Object selectedObject= null;
284
		Object selectedObject= null;
534
		IProject selectedProject = null;
285
		IProject selectedProject = null;
535
		boolean isSelection = false;
286
		boolean isSelection = false;
536
		if (iter.hasNext())
287
		if (iter.hasNext()) {
537
		{
538
			selectedObject = iter.next();
288
			selectedObject = iter.next();
539
			if (selectedObject instanceof IResource)
289
			if (selectedObject instanceof IResource) {
540
			{
541
				selectedProject = ((IResource) selectedObject).getProject();
290
				selectedProject = ((IResource) selectedObject).getProject();
542
				isSelection = true;
291
				isSelection = true;
543
			}
292
			}
544
		}
293
		}
545
294
546
		// Stuff the listbox with the text names of the projects 
295
		// Stuff the listbox with the text names of the projects
547
		// using the getName() method and select the selected 
296
		// Highlight the currently selected project in the workspace
548
		// project if available
297
		int selectedProjectIndex = 0;
549
	
298
		for (int a = 0; a < internalProjectList.length; a++) {
550
		
551
		for (int a = 0; a < internalProjectList.length; a++) 
552
		{
553
554
			try {
299
			try {
555
				IProjectNature cNature = internalProjectList[a].getNature(CProjectNature.C_NATURE_ID);
300
				if(internalProjectList[a].hasNature(RPMProjectNature.RPM_NATURE_ID)) {
556
				if (cNature!=null)
557
					projectList.add(internalProjectList[a].getName());
301
					projectList.add(internalProjectList[a].getName());
558
					if (isSelection && internalProjectList[a].equals(selectedProject))
302
					if (isSelection && internalProjectList[a].equals(selectedProject)) {
559
						projectList.setSelection(a);
303
						selectedProjectIndex = a;
560
				} catch (CoreException e) {
304
					}
561
	
305
				}
306
			} catch(CoreException e) {
307
				ExceptionHandler.handle(e, getShell(),
308
						Messages.getString("ErrorDialog.title"), e.getMessage());
562
			}
309
			}
563
		}
310
		}
311
		projectList.setSelection(selectedProjectIndex);
312
		try {
313
			rpmProject = RPMProjectFactory.getRPMProject(internalProjectList[selectedProjectIndex]);
314
		} catch(CoreException e) {
315
			ExceptionHandler.handle(e, getShell(),
316
					Messages.getString("ErrorDialog.title"), e.getMessage());
317
		}
564
		
318
		
565
		if (!isSelection)
319
		// Add a listener to the project box
566
			projectList.setSelection(0);//if none is selected select first project
567
		
568
		// Add a listener to set the name in the location box as 
569
		// it is selected in project box
570
		projectList.addListener(SWT.Selection,
320
		projectList.addListener(SWT.Selection,
571
			new Listener() {
321
			new Listener() {
572
				public void handleEvent(Event event) {
322
				public void handleEvent(Event event) {
573
					rpmVersion.setText("");
323
					// Reset the RPM project
574
					rpmRelease.setText("");
324
					int i = projectList.getSelectionIndex();
325
					if(i != -1) {
326
						IProject project = workspaceRoot.getProject(projectList.getSelection()[0]);
327
						try {
328
							rpmProject = RPMProjectFactory.getRPMProject(project);
329
							if(rpmProject.isChanged()) {
330
								setPatchNeeded(true);
331
								patchNeedHintGrid.setVisible(true);
332
								setPageComplete(true);
333
							} else {
334
								setPatchNeeded(false);
335
								patchNeedHintGrid.setVisible(false);
336
								setPageComplete(false);
337
							}
338
						} catch(CoreException e) {
339
							ExceptionHandler.handle(e, getShell(),
340
									Messages.getString("ErrorDialog.title"), e.getMessage());
341
						}
342
					} else {
343
						rpmProject = null;
344
						setPatchNeeded(false);
345
						patchNeedHintGrid.setVisible(false);
346
						setPageComplete(false);
347
					}
575
					setSpecFileComboData();
348
					setSpecFileComboData();
576
					if (compareCheckSum(returnProjectPath()).equals("patch")) //$NON-NLS-1$
349
					setVersionReleaseFields();
577
					  {
350
				}
578
						 setPatchModifier(true);
351
		});
579
						 patchNeedHintGrid.setVisible(true);
580
						 setPageComplete(true);
581
					 } else {
582
						 patchNeedHintGrid.setVisible(false);
583
						 setPatchModifier(false);
584
						 setPageComplete(false);
585
					 }
586
				 }
587
			});
588
	}
352
	}
589
353
590
	/**
354
	/**
Lines 596-611 Link Here
596
	private void setSpecFileComboData() {
360
	private void setSpecFileComboData() {
597
		specFileCombo.clearSelection();
361
		specFileCombo.clearSelection();
598
		specFileCombo.removeAll();
362
		specFileCombo.removeAll();
599
363
		if(rpmProject != null) {
600
		final ArrayList specFileList = returnSpecFiles(returnProject());
364
			String specFile = 
601
		Iterator i = specFileList.iterator();
365
				rpmProject.getSpecFile().getFile().getProjectRelativePath().toOSString();
602
366
			specFileCombo.add(specFile);
603
		while (i.hasNext())
367
			specFileCombo.setText(specFile);
604
			specFileCombo.add(i.next().toString());
605
606
		if (specFileList.size() > 0) {
607
			specFileCombo.setText(specFileList.get(0).toString());
608
			setVersionReleaseFields();
609
		}
368
		}
610
	}
369
	}
611
370
Lines 615-623 Link Here
615
	 *
374
	 *
616
	 * Creates the Spec file combo box
375
	 * Creates the Spec file combo box
617
	 */
376
	 */
618
	protected void createSpecFileField(Composite parent) {
377
	private void createSpecFileFields(Composite parent) {
619
		
620
621
		Group specGrid = new Group(parent, SWT.NONE);
378
		Group specGrid = new Group(parent, SWT.NONE);
622
		specGrid.setLayout(new GridLayout());
379
		specGrid.setLayout(new GridLayout());
623
		specGrid.setText(Messages.getString("RPMExportPage.SPEC_file")); //$NON-NLS-1$
380
		specGrid.setText(Messages.getString("RPMExportPage.SPEC_file")); //$NON-NLS-1$
Lines 646-652 Link Here
646
			new Listener() {
403
			new Listener() {
647
				public void handleEvent(Event event) {
404
				public void handleEvent(Event event) {
648
					if (!specFileCombo.getText().equals("")) { //$NON-NLS-1$
405
					if (!specFileCombo.getText().equals("")) { //$NON-NLS-1$
649
						setVersionReleaseFields();
406
						Path newSpecFilePath = new Path(specFileCombo.getText());
407
						IFile newSpecFile = rpmProject.getProject().getFile(newSpecFilePath);
408
						if(!newSpecFile.exists()) {
409
							setErrorMessage(Messages.getString("RPMExportPage.Cannont_find_file"));
410
						}
650
					}
411
					}
651
				}
412
				}
652
			});
413
			});
Lines 662-668 Link Here
662
															 			.getShell(),	SWT.OPEN);
423
															 			.getShell(),	SWT.OPEN);
663
					IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
424
					IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
664
																	.getRoot();
425
																	.getRoot();
665
					IProject detailProject = workspaceRoot.getProject(returnProject());
426
					IProject detailProject = workspaceRoot.getProject(getSelectedProjectName());
666
					IPath detailProjectLocation = detailProject.getLocation();
427
					IPath detailProjectLocation = detailProject.getLocation();
667
					rpmFileDialog.setFilterPath(detailProjectLocation.toString());
428
					rpmFileDialog.setFilterPath(detailProjectLocation.toString());
668
429
Lines 670-676 Link Here
670
431
671
					if (selectedSpecName != null) {
432
					if (selectedSpecName != null) {
672
						specFileCombo.setText(selectedSpecName);
433
						specFileCombo.setText(selectedSpecName);
673
						setVersionReleaseFields();
674
					}
434
					}
675
				}
435
				}
676
			});
436
			});
Lines 686-692 Link Here
686
				}
446
				}
687
			};
447
			};
688
            
448
            
689
		   ModifyListener trapChange = new ModifyListener(){
449
		ModifyListener trapChange = new ModifyListener(){
690
				public void modifyText(ModifyEvent e) {
450
				public void modifyText(ModifyEvent e) {
691
					handleEvent(null);
451
					handleEvent(null);
692
				}
452
				}
Lines 731-744 Link Here
731
		rpmRelease.addModifyListener(trapChange);
491
		rpmRelease.addModifyListener(trapChange);
732
	}
492
	}
733
493
734
	/**
494
	private void createPatchHint(Composite parent) {
735
	 * Method setPatchHint
736
	 * 
737
	 * Draws a patch hint for the user
738
	 * @param parent - composite to draw on
739
	 * 
740
	 */
741
	private void setPatchHint(Composite parent) {
742
		Display display = null;
495
		Display display = null;
743
		patchNeedHintGrid = new Group(parent, SWT.NONE);
496
		patchNeedHintGrid = new Group(parent, SWT.NONE);
744
		patchNeedHintGrid.setVisible(false);
497
		patchNeedHintGrid.setVisible(false);
Lines 767-841 Link Here
767
			Messages.getString("RPMExportPage.needPatch_desc")); //$NON-NLS-1$
520
			Messages.getString("RPMExportPage.needPatch_desc")); //$NON-NLS-1$
768
	}
521
	}
769
522
770
	/**
771
	 * Method setVersionReleaseFields
772
	 * 
773
	 * Sets the Version and Release fields to the 
774
	 * values mined from the selected spec file
775
	 */
776
	private void setVersionReleaseFields() {
777
		String specFileLocation = ""; //$NON-NLS-1$
778
779
		String selectSpecFile = specFileCombo.getText();
780
		specFileLocation = returnSpecFilePath(selectSpecFile);
781
		path_to_specfile = specFileLocation;
782
		//Calculate spec file's physical location
783
784
		ArrayList specVersionReleaseTag = returnSpecVersionRelease(specFileLocation);
785
786
		// Mine the spec file's version and release information from
787
		// the provided spec file 
788
789
		if (specVersionReleaseTag.size() == 3) {
790
			rpmVersion.setText(specVersionReleaseTag.get(0).toString());
791
			rpmRelease.setText(specVersionReleaseTag.get(1).toString());
792
		}
793
	}
794
795
	private String returnSpecFilePath(String giveSpecPath)
796
	{		
797
		if (!giveSpecPath.startsWith(file_sep)) { 
798
799
			IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
800
																		.getRoot();
801
			IProject projectDetail = workspaceRoot.getProject(returnProject());
802
			String projectLocation = projectDetail.getLocation().toOSString();
803
			return  projectLocation + file_sep + specFileCombo.getText();
804
		} else {
805
			return specFileCombo.getText();
806
		}
807
808
	}
809
	
523
	
810
	/**
524
	private void setVersionReleaseFields() {
811
	 * Method returnSpecVersionRelease
525
		if(rpmProject != null) {
812
	 * 
526
			String version = rpmProject.getSpecFile().getVersion();
813
	 * Method to return the Spec File version
527
			String release = rpmProject.getSpecFile().getRelease();
814
	 * and release
528
			rpmVersion.setText(version);
815
	 * @param giveSpecFileLocation
529
			rpmRelease.setText(release);
816
	 * @return
817
	 */
818
	private ArrayList returnSpecVersionRelease(String giveSpecFileLocation)
819
	{
820
		
821
		ArrayList specFileVersionTag;
822
		
823
		try {
824
			rpmExportCore = new RPMCore();
825
			specFileVersionTag = rpmExportCore.getNameVerRel(giveSpecFileLocation);
826
		} catch (FileNotFoundException e) {
827
			setErrorMessage(Messages.getString(
828
					"RPMExportPage.Cannont_find_file") + giveSpecFileLocation); //$NON-NLS-1$
829
830
			return null;
831
		} catch (CoreException e) {
832
			setErrorMessage(Messages.getString("RPMExportPage.Core_Exception") +
833
				e.getMessage()); //$NON-NLS-1$
834
835
			return null;
836
		}
530
		}
837
	
838
	return specFileVersionTag;
839
	}
531
	}
840
	
532
	
841
	/**
533
	/**
Lines 845-851 Link Here
845
	 * Create a generic filler control so that we can dump
537
	 * Create a generic filler control so that we can dump
846
	 * controls in a better layout
538
	 * controls in a better layout
847
	 */
539
	 */
848
	protected void createSpacer(Composite parent) {
540
	private void createSpacer(Composite parent) {
849
		Label spacer = new Label(parent, SWT.NONE);
541
		Label spacer = new Label(parent, SWT.NONE);
850
		GridData data = new GridData();
542
		GridData data = new GridData();
851
		data.horizontalAlignment = GridData.FILL;
543
		data.horizontalAlignment = GridData.FILL;
Lines 860-880 Link Here
860
	 * button can be set to true
552
	 * button can be set to true
861
	 * @return boolean. true if finish can be activated
553
	 * @return boolean. true if finish can be activated
862
	 */
554
	 */
863
864
	public boolean canFinish() {
555
	public boolean canFinish() {
865
		
866
		// Make sure project has been selected
556
		// Make sure project has been selected
867
		if (returnProject().equals("")) { //$NON-NLS-1$
557
		if (getSelectedProjectName() == null && rpmProject == null) {
868
			return false;
558
			return false;
869
		}
559
		}
870
560
		// Make sure version/release fields are filled in
871
		
561
		if (!checkVersionReleaseFields()) {
872
		if (checkVersionReleaseFields() == false) {
873
			return false;
562
			return false;
874
		}
563
		}
875
        
876
        // Make sure either export binary/source is checked
564
        // Make sure either export binary/source is checked
877
		if (exportBinary.getSelection() == false && exportSource.getSelection() == false)
565
		if (!exportBinary.getSelection() && !exportSource.getSelection())
878
			return false;
566
			return false;
879
        	
567
        	
880
	   return true;
568
	   return true;
Lines 889-901 Link Here
889
	 */
577
	 */
890
	private boolean checkVersionReleaseFields() {
578
	private boolean checkVersionReleaseFields() {
891
		if (!rpmVersion.getText().equals("")) { //$NON-NLS-1$
579
		if (!rpmVersion.getText().equals("")) { //$NON-NLS-1$
892
893
			if (!rpmRelease.getText().equals("")) { //$NON-NLS-1$
580
			if (!rpmRelease.getText().equals("")) { //$NON-NLS-1$
894
895
				return true;
581
				return true;
896
			}
582
			}
897
		}
583
		}
898
899
		return false;
584
		return false;
900
	}
585
	}
901
586
Lines 908-914 Link Here
908
	public boolean canGoNext() {
593
	public boolean canGoNext() {
909
		// if a patch is needed, the next button should
594
		// if a patch is needed, the next button should
910
		// be enabled
595
		// be enabled
911
		if (patchNeeded()) {
596
		if (isPatchNeeded()) {
912
			return true;
597
			return true;
913
		} else {
598
		} else {
914
			return false;
599
			return false;
Lines 918-924 Link Here
918
	public void handleEvent(Event e) {
603
	public void handleEvent(Event e) {
919
		setPageComplete(canGoNext());
604
		setPageComplete(canGoNext());
920
	}
605
	}
921
	public static String getSpecFilePath() {
922
		return path_to_specfile;
923
	}
924
}
606
}
(-)src/org/eclipse/cdt/rpm/ui/RPMExportPage_2.java (-403 lines)
Removed Link Here
1
/*
2
 * (c) 2004 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
 */
7
8
/**
9
 * @author pmuldoon
10
 * @version 1.0
11
 *
12
 * S/RPM  export page 2. Defines the patch page that is shown to the user when they choose
13
 * to export to an SRPM and patch. Defines the UI elements shown, and the basic validation (need to add to
14
 * this)
15
 */
16
package org.eclipse.cdt.rpm.ui;
17
18
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
19
20
import org.eclipse.jface.wizard.WizardPage;
21
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.events.KeyEvent;
24
import org.eclipse.swt.events.KeyListener;
25
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Event;
32
import org.eclipse.swt.widgets.Group;
33
import org.eclipse.swt.widgets.Label;
34
import org.eclipse.swt.widgets.Listener;
35
import org.eclipse.swt.widgets.Text;
36
37
import java.text.SimpleDateFormat;
38
import java.net.UnknownHostException;
39
import java.util.Date;
40
import java.util.ArrayList;
41
import java.io.*;
42
43
public class RPMExportPage_2 extends WizardPage implements Listener {
44
	// Composite file/browse control
45
	// Core RPM build class
46
	private RPMExportOperation rpmExport;
47
48
	// Checkbox Buttons
49
	private Button generatePatch;
50
51
	// Patch Fields
52
	private Text patchTag;
53
54
	private Text patchChangeLog;
55
56
	private Text patchChangeLogstamp;
57
58
	private boolean first_spec = true;
59
60
	private String path_to_specfile_save = null;
61
62
	private String last_gettext = ""; //$NON-NLS-1$
63
64
	private ArrayList patch_names;
65
66
	private boolean firstTag = true;
67
68
	private boolean patchTagError;
69
70
	private final String valid_char_list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"; //$NON-NLS-1$
71
72
	static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
73
74
	/**
75
	 * @see java.lang.Object#Object()
76
	 * 
77
	 * Constructor for RPMExportPage class
78
	 */
79
	public RPMExportPage_2() {
80
		super(
81
				Messages.getString("RPMExportPage.Export_SRPM"), //$NON-NLS-1$
82
				Messages.getString("RPMExportPage.Export_SRPM_from_project"), null); //$NON-NLS-1$ //$NON-NLS-2$
83
		setDescription(Messages.getString("RPMExportPage_2.0")); //$NON-NLS-1$
84
		patch_names = new ArrayList();
85
	}
86
87
	/**
88
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
89
	 *
90
	 * Parent control. Creates the listbox, Destination box, and options box
91
	 *
92
	 */
93
	public void createControl(Composite parent) {
94
		Composite composite = new Composite(parent, SWT.NULL);
95
		// Create a layout for the wizard page
96
		composite.setLayout(new GridLayout());
97
		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
98
		setControl(composite);
99
100
		// Create contols on the page
101
		createPatchFields(composite);
102
		populatePatchInfo();
103
	}
104
105
	/**
106
	 * Method populatePatchInfo
107
	 *
108
	 * Populate the patch widgets with data
109
	 */
110
	protected void populatePatchInfo() {
111
112
		String userName = RPMCorePlugin.getDefault().getPreferenceStore()
113
				.getString("IRpmConstants.AUTHOR_NAME"); //$NON-NLS-1$
114
		String userEmail = RPMCorePlugin.getDefault().getPreferenceStore()
115
				.getString("IRpmConstants.AUTHOR_EMAIL"); //$NON-NLS-1$
116
117
		// Populate the changeLog
118
		Date today = new Date();
119
		SimpleDateFormat df = new SimpleDateFormat("E MMM dd yyyy"); //$NON-NLS-1$
120
121
		patchChangeLogstamp.setText("* " + df.format(today) + //$NON-NLS-1$
122
				" -- " + userName + " <" + userEmail + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
123
		patchChangeLog.setText("- "); //$NON-NLS-1$
124
	}
125
126
	/**
127
	 * Method createGenPatchFields
128
	 *
129
	 * Create the patch generation widgets
130
	 */
131
	protected void createPatchFields(Composite parent) {
132
		Group group = new Group(parent, SWT.NONE);
133
		group.setLayout(new GridLayout());
134
		group.setText(Messages.getString("RPMExportPage.Patch_Options")); //$NON-NLS-1$
135
		group.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
136
				| GridData.HORIZONTAL_ALIGN_FILL));
137
138
		Composite composite = new Composite(group, SWT.NONE);
139
140
		GridLayout layout = new GridLayout();
141
		layout.numColumns = 2;
142
		composite.setLayout(layout);
143
		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
144
				| GridData.GRAB_HORIZONTAL));
145
146
		// Listen for changes to the patch tag field so we can make sure
147
		// this tag has not been used before
148
		ModifyListener trapTag = new ModifyListener() {
149
			public void modifyText(ModifyEvent e) {
150
				if (firstTag) {
151
					patch_names = getPatchNames(RPMExportPage.getSpecFilePath());
152
					firstTag = false;
153
				}
154
155
				patchTagError = false;
156
				// Does it have any spaces or special characters
157
				if (patchTag.getText().length() != 0) {
158
					for (int i = patchTag.getText().length(); i > 0; i--) {
159
						if (valid_char_list.lastIndexOf(patchTag.getText()
160
								.substring(i - 1,i)) == -1) {
161
							setErrorMessage(Messages
162
									.getString("RPMExportPage_2.1")); //$NON-NLS-1$
163
							patchTagError = true;
164
							handleEvent(null);
165
							return;
166
						}
167
					}
168
					// Is the patch tag unique? (That is, if there are any patch
169
					// tags.)
170
					if (!patch_names.isEmpty()) {
171
						for (int i = 0; i < patch_names.size(); i++) {
172
							if (patchTag.getText().equals(
173
									(String) patch_names.get(i))) {
174
								patchTagError = true;
175
								setErrorMessage(Messages
176
										.getString("RPMExportPage_2.3")); //$NON-NLS-1$
177
								handleEvent(null);
178
								return;
179
							}
180
						}
181
					}
182
				}
183
				setErrorMessage(null);
184
				setDescription(Messages.getString("RPMExportPage_2.0")); //$NON-NLS-1$
185
				handleEvent(null);
186
			}
187
		};
188
189
		ModifyListener trapPatch = new ModifyListener() {
190
191
			public void modifyText(ModifyEvent e) {
192
				handleEvent(null);
193
			}
194
		};
195
196
		GridData patchTagGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
197
				| GridData.GRAB_HORIZONTAL);
198
		new Label(composite, SWT.NONE).setText(Messages
199
				.getString("RPMExportPage.Patch_Tag")); //$NON-NLS-1$
200
		patchTag = new Text(composite, SWT.BORDER);
201
		patchTag.setToolTipText(Messages
202
				.getString("RPMExportPage.toolTip_Patch_Tag")); //$NON-NLS-1$
203
204
		patchTag.setLayoutData(patchTagGridData);
205
206
		GridData pChangelogStampGridData = new GridData(
207
				GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
208
		new Label(composite, SWT.NONE).setText(Messages
209
				.getString("RPMExportPage.Patch_Changelog_Stamp")); //$NON-NLS-1$
210
211
		patchChangeLogstamp = new Text(composite, SWT.BORDER);
212
		patchChangeLogstamp.setLayoutData(pChangelogStampGridData);
213
		patchTag.addModifyListener(trapTag);
214
		patchChangeLogstamp.addModifyListener(trapPatch);
215
		patchChangeLogstamp.setToolTipText(Messages
216
				.getString("RPMExportPage.toolTip_Changelog_Stamp")); //$NON-NLS-1$
217
218
		new Label(composite, SWT.NONE).setText(Messages
219
				.getString("RPMExportPage.Patch_Changelog")); //$NON-NLS-1$
220
221
		KeyListener patchChangelogListener = new KeyListener() {
222
			public void keyPressed(KeyEvent e) {
223
				handleEvent(null);
224
			}
225
226
			public void keyReleased(KeyEvent e) {
227
				handleEvent(null);
228
				if (e.keyCode == 13) {
229
					if (patchChangeLog.getCaretPosition() == patchChangeLog
230
							.getCharCount())
231
						patchChangeLog.append("- "); //$NON-NLS-1$
232
					else if (patchChangeLog.getText(
233
							patchChangeLog.getCaretPosition() - 1,
234
							patchChangeLog.getCaretPosition() - 1).equals("\n")) //$NON-NLS-1$
235
						patchChangeLog.insert("- "); //$NON-NLS-1$
236
				}
237
			}
238
		};
239
240
		GridData pChangelogGridData = new GridData(
241
				GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
242
243
		patchChangeLog = new Text(composite, SWT.BORDER | SWT.MULTI);
244
		pChangelogGridData.heightHint = 7 * patchChangeLog.getLineHeight();
245
		patchChangeLog.setLayoutData(pChangelogGridData);
246
		patchChangeLog.addKeyListener(patchChangelogListener);
247
		patchChangeLog.setToolTipText(Messages
248
				.getString("RPMExportPage.toolTip_Changelog")); //$NON-NLS-1$
249
250
	}
251
252
	/**
253
	 * canFinish()
254
	 * 
255
	 * Hot validation. Called to determine whether Finish
256
	 * button can be set to true
257
	 * @return boolean. true if finish can be activated
258
	 */
259
	public boolean canFinish() {
260
261
		// Is the patch tag empty
262
		if (patchTag.getText().equals("")) { //$NON-NLS-1$
263
			setErrorMessage(null);
264
			setDescription(Messages.getString("RPMExportPage_2.5")); //$NON-NLS-1$
265
			return false;
266
		}
267
268
		//		 Is tag a duplicate or have spaces?
269
		if (patchTagError) {
270
			return false;
271
		}
272
273
		else {
274
			setErrorMessage(null);
275
			setDescription(Messages.getString("RPMExportPage_2.4")); //$NON-NLS-1$
276
		}
277
278
		// Is the Changelog fields empty?
279
		if (patchChangeLog.getText().equals("- ") | patchChangeLog.getText().equals("") | //$NON-NLS-1$ //$NON-NLS-2$
280
				patchChangeLog.getText().equals("-")) {
281
			setDescription(Messages.getString("RPMExportPage_2.4")); //$NON-NLS-1$
282
283
			return false;
284
		} else if (patchTag.getText().equals("")) {
285
			setErrorMessage(null);
286
			setDescription(Messages.getString("RPMExportPage_2.5")); //$NON-NLS-1$
287
			return false;
288
		}
289
290
		// Is the time stamp empty?
291
		if (patchChangeLogstamp.getText().equals("")) { //$NON-NLS-1$
292
293
			return false;
294
		}
295
296
		setErrorMessage(null);
297
		setDescription(Messages.getString("RPMExportPage_2.2")); //$NON-NLS-1$
298
299
		return true;
300
	}
301
302
	public String[] patchData() {
303
		String[] patchDataList = new String[3];
304
305
		patchDataList[0] = patchTag.getText();
306
		patchDataList[1] = patchChangeLogstamp.getText();
307
		patchDataList[2] = patchChangeLog.getText();
308
309
		return patchDataList;
310
	}
311
312
	public void handleEvent(Event e) {
313
		setPageComplete(canFinish());
314
	}
315
316
	private String getHostName() {
317
		String hostname;
318
		try {
319
			hostname = java.net.InetAddress.getLocalHost().getHostName();
320
		} catch (UnknownHostException e) {
321
			return ""; //$NON-NLS-1$
322
		}
323
		// Trim off superflous stuff from the hostname
324
		int firstdot = hostname.indexOf("."); //$NON-NLS-1$
325
		int lastdot = hostname.lastIndexOf("."); //$NON-NLS-1$
326
		// If the two are equal, no need to trim name
327
		if (firstdot == lastdot) {
328
			return hostname;
329
		}
330
		String hosttemp = ""; //$NON-NLS-1$
331
		String hosttemp2 = hostname;
332
		while (firstdot != lastdot) {
333
			hosttemp = hosttemp2.substring(lastdot) + hosttemp;
334
			hosttemp2 = hostname.substring(0, lastdot);
335
			lastdot = hosttemp2.lastIndexOf("."); //$NON-NLS-1$
336
		}
337
		return hosttemp.substring(1);
338
	}
339
340
	/*
341
	 * This method gets the path to the spec file that will be used to create
342
	 * the rpm and gleans the patch names from it.
343
	 * @returns populated ArrayList if spec file found, null ArrayList if not
344
	 */
345
346
	private ArrayList getPatchNames(String path_to_specfile) {
347
348
		File f = new File(path_to_specfile);
349
		if (!f.exists()) {
350
			return null;
351
		}
352
		ArrayList patch_names = new ArrayList();
353
		try {
354
			FileReader sp_file = new FileReader(path_to_specfile);
355
			StreamTokenizer st = new StreamTokenizer(sp_file);
356
357
			// Make sure numbers, colons and percent signs are considered valid
358
			st.wordChars('a', 'z');
359
			st.wordChars('A', 'Z');
360
			st.wordChars(':', ':');
361
			st.wordChars('0', '9');
362
			st.wordChars('%', '%');
363
			st.wordChars('{', '}');
364
			st.wordChars('-', '-');
365
			st.wordChars('/', '/');
366
			st.wordChars('=', '=');
367
			st.wordChars('.', '.');
368
			st.wordChars('_', '_');
369
			st.eolIsSignificant(true);
370
			boolean found_patch = false;
371
372
			String new_word;
373
			int token = st.nextToken();
374
			while (token != StreamTokenizer.TT_EOF) {
375
				token = st.nextToken();
376
377
				switch (token) {
378
379
				case StreamTokenizer.TT_WORD:
380
					new_word = st.sval;
381
					if (new_word.startsWith("Patch")) { //$NON-NLS-1$
382
						found_patch = true;
383
						break;
384
					}
385
					if (new_word.endsWith(".patch") && found_patch) { //$NON-NLS-1$
386
						int i = new_word.lastIndexOf("-"); //$NON-NLS-1$
387
						int j = new_word.lastIndexOf(".patch"); //$NON-NLS-1$
388
						patch_names.add(new_word.substring(i + 1, j));
389
						found_patch = false;
390
						break;
391
					}
392
				default:
393
					found_patch = false;
394
					break;
395
				}
396
			}
397
			sp_file.close();
398
		} catch (IOException e) {
399
			return null;
400
		}
401
		return patch_names;
402
	}
403
}
(-)src/org/eclipse/cdt/rpm/ui/RPMExportWizard.java (-25 / +46 lines)
Lines 1-36 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
6
*/
6
*/
7
package org.eclipse.cdt.rpm.ui;
7
package org.eclipse.cdt.rpm.ui;
8
8
9
import org.eclipse.core.runtime.CoreException;
9
import java.lang.reflect.InvocationTargetException;
10
10
11
import org.eclipse.cdt.rpm.core.IRPMProject;
12
import org.eclipse.cdt.rpm.core.RPMExportDelta;
13
import org.eclipse.core.runtime.MultiStatus;
14
import org.eclipse.jface.dialogs.ErrorDialog;
11
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
12
import org.eclipse.jface.wizard.Wizard;
16
import org.eclipse.jface.wizard.Wizard;
13
14
import org.eclipse.ui.IExportWizard;
17
import org.eclipse.ui.IExportWizard;
15
import org.eclipse.ui.IWorkbench;
18
import org.eclipse.ui.IWorkbench;
16
19
17
18
/**
19
 * @author pmuldoon
20
 * @version 1.0
21
 *
22
 *
23
 * Plug-in entry point. When the user chooses to export an SRPM ,the plug-in manager in Eclipse
24
 * will invoke this class. This class extends Wizard and implements IExportWizard.
25
 *
26
 * The main plugin class to be used in the desktop. This is the "entrypoint"
27
 * for the export rpm plug-in.
28
 */
29
public class RPMExportWizard extends Wizard implements IExportWizard {
20
public class RPMExportWizard extends Wizard implements IExportWizard {
30
	// Create a local reference to RPMExportPage
21
	private RPMExportPage mainPage;
31
	RPMExportPage mainPage;
22
	private RPMExportPatchPage patchPage;
32
	RPMExportPage_2 patchPage;
33
	private IStructuredSelection selection;
23
	private IStructuredSelection selection;
24
	private IRPMProject rpmProject;
25
	
34
	/**
26
	/**
35
	 * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
27
	 * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
36
	 *
28
	 *
Lines 43-56 Link Here
43
		selection = currentSelection;
35
		selection = currentSelection;
44
	}
36
	}
45
37
46
	// We have elected to do the Finish button clickin in the RPMExportPage. So override
47
	//the default and point to RPMExport finish()
48
	public boolean performFinish() {
38
	public boolean performFinish() {
49
		try {
39
		RPMExportDelta exportDelta = new RPMExportDelta();
50
			return mainPage.finish(patchPage.patchData());
40
		exportDelta.setVersion(mainPage.getSelectedVersion());
51
		} catch (CoreException e) {
41
		exportDelta.setRelease(mainPage.getSelectedRelease());
42
		exportDelta.setSpecFile(mainPage.getSelectedSpecFile());
43
		if(mainPage.canGoNext()) {
44
			exportDelta.setPatchName(patchPage.getSelectedPatchName());
45
			exportDelta.setChangelogEntry(patchPage.getSelectedChangelog());
46
		}
47
		
48
		// Create a new instance of the RPMExportOperation runnable
49
		RPMExportOperation rpmExport = new RPMExportOperation(mainPage.getSelectedRPMProject(),
50
				mainPage.getExportType(), exportDelta); 
51
		
52
		 // Run the export
53
		  try {
54
				getContainer().run(true, true, rpmExport);
55
			} catch (InvocationTargetException e1) {
56
				// use ExceptionHandler?
57
				return false;
58
			} catch (InterruptedException e1) {		
59
			}
60
61
		MultiStatus status = rpmExport.getStatus();
62
63
		if (!status.isOK()) {
64
			ErrorDialog.openError(getContainer().getShell(),
65
				Messages.getString(
66
					"RPMExportPage.Errors_encountered_importing_SRPM"), //$NON-NLS-1$
67
				null, // no special message
68
				status);
69
52
			return false;
70
			return false;
53
		}
71
		}
72
73
		// Need to return some meaninful status. Should only return true if the wizard completed
74
		// successfully.
75
		return true;
54
	}
76
	}
55
77
56
	public boolean canFinish() {
78
	public boolean canFinish() {
Lines 59-65 Link Here
59
		} else if (mainPage.canFinish() && patchPage.canFinish()) {
81
		} else if (mainPage.canFinish() && patchPage.canFinish()) {
60
			return true;
82
			return true;
61
		}
83
		}
62
63
		return false;
84
		return false;
64
	}
85
	}
65
86
Lines 67-73 Link Here
67
	public void addPages() {
88
	public void addPages() {
68
		mainPage = new RPMExportPage(selection);
89
		mainPage = new RPMExportPage(selection);
69
		addPage(mainPage);
90
		addPage(mainPage);
70
		patchPage = new RPMExportPage_2();
91
		patchPage = new RPMExportPatchPage();
71
		addPage(patchPage);
92
		addPage(patchPage);
72
	}
93
	}
73
}
94
}
(-)src/org/eclipse/cdt/rpm/ui/SRPMImportOperation.java (-76 / +17 lines)
Lines 1-49 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
6
*/
6
*/
7
package org.eclipse.cdt.rpm.ui;
7
package org.eclipse.cdt.rpm.ui;
8
8
9
import org.eclipse.cdt.rpm.core.*;
9
import java.io.File;
10
import java.lang.reflect.InvocationTargetException;
11
import java.util.ArrayList;
12
import java.util.Iterator;
13
import java.util.List;
10
14
15
import org.eclipse.cdt.rpm.core.IRPMProject;
16
import org.eclipse.cdt.rpm.core.RPMProjectFactory;
11
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
12
import org.eclipse.core.resources.IWorkspaceRoot;
13
import org.eclipse.core.resources.ResourcesPlugin;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.MultiStatus;
20
import org.eclipse.core.runtime.MultiStatus;
18
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.Status;
19
20
import org.eclipse.jface.operation.IRunnableWithProgress;
22
import org.eclipse.jface.operation.IRunnableWithProgress;
21
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
23
24
24
import java.lang.reflect.InvocationTargetException;
25
26
import java.util.ArrayList;
27
import java.util.Iterator;
28
import java.util.List;
29
30
/**
25
/**
31
 * @author pmuldoon
32
 *
33
 * Import Operation Class for RPM plug-in. This allows us to abstract the operations
26
 * Import Operation Class for RPM plug-in. This allows us to abstract the operations
34
 *  to  a utility class which also inherits IRunnableWithProgress that allows use of
27
 *  to  a utility class which also inherits IRunnableWithProgress that allows use of
35
 * progress bar
28
 * progress bar
36
 */
29
 */
37
30
38
public class SRPMImportOperation implements IRunnableWithProgress {
31
public class SRPMImportOperation implements IRunnableWithProgress {
39
	// Class variable that are use for storage
32
	private IProject project;
40
	// as they are passed into the constrcutor
33
	private File sourceRPM;
41
	private String srpmname;
42
	private IProject project_name;
43
	private boolean preserve_env;
44
	private boolean keep_log;
45
	private boolean applyPatches;
46
	private boolean runAutoConf;
47
34
48
	// Progressmonitor
35
	// Progressmonitor
49
	private IProgressMonitor monitor;
36
	private IProgressMonitor monitor;
Lines 57-72 Link Here
57
	 * @param applyPatchesFlag - Apply patches on import
44
	 * @param applyPatchesFlag - Apply patches on import
58
	 * @param runAutoConfFlag - Run autoconf on import
45
	 * @param runAutoConfFlag - Run autoconf on import
59
	 */
46
	 */
60
	public SRPMImportOperation(
47
	public SRPMImportOperation(IProject project, File sourceRPM) {
61
		IProject name,
48
		this.project = project;
62
		String srpm_name,
49
		this.sourceRPM = sourceRPM;
63
		boolean applyPatchesFlag,
64
		boolean runAutoConfFlag) {
65
		// Copy passed variables to constructor, to class variables	
66
		project_name = name;
67
		srpmname = srpm_name;
68
		applyPatches = applyPatchesFlag;
69
		runAutoConf = runAutoConfFlag;
70
	}
50
	}
71
51
72
	/**
52
	/**
Lines 82-140 Link Here
82
		monitor = progressMonitor;
62
		monitor = progressMonitor;
83
		rpm_errorTable = new ArrayList();
63
		rpm_errorTable = new ArrayList();
84
64
85
		SRPMImport srpmimport;
86
87
		monitor.beginTask(Messages.getString("SRPMImportOperation.Starting"), //$NON-NLS-1$
65
		monitor.beginTask(Messages.getString("SRPMImportOperation.Starting"), //$NON-NLS-1$
88
		totalWork); //$NON-NLS-1$
66
		totalWork); //$NON-NLS-1$
89
67
90
		// Try to create an instance of the build class. 
68
		// Try to create an instance of the build class. 
91
		try {
69
		try {
92
			srpmimport = new SRPMImport(project_name.getLocation().toOSString(), srpmname); //$NON-NLS-1$
70
			IRPMProject rpmProject = RPMProjectFactory.getRPMProject(project);
71
			monitor.worked(1);
72
			monitor.setTaskName(Messages.getString("SRPMImportOperation.Importing_SRPM")); //$NON-NLS-1$
73
			rpmProject.importSourceRPM(sourceRPM);
93
		} catch (Exception e) {
74
		} catch (Exception e) {
94
			rpm_errorTable.add(e);
75
			rpm_errorTable.add(e);
95
			return;
76
			return;
96
		}
77
		}
97
		monitor.worked(1);
78
		monitor.worked(1);
98
		String rpm_release;
99
		String rpm_version;
100
		String usr_rpm_cmd = RPMCorePlugin.getDefault().getPreferenceStore().getString("IRpmConstants.RPM_CMD"); //$NON_NLS-1$
101
		
102
		rpm_version = LinuxShellCmds.getInfo(usr_rpm_cmd + " --qf %{VERSION} -qp " + //$NON-NLS-1$
103
						srpmname);
104
		rpm_release = LinuxShellCmds.getInfo(usr_rpm_cmd + " --qf %{RELEASE} -qp " + //$NON-NLS-1$;
105
						srpmname);
106
		// If the generated checksum, and the one in the srpmInfo file are the same
107
		// then the project has not changed since last import and does not need a patch
108
					
109
				
110
		// set state and options
111
		srpmimport.setDoAutoconf(runAutoConf);
112
		srpmimport.setDoPatches(applyPatches);
113
		srpmimport.setRpm_release(rpm_release);
114
		srpmimport.setRpm_version(rpm_version);
115
116
		monitor.setTaskName(Messages.getString("SRPMImportOperation.Importing_SRPM")); //$NON-NLS-1$
117
118
		// execute import
119
		try {
120
			srpmimport.run();
121
		} catch (CoreException e) {
122
			rpm_errorTable.add(e.getStatus());
123
			return;
124
		}
125
126
		monitor.worked(1);
127
128
		// Refresh the workspace
129
		IWorkspaceRoot myWorkspaceRoot =
130
			ResourcesPlugin.getWorkspace().getRoot();
131
132
		try {
133
			myWorkspaceRoot.refreshLocal(2, null);
134
			project_name.refreshLocal(2, null);
135
		} catch (CoreException e1) {
136
			rpm_errorTable.add(e1.getStatus());
137
		}
138
	}
79
	}
139
80
140
81
(-)src/org/eclipse/cdt/rpm/ui/SRPMImportPage.java (-100 / +45 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
Lines 19-27 Link Here
19
import java.util.Iterator;
19
import java.util.Iterator;
20
import java.util.Vector;
20
import java.util.Vector;
21
21
22
import org.eclipse.cdt.core.CProjectNature;
23
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IProject;
24
import org.eclipse.core.resources.IProjectNature;
25
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.IResource;
26
import org.eclipse.core.resources.IResourceChangeEvent;
24
import org.eclipse.core.resources.IResourceChangeEvent;
27
import org.eclipse.core.resources.IResourceChangeListener;
25
import org.eclipse.core.resources.IResourceChangeListener;
Lines 31-41 Link Here
31
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
33
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.IStatus;
34
35
import org.eclipse.jface.dialogs.ErrorDialog;
32
import org.eclipse.jface.dialogs.ErrorDialog;
36
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.jface.viewers.IStructuredSelection;
37
import org.eclipse.jface.wizard.WizardPage;
34
import org.eclipse.jface.wizard.WizardPage;
38
39
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.events.ModifyEvent;
36
import org.eclipse.swt.events.ModifyEvent;
41
import org.eclipse.swt.events.ModifyListener;
37
import org.eclipse.swt.events.ModifyListener;
Lines 51-64 Link Here
51
import org.eclipse.swt.widgets.Group;
47
import org.eclipse.swt.widgets.Group;
52
import org.eclipse.swt.widgets.List;
48
import org.eclipse.swt.widgets.List;
53
import org.eclipse.swt.widgets.Listener;
49
import org.eclipse.swt.widgets.Listener;
54
55
import org.eclipse.ui.IWorkbench;
50
import org.eclipse.ui.IWorkbench;
56
import org.eclipse.ui.PlatformUI;
51
import org.eclipse.ui.PlatformUI;
57
import org.eclipse.ui.actions.NewProjectAction;
52
import org.eclipse.ui.actions.NewProjectAction;
58
53
59
/**
54
/**
60
 * @author pmuldoon
61
 *
62
 * SRPMImportPage. Called by SRPMImportwizard.  Class can not be subclassed
55
 * SRPMImportPage. Called by SRPMImportwizard.  Class can not be subclassed
63
 * extends WizardPage and implements Listener (for events)
56
 * extends WizardPage and implements Listener (for events)
64
 *
57
 *
Lines 97-110 Link Here
97
90
98
	private IWorkbench workbench;
91
	private IWorkbench workbench;
99
92
100
	// Convienience SRPM import operation class 
101
	private SRPMImportOperation srpmImport;
102
103
	// GUI Control variables	
93
	// GUI Control variables	
104
	private Combo sourceSRPM;
94
	private Combo sourceSRPM;
105
	private Button applyPatch;
106
	private Button runAutoConf;
107
	private Button buildSource;
108
	private Button intoConfigured;
95
	private Button intoConfigured;
109
	private Button intoExisting;
96
	private Button intoExisting;
110
	private List projectList;
97
	private List projectList;
Lines 131-147 Link Here
131
	}
118
	}
132
119
133
	
120
	
134
	public String returnProject() {
121
	private String getSelectedProjectName() {
135
		String projSelect;
122
		String[] selections = projectList.getSelection();
136
		String[] projDetails = projectList.getSelection();
123
		if (selections.length > 0) {
137
124
			return selections[0];
138
		if (projDetails.length > 0) {
139
			projSelect = projDetails[0];
140
		} else {
141
			projSelect = ""; //$NON-NLS-1$
142
		}
125
		}
143
126
		return null;
144
		return projSelect;
127
	}
128
	
129
	private File getSelectedSRPM() {
130
		String srpmName = sourceSRPM.getText();
131
		if(srpmName.equals("") || srpmName == null) { //$NON-NLS-1$
132
			return null;
133
		}
134
		return new File(sourceSRPM.getText());
145
	}
135
	}
146
136
147
	public void createControl(Composite parent) {
137
	public void createControl(Composite parent) {
Lines 158-169 Link Here
158
		setControl(composite);
148
		setControl(composite);
159
149
160
		// Create contols on the page
150
		// Create contols on the page
161
		sourceRPMcombo(composite);
151
		createSourceRPMCombo(composite);
162
		createProjectBox(composite);
152
		createProjectBox(composite);
163
		createOptions(composite);
164
	}
153
	}
165
154
166
	protected void sourceRPMcombo(Composite parent) {
155
	private void createSourceRPMCombo(Composite parent) {
167
		Group specGrid = new Group(parent, SWT.NONE);
156
		Group specGrid = new Group(parent, SWT.NONE);
168
		specGrid.setLayout(new GridLayout());
157
		specGrid.setLayout(new GridLayout());
169
		specGrid.setText(Messages.getString("SRPMImportPage.SRPM_Name")); //$NON-NLS-1$
158
		specGrid.setText(Messages.getString("SRPMImportPage.SRPM_Name")); //$NON-NLS-1$
Lines 216-244 Link Here
216
		srpmBrowse.addListener(SWT.FocusOut, this);
205
		srpmBrowse.addListener(SWT.FocusOut, this);
217
	}
206
	}
218
207
219
	protected void createOptions(Composite parent) {
220
		//Create a group for the control and set up the layout.
221
		Group group = new Group(parent, SWT.NONE);
222
		group.setLayout(new GridLayout());
223
		group.setText(Messages.getString("SRPMImportPage.Build_Options")); //$NON-NLS-1$
224
		group.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL |
225
				GridData.HORIZONTAL_ALIGN_FILL));
226
227
		// Create the build environment checkbox
228
		applyPatch = new Button(group, SWT.CHECK);
229
		applyPatch.setText(Messages.getString("SRPMImportPage.ApplyPatches")); //$NON-NLS-1$
230
		applyPatch.setSelection(true);
231
		applyPatch.setToolTipText(Messages.getString(
232
				"SRPMImportPage.toolTip_ApplyPatches")); //$NON-NLS-1$
233
234
		runAutoConf = new Button(group, SWT.CHECK);
235
		runAutoConf.setText(Messages.getString("SRPMImportPage.runAutoConf")); //$NON-NLS-1$
236
		runAutoConf.setSelection(true);
237
		runAutoConf.setToolTipText(Messages.getString(
238
				"SRPMImportPage.toolTip_runAutoConf")); //$NON-NLS-1$
239
240
	}
241
242
	/**
208
	/**
243
	 * Method createProjectBox.
209
	 * Method createProjectBox.
244
	 * @param parent - parent widget
210
	 * @param parent - parent widget
Lines 247-253 Link Here
247
	 * the list of current projects in the workspace
213
	 * the list of current projects in the workspace
248
	 * along with adding the option for a configured project
214
	 * along with adding the option for a configured project
249
	 */
215
	 */
250
	protected void createProjectBox(Composite parent) {
216
	private void createProjectBox(Composite parent) {
251
		// Creates a control that enumerates all the projects in the current 
217
		// Creates a control that enumerates all the projects in the current 
252
		// Workspace and places them in a listbox. 
218
		// Workspace and places them in a listbox. 
253
		// Give the option of importing into an existing project or creating a new one
219
		// Give the option of importing into an existing project or creating a new one
Lines 315-347 Link Here
315
		
281
		
316
		for (int a = 0; a < internalProjectList.length; a++) 
282
		for (int a = 0; a < internalProjectList.length; a++) 
317
		{
283
		{
318
284
			projectList.add(internalProjectList[a].getName());
319
			try {
285
			if (isSelection && internalProjectList[a].equals(selectedProject)) {
320
				IProjectNature cNature = internalProjectList[a].getNature(CProjectNature.C_NATURE_ID);
286
				projectList.setSelection(a);
321
				if (cNature!=null)
322
					projectList.add(internalProjectList[a].getName());
323
					if (isSelection && internalProjectList[a].equals(selectedProject))
324
						projectList.setSelection(a);
325
				} catch (CoreException e) {
326
	
327
			}
287
			}
328
		}
288
		}
329
		
289
		
330
		if (projectList.getItemCount() == 0) //there were no C/C++ projects
290
		if (projectList.getItemCount() == 0) //there were no projects
331
		{
291
		{
332
			projectList.add(Messages.getString(
292
			projectList.add(Messages.getString(
333
			"RPMPage.No_c/c++_projects_found_2")); //$NON-NLS-1$
293
			"SRPMImportPage.No_projects_found")); //$NON-NLS-1$
334
			intoExisting.setEnabled(false); // Can't very well import into an existing
294
			intoExisting.setEnabled(false); // Can't very well import into an existing
335
			projectList.setEnabled(false);  // project now can we?
295
			projectList.setEnabled(false);  // project now can we?
336
			intoConfigured.setSelection(true);
296
			intoConfigured.setSelection(true);
337
			isSelection = true; // we don't want select the "RPMPage.No_c/c++_projects_found_2"
297
			isSelection = true; // we don't want select the "RPMPage.No_c/c++_projects_found_2"
338
		}
298
		}
339
		else
299
		else {
340
			intoExisting.setSelection(true);
300
			intoExisting.setSelection(true);	
341
			
301
		}
342
		if (!isSelection) //if none is selected select first project
302
		
303
		if (!isSelection) { //if none is selected select first project
343
			projectList.setSelection(0);
304
			projectList.setSelection(0);
344
		else
305
		}
306
		else {
345
			projectList.addSelectionListener(new SelectionListener() {
307
			projectList.addSelectionListener(new SelectionListener() {
346
				public void widgetSelected(SelectionEvent e) {
308
				public void widgetSelected(SelectionEvent e) {
347
					handleEvent(null);
309
					handleEvent(null);
Lines 350-355 Link Here
350
				public void widgetDefaultSelected(SelectionEvent e) {
312
				public void widgetDefaultSelected(SelectionEvent e) {
351
				}
313
				}
352
			});
314
			});
315
		}
353
316
354
		intoExisting.addListener(SWT.Selection, this);
317
		intoExisting.addListener(SWT.Selection, this);
355
		intoConfigured.addListener(SWT.Selection, this);
318
		intoConfigured.addListener(SWT.Selection, this);
Lines 385-415 Link Here
385
	public boolean canFinish() {
348
	public boolean canFinish() {
386
		// Make sure project has been selected or the user 
349
		// Make sure project has been selected or the user 
387
		// has decided to configure a new one instead
350
		// has decided to configure a new one instead
388
		if (intoConfigured.getSelection())
351
		if (getSelectedProjectName() == null && !intoConfigured.getSelection()) {
389
		{
390
			return true;
391
		}
392
		else if (returnProject().equals("")) { //$NON-NLS-1$
393
			return false;
352
			return false;
394
		}
353
		}
395
354
396
		// Make sure an rpm name has been provided
355
		// Make sure an srpm name has been provided
397
		if (sourceSRPM.getText().equals("")) { //$NON-NLS-1$
356
		if (sourceSRPM.getText().equals("")) { //$NON-NLS-1$
398
			return false;
357
			return false;
399
		}
358
		}
400
  
359
		File srpm = new File(sourceSRPM.getText());
401
		return true;
360
		if (!srpm.isFile()){
402
	}
403
404
	/**
405
	 * validateFinish()
406
	 * Second validation step. Validates minimum conditions
407
	 * for starting import
408
	 * @return boolean - true for go; false for problems
409
	 */
410
	public boolean validateFinish(){
411
		File srpmExists = new File(sourceSRPM.getText());
412
		if (!srpmExists.isFile()){
413
			setErrorMessage(Messages.getString("SRPMImportPage.Source_not_Valid"));
361
			setErrorMessage(Messages.getString("SRPMImportPage.Source_not_Valid"));
414
			return false;
362
			return false;
415
		}
363
		}
Lines 418-430 Link Here
418
			setErrorMessage(Messages.getString("SRPMImportPage.No_src_rpm_ext"));
366
			setErrorMessage(Messages.getString("SRPMImportPage.No_src_rpm_ext"));
419
			return false;
367
			return false;
420
		}
368
		}
421
		
369
  
422
		return true;
370
		return true;
423
		
424
			
425
	}
371
	}
426
	
372
	
427
	
428
	/**
373
	/**
429
	 * finish()
374
	 * finish()
430
	 * 
375
	 * 
Lines 435-443 Link Here
435
	public boolean finish() throws CoreException {
380
	public boolean finish() throws CoreException {
436
		IPath detailedProjectLocation = null;
381
		IPath detailedProjectLocation = null;
437
		IProject detailedProject;
382
		IProject detailedProject;
438
		// Check second step validation
439
		if (!validateFinish())
440
			return false;
441
			
383
			
442
		// Get the handle to the current activate Workspace	    
384
		// Get the handle to the current activate Workspace	    
443
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
385
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
Lines 452-459 Link Here
452
			// in the returned array is valid.
394
			// in the returned array is valid.
453
			detailedProject = workspaceRoot.getProject(selectedProject[0]);
395
			detailedProject = workspaceRoot.getProject(selectedProject[0]);
454
		}		
396
		}		
455
		else 
397
		else {
456
			detailedProject = getNewProject();
398
			detailedProject = getNewProject();
399
			if(detailedProject == null) {
400
				return false;
401
			}
402
		}
457
		// Add this SRPM to srpmList
403
		// Add this SRPM to srpmList
458
		for (int i = 0; i < srpmVector.size(); i++)
404
		for (int i = 0; i < srpmVector.size(); i++)
459
		{	// There can only be one occurance 
405
		{	// There can only be one occurance 
Lines 465-483 Link Here
465
		}
411
		}
466
		srpmVector.add((String)(sourceSRPM.getText()));
412
		srpmVector.add((String)(sourceSRPM.getText()));
467
		
413
		
468
		// Create a new instance of SRPMImportOperation build class
414
		SRPMImportOperation srpmImportOp = null;
469
		try {
415
		try {
470
			srpmImport = new SRPMImportOperation(detailedProject,
416
			srpmImportOp = new SRPMImportOperation(detailedProject,
471
					sourceSRPM.getText(), applyPatch.getSelection(),
417
					getSelectedSRPM());
472
					runAutoConf.getSelection());
418
			getContainer().run(true, true, srpmImportOp);
473
			getContainer().run(true, true, srpmImport);
474
		} catch (Exception e) {
419
		} catch (Exception e) {
475
			setErrorMessage(e.toString());
420
			setErrorMessage(e.toString());
476
			return false;
421
			return false;
477
		}
422
		}
478
423
479
		// Get the status of the operation
424
		// Get the status of the operation
480
		IStatus srpmImportStatus = srpmImport.getStatus();
425
		IStatus srpmImportStatus = srpmImportOp.getStatus();
481
426
482
		// If the status does not come back clean, open error dialog
427
		// If the status does not come back clean, open error dialog
483
		if (!srpmImportStatus.isOK()) {
428
		if (!srpmImportStatus.isOK()) {
(-)src/org/eclipse/cdt/rpm/ui/SRPMImportwizard.java (-86 lines)
Removed Link Here
1
/*
2
 * (c) 2004 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
*/
7
8
/**
9
 * @author pmuldoon
10
 * @version 1.0
11
 *
12
 *
13
 * Plug-in entry point. When the user chooses to import an RPM the plug-in manager in Eclipse
14
 * will invoke this class. This class extends Wizard and implements IImportWizard.
15
 */
16
package org.eclipse.cdt.rpm.ui;
17
18
import org.eclipse.core.runtime.CoreException;
19
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.wizard.Wizard;
22
23
import org.eclipse.ui.IImportWizard;
24
import org.eclipse.ui.IWorkbench;
25
26
27
/**
28
 * @author pmuldoon
29
 *
30
  * The main plugin class to be used in the desktop. This is the "entrypoint"
31
 * for the import rpm plug-in.
32
 */
33
public class SRPMImportwizard extends Wizard implements IImportWizard {
34
	private IWorkbench workbench;
35
	private IStructuredSelection selection;
36
37
	// Create a local reference to SRPMImportPage
38
	private SRPMImportPage mainPage;
39
40
	/**
41
	 * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
42
	 */
43
44
	//Basic constructor. Don't do much, just print out debug, and set progress
45
	//monitor status to true
46
	public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
47
		this.workbench = workbench;
48
		selection = currentSelection;
49
		setWindowTitle(Messages.getString("SRPMImportwizard.Import_an_SRPM")); //$NON-NLS-1$
50
		setNeedsProgressMonitor(true);
51
	}
52
53
	/**
54
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
55
	 */
56
57
	// We have elected to do the Finish button clickin in the SRPMImportPage. So override
58
	//the default and point to SRPMImport finish()
59
	public boolean performFinish() {
60
		try {
61
			return mainPage.finish();
62
		} catch (CoreException e) {
63
			return false;
64
		}
65
	}
66
67
	/**
68
	 * @see org.eclipse.jface.wizard.IWizard#canFinish()
69
	 *
70
	 * Select to finish validation in the SRPMImportPage
71
	 */
72
	public boolean canFinish() {
73
		return mainPage.canFinish();
74
	}
75
76
	/**
77
	 * @see org.eclipse.jface.wizard.IWizard#addPages()
78
	 */
79
80
	// Add the SRPMImportPage as the only page in this wizard.
81
	public void addPages() {
82
		mainPage = new SRPMImportPage(workbench, selection);
83
		addPage(mainPage);
84
		super.addPages();
85
	}
86
}
(-)src/org/eclipse/cdt/rpm/ui/rpm_strings.properties (-7 / +11 lines)
Lines 30-36 Link Here
30
RPMExportPage.Makefile_lc=makefile
30
RPMExportPage.Makefile_lc=makefile
31
RPMExportPage.specify_version_and_release_if_SPEC_file_not_provided=You must specify a version and release if a SPEC file is not provided
31
RPMExportPage.specify_version_and_release_if_SPEC_file_not_provided=You must specify a version and release if a SPEC file is not provided
32
RPMExportPage.selected_project_does_not_have_Makefile=The selected project does not have a Makefile
32
RPMExportPage.selected_project_does_not_have_Makefile=The selected project does not have a Makefile
33
RPMExportPage.Cannont_find_file=Cannont find the file: 
33
RPMExportPage.Cannont_find_file=Cannot find the file: 
34
RPMExportPage.Core_Exception=Core Exception: 
34
RPMExportPage.Core_Exception=Core Exception: 
35
RPMExportPage.SPEC_file=SPEC file
35
RPMExportPage.SPEC_file=SPEC file
36
RPMExportPage.Version=Version: 
36
RPMExportPage.Version=Version: 
Lines 50-59 Link Here
50
50
51
RPMexportwiz.Export_an_RPM_title=Export an RPM
51
RPMexportwiz.Export_an_RPM_title=Export an RPM
52
52
53
SRPMImportPage.Configured_New_Project=Check out as a project &configured using the New Project Wizard
53
SRPMImportPage.Configured_New_Project=Import into project &configured using the New Project Wizard
54
SRPMImportPage.Project_does_not_exist=Project does not exist. Please select a project
54
SRPMImportPage.Project_does_not_exist=Project does not exist. Please select a project
55
SRPMImportPage.Problems_identifying_import_source_directory=Problems identifying import source directory
55
SRPMImportPage.Problems_identifying_import_source_directory=Problems identifying import source directory
56
SRPMImportPage.SRPM_Name=SRPM Name
56
SRPMImportPage.SRPM_Name=SRPM
57
SRPMImportPage.Import_SRPM=Import SRPM
57
SRPMImportPage.Import_SRPM=Import SRPM
58
SRPMImportPage.Select_project_to_import=Select a project to import an SRPM into
58
SRPMImportPage.Select_project_to_import=Select a project to import an SRPM into
59
SRPMImportPage.No_objects_selected_to_be_imported=No objects have been selected to be imported
59
SRPMImportPage.No_objects_selected_to_be_imported=No objects have been selected to be imported
Lines 71-76 Link Here
71
SRPMImportPage.Build_Options=Build Options
71
SRPMImportPage.Build_Options=Build Options
72
SRPMImportPage.import_srpm_into=Import SRPM into...
72
SRPMImportPage.import_srpm_into=Import SRPM into...
73
SRPMImportwizard.Import_an_SRPM=Import an SRPM
73
SRPMImportwizard.Import_an_SRPM=Import an SRPM
74
SRPMImportPage.No_projects_found=No projects found
74
75
75
76
76
SRPMImportPage.toolTip_ApplyPatches=Typically, an SRPM is comprised of a source tarball\nand a set of patches that are applied to that tarball.\nTherefore changes are made to the SRPM in the form of\npatches, while leaving the original source 'pristine'\n\nThis option allows you to import the unpatched\n'pristine' source code, and not apply patches
77
SRPMImportPage.toolTip_ApplyPatches=Typically, an SRPM is comprised of a source tarball\nand a set of patches that are applied to that tarball.\nTherefore changes are made to the SRPM in the form of\npatches, while leaving the original source 'pristine'\n\nThis option allows you to import the unpatched\n'pristine' source code, and not apply patches
Lines 109-115 Link Here
109
RPMExportPage_2.0=Enter patch/changelog information for spec file
110
RPMExportPage_2.0=Enter patch/changelog information for spec file
110
RPMExportPage_2.1=Patch Tag cannot have a special character\!
111
RPMExportPage_2.1=Patch Tag cannot have a special character\!
111
RPMExportPage_2.2=Enter patch/changelog information for spec file
112
RPMExportPage_2.2=Enter patch/changelog information for spec file
112
RPMExportPage_2.3=Patch tag is not unique\!
113
RPMExportPage_2.3=Patch name is not unique
113
RPMExportPage_2.4=Enter changelog entry info
114
RPMExportPage_2.4=Enter changelog entry info
114
RPMExportPage_2.5=Enter a patch tag name
115
RPMExportPage_2.5=Enter a patch tag name
115
RPMExportPage.Generate_patch=Generate patch (against previously imported SRPM)
116
RPMExportPage.Generate_patch=Generate patch (against previously imported SRPM)
Lines 135-147 Link Here
135
RPMExportPage.toolTip_file_navigator=Click to open a file navigator to select an external SPEC file
136
RPMExportPage.toolTip_file_navigator=Click to open a file navigator to select an external SPEC file
136
RPMExportPage.toolTip_Version=The Version associated with this RPM.\nChange the version here to change the\nversion of the RPM.
137
RPMExportPage.toolTip_Version=The Version associated with this RPM.\nChange the version here to change the\nversion of the RPM.
137
RPMExportPage.toolTip_Release=The Release associated with this RPM.\nChange the release here to change the release number of the RPM.
138
RPMExportPage.toolTip_Release=The Release associated with this RPM.\nChange the release here to change the release number of the RPM.
138
RPMExportPage.toolTip_Patch_Tag=Patch Tag - unique identifier for patch. Combined with the\npackage name and the version number to form the patch name. \n\nExample:\npump-1.1-exampletag.patch. \n\nThe 'exampletag' would be your tag.
139
RPMExportPage.toolTip_Patch_Name=Patch Name - unique identifier for patch. 
139
RPMExportPage.toolTip_Changelog_Stamp=Changelog Date - Date stamp for the changelog entry. \n\nExample: * Wed Oct 12 2003 -- John Doe <jdoe@redhat.com>
140
RPMExportPage.toolTip_Changelog_Stamp=Changelog Date - Date stamp for the changelog entry. \n\nExample: * Wed Oct 12 2003 -- John Doe <jdoe@redhat.com>
140
RPMExportPage.toolTip_Changelog=Changelog Comment - short descriptive summary of change made in patch\n\nExample: - Fixed bugzilla entry #125642
141
RPMExportPage.toolTip_Changelog=Changelog Comment - short descriptive summary of change made in patch\n\nExample: - Fixed bugzilla entry #125642
141
142
142
RPMPage.Browse=Browse...
143
RPMPage.Browse=Browse...
143
RPMPage.Select_a_project=Select a project ...
144
RPMPage.Select_a_project=Select a project ...
144
RPMPage.No_c/c++_projects_found_2=---> No c/c++ projects found <---
145
RPMPage.No_RPM_projects_found=No RPM projects found
145
146
146
147
147
RPMExportWizard.Export_an_SRPM=Export an SRPM
148
RPMExportWizard.Export_an_SRPM=Export an SRPM
Lines 153-156 Link Here
153
SRPMImportOperation.2=Undefined Error\!
154
SRPMImportOperation.2=Undefined Error\!
154
SRPMImportOperation.3=Source RPM Import Error
155
SRPMImportOperation.3=Source RPM Import Error
155
SRPMImportOperation.Open_SRPM_Errors=Import SRPM Errors=
156
SRPMImportOperation.Open_SRPM_Errors=Import SRPM Errors=
156
SRPMImportOperation.Importing_SRPM=Importing SRPM
157
SRPMImportOperation.Importing_SRPM=Importing SRPM
158
159
ExceptionDialog.seeErrorLogMessage=An exception occurred.  See error log for details.
160
ErrorDialog.title=Error
(-)src/org/eclipse/cdt/rpm/ui/logviewer/LogReader.java (-7 / +8 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
Lines 8-13 Link Here
8
package org.eclipse.cdt.rpm.ui.logviewer;
8
package org.eclipse.cdt.rpm.ui.logviewer;
9
9
10
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
10
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
11
import org.eclipse.core.runtime.CoreException;
11
12
12
import java.io.BufferedReader;
13
import java.io.BufferedReader;
13
import java.io.File;
14
import java.io.File;
Lines 94-105 Link Here
94
	}
95
	}
95
	
96
	
96
	public String getLogFile() {
97
	public String getLogFile() {
97
		String wksp_path = RPMCorePlugin.getDefault().getPreferenceStore()
98
		File f = null;
98
				.getString("IRpmConstants.RPM_WORK_AREA"); //$NON-NLS-1$
99
		try {
99
		String log_name = RPMCorePlugin.getDefault().getPreferenceStore()
100
			f = RPMCorePlugin.getDefault().getExternalLogFile();
100
				.getString("IRpmConstants.RPM_DISPLAYED_LOG_NAME"); //$NON-NLS-1$
101
		} catch(CoreException e) {
101
		String log_file_name = wksp_path + file_sep + log_name + file_sep;
102
			// Too bad.
102
		File f = new File(log_file_name);
103
		}
103
		if (!f.exists()) {
104
		if (!f.exists()) {
104
			return null;
105
			return null;
105
		}
106
		}
(-)src/org/eclipse/cdt/rpm/ui/preferences/RPMPluginPreferencesPage.java (-107 / +23 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * (c) 2004 Red Hat, Inc.
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
3
 *
4
 * This program is open source software licensed under the 
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
5
 * Eclipse Public License ver. 1
Lines 27-32 Link Here
27
import org.eclipse.ui.IWorkbench;
27
import org.eclipse.ui.IWorkbench;
28
import org.eclipse.ui.IWorkbenchPreferencePage;
28
import org.eclipse.ui.IWorkbenchPreferencePage;
29
29
30
import org.eclipse.cdt.rpm.core.IRPMConstants;
30
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
31
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
31
32
32
33
Lines 38-65 Link Here
38
	implements IWorkbenchPreferencePage, SelectionListener, ModifyListener {
39
	implements IWorkbenchPreferencePage, SelectionListener, ModifyListener {
39
    
40
    
40
	private Button dateFormat;
41
	private Button dateFormat;
41
	private Text rpmMacrosFileNameField;
42
	private Text rpmResourceFileNameField;
43
	private Text rpmWorkAreaField;
44
	private Text rpmLogNameField;
45
	private Text displayedRpmLogNameField;
46
	private Text specFilePrefixField;
47
	private Text srpmInfoFileNameField;
48
	private Text rpmShellScriptFileNameField;
49
	private Text emailField;
42
	private Text emailField;
50
	private Text nameField;
43
	private Text nameField;
51
	private Text WorkAreaField;
52
	
44
	
53
	private Text makeField;
54
	private Text rpmField;
45
	private Text rpmField;
55
	private Text rpmbuildField;
46
	private Text rpmbuildField;
56
	private Text chmodField;
57
	private Text cpField;
58
	private Text diffField;
47
	private Text diffField;
59
	private Text tarField;
60
	
61
	
62
	static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
63
    
48
    
64
	private Button createCheckBox(Composite group, String label) {
49
	private Button createCheckBox(Composite group, String label) {
65
	   Button button = new Button(group, SWT.CHECK | SWT.LEFT);
50
	   Button button = new Button(group, SWT.CHECK | SWT.LEFT);
Lines 156-167 Link Here
156
	   gridData.grabExcessVerticalSpace = false;
141
	   gridData.grabExcessVerticalSpace = false;
157
	   vfiller.setLayoutData(gridData);
142
	   vfiller.setLayoutData(gridData);
158
   }
143
   }
159
   protected IPreferenceStore doGetPreferenceStore() {
160
	   return RPMCorePlugin.getDefault().getPreferenceStore();
161
   }
162
   
144
   
163
   public void init(IWorkbench workbench){
145
   public void init(IWorkbench workbench){
164
		initializeDefaultPreferences(getPreferenceStore());
165
   }
146
   }
166
   
147
   
167
   private String getUserName()
148
   private String getUserName()
Lines 169-247 Link Here
169
		return System.getProperty ( "user.name" ); //$NON-NLS-1$
150
		return System.getProperty ( "user.name" ); //$NON-NLS-1$
170
	
151
	
171
   }
152
   }
172
173
   protected void initializeDefaultPreferences(IPreferenceStore store)
174
   {
175
	store.setDefault("IRpmConstants.RPM_WORK_AREA","/var/tmp"); //$NON-NLS-1$ //$NON-NLS-2$
176
	store.setDefault("IRpmConstants.USER_WORK_AREA",file_sep+"rpm_workarea"); //$NON-NLS-1$ //$NON-NLS-2$
177
	store.setDefault("IRpmConstants.RPM_DISPLAYED_LOG_NAME",".logfilename_" +  //$NON-NLS-1$ //$NON-NLS-2$
178
			getUserName());
179
	store.setDefault("IRpmConstants.SPEC_FILE_PREFIX","eclipse_"); //$NON-NLS-1$ //$NON-NLS-2$
180
	store.setDefault("IRpmConstants.SRPM_INFO_FILE",file_sep+".srpminfo"); //$NON-NLS-1$ //$NON-NLS-2$
181
	store.setDefault("IRpmConstants.RPM_SHELL SCRIPT","rpmshell.sh"); //$NON-NLS-1$ //$NON-NLS-2$
182
	store.setDefault("IRpmConstants.RPM_LOG_NAME","rpmbuild.log"); //$NON-NLS-1$ //$NON-NLS-2$
183
	store.setDefault("IRpmConstants.RPM_RESOURCE_FILE",".rpmrc"); //$NON-NLS-1$ //$NON-NLS-2$
184
	store.setDefault("IRpmConstants.RPM_MACROS_FILE",".rpm_macros"); //$NON-NLS-1$ //$NON-NLS-2$
185
	store.setDefault("IRpmConstants.AUTHOR_NAME",getUserName()); //$NON-NLS-1$ //$NON-NLS-2$
186
	store.setDefault("IRpmConstants.AUTHOR_EMAIL",getUserName()+"@" + RPMCorePlugin.getHostName()); //$NON-NLS-1$ //$NON-NLS-2$
187
   
188
	store.setDefault("IRpmConstants.MAKE_CMD", "/usr/bin/make"); //$NON-NLS-1$ //$NON-NLS-2$
189
	store.setDefault("IRpmConstants.RPM_CMD", "/bin/rpm"); //$NON-NLS-1$ //$NON-NLS-2$
190
	store.setDefault("IRpmConstants.RPMBUILD_CMD", "/usr/bin/rpmbuild"); //$NON-NLS-1$ //$NON-NLS-2$
191
	store.setDefault("IRpmConstants.CHMOD_CMD", "/bin/chmod"); //$NON-NLS-1$ //$NON-NLS-2$
192
	store.setDefault("IRpmConstants.CP_CMD", "/bin/cp"); //$NON-NLS-1$ //$NON-NLS-2$
193
	store.setDefault("IRpmConstants.DIFF_CMD", "/usr/bin/diff"); //$NON-NLS-1$ //$NON-NLS-2$
194
	store.setDefault("IRpmConstants.TAR_CMD", "/bin/tar"); //$NON-NLS-1$ //$NON-NLS-2$
195
   }
196
   
153
   
197
   private void initializeDefaults()
154
   private void initializeDefaults()
198
   {
155
   {
199
		IPreferenceStore store = getPreferenceStore();
156
		IPreferenceStore store = RPMCorePlugin.getDefault().getPreferenceStore();
200
		
157
		
201
		emailField.setText(store.getDefaultString("IRpmConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
158
		emailField.setText(store.getDefaultString(IRPMConstants.AUTHOR_EMAIL));
202
		nameField.setText(store.getDefaultString("IRpmConstants.AUTHOR_NAME")); //$NON-NLS-1$
159
		nameField.setText(store.getDefaultString(IRPMConstants.AUTHOR_NAME));
203
		rpmWorkAreaField.setText(store.getDefaultString("IRpmConstants.RPM_WORK_AREA")); //$NON-NLS-1$
160
		rpmField.setText(store.getDefaultString(IRPMConstants.RPM_CMD));
204
		makeField.setText(store.getDefaultString("IRpmConstants.MAKE_CMD")); //$NON-NLS-1$
161
		rpmbuildField.setText(store.getDefaultString(IRPMConstants.RPMBUILD_CMD));
205
		rpmField.setText(store.getDefaultString("IRpmConstants.RPM_CMD")); //$NON-NLS-1$
162
		diffField.setText(store.getDefaultString(IRPMConstants.DIFF_CMD));
206
		rpmbuildField.setText(store.getDefaultString("IRpmConstants.RPMBUILD_CMD")); //$NON-NLS-1$
207
		chmodField.setText(store.getDefaultString("IRpmConstants.CHMOD_CMD")); //$NON-NLS-1$
208
		cpField.setText(store.getDefaultString("IRpmConstants.CP_CMD")); //$NON-NLS-1$
209
		diffField.setText(store.getDefaultString("IRpmConstants.DIFF_CMD")); //$NON-NLS-1$
210
		tarField.setText(store.getDefaultString("IRpmConstants.TAR_CMD")); //$NON-NLS-1$
211
		
163
		
212
		storeValues();
213
   }
164
   }
214
   
165
   
215
   private void initializeValues()
166
   private void initializeValues() {
216
	 {
167
	   IPreferenceStore store = RPMCorePlugin.getDefault().getPreferenceStore();
217
		   IPreferenceStore store = getPreferenceStore();
168
	   
218
		
169
	   emailField.setText(store.getString(IRPMConstants.AUTHOR_EMAIL));
219
			rpmWorkAreaField.setText(store.getString("IRpmConstants.RPM_WORK_AREA")); //$NON-NLS-1$
170
	   nameField.setText(store.getString(IRPMConstants.AUTHOR_NAME));
220
			emailField.setText(store.getString("IRpmConstants.AUTHOR_EMAIL")); //$NON-NLS-1$
171
	   rpmField.setText(store.getString(IRPMConstants.RPM_CMD));
221
			nameField.setText(store.getString("IRpmConstants.AUTHOR_NAME")); //$NON-NLS-1$
172
	   rpmbuildField.setText(store.getString(IRPMConstants.RPMBUILD_CMD));
222
			makeField.setText(store.getString("IRpmConstants.MAKE_CMD")); //$NON-NLS-1$
173
	   diffField.setText(store.getString(IRPMConstants.DIFF_CMD));
223
			rpmField.setText(store.getString("IRpmConstants.RPM_CMD")); //$NON-NLS-1$
174
   }
224
			rpmbuildField.setText(store.getString("IRpmConstants.RPMBUILD_CMD")); //$NON-NLS-1$
225
			chmodField.setText(store.getString("IRpmConstants.CHMOD_CMD")); //$NON-NLS-1$
226
			cpField.setText(store.getString("IRpmConstants.CP_CMD")); //$NON-NLS-1$
227
			diffField.setText(store.getString("IRpmConstants.DIFF_CMD")); //$NON-NLS-1$
228
			tarField.setText(store.getString("IRpmConstants.TAR_CMD")); //$NON-NLS-1$
229
	 }
230
231
	
175
	
232
   private void storeValues() {
176
   private void storeValues() {
233
		IPreferenceStore store = getPreferenceStore();
177
		IPreferenceStore store = RPMCorePlugin.getDefault().getPreferenceStore();
234
	   	
178
	   	
235
		store.setValue("IRpmConstants.RPM_WORK_AREA",rpmWorkAreaField.getText()); //$NON-NLS-1$
179
		store.setValue(IRPMConstants.AUTHOR_NAME, nameField.getText());
236
		store.setValue("IRpmConstants.AUTHOR_NAME",nameField.getText()); //$NON-NLS-1$
180
		store.setValue(IRPMConstants.AUTHOR_EMAIL, emailField.getText());
237
		store.setValue("IRpmConstants.AUTHOR_EMAIL",emailField.getText()); //$NON-NLS-1$
181
		store.setValue(IRPMConstants.RPM_CMD, rpmField.getText());
238
		store.setValue("IRpmConstants.RPM_CMD", rpmField.getText()); //$NON-NLS-1$
182
		store.setValue(IRPMConstants.RPMBUILD_CMD, rpmbuildField.getText());
239
		store.setValue("IRpmConstants.RPMBUILD_CMD", rpmbuildField.getText()); //$NON-NLS-1$
183
		store.setValue(IRPMConstants.DIFF_CMD, diffField.getText());
240
		store.setValue("IRpmConstants.TAR_CMD", tarField.getText()); //$NON-NLS-1$
241
		store.setValue("IRpmConstants.MAKE_CMD", makeField.getText()); //$NON-NLS-1$
242
		store.setValue("IRpmConstants.CHMOD_CMD", chmodField.getText()); //$NON-NLS-1$
243
		store.setValue("IRpmConstants.CP_CMD", cpField.getText()); //$NON-NLS-1$
244
		store.setValue("IRpmConstants.DIFF_CMD", diffField.getText()); //$NON-NLS-1$
245
   	}
184
   	}
246
    
185
    
247
	public void modifyText(ModifyEvent event) {
186
	public void modifyText(ModifyEvent event) {
Lines 285-293 Link Here
285
		createLabel(userPrefs, "Author Email: ");	 //$NON-NLS-1$
224
		createLabel(userPrefs, "Author Email: ");	 //$NON-NLS-1$
286
		emailField = createTextField(userPrefs);
225
		emailField = createTextField(userPrefs);
287
		
226
		
288
		createLabel(userPrefs, "RPM Work Area: ");	 //$NON-NLS-1$
289
		rpmWorkAreaField = createTextField(userPrefs);
290
		
291
		createSpacer(mainComposite, 2);
227
		createSpacer(mainComposite, 2);
292
		
228
		
293
		Group shellPrefs = new Group(mainComposite, SWT.NONE);
229
		Group shellPrefs = new Group(mainComposite, SWT.NONE);
Lines 309-339 Link Here
309
		createLabel(shellPrefs, title + spacer);
245
		createLabel(shellPrefs, title + spacer);
310
		rpmbuildField = createTextField(shellPrefs);
246
		rpmbuildField = createTextField(shellPrefs);
311
		createBrowseButton(shellPrefs, rpmbuildField, title);
247
		createBrowseButton(shellPrefs, rpmbuildField, title);
312
313
		title = "make"; //$NON-NLS-1$
314
		createLabel(shellPrefs, title + spacer);
315
		makeField = createTextField(shellPrefs);
316
		createBrowseButton(shellPrefs, makeField, title);
317
		
248
		
318
		title = "diff"; //$NON-NLS-1$
249
		title = "diff"; //$NON-NLS-1$
319
		createLabel(shellPrefs, title + spacer);
250
		createLabel(shellPrefs, title + spacer);
320
		diffField = createTextField(shellPrefs);
251
		diffField = createTextField(shellPrefs);
321
		createBrowseButton(shellPrefs, diffField, title);
252
		createBrowseButton(shellPrefs, diffField, title);
322
		
323
		title = "tar"; //$NON-NLS-1$
324
		createLabel(shellPrefs, title + spacer);
325
		tarField = createTextField(shellPrefs);
326
		createBrowseButton(shellPrefs, tarField, title);
327
		
328
		title = "chmod";	//$NON-NLS-1$
329
		createLabel(shellPrefs, title + spacer);
330
		chmodField = createTextField(shellPrefs);
331
		createBrowseButton(shellPrefs, chmodField, title);
332
		
333
		title = "cp"; //$NON-NLS-1$
334
		createLabel(shellPrefs, title + spacer);
335
		cpField = createTextField(shellPrefs);
336
		createBrowseButton(shellPrefs, cpField, title);
337
253
338
		initializeValues();
254
		initializeValues();
339
255
(-)src/org/eclipse/cdt/rpm/ui/IRPMUIConstants.java (+22 lines)
Added Link Here
1
/*
2
 * (c) 2005 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
 */
7
8
package org.eclipse.cdt.rpm.ui;
9
10
public interface IRPMUIConstants {
11
12
	public static final String FILE_SEP = System.getProperty("file.separator"); //$NON-NLS-1$
13
14
	public static final String LINE_SEP = System.getProperty("line.separator"); //$NON-NLS-1$
15
	
16
	public static final int BUILD_ALL = 1;
17
	
18
	public static final int BUILD_BINARY = 2;
19
	
20
	public static final int BUILD_SOURCE = 3;
21
	
22
}
(-)src/org/eclipse/cdt/rpm/ui/RPMExportPatchPage.java (+290 lines)
Added Link Here
1
/*
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
 */
7
8
/**
9
 * @author pmuldoon
10
 * @version 1.0
11
 *
12
 * S/RPM  export page 2. Defines the patch page that is shown to the user when they choose
13
 * to export to an SRPM and patch. Defines the UI elements shown, and the basic validation (need to add to
14
 * this)
15
 */
16
package org.eclipse.cdt.rpm.ui;
17
18
import java.net.UnknownHostException;
19
import java.text.SimpleDateFormat;
20
import java.util.ArrayList;
21
import java.util.Date;
22
23
import org.eclipse.cdt.rpm.core.IRPMConstants;
24
import org.eclipse.cdt.rpm.core.RPMCorePlugin;
25
import org.eclipse.jface.wizard.WizardPage;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.KeyEvent;
28
import org.eclipse.swt.events.KeyListener;
29
import org.eclipse.swt.events.ModifyEvent;
30
import org.eclipse.swt.events.ModifyListener;
31
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.Button;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Event;
36
import org.eclipse.swt.widgets.Group;
37
import org.eclipse.swt.widgets.Label;
38
import org.eclipse.swt.widgets.Listener;
39
import org.eclipse.swt.widgets.Text;
40
41
public class RPMExportPatchPage extends WizardPage implements Listener {
42
	// Checkbox Buttons
43
	private Button generatePatch;
44
45
	// Patch Fields
46
	private Text patchTag;
47
48
	private Text patchChangeLog;
49
50
	private Text patchChangeLogstamp;
51
52
	private boolean first_spec = true;
53
54
	private String path_to_specfile_save = null;
55
56
	private String last_gettext = ""; //$NON-NLS-1$
57
58
	private ArrayList patch_names;
59
60
	private boolean firstTag = true;
61
62
	private boolean patchTagError;
63
64
	private final String valid_char_list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"; //$NON-NLS-1$
65
66
	static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
67
68
	/**
69
	 * @see java.lang.Object#Object()
70
	 * 
71
	 * Constructor for RPMExportPage class
72
	 */
73
	public RPMExportPatchPage() {
74
		super(
75
				Messages.getString("RPMExportPage.Export_SRPM"), //$NON-NLS-1$
76
				Messages.getString("RPMExportPage.Export_SRPM_from_project"), null); //$NON-NLS-1$ //$NON-NLS-2$
77
		setDescription(Messages.getString("RPMExportPage_2.0")); //$NON-NLS-1$
78
		patch_names = new ArrayList();
79
	}
80
81
	/**
82
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
83
	 *
84
	 * Parent control. Creates the listbox, Destination box, and options box
85
	 *
86
	 */
87
	public void createControl(Composite parent) {
88
		Composite composite = new Composite(parent, SWT.NULL);
89
		// Create a layout for the wizard page
90
		composite.setLayout(new GridLayout());
91
		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
92
		setControl(composite);
93
94
		// Create contols on the page
95
		createPatchFields(composite);
96
		populatePatchInfo();
97
	}
98
99
	/**
100
	 * Method populatePatchInfo
101
	 *
102
	 * Populate the patch widgets with data
103
	 */
104
	private void populatePatchInfo() {
105
106
		String userName = RPMCorePlugin.getDefault().getPreferenceStore()
107
				.getString(IRPMConstants.AUTHOR_NAME); //$NON-NLS-1$
108
		String userEmail = RPMCorePlugin.getDefault().getPreferenceStore()
109
				.getString(IRPMConstants.AUTHOR_EMAIL); //$NON-NLS-1$
110
111
		// Populate the changeLog
112
		Date today = new Date();
113
		SimpleDateFormat df = new SimpleDateFormat("E MMM dd yyyy"); //$NON-NLS-1$
114
115
		patchChangeLogstamp.setText("* " + df.format(today) + //$NON-NLS-1$
116
				" -- " + userName + " <" + userEmail + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
117
		patchChangeLog.setText("- "); //$NON-NLS-1$
118
	}
119
120
	/**
121
	 * Method createGenPatchFields
122
	 *
123
	 * Create the patch generation widgets
124
	 */
125
	private void createPatchFields(Composite parent) {
126
		Group group = new Group(parent, SWT.NONE);
127
		group.setLayout(new GridLayout());
128
		group.setText(Messages.getString("RPMExportPage.Patch_Options")); //$NON-NLS-1$
129
		group.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
130
				| GridData.HORIZONTAL_ALIGN_FILL));
131
132
		Composite composite = new Composite(group, SWT.NONE);
133
134
		GridLayout layout = new GridLayout();
135
		layout.numColumns = 2;
136
		composite.setLayout(layout);
137
		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
138
				| GridData.GRAB_HORIZONTAL));
139
140
		ModifyListener trapPatch = new ModifyListener() {
141
142
			public void modifyText(ModifyEvent e) {
143
				handleEvent(null);
144
			}
145
		};
146
147
		GridData patchTagGridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
148
				| GridData.GRAB_HORIZONTAL);
149
		new Label(composite, SWT.NONE).setText(Messages
150
				.getString("RPMExportPage.Patch_Name")); //$NON-NLS-1$
151
		patchTag = new Text(composite, SWT.BORDER);
152
		patchTag.setToolTipText(Messages
153
				.getString("RPMExportPage.toolTip_Patch_Tag")); //$NON-NLS-1$
154
155
		patchTag.setLayoutData(patchTagGridData);
156
157
		GridData pChangelogStampGridData = new GridData(
158
				GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
159
		new Label(composite, SWT.NONE).setText(Messages
160
				.getString("RPMExportPage.Patch_Changelog_Stamp")); //$NON-NLS-1$
161
162
		patchChangeLogstamp = new Text(composite, SWT.BORDER);
163
		patchChangeLogstamp.setLayoutData(pChangelogStampGridData);
164
		//patchTag.addModifyListener(trapTag);
165
		patchChangeLogstamp.addModifyListener(trapPatch);
166
		patchChangeLogstamp.setToolTipText(Messages
167
				.getString("RPMExportPage.toolTip_Changelog_Stamp")); //$NON-NLS-1$
168
169
		new Label(composite, SWT.NONE).setText(Messages
170
				.getString("RPMExportPage.Patch_Changelog")); //$NON-NLS-1$
171
172
		KeyListener patchChangelogListener = new KeyListener() {
173
			public void keyPressed(KeyEvent e) {
174
				handleEvent(null);
175
			}
176
177
			public void keyReleased(KeyEvent e) {
178
				handleEvent(null);
179
				if (e.keyCode == 13) {
180
					if (patchChangeLog.getCaretPosition() == patchChangeLog
181
							.getCharCount())
182
						patchChangeLog.append("- "); //$NON-NLS-1$
183
					else if (patchChangeLog.getText(
184
							patchChangeLog.getCaretPosition() - 1,
185
							patchChangeLog.getCaretPosition() - 1).equals("\n")) //$NON-NLS-1$
186
						patchChangeLog.insert("- "); //$NON-NLS-1$
187
				}
188
			}
189
		};
190
191
		GridData pChangelogGridData = new GridData(
192
				GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
193
194
		patchChangeLog = new Text(composite, SWT.BORDER | SWT.MULTI);
195
		pChangelogGridData.heightHint = 7 * patchChangeLog.getLineHeight();
196
		patchChangeLog.setLayoutData(pChangelogGridData);
197
		patchChangeLog.addKeyListener(patchChangelogListener);
198
		patchChangeLog.setToolTipText(Messages
199
				.getString("RPMExportPage.toolTip_Changelog")); //$NON-NLS-1$
200
201
	}
202
203
	/**
204
	 * canFinish()
205
	 * 
206
	 * Hot validation. Called to determine whether Finish
207
	 * button can be set to true
208
	 * @return boolean. true if finish can be activated
209
	 */
210
	public boolean canFinish() {
211
212
		// Is the patch tag empty
213
		if (patchTag.getText().equals("")) { //$NON-NLS-1$
214
			setErrorMessage(null);
215
			setDescription(Messages.getString("RPMExportPage_2.5")); //$NON-NLS-1$
216
			return false;
217
		}
218
219
		//		 Is tag a duplicate or have spaces?
220
		if (patchTagError) {
221
			return false;
222
		}
223
224
		else {
225
			setErrorMessage(null);
226
			setDescription(Messages.getString("RPMExportPage_2.4")); //$NON-NLS-1$
227
		}
228
229
		// Is the Changelog fields empty?
230
		if (patchChangeLog.getText().equals("- ") | patchChangeLog.getText().equals("") | //$NON-NLS-1$ //$NON-NLS-2$
231
				patchChangeLog.getText().equals("-")) {
232
			setDescription(Messages.getString("RPMExportPage_2.4")); //$NON-NLS-1$
233
234
			return false;
235
		} else if (patchTag.getText().equals("")) {
236
			setErrorMessage(null);
237
			setDescription(Messages.getString("RPMExportPage_2.5")); //$NON-NLS-1$
238
			return false;
239
		}
240
241
		// Is the time stamp empty?
242
		if (patchChangeLogstamp.getText().equals("")) { //$NON-NLS-1$
243
244
			return false;
245
		}
246
247
		setErrorMessage(null);
248
		setDescription(Messages.getString("RPMExportPage_2.2")); //$NON-NLS-1$
249
250
		return true;
251
	}
252
	
253
	public String getSelectedPatchName() {
254
		return patchTag.getText();
255
	}
256
	
257
	public String getSelectedChangelog() {
258
		return patchChangeLogstamp.getText() + IRPMUIConstants.LINE_SEP + 
259
			patchChangeLog.getText() + IRPMUIConstants.LINE_SEP + 
260
			IRPMUIConstants.LINE_SEP;
261
	}
262
263
	public void handleEvent(Event e) {
264
		setPageComplete(canFinish());
265
	}
266
267
	private String getHostName() {
268
		String hostname;
269
		try {
270
			hostname = java.net.InetAddress.getLocalHost().getHostName();
271
		} catch (UnknownHostException e) {
272
			return ""; //$NON-NLS-1$
273
		}
274
		// Trim off superflous stuff from the hostname
275
		int firstdot = hostname.indexOf("."); //$NON-NLS-1$
276
		int lastdot = hostname.lastIndexOf("."); //$NON-NLS-1$
277
		// If the two are equal, no need to trim name
278
		if (firstdot == lastdot) {
279
			return hostname;
280
		}
281
		String hosttemp = ""; //$NON-NLS-1$
282
		String hosttemp2 = hostname;
283
		while (firstdot != lastdot) {
284
			hosttemp = hosttemp2.substring(lastdot) + hosttemp;
285
			hosttemp2 = hostname.substring(0, lastdot);
286
			lastdot = hosttemp2.lastIndexOf("."); //$NON-NLS-1$
287
		}
288
		return hosttemp.substring(1);
289
	}
290
}
(-)src/org/eclipse/cdt/rpm/ui/RPMUIPlugin.java (+122 lines)
Added Link Here
1
/* 
2
 * (c) 2005 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
*/
7
package org.eclipse.cdt.rpm.ui;
8
9
import java.util.MissingResourceException;
10
import java.util.ResourceBundle;
11
12
import org.eclipse.swt.widgets.Shell;
13
import org.eclipse.ui.IWorkbenchWindow;
14
import org.eclipse.ui.plugin.AbstractUIPlugin;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.osgi.framework.BundleContext;
19
20
/**
21
 * The main plugin class to be used in the desktop.
22
 */
23
public class RPMUIPlugin extends AbstractUIPlugin {
24
	//The shared instance.
25
	private static RPMUIPlugin plugin;
26
	//Resource bundle.
27
	private ResourceBundle resourceBundle;
28
	
29
	public static final String ID = "org.eclipse.cdt.rpm.ui"; //$NON-NLS-1$
30
	
31
	/**
32
	 * The constructor.
33
	 */
34
	public RPMUIPlugin() {
35
		super();
36
		plugin = this;
37
	}
38
39
	/**
40
	 * This method is called upon plug-in activation
41
	 */
42
	public void start(BundleContext context) throws Exception {
43
		super.start(context);
44
	}
45
46
	/**
47
	 * This method is called when the plug-in is stopped
48
	 */
49
	public void stop(BundleContext context) throws Exception {
50
		super.stop(context);
51
		plugin = null;
52
		resourceBundle = null;
53
	}
54
55
	/**
56
	 * Returns the shared instance.
57
	 */
58
	public static RPMUIPlugin getDefault() {
59
		return plugin;
60
	}
61
62
	/**
63
	 * Returns the string from the plugin's resource bundle,
64
	 * or 'key' if not found.
65
	 */
66
	public static String getResourceString(String key) {
67
		ResourceBundle bundle = RPMUIPlugin.getDefault().getResourceBundle();
68
		try {
69
			return (bundle != null) ? bundle.getString(key) : key;
70
		} catch (MissingResourceException e) {
71
			return key;
72
		}
73
	}
74
75
	/**
76
	 * Returns the plugin's resource bundle,
77
	 */
78
	public ResourceBundle getResourceBundle() {
79
		try {
80
			if (resourceBundle == null)
81
				resourceBundle = ResourceBundle.getBundle("rpmui.RpmuiPluginResources");
82
		} catch (MissingResourceException x) {
83
			resourceBundle = null;
84
		}
85
		return resourceBundle;
86
	}
87
88
	/**
89
	 * Returns an image descriptor for the image file at the given
90
	 * plug-in relative path.
91
	 *
92
	 * @param path the path
93
	 * @return the image descriptor
94
	 */
95
	public static ImageDescriptor getImageDescriptor(String path) {
96
		return AbstractUIPlugin.imageDescriptorFromPlugin("rpmui", path);
97
	}
98
	
99
	public void log(Throwable e) {
100
		log(new Status(IStatus.ERROR, ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$
101
	}
102
103
	public void log(IStatus status) {
104
		getLog().log(status);
105
	}
106
	
107
	public void logErrorMessage(String message) {
108
		log(new Status(IStatus.ERROR, ID, 1, message, null));
109
	}
110
	
111
	public static Shell getActiveWorkbenchShell() {
112
		 IWorkbenchWindow window= getActiveWorkbenchWindow();
113
		 if (window != null) {
114
		 	return window.getShell();
115
		 }
116
		 return null;
117
	}
118
	
119
	public static IWorkbenchWindow getActiveWorkbenchWindow() {
120
		return getDefault().getWorkbench().getActiveWorkbenchWindow();
121
	}
122
}
(-)src/org/eclipse/cdt/rpm/ui/SRPMImportWizard.java (+79 lines)
Added Link Here
1
/*
2
 * (c) 2004, 2005 Red Hat, Inc.
3
 *
4
 * This program is open source software licensed under the 
5
 * Eclipse Public License ver. 1
6
*/
7
8
/**
9
 * @author pmuldoon
10
 * @version 1.0
11
 *
12
 *
13
 * Plug-in entry point. When the user chooses to import an RPM the plug-in manager in Eclipse
14
 * will invoke this class. This class extends Wizard and implements IImportWizard.
15
 */
16
package org.eclipse.cdt.rpm.ui;
17
18
import org.eclipse.core.runtime.CoreException;
19
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.wizard.Wizard;
22
23
import org.eclipse.ui.IImportWizard;
24
import org.eclipse.ui.IWorkbench;
25
26
27
/**
28
 * The main plugin class to be used in the desktop. This is the "entrypoint"
29
 * for the import rpm plug-in.
30
 */
31
public class SRPMImportWizard extends Wizard implements IImportWizard {
32
	private IWorkbench workbench;
33
	private IStructuredSelection selection;
34
	private SRPMImportPage mainPage;
35
36
	/**
37
	 * @see org.eclipse.ui.IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
38
	 */
39
	public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
40
		this.workbench = workbench;
41
		selection = currentSelection;
42
		setWindowTitle(Messages.getString("SRPMImportwizard.Import_an_SRPM")); //$NON-NLS-1$
43
		setNeedsProgressMonitor(true);
44
	}
45
46
	/**
47
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
48
	 */
49
50
	// We have elected to do the Finish button clickin in the SRPMImportPage. So override
51
	//the default and point to SRPMImport finish()
52
	public boolean performFinish() {
53
		try {
54
			return mainPage.finish();
55
		} catch (CoreException e) {
56
			return false;
57
		}
58
	}
59
60
	/**
61
	 * @see org.eclipse.jface.wizard.IWizard#canFinish()
62
	 *
63
	 * Select to finish validation in the SRPMImportPage
64
	 */
65
	public boolean canFinish() {
66
		return mainPage.canFinish();
67
	}
68
69
	/**
70
	 * @see org.eclipse.jface.wizard.IWizard#addPages()
71
	 */
72
73
	// Add the SRPMImportPage as the only page in this wizard.
74
	public void addPages() {
75
		mainPage = new SRPMImportPage(workbench, selection);
76
		addPage(mainPage);
77
		super.addPages();
78
	}
79
}
(-)src/org/eclipse/cdt/rpm/ui/util/ExceptionHandler.java (+137 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2001 Rational Software Corp. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v0.5 
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v05.html
7
 * 
8
 * Contributors:
9
 *     Rational Software - initial implementation
10
 *     Red Hat, Inc. - modified for reuse
11
 ******************************************************************************/
12
package org.eclipse.cdt.rpm.ui.util;
13
14
15
import java.io.StringWriter;
16
import java.lang.reflect.InvocationTargetException;
17
18
import org.eclipse.swt.widgets.Shell;
19
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
23
24
import org.eclipse.cdt.rpm.ui.Messages;
25
import org.eclipse.cdt.rpm.ui.RPMUIPlugin;
26
import org.eclipse.jface.dialogs.ErrorDialog;
27
import org.eclipse.jface.dialogs.MessageDialog;
28
29
/**
30
 * The default exception handler shows an error dialog when one of its handle methods
31
 * is called. If the passed exception is a <code>CoreException</code> an error dialog
32
 * pops up showing the exception's status information. For a <code>InvocationTargetException</code>
33
 * a normal message dialog pops up showing the exception's message. Additionally the exception
34
 * is written to the platform log.
35
 */
36
public class ExceptionHandler {
37
38
	private static ExceptionHandler fgInstance= new ExceptionHandler();
39
	
40
	/**
41
	 * Logs the given exception using the platform's logging mechanism. The exception is
42
	 * logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>.
43
	 */
44
	public static void log(Throwable t, String message) {
45
		RPMUIPlugin.getDefault().log(new Status(IStatus.ERROR, RPMUIPlugin.ID, 
46
			1, message, t));
47
	}
48
	
49
	/**
50
	 * Handles the given <code>CoreException</code>. The workbench shell is used as a parent
51
	 * for the dialog window.
52
	 * 
53
	 * @param e the <code>CoreException</code> to be handled
54
	 * @param title the dialog window's window title
55
	 * @param message message to be displayed by the dialog window
56
	 */
57
	public static void handle(CoreException e, String title, String message) {
58
		handle(e, RPMUIPlugin.getActiveWorkbenchShell(), title, message);
59
	}
60
	
61
	/**
62
	 * Handles the given <code>CoreException</code>. 
63
	 * 
64
	 * @param e the <code>CoreException</code> to be handled
65
	 * @param parent the dialog window's parent shell
66
	 * @param title the dialog window's window title
67
	 * @param message message to be displayed by the dialog window
68
	 */
69
	public static void handle(CoreException e, Shell parent, String title, String message) {
70
		fgInstance.perform(e, parent, title, message);
71
	}
72
	
73
	/**
74
	 * Handles the given <code>InvocationTargetException</code>. The workbench shell is used 
75
	 * as a parent for the dialog window.
76
	 * 
77
	 * @param e the <code>InvocationTargetException</code> to be handled
78
	 * @param title the dialog window's window title
79
	 * @param message message to be displayed by the dialog window
80
	 */
81
	public static void handle(InvocationTargetException e, String title, String message) {
82
		handle(e, RPMUIPlugin.getActiveWorkbenchShell(), title, message);
83
	}
84
	
85
	/**
86
	 * Handles the given <code>InvocationTargetException</code>. 
87
	 * 
88
	 * @param e the <code>InvocationTargetException</code> to be handled
89
	 * @param parent the dialog window's parent shell
90
	 * @param title the dialog window's window title
91
	 * @param message message to be displayed by the dialog window
92
	 */
93
	public static void handle(InvocationTargetException e, Shell parent, String title, String message) {
94
		fgInstance.perform(e, parent, title, message);
95
	}
96
97
	//---- Hooks for subclasses to control exception handling ------------------------------------
98
	
99
	protected void perform(CoreException e, Shell shell, String title, String message) {
100
		RPMUIPlugin.getDefault().log(e);
101
		IStatus status= e.getStatus();
102
		if (status != null) {
103
			ErrorDialog.openError(shell, title, message, status);
104
		} else {
105
			displayMessageDialog(e, e.getMessage(), shell, title, message);
106
		}
107
	}
108
109
	protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
110
		Throwable target= e.getTargetException();
111
		if (target instanceof CoreException) {
112
			perform((CoreException)target, shell, title, message);
113
		} else {
114
			RPMUIPlugin.getDefault().log(e);
115
			if (e.getMessage() != null && e.getMessage().length() > 0) {
116
				displayMessageDialog(e, e.getMessage(), shell, title, message);
117
			} else {
118
				displayMessageDialog(e, target.getMessage(), shell, title, message);
119
			}
120
		}
121
	}
122
123
	//---- Helper methods -----------------------------------------------------------------------
124
	
125
	private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
126
		StringWriter msg= new StringWriter();
127
		if (message != null) {
128
			msg.write(message);
129
			msg.write("\n\n"); //$NON-NLS-1$
130
		}
131
		if (exceptionMessage == null || exceptionMessage.length() == 0)
132
			msg.write(Messages.getString("ExceptionDialog.seeErrorLogMessage")); //$NON-NLS-1$
133
		else
134
			msg.write(exceptionMessage);
135
		MessageDialog.openError(shell, title, msg.toString());			
136
	}	
137
}

Return to bug 82195