Commit 25e5144f authored by Alexander Diewald's avatar Alexander Diewald
Browse files

- Avoid presenting the CellEditor for boolean annotations in (Linux) GTK environments.

- Replace custom bundle search method with one provided by the eclipse Platform.
refs 2406
parent ba82b7bc
......@@ -17,6 +17,8 @@
*/
package org.fortiss.tooling.base.ui.annotation.editingsupport;
import static org.eclipse.core.runtime.Platform.getBundle;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
import org.eclipse.swt.SWT;
......@@ -34,7 +36,7 @@ import org.eclipse.swt.widgets.Control;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: BD271C9AB31747CE59FA19C8A9DCB9A7
* @ConQAT.Rating YELLOW Hash: EFD0302B4B0E12BEC467B3A359C4DFA7
*/
public class BooleanCellEditor extends CellEditor {
......@@ -94,6 +96,14 @@ public class BooleanCellEditor extends CellEditor {
// called).
button.getParent().layout();
// For GTK-environments, the layout call is not sufficient to hide
// the cell editor. Here, it is required to unset the focus. This
// results in a NPE in windows, so restrict to gtk environments.
if(getBundle("org.eclipse.swt.gtk.linux.x86_64") != null ||
getBundle("org.eclipse.swt.gtk.linux.x86") != null) {
focusLost();
}
// TODO (see #2268): This BooleanCellEditor widget is temporarily shown at a wrong
// position (seen best when holding mouse button down for a longer time
// when clicking the cell).
......
......@@ -14,6 +14,7 @@
*******************************************************************************/
package org.fortiss.tooling.base.ui.annotation.labelprovider;
import static org.eclipse.core.runtime.Platform.getBundle;
import static org.eclipse.jface.resource.JFaceResources.getImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
......@@ -36,12 +37,9 @@ 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>
......@@ -64,7 +62,7 @@ import org.osgi.framework.BundleContext;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: E432AD2266E44A4DE3B3DE4ACB2D852E
* @ConQAT.Rating YELLOW Hash: 9FD4DCC024810D15D8579ED28EE19528
*/
public class EmulatedNativeCheckBoxLabelProvider extends AnnotationLabelProvider {
......@@ -184,7 +182,7 @@ public class EmulatedNativeCheckBoxLabelProvider extends AnnotationLabelProvider
// 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")) {
if(getBundle("org.eclipse.swt.gtk") != null) {
Shell shell2 = new Shell(control.getShell(), SWT.NO_TRIM);
shell2.open();
shell2.close();
......@@ -205,20 +203,6 @@ 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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment