forked from bndtools/bnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements cancel for resolve job bndtools#4154
- Adds the ability to keep the resolve log after it is canceled Signed-off-by: Juergen Albert <j.albert@data-in-motion.biz>
- Loading branch information
1 parent
16d4167
commit d3367fe
Showing
11 changed files
with
292 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@Version("6.0.0") | ||
@Version("6.1.0") | ||
package biz.aQute.resolve; | ||
|
||
import org.osgi.annotation.versioning.Version; |
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
27 changes: 27 additions & 0 deletions
27
bndtools.core/src/org/bndtools/core/resolve/CancelOperationCallback.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,27 @@ | ||
package org.bndtools.core.resolve; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.osgi.resource.Capability; | ||
import org.osgi.resource.Requirement; | ||
|
||
import biz.aQute.resolve.ResolutionCallback; | ||
|
||
public class CancelOperationCallback implements ResolutionCallback { | ||
|
||
private IProgressMonitor monitor; | ||
|
||
public CancelOperationCallback(IProgressMonitor monitor) { | ||
this.monitor = monitor; | ||
} | ||
|
||
@Override | ||
public void processCandidates(Requirement requirement, Set<Capability> wired, List<Capability> candidates) { | ||
if (monitor.isCanceled()) { | ||
throw new ResolveCancelledException(); | ||
} | ||
} | ||
|
||
} |
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
118 changes: 118 additions & 0 deletions
118
bndtools.core/src/org/bndtools/core/resolve/ui/ResolutionCanceledPanel.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,118 @@ | ||
package org.bndtools.core.resolve.ui; | ||
|
||
import org.bndtools.core.resolve.ResolutionResult; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.events.SelectionAdapter; | ||
import org.eclipse.swt.events.SelectionEvent; | ||
import org.eclipse.swt.graphics.Image; | ||
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.Control; | ||
import org.eclipse.swt.widgets.Text; | ||
import org.eclipse.ui.forms.widgets.ExpandableComposite; | ||
import org.eclipse.ui.forms.widgets.FormToolkit; | ||
import org.eclipse.ui.forms.widgets.Section; | ||
import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
import org.osgi.service.resolver.ResolutionException; | ||
|
||
import biz.aQute.resolve.ResolverLogger; | ||
import bndtools.Plugin; | ||
|
||
public class ResolutionCanceledPanel { | ||
|
||
private final Image clipboardImg = AbstractUIPlugin | ||
.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/page_copy.png") | ||
.createImage(); | ||
private final Image treeViewImg = AbstractUIPlugin | ||
.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/tree_mode.gif") | ||
.createImage(); | ||
private final Image flatViewImg = AbstractUIPlugin | ||
.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/flat_mode.gif") | ||
.createImage(); | ||
|
||
private Composite composite; | ||
|
||
private Text processingLog; | ||
private Section sectProcessingLog; | ||
private ResolverLogger logger; | ||
private Section sectProcessingLogFile; | ||
private Button button; | ||
|
||
public ResolutionCanceledPanel(ResolverLogger logger) { | ||
this.logger = logger; | ||
} | ||
|
||
public void createControl(final Composite parent) { | ||
FormToolkit toolkit = new FormToolkit(parent.getDisplay()); | ||
composite = toolkit.createComposite(parent); | ||
|
||
composite.setLayout(new GridLayout(1, false)); | ||
GridData gd; | ||
|
||
sectProcessingLog = toolkit.createSection(composite, | ||
ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED); | ||
sectProcessingLog.setText("Processing Log:"); | ||
|
||
processingLog = toolkit.createText(sectProcessingLog, "", | ||
SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); | ||
sectProcessingLog.setClient(processingLog); | ||
|
||
gd = new GridData(SWT.FILL, SWT.FILL, true, true); | ||
gd.widthHint = 600; | ||
gd.heightHint = 300; | ||
sectProcessingLog.setLayoutData(gd); | ||
|
||
sectProcessingLogFile = toolkit.createSection(composite, | ||
ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED); | ||
sectProcessingLogFile.setText("Processing Logfile:"); | ||
Composite composite = toolkit.createComposite(sectProcessingLogFile); | ||
sectProcessingLogFile.setClient(composite); | ||
|
||
button = new Button(composite, SWT.CHECK); | ||
button.setText("Keep Resolver log file after cancel"); | ||
button.setToolTipText("This is still a temporary file and will be deleted when Eclipse closes."); | ||
|
||
button.addSelectionListener(new SelectionAdapter() { | ||
@Override | ||
public void widgetSelected(SelectionEvent e) { | ||
logger.setKeepLogFileTillExit(button.getSelection()); | ||
} | ||
}); | ||
|
||
GridLayout layout = new GridLayout(1, false); | ||
layout.horizontalSpacing = 0; | ||
layout.verticalSpacing = 0; | ||
layout.marginHeight = 0; | ||
layout.marginWidth = 0; | ||
composite.setLayout(layout); | ||
|
||
gd = new GridData(SWT.FILL, SWT.FILL, true, true); | ||
gd.widthHint = 600; | ||
gd.heightHint = 100; | ||
sectProcessingLogFile.setLayoutData(gd); | ||
} | ||
|
||
public Control getControl() { | ||
return composite; | ||
} | ||
|
||
public void setInput(ResolutionResult resolutionResult) { | ||
if (composite == null) | ||
throw new IllegalStateException("Control not created"); | ||
else if (composite.isDisposed()) | ||
throw new IllegalStateException("Control already disposed"); | ||
|
||
ResolutionException resolutionException = resolutionResult.getResolutionException(); | ||
|
||
processingLog.setText(resolutionResult.getLog()); | ||
} | ||
|
||
public void dispose() { | ||
logger.close(); | ||
clipboardImg.dispose(); | ||
treeViewImg.dispose(); | ||
flatViewImg.dispose(); | ||
} | ||
} |
Oops, something went wrong.