### Eclipse Workspace Patch 1.0
#P org.eclipse.ui.ide
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/META-INF/MANIFEST.MF,v
retrieving revision 1.51
diff -u -r1.51 MANIFEST.MF
--- META-INF/MANIFEST.MF 13 Jan 2010 18:45:45 -0000 1.51
+++ META-INF/MANIFEST.MF 18 Feb 2010 05:53:48 -0000
@@ -34,6 +34,7 @@
org.eclipse.ui.internal.views.tasklist;x-internal:=true,
org.eclipse.ui.internal.wizards.datatransfer;x-internal:=true,
org.eclipse.ui.internal.wizards.newresource;x-internal:=true,
+ org.eclipse.ui.internal.wizards.refreshsnapshot;x-internal:=true,
org.eclipse.ui.model,
org.eclipse.ui.part,
org.eclipse.ui.views.bookmarkexplorer,
Index: plugin.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.properties,v
retrieving revision 1.155
diff -u -r1.155 plugin.properties
--- plugin.properties 4 Feb 2010 19:44:08 -0000 1.155
+++ plugin.properties 18 Feb 2010 05:53:46 -0000
@@ -28,9 +28,11 @@
ExportWizards.FileSystem = File System
ExportWizards.Preferences = Preferences
ExportWizards.ZipFile = Archive File
+ExportWizards.ProjectRefreshSnapshot = Project Refresh Snapshot
ExportWizards.FileSystemDescription = Export resources to the local file system.
ExportWizards.PreferencesDescription = Export preferences to the local file system.
ExportWizards.ZipFileDescription = Export resources to an archive file on the local file system.
+ExportWizards.ProjectRefreshSnapshotDescription = Export a refresh snapshot into selected projects for trusted import in other workspaces.
ImportWizards.FileSystem = File System
ImportWizards.Preferences = Preferences
ImportWizards.ZipFile = Archive File
Index: plugin.xml
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/plugin.xml,v
retrieving revision 1.300
diff -u -r1.300 plugin.xml
--- plugin.xml 4 Feb 2010 13:51:21 -0000 1.300
+++ plugin.xml 18 Feb 2010 05:53:48 -0000
@@ -132,6 +132,19 @@
id="org.eclipse.ui.ide.project">
+
+
+
+
+ %ExportWizards.ProjectRefreshSnapshotDescription
+
+
Index: src/org/eclipse/ui/internal/wizards/refreshsnapshot/Messages.java
===================================================================
RCS file: src/org/eclipse/ui/internal/wizards/refreshsnapshot/Messages.java
diff -N src/org/eclipse/ui/internal/wizards/refreshsnapshot/Messages.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ui/internal/wizards/refreshsnapshot/Messages.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ * Francis Lynch - adapted for refresh snapshot
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.wizards.refreshsnapshot;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Externalized messages for refresh snapshot wizard
+ *
+ */
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.ui.internal.wizards.refreshsnapshot.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ /*
+ * no initialization needed
+ */
+ }
+
+ /**
+ * @param key
+ * @return a String corresponding to the key.
+ */
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+}
Index: src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizard.java
===================================================================
RCS file: src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizard.java
diff -N src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizard.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizard.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ * Francis Lynch - adapted for refresh snapshot
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.wizards.refreshsnapshot;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.wizards.refreshsnapshot.Messages;
+
+/**
+ * Wizard to create refresh snapshots
+ *
+ */
+public class ProjectRefreshSnapshotWizard extends Wizard implements IExportWizard {
+ private static final String DIALOG_SETTINGS_SECTION = "ProjectRefreshSnapshotWizard"; //$NON-NLS-1$
+ private ProjectRefreshSnapshotWizardPage fMainPage;
+ private IStructuredSelection fSelection;
+
+ /**
+ *
+ */
+ public ProjectRefreshSnapshotWizard() {
+ IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section == null) {
+ section = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION);
+ }
+ setDialogSettings(section);
+ }
+
+ //@Override
+ public void addPages() {
+ super.addPages();
+ fMainPage = new ProjectRefreshSnapshotWizardPage(fSelection);
+ addPage(fMainPage);
+ }
+
+ //@Override
+ public boolean performFinish() {
+ return fMainPage.finish();
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ fSelection= selection;
+ setWindowTitle(Messages.getString("ProjectRefreshSnapshotExportWizard.0")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportzip_wiz.png")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+}
Index: src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizardPage.java
===================================================================
RCS file: src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizardPage.java
diff -N src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizardPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ui/internal/wizards/refreshsnapshot/ProjectRefreshSnapshotWizardPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ * Francis Lynch - adapted for refresh snapshot
+ *******************************************************************************/
+package org.eclipse.ui.internal.wizards.refreshsnapshot;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.dialogs.WizardDataTransferPage;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.internal.wizards.refreshsnapshot.Messages;
+
+/**
+ * The wizard page for refresh snapshot
+ *
+ */
+public class ProjectRefreshSnapshotWizardPage extends WizardDataTransferPage {
+
+ private IStructuredSelection fInitialSelection;
+ private CheckboxTableViewer fProjectViewer;
+
+
+ /**
+ * Create an instance of this class
+ */
+ protected ProjectRefreshSnapshotWizardPage(String name, IStructuredSelection selection) {
+ super(name);
+ fInitialSelection= selection;
+ }
+
+ /**
+ * Create an instance of this class.
+ *
+ * @param selection the selection
+ */
+ public ProjectRefreshSnapshotWizardPage(IStructuredSelection selection) {
+ this("indexExportPage", selection); //$NON-NLS-1$
+ setTitle(Messages.getString("ProjectRefreshSnapshotExportWizardPage.0")); //$NON-NLS-1$
+ setDescription(Messages.getString("ProjectRefreshSnapshotExportWizardPage.1")); //$NON-NLS-1$
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ composite.setFont(parent.getFont());
+
+ createResourcesGroup(composite);
+ createDestinationGroup(composite);
+ createOptionsArea(composite);
+
+ restoreWidgetValues();
+ if (fInitialSelection != null) {
+ setupBasedOnInitialSelections();
+ }
+
+ updateWidgetEnablements();
+ setPageComplete(determinePageCompletion());
+ setErrorMessage(null); // should not initially have error message
+
+ setControl(composite);
+ }
+
+ /**
+ * Creates the checkbox tree and list for selecting resources.
+ *
+ * @param parent the parent control
+ */
+ private final void createResourcesGroup(Composite parent) {
+ Composite resourcesGroup = new Composite(parent, SWT.NONE);
+ resourcesGroup.setLayout(new GridLayout());
+ resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ resourcesGroup.setFont(parent.getFont());
+
+ new Label(resourcesGroup, SWT.NONE).setText(Messages.getString("ProjectRefreshSnapshotExportWizardPage.2")); //$NON-NLS-1$
+ Table table= new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fProjectViewer= new CheckboxTableViewer(table);
+ fProjectViewer.setContentProvider(new IStructuredContentProvider() {
+ List fContents;
+
+ public Object[] getElements(Object input) {
+ if (fContents != null && fContents == input)
+ return fContents.toArray();
+ return new Object[0];
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput instanceof List)
+ fContents= (List)newInput;
+ else
+ fContents= null;
+ // we use a fixed set.
+ }
+
+ public void dispose() {
+ }
+
+
+ } );
+ fProjectViewer.setLabelProvider(new WorkbenchLabelProvider());
+ ICheckStateListener checkListener = new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ updateWidgetEnablements();
+ }
+ };
+ fProjectViewer.addCheckStateListener(checkListener);
+
+
+ // top level group
+ Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
+ buttonComposite.setFont(parent.getFont());
+
+ GridLayout layout = new GridLayout(2, true);
+ layout.marginHeight= layout.marginWidth= 0;
+ buttonComposite.setLayout(layout);
+ buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+
+
+ Button selectButton = createButton(buttonComposite,
+ IDialogConstants.SELECT_ALL_ID, Messages.getString("ProjectRefreshSnapshotExportWizardPage.3"), false); //$NON-NLS-1$
+
+ SelectionAdapter listener = new SelectionAdapter() {
+ //@Override
+ public void widgetSelected(SelectionEvent e) {
+ fProjectViewer.setAllChecked(true);
+ updateWidgetEnablements();
+ }
+ };
+ selectButton.addSelectionListener(listener);
+
+ Button deselectButton = createButton(buttonComposite,
+ IDialogConstants.DESELECT_ALL_ID, Messages.getString("ProjectRefreshSnapshotExportWizardPage.4"), false); //$NON-NLS-1$
+
+ listener = new SelectionAdapter() {
+ //@Override
+ public void widgetSelected(SelectionEvent e) {
+ fProjectViewer.setAllChecked(false);
+ updateWidgetEnablements();
+ }
+ };
+ deselectButton.addSelectionListener(listener);
+
+ initProjects();
+ }
+
+ private Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ Button button = new Button(parent, SWT.PUSH);
+
+ GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
+ button.setLayoutData(buttonData);
+
+ button.setData(new Integer(id));
+ button.setText(label);
+ button.setFont(parent.getFont());
+
+ if (defaultButton) {
+ Shell shell = parent.getShell();
+ if (shell != null) {
+ shell.setDefaultButton(button);
+ }
+ button.setFocus();
+ }
+ button.setFont(parent.getFont());
+ setButtonLayoutData(button);
+ return button;
+ }
+
+ private void initProjects() {
+ ArrayList input = new ArrayList();
+ IProject[] projects;
+ projects = IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ if (projects[i].isOpen()) {
+ input.add(projects[i]);
+ }
+ }
+ fProjectViewer.setInput(input);
+ }
+
+ private void setupBasedOnInitialSelections() {
+ HashSet names= new HashSet();
+ Iterator it = fInitialSelection.iterator();
+ while (it.hasNext()) {
+ IProject project = (IProject) it.next();
+ names.add(project.getName());
+ }
+
+ Collection prjsc= (Collection) fProjectViewer.getInput();
+ Object[] prjs= prjsc.toArray();
+ for (int i = 0; i < prjs.length; i++) {
+ Object element = prjs[i];
+ IProject prj = (IProject) element;
+ if (names.contains(prj.getName())) {
+ fProjectViewer.setChecked(prj, true);
+ }
+ }
+ }
+
+
+
+
+ private void createDestinationGroup(Composite parent) {
+ Font font = parent.getFont();
+ // destination specification group
+ Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
+ destinationSelectionGroup.setLayout(new GridLayout(2, false));
+ destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+ destinationSelectionGroup.setFont(font);
+
+
+ }
+
+ /**
+ * Create the area with the extra options.
+ *
+ * @param workArea
+ */
+ private void createOptionsArea(Composite workArea) {
+ Composite optionsGroup = new Composite(workArea, SWT.NONE);
+ optionsGroup.setLayout(new GridLayout());
+ optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ }
+
+
+ /**
+ * @return Return true to indicate that the operation was a success
+ *
+ */
+ public boolean finish() {
+ IProject[] projectsToSnapshot= getCheckedElements();
+
+ // about to invoke the operation so save our state
+ saveWidgetValues();
+
+ return executeSnapshotOperation(projectsToSnapshot);
+ }
+
+ private IProject[] getCheckedElements() {
+ Object[] obj= fProjectViewer.getCheckedElements();
+ IProject[] prjs= new IProject[obj.length];
+ System.arraycopy(obj, 0, prjs, 0, obj.length);
+ return prjs;
+ }
+
+ private boolean executeSnapshotOperation(final IProject[] projects) {
+ //final String dest= getDestinationValue();
+ final MultiStatus status= new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH,
+ 0, "ProjectRefreshSnapshotExportWizardPage.5", null); //$NON-NLS-1$
+
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ try {
+ project.writeRefreshSnapshot(null);
+ }
+ catch (CoreException e) {
+ status.merge(e.getStatus());
+ }
+ }
+ if (!status.isOK()) {
+ IDEWorkbenchPlugin.log("",status); //$NON-NLS-1$
+ ErrorDialog.openError(getContainer().getShell(),
+ getErrorDialogTitle(),
+ null, // no special message
+ status);
+ return false;
+ }
+
+ return true;
+ }
+
+
+ //@Override
+ protected boolean validateSourceGroup() {
+ // there must be some resources selected for Export
+ boolean isValid = true;
+ Object[] projectsToExport = getCheckedElements();
+ if (projectsToExport.length == 0){
+ setErrorMessage(Messages.getString("ProjectRefreshSnapshotExportWizardPage.6")); //$NON-NLS-1$
+ isValid = false;
+ } else {
+ setErrorMessage(null);
+ }
+ return super.validateSourceGroup() && isValid;
+ }
+
+ //@Override
+ protected void updateWidgetEnablements() {
+ boolean pageComplete = determinePageCompletion();
+ setPageComplete(pageComplete);
+ if (pageComplete) {
+ setMessage(null);
+ }
+ super.updateWidgetEnablements();
+ }
+
+
+ public void handleEvent(Event event) {
+ updateWidgetEnablements();
+ }
+
+ //@Override
+ protected String getErrorDialogTitle() {
+ return Messages.getString("ProjectRefreshSnapshotExportWizardPage.7"); //$NON-NLS-1$
+ }
+
+ //@Override
+ protected boolean allowNewContainerName() {
+ return false;
+ }
+}
Index: src/org/eclipse/ui/internal/wizards/refreshsnapshot/messages.properties
===================================================================
RCS file: src/org/eclipse/ui/internal/wizards/refreshsnapshot/messages.properties
diff -N src/org/eclipse/ui/internal/wizards/refreshsnapshot/messages.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ui/internal/wizards/refreshsnapshot/messages.properties 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2000, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+
+###############################################################################
+
+ProjectRefreshSnapshotExportWizard.0=Export
+ProjectRefreshSnapshotExportWizardPage.0=Export Project Refresh Snapshot Information
+ProjectRefreshSnapshotExportWizardPage.1=Export a refresh snapshot into selected projects for trusted import in other workspaces
+ProjectRefreshSnapshotExportWizardPage.2=Select &projects to snapshot:
+ProjectRefreshSnapshotExportWizardPage.3=&Select All
+ProjectRefreshSnapshotExportWizardPage.4=&Deselect All
+ProjectRefreshSnapshotExportWizardPage.5=Errors occurred while exporting project refresh snapshot
+ProjectRefreshSnapshotExportWizardPage.6=At least one project must be selected.
+ProjectRefreshSnapshotExportWizardPage.7=Export Project Refresh Snapshot Information