Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround a random crash in the Data Explorer on GTK #1998

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
import org.eclipse.chemclipse.rcp.ui.icons.core.ApplicationImageFactory;
import org.eclipse.chemclipse.rcp.ui.icons.core.IApplicationImage;
import org.eclipse.chemclipse.rcp.ui.icons.core.IApplicationImageProvider;
import org.eclipse.chemclipse.support.settings.OperatingSystemUtils;
import org.eclipse.chemclipse.ux.extension.ui.editors.EditorDescriptor;
import org.eclipse.chemclipse.ux.extension.ui.swt.IdentifierCacheSupport;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.navigator.IDescriptionProvider;

public class DataExplorerLabelProvider extends LabelProvider implements ILabelProvider, IDescriptionProvider {
public class DataExplorerLabelProvider extends ColumnLabelProvider implements ILabelProvider, IDescriptionProvider {

private final Function<File, Map<ISupplierFileIdentifier, Collection<ISupplier>>> supplierFunction;
private ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources());
private boolean isInitial = true;

public DataExplorerLabelProvider(Collection<? extends ISupplierFileIdentifier> supplierFileIdentifierList) {

Expand Down Expand Up @@ -74,15 +74,22 @@ public String getDescription(Object element) {
}

@Override
public Image getImage(Object element) {

/*
* Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=573090
*/
if(isInitial && OperatingSystemUtils.isLinux()) {
isInitial = false;
return null;
}
public void update(ViewerCell cell) {

Object element = cell.getElement();
cell.setText(getText(element));
Image image = getIcon(element);
// https://github.com/eclipse-platform/eclipse.platform.swt/issues/678
Display.getCurrent().asyncExec(() -> {
cell.setImage(image);
});
cell.setBackground(getBackground(element));
cell.setForeground(getForeground(element));
cell.setFont(getFont(element));
}

public Image getIcon(Object element) {

if(element instanceof File file) {
ImageDescriptor descriptor = null;
//
Expand Down
Loading