?? antennabuildexportaction.java
字號(hào):
/**
* Copyright (c) 2003-2005 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.ui.internal.actions;
import java.io.File;
import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.internal.tools.AntennaBuildExporter;
import eclipseme.core.model.IMidletSuiteProject;
import eclipseme.core.model.MidletSuiteFactory;
import eclipseme.ui.internal.preferences.J2MEPreferencePage;
import eclipseme.ui.internal.utils.LogAndDisplaySafeRunnable;
/**
* Action delegate implementation that provides a means for the user
* to create Ant build files for Antenna.
* <p />
* Copyright (c) 2003-2005 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.6 $
* <br>
* $Date: 2006/02/16 23:55:43 $
* <br>
* @author Craig Setera
*/
public class AntennaBuildExportAction extends AbstractJavaProjectAction {
/**
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
if ((selection != null) && !selection.isEmpty()) {
if (configurationIsValid()) {
// Setup the progress monitoring
ProgressMonitorDialog dialog =
new ProgressMonitorDialog(workbenchPart.getSite().getShell());
dialog.open();
final IProgressMonitor monitor = dialog.getProgressMonitor();
monitor.beginTask("Export Antenna Build Files", 3);
// Create the packages
Iterator iter = selection.iterator();
IMidletSuiteProject suite = getMidletSuite(iter.next());
if (suite != null) {
final AntennaBuildExporter exporter = new AntennaBuildExporter(suite);
Platform.run(new LogAndDisplaySafeRunnable(
workbenchPart.getSite().getShell(),
"export")
{
public void run() throws Exception {
exporter.doExport(monitor);
}
});
}
// All done
monitor.done();
dialog.close();
} else {
warnUserAboutConfigurationError();
}
}
}
/**
* Return a boolean indicating whether or not the configuration is valid
* for this operation.
*
* @return
*/
private boolean configurationIsValid() {
// A simplistic view of whether or not this is a valid configuration
Preferences prefs = EclipseMECorePlugin.getDefault().getPluginPreferences();
File antennaJar = new File(prefs.getString(IEclipseMECoreConstants.PREF_ANTENNA_JAR));
File wtkRoot = new File(prefs.getString(IEclipseMECoreConstants.PREF_WTK_ROOT));
return
antennaJar.exists() && antennaJar.isFile() &&
wtkRoot.exists() && wtkRoot.isDirectory();
}
/**
* Return the midlet suite project associated with the
* selected object.
*
* @param selected
* @return
*/
private IMidletSuiteProject getMidletSuite(Object selected) {
IMidletSuiteProject suite = null;
IJavaProject project = getJavaProject(selected);
if (project != null) {
suite = MidletSuiteFactory.getMidletSuiteProject(project);
}
return suite;
}
/**
* Warn the user about the antenna configuration errors. Allow
* the user to open the configuration.
*/
private void warnUserAboutConfigurationError() {
String message =
"Antenna preferences are not correctly configured.\n" +
"Please configure Antenna preferences.";
ConfigurationErrorDialog dialog = new ConfigurationErrorDialog(
getShell(),
J2MEPreferencePage.ID,
"Antenna Export Error",
message,
"Configure Antenna Preferences...");
dialog.open();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -