-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Action to convert MANIFEST-first PDE projects to PDE automatic manifest
If one has a traditional MANIFEST-first PDE project and want to make use of the new automatic manifest generation these can include some tedious steps to perform that are prone to errors. This adds a new refactoring wizard that helps the user in perform the necessary steps in a convenient and configurable way. Fix #703
- Loading branch information
Showing
17 changed files
with
1,355 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
....pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/ConvertAutomaticManifestAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.pde.internal.ui.wizards.tools; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.jdt.core.IJavaProject; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; | ||
import org.eclipse.pde.internal.core.natures.BndProject; | ||
import org.eclipse.pde.internal.core.natures.PDE; | ||
import org.eclipse.pde.internal.ui.PDEPlugin; | ||
import org.eclipse.pde.internal.ui.PDEUIMessages; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
|
||
/** | ||
* Command handler to run the convert to automatic manifests operation. | ||
* | ||
*/ | ||
public class ConvertAutomaticManifestAction extends AbstractHandler { | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
if (PlatformUI.getWorkbench().saveAllEditors(true)) { | ||
// only do our work when all work is committed to files... | ||
if (HandlerUtil.getCurrentSelection(event) instanceof IStructuredSelection selection) { | ||
List<IProject> projects = selection.stream().map(ConvertAutomaticManifestAction::toProject) | ||
.filter(Objects::nonNull) | ||
.filter(proj -> PDE.hasPluginNature(proj)) | ||
.filter(proj -> !BndProject.isBndProject(proj)).toList(); | ||
if (projects.isEmpty()) { | ||
MessageDialog.openInformation(PDEPlugin.getActiveWorkbenchShell(), | ||
PDEUIMessages.ConvertAutomaticManifestWizardPage_title, | ||
PDEUIMessages.OrganizeManifestsWizardPage_errorMsg); | ||
return null; | ||
} | ||
RefactoringWizardOpenOperation refactoringOperation = new RefactoringWizardOpenOperation(new ConvertAutomaticManifestsWizard(projects)); | ||
try { | ||
refactoringOperation.run(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.ConvertAutomaticManifestWizardPage_title); | ||
} catch (final InterruptedException e) { | ||
// ignore... | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private static IProject toProject(Object object) { | ||
if (object instanceof IJavaProject java) { | ||
return java.getProject(); | ||
} | ||
if (object instanceof IResource resource) { | ||
return resource.getProject(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.