summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-11-29 23:12:14 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-11-29 23:12:14 +0100
commit0fbe088f812ad8b3c17ab33913022936191be35f (patch)
tree980623034368a22e1d267cd5bd149defcb002914
parent29df6eb2cf479f5240918bc3688e3164108353b5 (diff)
Adding a package content selection tab to the new launch config.
Reusing the Export wizard elements where possible
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java206
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/IOfficeLaunchConstants.java23
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/LaunchConfigurationTabs.java23
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeLaunchDelegate.java89
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeTab.java36
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java145
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/wizards/pages/ManifestExportPage.java2
-rw-r--r--core/source/org/openoffice/ide/eclipse/core/wizards/pages/UnoPackageExportPage.java120
8 files changed, 425 insertions, 219 deletions
diff --git a/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java b/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java
new file mode 100644
index 0000000..b1194b6
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/gui/PackageContentSelector.java
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the GNU Lesser General Public License Version 2.1
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2010 by Cédric Bosdonnat
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * The Initial Developer of the Original Code is: Cédric Bosdonnat.
+ *
+ * Copyright: 2010 by Cédric Bosdonnat
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.gui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+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.jface.viewers.ITreeContentProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.internal.ide.DialogUtil;
+import org.eclipse.ui.internal.ide.dialogs.ResourceTreeAndListGroup;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+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.utils.FilesFinder;
+
+/**
+ * Common helper GUI part to select elements to add in the UNO package to be exported.
+ *
+ * @author Cedric Bosdonnat
+ *
+ */
+@SuppressWarnings("restriction")
+public class PackageContentSelector extends Composite {
+
+ private ResourceTreeAndListGroup mResourceGroup;
+
+ /**
+ * Constructor based on SWT composite's one.
+ *
+ * @param pParent the parent composite.
+ * @param pStyle the SWT style to give to the composite
+ */
+ public PackageContentSelector( Composite pParent, int pStyle ) {
+ super( pParent, pStyle );
+
+ setLayout( new GridLayout( 2, false ) );
+ setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+ mResourceGroup = new ResourceTreeAndListGroup(this, new ArrayList<Object>(),
+ getResourceProvider(IResource.FOLDER | IResource.FILE),
+ WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
+ getResourceProvider(IResource.FILE), WorkbenchLabelProvider
+ .getDecoratingWorkbenchLabelProvider(), SWT.NONE,
+ DialogUtil.inRegularFontMode(this));
+ }
+
+ /**
+ * Set the project to work on.
+ *
+ * @param pPrj the project to show.
+ */
+ public void setProject(IProject pPrj) {
+ mResourceGroup.setRoot( pPrj );
+ }
+
+ /**
+ * Populate the resource view with some fresh data.
+ *
+ * @param pSelectedProject the UNO project for which to show the resources
+ */
+ public void loadData( IUnoidlProject pSelectedProject ) {
+ // Select the XCU / XCS files by default
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pSelectedProject.getName() );
+ FilesFinder finder = new FilesFinder(
+ new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION } );
+ try {
+ finder.addExclude( pSelectedProject.getDistFolder().getFullPath() );
+ prj.accept( finder );
+ } catch (CoreException e) {
+ PluginLogger.error("Could not visit the project's content.", e);
+ }
+
+ ArrayList< IFile > files = finder.getResults();
+ for (IFile file : files) {
+ mResourceGroup.initialCheckListItem( file );
+ mResourceGroup.initialCheckTreeItem( file );
+ }
+ }
+
+ /**
+ * @return all the selected items
+ */
+ public List<?> getSelected() {
+ return mResourceGroup.getAllWhiteCheckedItems();
+ }
+
+ /**
+ * Set the given resources to selected.
+ *
+ * @param pSelected the items to select.
+ */
+ public void setSelected( List<IResource> pSelected ) {
+ for (IResource res : pSelected) {
+ mResourceGroup.initialCheckTreeItem( res );
+ }
+ }
+
+ /**
+ * @param pResourceType the type of the resources to return by the provider.
+ *
+ * @return a content provider for <code>IResource</code>s that returns
+ * only children of the given resource type.
+ */
+ private ITreeContentProvider getResourceProvider( final int pResourceType ) {
+ return new WorkbenchContentProvider() {
+ public Object[] getChildren( Object pObject ) {
+ ArrayList<IResource> results = new ArrayList<IResource>();
+
+ if (pObject instanceof ArrayList<?>) {
+ ArrayList<?> objs = (ArrayList<?>)pObject;
+ for (Object o : objs) {
+ if ( o instanceof IResource ) {
+ results.add( ( IResource ) o );
+ }
+ }
+ } else if (pObject instanceof IContainer) {
+ IResource[] members = null;
+ try {
+ members = ((IContainer) pObject).members();
+
+ //filter out the desired resource types
+ for (int i = 0; i < members.length; i++) {
+ //And the test bits with the resource types to see if they are what we want
+ if ((members[i].getType() & pResourceType) > 0 && !isHiddenResource( members[i] ) ) {
+ results.add(members[i]);
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+ return results.toArray( );
+ }
+ };
+ }
+
+ /**
+ * @param pRes the resource to be checked
+ *
+ * @return <code>true</code> if the resource is hidden in the lists, <code>false</code>
+ * otherwise.
+ */
+ private boolean isHiddenResource( IResource pRes ) {
+ boolean hidden = false;
+
+ // Hide the binaries: they are always included from somewhere else
+ IUnoidlProject unoprj = ProjectsManager.getProject( pRes.getProject().getName() );
+ hidden |= unoprj.getFolder( unoprj.getBuildPath() ).equals( pRes );
+
+ IFolder[] bins = unoprj.getBinFolders();
+ for (IFolder bin : bins) {
+ hidden |= bin.equals( pRes );
+ }
+
+ // Hide the hidden files
+ hidden |= pRes.getName().startsWith( "." ); //$NON-NLS-1$
+
+ // Hide files which are always included in the package
+ hidden |= pRes.getName().equals( IUnoidlProject.DESCRIPTION_FILENAME );
+ hidden |= pRes.getName().equals( "MANIFEST.MF" ); //$NON-NLS-1$
+ hidden |= pRes.getName().equals( "manifest.xml" ); //$NON-NLS-1$
+ hidden |= pRes.getName().equals( "types.rdb" ); //$NON-NLS-1$
+
+ return hidden;
+ }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/IOfficeLaunchConstants.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/IOfficeLaunchConstants.java
index 5605121..5c56d33 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/IOfficeLaunchConstants.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/IOfficeLaunchConstants.java
@@ -1,21 +1,11 @@
/*************************************************************************
*
- * $RCSfile: $
- *
- * $Revision: $
- *
- * last change: $Author: $ $Date: $
- *
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
*
- * Sun Microsystems Inc., October, 2000
- *
- *
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2000 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ * Copyright 2010 by Dan Corneanu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,15 +21,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ * The Initial Developer of the Original Code is: Dan Corneanu.
*
- * Copyright: 2002 by Sun Microsystems, Inc.
+ * Copyright: 2010 by Dan Corneanu
*
* All Rights Reserved.
- *
- * Contributor(s): Cedric Bosdonnat, Dan Corneanu
- *
- *
+ *
************************************************************************/
package org.openoffice.ide.eclipse.core.launch.office;
@@ -55,5 +42,7 @@ public interface IOfficeLaunchConstants {
String PROJECT_NAME = OOEclipsePlugin.OOECLIPSE_PLUGIN_ID + ".PROJECT_ATTR";
String CLEAN_USER_INSTALLATION = OOEclipsePlugin.OOECLIPSE_PLUGIN_ID + ".USE_CLEAN_USER_INSTALLATION_ATTR";
+ String CONTENT_PATHS = OOEclipsePlugin.OOECLIPSE_PLUGIN_ID + ".PACKAGE_CONTENT_PATHS";
+ String PATHS_SEPARATOR = ":";
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/LaunchConfigurationTabs.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/LaunchConfigurationTabs.java
index 93fb7a1..a241495 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/LaunchConfigurationTabs.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/LaunchConfigurationTabs.java
@@ -1,21 +1,11 @@
/*************************************************************************
*
- * $RCSfile: $
- *
- * $Revision: $
- *
- * last change: $Author: $ $Date: $
- *
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
*
- * Sun Microsystems Inc., October, 2000
- *
- *
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2000 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ * Copyright 2010 by Dan Corneanu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,15 +21,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ * The Initial Developer of the Original Code is: Dan Corneanu.
*
- * Copyright: 2002 by Sun Microsystems, Inc.
+ * Copyright: 2010 by Dan Corneanu
*
* All Rights Reserved.
- *
- * Contributor(s): Cedric Bosdonnat, Dan Corneanu
- *
- *
+ *
************************************************************************/
package org.openoffice.ide.eclipse.core.launch.office;
@@ -66,11 +53,13 @@ public class LaunchConfigurationTabs extends AbstractLaunchConfigurationTabGroup
if (ILaunchManager.DEBUG_MODE.equals(pMode)) {
tabs = new ILaunchConfigurationTab[] {
new OfficeTab(),
+ new PackageConfigTab(),
new SourceLookupTab(),
new CommonTab() };
} else {
tabs = new ILaunchConfigurationTab[] {
new OfficeTab(),
+ new PackageConfigTab(),
new CommonTab() };
}
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 866c008..b6bf935 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
@@ -1,21 +1,11 @@
/*************************************************************************
*
- * $RCSfile: $
- *
- * $Revision: $
- *
- * last change: $Author: $ $Date: $
- *
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
*
- * Sun Microsystems Inc., October, 2000
- *
- *
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2000 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ * Copyright 2010 by Dan Corneanu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,15 +21,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ * The Initial Developer of the Original Code is: Dan Corneanu.
*
- * Copyright: 2002 by Sun Microsystems, Inc.
+ * Copyright: 2010 by Dan Corneanu
*
* All Rights Reserved.
- *
- * Contributor(s): Cedric Bosdonnat, Dan Corneanu
- *
- *
+ *
************************************************************************/
package org.openoffice.ide.eclipse.core.launch.office;
@@ -63,7 +50,6 @@ 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.helpers.SystemHelper;
import org.openoffice.ide.eclipse.core.internal.helpers.UnoidlProjectHelper;
import org.openoffice.ide.eclipse.core.internal.model.UnoidlProject;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
@@ -71,8 +57,9 @@ import org.openoffice.ide.eclipse.core.model.ProjectsManager;
import org.openoffice.ide.eclipse.core.model.config.IOOo;
import org.openoffice.ide.eclipse.core.model.config.NullExtraOptionsProvider;
import org.openoffice.ide.eclipse.core.model.language.ILanguageBuilder;
-import org.openoffice.ide.eclipse.core.model.pack.UnoPackage;
+import org.openoffice.ide.eclipse.core.model.utils.SystemHelper;
import org.openoffice.ide.eclipse.core.utils.FilesFinder;
+import org.openoffice.plugin.core.model.UnoPackage;
/**
* OpenOffice launcher implementation.
@@ -216,37 +203,39 @@ public class OfficeLaunchDelegate extends LaunchConfigurationDelegate {
*/
private File exportComponent(IProgressMonitor pMonitor, IUnoidlProject pPrj) throws Exception {
- ILanguageBuilder langBuilder = pPrj.getLanguage().getLanguageBuidler();
- IPath libraryPath = langBuilder.createLibrary(pPrj);
-
- IFolder distFolder = pPrj.getFolder(pPrj.getDistPath());
-
- File destFile = distFolder.getFile(pPrj.getName() + ".oxt").getLocation().toFile();
- UnoPackage pack = UnoidlProjectHelper.createMinimalUnoPackage(pPrj, destFile);
- pack.addToClean(libraryPath);
-
- // FIXME this code is duplicated.
- IFile descrFile = pPrj.getFile(IUnoidlProject.DESCRIPTION_FILENAME);
- if (descrFile.exists()) {
- pack.addContent(descrFile);
- }
-
- // Select the XCU / XCS files by default
- FilesFinder finder = new FilesFinder(
- new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION });
- finder.addExclude(pPrj.getDistFolder().getFullPath());
- try {
- ((UnoidlProject) pPrj).getProject().accept(finder);
- } catch (CoreException e) {
- // Nothing to log here
- }
- ArrayList<IFile> files = finder.getResults();
- for (IFile aFile : files) {
- pack.addContent(aFile);
- }
-
- pack.close(pMonitor);
- return destFile;
+ // TODO Repair this one!
+// ILanguageBuilder langBuilder = pPrj.getLanguage().getLanguageBuidler();
+// IPath libraryPath = langBuilder.createLibrary(pPrj);
+//
+// IFolder distFolder = pPrj.getFolder(pPrj.getDistPath());
+//
+// File destFile = distFolder.getFile(pPrj.getName() + ".oxt").getLocation().toFile();
+// UnoPackage pack = UnoidlProjectHelper.createMinimalUnoPackage(pPrj, destFile);
+// pack.addToClean(libraryPath);
+//
+// // FIXME this code is duplicated.
+// IFile descrFile = pPrj.getFile(IUnoidlProject.DESCRIPTION_FILENAME);
+// if (descrFile.exists()) {
+// pack.addContent(descrFile);
+// }
+//
+// // Select the XCU / XCS files by default
+// FilesFinder finder = new FilesFinder(
+// new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION });
+// finder.addExclude(pPrj.getDistFolder().getFullPath());
+// try {
+// ((UnoidlProject) pPrj).getProject().accept(finder);
+// } catch (CoreException e) {
+// // Nothing to log here
+// }
+// ArrayList<IFile> files = finder.getResults();
+// for (IFile aFile : files) {
+// pack.addContent(aFile);
+// }
+//
+// pack.close(pMonitor);
+// return destFile;
+ return null;
}
}
diff --git a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeTab.java b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeTab.java
index 432dd08..5f73e3a 100644
--- a/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeTab.java
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/OfficeTab.java
@@ -1,21 +1,11 @@
/*************************************************************************
*
- * $RCSfile: $
- *
- * $Revision: $
- *
- * last change: $Author: $ $Date: $
- *
* The Contents of this file are made available subject to the terms of
* the GNU Lesser General Public License Version 2.1
*
- * Sun Microsystems Inc., October, 2000
- *
- *
* GNU Lesser General Public License Version 2.1
* =============================================
- * Copyright 2000 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ * Copyright 2010 by Dan Corneanu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -31,22 +21,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
- * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ * The Initial Developer of the Original Code is: Dan Corneanu.
*
- * Copyright: 2002 by Sun Microsystems, Inc.
+ * Copyright: 2010 by Dan Corneanu
*
* All Rights Reserved.
- *
- * Contributor(s): Cedric Bosdonnat, Dan Corneanu
- *
- *
+ *
************************************************************************/
package org.openoffice.ide.eclipse.core.launch.office;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.sourcelookup.ISourcePathComputer;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.window.Window;
@@ -54,6 +40,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -148,6 +135,15 @@ public class OfficeTab extends AbstractLaunchConfigurationTab {
public String getName() {
return Messages.OfficeTab_Title;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage() {
+ // TODO Auto-generated method stub
+ return super.getImage();
+ }
/**
* {@inheritDoc}
@@ -221,8 +217,8 @@ public class OfficeTab extends AbstractLaunchConfigurationTab {
if (pEvent.getSource().equals(mProjectBtn)) {
ILabelProvider labelProvider = new UnoProjectLabelProvider();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setTitle("ProjectChooserTitle"); //$NON-NLS-1$
- dialog.setMessage("ProjectChooserMessage"); //$NON-NLS-1$
+ dialog.setTitle(Messages.OfficeTab_ProjectChooserTitle);
+ dialog.setMessage(Messages.OfficeTab_ProjectChooserMessage);
dialog.setElements(ProjectsManager.getProjects());
if (dialog.open() == Window.OK) {
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
new file mode 100644
index 0000000..2f92c75
--- /dev/null
+++ b/core/source/org/openoffice/ide/eclipse/core/launch/office/PackageConfigTab.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the GNU Lesser General Public License Version 2.1
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2010 by Cédric Bosdonnat
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * The Initial Developer of the Original Code is: Cédric Bosdonnat.
+ *
+ * Copyright: 2010 by Cédric Bosdonnat
+ *
+ * All Rights Reserved.
+ *
+ ************************************************************************/
+package org.openoffice.ide.eclipse.core.launch.office;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.gui.PackageContentSelector;
+import org.openoffice.ide.eclipse.core.model.ProjectsManager;
+
+/**
+ * Tab for selecting the content of the package to test.
+ *
+ * @author Cédric Bosdonnat
+ *
+ */
+public class PackageConfigTab extends AbstractLaunchConfigurationTab {
+
+ PackageContentSelector mContentSelector;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createControl(Composite pParent) {
+
+ Composite body = new Composite( pParent, SWT.NONE );
+ body.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ body.setLayout( new GridLayout() );
+
+ mContentSelector = new PackageContentSelector( body, SWT.NONE );
+
+ setControl( body );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return "Package content";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void initializeFrom(ILaunchConfiguration pConfiguration) {
+ try {
+ String prjName = pConfiguration.getAttribute( IOfficeLaunchConstants.PROJECT_NAME, new String() );
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+ mContentSelector.setProject( prj );
+
+ String paths = pConfiguration.getAttribute( IOfficeLaunchConstants.CONTENT_PATHS, new String() );
+ if ( paths.isEmpty() ) {
+ mContentSelector.loadData( ProjectsManager.getProject( prjName ) );
+ } else {
+ String[] pathsItems = paths.split( IOfficeLaunchConstants.PATHS_SEPARATOR );
+ ArrayList<IResource> selected = new ArrayList<IResource>();
+ for (String path : pathsItems) {
+ IResource res = prj.findMember( path );
+ if ( res != null ) {
+ selected.add( res );
+ }
+ }
+ mContentSelector.setSelected( selected );
+ }
+ } catch (CoreException e) {
+ PluginLogger.error(Messages.OfficeTab_Configurationerror, e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy pConfiguration) {
+ List<?> selected = mContentSelector.getSelected();
+ String paths = new String();
+ for (Object obj : selected) {
+ if ( obj instanceof IResource ) {
+ IResource res = (IResource)obj;
+
+ if ( !paths.isEmpty() ) {
+ paths += IOfficeLaunchConstants.PATHS_SEPARATOR;
+ }
+ paths += res.getProjectRelativePath().toString();
+ }
+ }
+ pConfiguration.setAttribute( IOfficeLaunchConstants.CONTENT_PATHS, paths );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy pConfiguration) {
+ try {
+ String prjName = pConfiguration.getAttribute( IOfficeLaunchConstants.PROJECT_NAME, new String() );
+ if ( !prjName.isEmpty() ) {
+ IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+ mContentSelector.setProject( prj );
+
+ mContentSelector.loadData( ProjectsManager.getProject( prjName ) );
+ }
+ } catch (CoreException e) {
+ // Don't do anything in that case
+ }
+ }
+}
diff --git a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/ManifestExportPage.java b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/ManifestExportPage.java
index a8e79f6..5440304 100644
--- a/core/source/org/openoffice/ide/eclipse/core/wizards/pages/ManifestExportPage.java
+++ b/core/source/org/openoffice/ide/eclipse/core/wizards/pages/ManifestExportPage.java
@@ -129,7 +129,7 @@ public class ManifestExportPage extends WizardPage {
public void configureManifest(UnoPackage pModel) {
IFile saveFile = getSaveManifestFile( );
if ( saveFile != null ) {
- pModel.setSaveManifestFile( SystemHelper.getFile( saveFile ) );
+ pModel.setCopyManifestFileTo( SystemHelper.getFile( saveFile ) );
}
IFile readFile = getReadManifestFile( );
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 b95364b..17be342 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
@@ -32,19 +32,15 @@ package org.openoffice.ide.eclipse.core.wizards.pages;
import java.io.File;
import java.text.MessageFormat;
-import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
-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.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -59,12 +55,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.internal.ide.DialogUtil;
-import org.eclipse.ui.internal.ide.dialogs.ResourceTreeAndListGroup;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.openoffice.ide.eclipse.core.OOEclipsePlugin;
import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.gui.PackageContentSelector;
import org.openoffice.ide.eclipse.core.i18n.ImagesConstants;
import org.openoffice.ide.eclipse.core.internal.helpers.UnoidlProjectHelper;
import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
@@ -72,7 +65,6 @@ import org.openoffice.ide.eclipse.core.model.ProjectsManager;
import org.openoffice.ide.eclipse.core.model.config.IOOo;
import org.openoffice.ide.eclipse.core.model.language.ILanguageBuilder;
import org.openoffice.ide.eclipse.core.model.utils.SystemHelper;
-import org.openoffice.ide.eclipse.core.utils.FilesFinder;
import org.openoffice.ide.eclipse.core.wizards.Messages;
import org.openoffice.plugin.core.model.UnoPackage;
@@ -82,7 +74,6 @@ import org.openoffice.plugin.core.model.UnoPackage;
* @author Cédric Bosdonnat
*
*/
-@SuppressWarnings("restriction")
public class UnoPackageExportPage extends WizardPage {
private static final int DESTINATION_PART_COLS = 3;
@@ -94,7 +85,7 @@ public class UnoPackageExportPage extends WizardPage {
private static final int MAX_DESTINATION_STORED = 5;
private Combo mProjectsList;
- private ResourceTreeAndListGroup mResourceGroup;
+ private PackageContentSelector mContentSelector;
private Combo mDestinationCombo;
private Button mOverwriteBox;
private Button mAutodeployBox;
@@ -131,7 +122,7 @@ public class UnoPackageExportPage extends WizardPage {
setControl( body );
createProjectSelection( );
- createResourcesGroup( );
+ mContentSelector = new PackageContentSelector( body, SWT.NONE );
createDestinationGroup( );
createOptionsGroup( );
@@ -159,21 +150,7 @@ public class UnoPackageExportPage extends WizardPage {
i++;
}
- // Select the XCU / XCS files by default
- IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( mSelectedProject.getName() );
- FilesFinder finder = new FilesFinder( new String[] { IUnoidlProject.XCU_EXTENSION, IUnoidlProject.XCS_EXTENSION } );
- try {
- finder.addExclude(mSelectedProject.getDistFolder().getFullPath());
- prj.accept( finder );
- } catch (CoreException e) {
- PluginLogger.error("Could not visit the project's content.", e);
- }
-
- ArrayList< IFile > files = finder.getResults();
- for (IFile file : files) {
- mResourceGroup.initialCheckListItem( file );
- mResourceGroup.initialCheckTreeItem( file );
- }
+ mContentSelector.loadData( mSelectedProject );
restoreWidgetValues();
}
@@ -215,30 +192,13 @@ public class UnoPackageExportPage extends WizardPage {
// Change the project in the manifest page
mManifestPage.setProject( unoprj );
- mResourceGroup.setRoot( prj );
+ mContentSelector.setProject( prj );
}
setPageComplete( checkPageCompletion() );
}
});
}
-
- /**
- * Creates the project's resources selection part of the dialog.
- */
- private void createResourcesGroup() {
- Composite body = (Composite)getControl();
- Composite selectionBody = new Composite( body, SWT.NONE );
- selectionBody.setLayout( new GridLayout( 2, false ) );
- selectionBody.setLayoutData( new GridData( SWT.FILL, SWT.BEGINNING, true, false ) );
-
- mResourceGroup = new ResourceTreeAndListGroup(selectionBody, new ArrayList<Object>(),
- getResourceProvider(IResource.FOLDER | IResource.FILE),
- WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
- getResourceProvider(IResource.FILE), WorkbenchLabelProvider
- .getDecoratingWorkbenchLabelProvider(), SWT.NONE,
- DialogUtil.inRegularFontMode(selectionBody));
- }
/**
* Creates the package destination part of the dialog.
@@ -325,74 +285,6 @@ public class UnoPackageExportPage extends WizardPage {
/*
* Data handling and filtering methods
*/
-
- /**
- * @param pRes the resource to be checked
- *
- * @return <code>true</code> if the resource is hidden in the lists, <code>false</code>
- * otherwise.
- */
- private boolean isHiddenResource( IResource pRes ) {
- boolean hidden = false;
-
- // Hide the binaries: they are always included from somewhere else
- IUnoidlProject unoprj = ProjectsManager.getProject( pRes.getProject().getName() );
- hidden |= unoprj.getFolder( unoprj.getBuildPath() ).equals( pRes );
-
- IFolder[] bins = unoprj.getBinFolders();
- for (IFolder bin : bins) {
- hidden |= bin.equals( pRes );
- }
-
- // Hide the hidden files
- hidden |= pRes.getName().startsWith( "." ); //$NON-NLS-1$
-
- // Hide files which are always included in the package
- hidden |= pRes.getName().equals( IUnoidlProject.DESCRIPTION_FILENAME );
- hidden |= pRes.getName().equals( "MANIFEST.MF" ); //$NON-NLS-1$
- hidden |= pRes.getName().equals( "manifest.xml" ); //$NON-NLS-1$
- hidden |= pRes.getName().equals( "types.rdb" ); //$NON-NLS-1$
-
- return hidden;
- }
-
- /**
- * @param pResourceType the type of the resources to return by the provider.
- *
- * @return a content provider for <code>IResource</code>s that returns
- * only children of the given resource type.
- */
- private ITreeContentProvider getResourceProvider( final int pResourceType ) {
- return new WorkbenchContentProvider() {
- public Object[] getChildren( Object pObject ) {
- ArrayList<IResource> results = new ArrayList<IResource>();
-
- if (pObject instanceof ArrayList<?>) {
- ArrayList<?> objs = (ArrayList<?>)pObject;
- for (Object o : objs) {
- if ( o instanceof IResource ) {
- results.add( ( IResource ) o );
- }
- }
- } else if (pObject instanceof IContainer) {
- IResource[] members = null;
- try {
- members = ((IContainer) pObject).members();
-
- //filter out the desired resource types
- for (int i = 0; i < members.length; i++) {
- //And the test bits with the resource types to see if they are what we want
- if ((members[i].getType() & pResourceType) > 0 && !isHiddenResource( members[i] ) ) {
- results.add(members[i]);
- }
- }
- } catch (CoreException e) {
- }
- }
- return results.toArray( );
- }
- };
- }
/**
* Stores the controls values for the next instance of the page.
@@ -476,7 +368,7 @@ public class UnoPackageExportPage extends WizardPage {
}
// Add the additional content to the package
- List<?> items = mResourceGroup.getAllWhiteCheckedItems();
+ List<?> items = mContentSelector.getSelected();
for (Object item : items) {
if ( item instanceof IResource ) {
File resFile = SystemHelper.getFile( (IResource)item );