]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2007, 2008 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 83258 [jar exporter] Deploy java application as executable jar | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.jdt.internal.ui.jarpackager; | |
13 | ||
14 | import org.eclipse.swt.widgets.Shell; | |
15 | ||
16 | import org.eclipse.core.runtime.CoreException; | |
17 | import org.eclipse.core.runtime.IStatus; | |
18 | import org.eclipse.core.runtime.MultiStatus; | |
19 | import org.eclipse.core.runtime.Status; | |
20 | ||
21 | import org.eclipse.jdt.ui.jarpackager.IJarBuilder; | |
22 | import org.eclipse.jdt.ui.jarpackager.JarPackageData; | |
23 | ||
24 | import org.eclipse.jdt.internal.ui.IJavaStatusConstants; | |
25 | import org.eclipse.jdt.internal.ui.JavaPlugin; | |
26 | ||
27 | /** | |
28 | * Base class for all jar builders. | |
29 | * | |
30 | * @since 3.4 | |
31 | */ | |
32 | public abstract class JarBuilder implements IJarBuilder { | |
33 | ||
34 | private MultiStatus fStatus; | |
35 | ||
36 | /** | |
37 | * {@inheritDoc} | |
38 | */ | |
39 | public void open(JarPackageData jarPackage, Shell shell, MultiStatus status) throws CoreException { | |
40 | fStatus= status; | |
41 | } | |
42 | ||
43 | //some methods for convenience | |
44 | protected final void addInfo(String message, Throwable error) { | |
45 | fStatus.add(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, error)); | |
46 | } | |
47 | ||
48 | protected final void addWarning(String message, Throwable error) { | |
49 | fStatus.add(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, error)); | |
50 | } | |
51 | ||
52 | protected final void addError(String message, Throwable error) { | |
53 | fStatus.add(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, error)); | |
54 | } | |
55 | ||
56 | protected final void addToStatus(CoreException ex) { | |
57 | IStatus status= ex.getStatus(); | |
58 | String message= ex.getLocalizedMessage(); | |
59 | if (message == null || message.length() < 1) { | |
60 | message= JarPackagerMessages.JarFileExportOperation_coreErrorDuringExport; | |
61 | status= new Status(status.getSeverity(), status.getPlugin(), status.getCode(), message, ex); | |
62 | } | |
63 | fStatus.add(status); | |
64 | } | |
65 | } |