[ooo-build-commit] ooeclipse: Branch 'master' - 3 commits
Cédric Bosdonnat
cbosdo at kemper.freedesktop.org
Tue Jan 4 12:22:49 PST 2011
core/plugin.xml | 25 +
core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java | 6
core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java | 35 +
core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java | 23 -
core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchShortcut.java | 196 ++++++++++
core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java | 4
core/source/org/openoffice/ide/eclipse/core/wizards/PackageExportWizard.java | 50 +-
core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java | 12
8 files changed, 307 insertions(+), 44 deletions(-)
New commits:
commit fa643d1adad92e29aad01d98996bcc7c5d8db702
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Tue Jan 4 21:22:11 2011 +0100
Added launch configuration shortcut for office launches
diff --git a/core/plugin.xml b/core/plugin.xml
index 48000f7..11fab23 100644
--- a/core/plugin.xml
+++ b/core/plugin.xml
@@ -335,4 +335,29 @@
</action>
</objectContribution>
</extension>
+ <extension
+ point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ class="org.openoffice.ide.eclipse.core.launch.office.OfficeLaunchShortcut"
+ icon="icons/libreoffice_16.png"
+ id="org.openoffice.ide.eclipse.core.launch.shortcut"
+ label="LibreOffice extension"
+ modes="run, debug">
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1" />
+ <iterate>
+ <and>
+ <adapt type="org.eclipse.core.resources.IProject" />
+ <test property="org.eclipse.debug.ui.projectNature"
+ value="org.openoffice.ide.eclipse.core.unonature" />
+ </and>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ <configurationType id="org.openoffice.ide.eclipse.core.launchOpenOffice" />
+ </shortcut>
+ </extension>
</plugin>
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java b/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java
index 3271a16..a62dc4e 100644
--- a/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java
@@ -106,18 +106,7 @@ public class PackageContentSelector extends Composite {
* Populate the resource view with some default data (mainly the XCU / XCS files).
*/
public void loadDefaults( ) {
- // Select the XCU / XCS files by default
- IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( mProject.getName() );
- FilesFinder finder = new FilesFinder(
- new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION } );
- try {
- finder.addExclude( mProject.getDistFolder().getFullPath() );
- prj.accept( finder );
- } catch (CoreException e) {
- PluginLogger.error("Could not visit the project's content.", e);
- }
-
- ArrayList< IFile > files = finder.getResults();
+ List< IFile > files = getDefaultContent( mProject );
for (IFile file : files) {
mResourceGroup.initialCheckListItem( file );
mResourceGroup.initialCheckTreeItem( file );
@@ -143,6 +132,28 @@ public class PackageContentSelector extends Composite {
}
/**
+ * Get the default files to include in a package (mainly the XCU / XCS files).
+ *
+ * @param pUnoPrj the uno project to get the defaults from
+ *
+ * @return the list of the files to include by default
+ */
+ public static List<IFile> getDefaultContent( IUnoidlProject pUnoPrj ) {
+ // Select the XCU / XCS files by default
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pUnoPrj.getName() );
+ FilesFinder finder = new FilesFinder(
+ new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION } );
+ try {
+ finder.addExclude( pUnoPrj.getDistFolder().getFullPath() );
+ prj.accept( finder );
+ } catch (CoreException e) {
+ PluginLogger.error("Could not visit the project's content.", e);
+ }
+
+ return finder.getResults();
+ }
+
+ /**
* Convenience method to create and populate the UnoPackage.
*
* @param pProject the project to export
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchShortcut.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchShortcut.java
new file mode 100644
index 0000000..9728b56
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchShortcut.java
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program.
+ * If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright: 2010 by Cédric Bosdonnat
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.launch.office;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.gui.PackageContentSelector;
+import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
+import org.openoffice.ide.eclipse.core.model.ProjectsManager;
+
+/**
+ * Class launching the selected uno project as a LibreOffice extension.
+ *
+ * @author Cedric Bosdonnat
+ *
+ */
+public class OfficeLaunchShortcut implements ILaunchShortcut {
+
+ private static final String OFFICE_LAUNCH_CONFIG_ID =
+ "org.openoffice.ide.eclipse.core.launchOpenOffice"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ */
+ public void launch(ISelection pSelection, String pMode) {
+ if ( pSelection instanceof IStructuredSelection ) {
+ IStructuredSelection sel = ( IStructuredSelection ) pSelection;
+ Iterator<?> it = sel.iterator();
+
+ IUnoidlProject project = null;
+ while ( it.hasNext() && project == null) {
+ Object o = it.next();
+ if ( o instanceof IAdaptable ) {
+ IAdaptable adaptable = ( IAdaptable ) o;
+ IResource res = (IResource)adaptable.getAdapter( IResource.class );
+ if ( res != null ) {
+ project = ProjectsManager.getProject( res.getProject().getName() );
+ }
+ }
+ }
+
+ if ( project != null ) {
+ launch( project, pMode );
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void launch(IEditorPart pEditor, String pMode) {
+ IEditorInput input = pEditor.getEditorInput();
+ IFile file = ( IFile ) input.getAdapter( IFile.class );
+
+ if ( file != null ) {
+ IUnoidlProject prj = ProjectsManager.getProject( file.getProject().getName() );
+ if ( prj != null ) {
+ launch( prj, pMode );
+ }
+ }
+ }
+
+ /**
+ * Create a default launch configuration for the UNO project.
+ *
+ * @param pProject the UNO project for which to create the default launch config
+ * @return the newly created and saved launch configuration.
+ */
+ private ILaunchConfiguration createDefaultLaunchConfiguration( IUnoidlProject pProject ) {
+ ILaunchConfiguration created = null;
+ try {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = launchManager.getLaunchConfigurationType( OFFICE_LAUNCH_CONFIG_ID );
+
+ String name = launchManager.generateUniqueLaunchConfigurationNameFrom( pProject.getName() );
+ ILaunchConfigurationWorkingCopy createdConfiguration = type.newInstance( null, name );
+
+ createdConfiguration.setAttribute( IOfficeLaunchConstants.PROJECT_NAME, pProject.getName() );
+ createdConfiguration.setAttribute( IOfficeLaunchConstants.CLEAN_USER_INSTALLATION, true );
+
+ List< IFile > content = PackageContentSelector.getDefaultContent( pProject );
+ String paths = new String();
+ for (IFile file : content) {
+ if ( !paths.isEmpty() ) {
+ paths += IOfficeLaunchConstants.PATHS_SEPARATOR;
+ }
+ paths += file.getProjectRelativePath().toString();
+ }
+ createdConfiguration.setAttribute( IOfficeLaunchConstants.CONTENT_PATHS, paths);
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( pProject.getName() );
+ createdConfiguration.setMappedResources( new IResource[]{ project } );
+
+ // Common Tab Arguments
+ CommonTab tab = new CommonTab();
+ tab.setDefaults(createdConfiguration);
+ tab.dispose();
+
+ created = createdConfiguration.doSave();
+ } catch ( CoreException e ) {
+ PluginLogger.error( "Error creating the launch configuration", e );
+ created = null;
+ }
+
+ return created;
+ }
+
+ /**
+ * COPIED/MODIFIED from AntLaunchShortcut
+ * Returns a list of existing launch configuration for the given file.
+ *
+ * @param pProject the UNO project for which to look for existing launch configurations
+ * @return the list of the matching launch configurations
+ */
+ protected List< ILaunchConfiguration > findExistingLaunchConfigurations( IUnoidlProject pProject ) {
+ ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType( OFFICE_LAUNCH_CONFIG_ID );
+ List<ILaunchConfiguration> validConfigs = new ArrayList<ILaunchConfiguration>();
+ if (type != null) {
+ try {
+ ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
+
+ for ( int i = 0; i < configs.length; i++ ) {
+ String projectName = configs[i].getAttribute(IOfficeLaunchConstants.PROJECT_NAME, "");
+ if ( pProject.getName().equals( projectName ) ) {
+ validConfigs.add(configs[i]);
+ }
+ }
+ } catch (CoreException e) {
+ PluginLogger.error( "Unexpected error", e );
+ }
+ }
+ return validConfigs;
+ }
+
+ /**
+ * Launch a unoidl project using the default configuration.
+ *
+ * @param pProject the project to launch
+ * @param pMode the mode of the launch
+ */
+ private void launch(IUnoidlProject pProject, String pMode) {
+ ILaunchConfiguration conf = null;
+ List<ILaunchConfiguration> configurations = findExistingLaunchConfigurations( pProject );
+ if ( configurations.isEmpty( ) ) {
+ conf = createDefaultLaunchConfiguration( pProject );
+ } else {
+ conf = configurations.get( 0 );
+ }
+
+ if (conf != null ) {
+ DebugUITools.launch( conf, pMode );
+ }
+ }
+
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java
index affe3c8..ba5eb98 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java
@@ -79,7 +79,7 @@ public class PackageConfigTab extends AbstractLaunchConfigurationTab {
IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
String paths = pConfiguration.getAttribute( IOfficeLaunchConstants.CONTENT_PATHS, new String() );
- if(!paths.isEmpty()) {
+ if ( !paths.isEmpty() ) {
String[] pathsItems = paths.split( IOfficeLaunchConstants.PATHS_SEPARATOR );
for (String path : pathsItems) {
@@ -129,7 +129,7 @@ public class PackageConfigTab extends AbstractLaunchConfigurationTab {
String prjName = pConfiguration.getAttribute( IOfficeLaunchConstants.PROJECT_NAME, new String() );
IUnoidlProject project = ProjectsManager.getProject( prjName );
- if(null != project) {
+ if ( null != project ) {
mContentSelector.setProject( project );
List<IResource> selected = getResources( pConfiguration );
commit 9d7b336d8e56f57b44529df134c102081b00ba66
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Wed Dec 15 22:41:27 2010 +0100
[core] force build before launching and exporting
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
index 45b3306..6672d57 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java
@@ -35,7 +35,9 @@ import java.text.MessageFormat;
import java.util.List;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -47,6 +49,7 @@ import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.builders.TypesBuilder;
import org.openoffice.ide.eclipse.core.gui.PackageContentSelector;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
import org.openoffice.ide.eclipse.core.model.ProjectsManager;
@@ -88,29 +91,33 @@ public class OfficeLaunchDelegate extends LaunchConfigurationDelegate {
boolean useCleanUserInstalation = pConfiguration.getAttribute(
IOfficeLaunchConstants.CLEAN_USER_INSTALLATION, false);
- IUnoidlProject prj = ProjectsManager.getProject(prjName);
+ IUnoidlProject unoprj = ProjectsManager.getProject(prjName);
- if (null != prj) {
+ if (null != unoprj) {
try {
IPath userInstallation = null;
if (useCleanUserInstalation) {
- IFolder userInstallationFolder = prj.getOpenOfficeUserProfileFolder();
+ IFolder userInstallationFolder = unoprj.getOpenOfficeUserProfileFolder();
userInstallation = userInstallationFolder.getLocation();
}
+ // Force the build
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+ TypesBuilder.build( prj, pMonitor );
+
List<IResource> resources = PackageConfigTab.getResources( pConfiguration );
- File destFile = exportComponent( prj, resources );
+ File destFile = exportComponent( unoprj, resources );
pMonitor.worked(1);
// Deploy the component
- deployComponent(prj, userInstallation, destFile);
+ deployComponent(unoprj, userInstallation, destFile);
pMonitor.worked(1);
// Run an OpenOffice instance
if (ILaunchManager.DEBUG_MODE.equals(pMode)) {
- prj.getLanguage().connectDebuggerToOpenOffice(prj, pLaunch, userInstallation, pMonitor);
+ unoprj.getLanguage().connectDebuggerToOpenOffice(unoprj, pLaunch, userInstallation, pMonitor);
} else {
- prj.getOOo().runOpenOffice(prj, pLaunch, userInstallation, new NullExtraOptionsProvider(),
+ unoprj.getOOo().runOpenOffice(unoprj, pLaunch, userInstallation, new NullExtraOptionsProvider(),
pMonitor);
}
pMonitor.worked(1);
@@ -161,7 +168,7 @@ public class OfficeLaunchDelegate extends LaunchConfigurationDelegate {
* if something goes wrong.
*/
private File exportComponent(IUnoidlProject pPrj, List<IResource> pResources) throws Exception {
-
+
IFolder distFolder = pPrj.getFolder(pPrj.getDistPath());
File destFile = distFolder.getFile(pPrj.getName() + ".oxt").getLocation().toFile();
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/PackageExportWizard.java b/core/source/org/openoffice/ide/eclipse/core/wizards/PackageExportWizard.java
index 1389b42..962c57f 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/PackageExportWizard.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/PackageExportWizard.java
@@ -41,6 +41,7 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
+import org.openoffice.ide.eclipse.core.PluginLogger;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
import org.openoffice.ide.eclipse.core.model.ProjectsManager;
import org.openoffice.ide.eclipse.core.wizards.pages.ManifestExportPage;
@@ -81,28 +82,35 @@ public class PackageExportWizard extends Wizard implements IExportWizard {
boolean finished = false;
UnoPackage model = mMainPage.getPackageModel( );
if ( model != null ) {
- // Configure the manifest.xml for the model
- mManifestPage.configureManifest( model );
-
- // TODO Run the next operations in a job
-
- // Write the build scripts if needed
- mManifestPage.createBuildScripts( model );
-
- // Export the package
- File out = model.close( );
- finished = out != null;
-
- mMainPage.refreshProject();
-
- if ( mHasNewDialogSettings ) {
- IDialogSettings workbenchSettings = OOEclipsePlugin.getDefault().getDialogSettings();
- IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_KEY);
- section = workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY);
- setDialogSettings(section);
- }
+ try {
+ // Force a build on the project
+ mMainPage.forceBuild();
+
+ // Configure the manifest.xml for the model
+ mManifestPage.configureManifest( model );
+
+ // TODO Run the next operations in a job
+
+ // Write the build scripts if needed
+ mManifestPage.createBuildScripts( model );
+
+ // Export the package
+ File out = model.close( );
+ finished = out != null;
- mMainPage.saveWidgetValues();
+ mMainPage.refreshProject();
+
+ if ( mHasNewDialogSettings ) {
+ IDialogSettings workbenchSettings = OOEclipsePlugin.getDefault().getDialogSettings();
+ IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_KEY);
+ section = workbenchSettings.addNewSection(DIALOG_SETTINGS_KEY);
+ setDialogSettings(section);
+ }
+
+ mMainPage.saveWidgetValues();
+ } catch ( Exception e ) {
+ PluginLogger.error( "Project couldn't be built", e );
+ }
}
return finished;
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java
index 7c1a624..74d2d13 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java
@@ -55,6 +55,7 @@ import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.builders.TypesBuilder;
import org.openoffice.ide.eclipse.core.gui.PackageContentSelector;
import org.openoffice.ide.eclipse.core.i18n.ImagesConstants;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
@@ -403,4 +404,15 @@ public class UnoPackageExportPage extends WizardPage {
}
}
}
+
+ /**
+ * Force a build of the selected project.
+ *
+ * @throws Exception if the project couldn't be built.
+ */
+ public void forceBuild( ) throws Exception {
+ String prjName = mSelectedProject.getName();
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+ TypesBuilder.build( prj, null );
+ }
}
commit 3615ff3124f59da12b45b1960fe26522bbe858c2
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date: Wed Dec 15 22:39:10 2010 +0100
[core] Create the urd folder if needed during the build
diff --git a/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java b/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
index d1036c2..6ffcd74 100644
--- a/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
+++ b/core/source/org/openoffice/ide/eclipse/core/builders/TypesBuilder.java
@@ -155,7 +155,7 @@ public class TypesBuilder extends IncrementalProjectBuilder {
CoreException thrown = new CoreException(new Status(
Status.ERROR, OOEclipsePlugin.OOECLIPSE_PLUGIN_ID,
Messages.getString("TypesBuilder.BuildError0"), e)); //$NON-NLS-1$
- if (!(e instanceof CoreException)) {
+ if ( e instanceof CoreException ) {
thrown = (CoreException)e;
}
throw thrown;
@@ -276,6 +276,10 @@ public class TypesBuilder extends IncrementalProjectBuilder {
Path sdkPath = new Path(sdkHome);
int segmentCount = project.getIdlPath().segmentCount();
+ if ( !project.getUrdPath().toFile().exists() ) {
+ project.getUrdPath().toFile().mkdirs();
+ }
+
IPath outputLocation = project.getUrdPath().append(
pFile.getProjectRelativePath().removeLastSegments(1).
removeFirstSegments(segmentCount));
More information about the ooo-build-commit
mailing list