Skip to content
Snippets Groups Projects
Commit b0fe7fda authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Open a second shell before taking the screenshot of the "tick" button for...

Open a second shell before taking the screenshot of the "tick" button for boolean annotations in GTK environments.
refs 2406
parent 82f524c0
No related branches found
No related tags found
No related merge requests found
......@@ -36,9 +36,12 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.fortiss.tooling.base.ToolingBaseActivator;
import org.fortiss.tooling.base.annotation.AnnotationEntry;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
* <p>
......@@ -61,7 +64,7 @@ import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 4C99360BCBA6F717DE35D5AE9554F25B
* @ConQAT.Rating YELLOW Hash: E432AD2266E44A4DE3B3DE4ACB2D852E
*/
public class EmulatedNativeCheckBoxLabelProvider extends AnnotationLabelProvider {
......@@ -176,6 +179,17 @@ public class EmulatedNativeCheckBoxLabelProvider extends AnnotationLabelProvider
shell.setSize(bsize);
shell.open();
// Work around a gtk display error that causes the widgets in the
// shell not being "visible". Opening a second Shell modifies some
// internal properties of the existing shell, such that the widgets
// become visible.
if(isBundleLoaded("org.eclipse.swt.gtk")) {
Shell shell2 = new Shell(control.getShell(), SWT.NO_TRIM);
shell2.open();
shell2.close();
}
GC gc = new GC(shell);
Image image = new Image(control.getDisplay(), bsize.x, bsize.y);
gc.copyArea(image, 0, 0);
......@@ -191,6 +205,20 @@ public class EmulatedNativeCheckBoxLabelProvider extends AnnotationLabelProvider
return new Image(control.getDisplay(), imageData);
}
/** Returns whether any bundle containing the given qualifier has been loaded. */
private boolean isBundleLoaded(String bundleNameFragment) {
BundleContext bundleContext =
ToolingBaseActivator.getDefault().getBundle().getBundleContext();
for(Bundle bundle : bundleContext.getBundles()) {
if(bundle.getSymbolicName().contains(bundleNameFragment)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public String getText(Object element) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment