From f08de55a15d5321e7a9e5f7e5aaf1f2c2dc98f55 Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Wed, 21 Feb 2007 17:36:52 +0000 Subject: [PATCH] New implementations to use instead of internal ones. --- .../eclipse/cdt/ui/newui/CDTStatusInfo.java | 27 +++++++++++++++ .../cdt/ui/newui/TypedCDTViewerFilter.java | 33 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java new file mode 100644 index 00000000000..4e431a18d4e --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java @@ -0,0 +1,27 @@ +package org.eclipse.cdt.ui.newui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.cdt.ui.CUIPlugin; + +/** + * Simple IStatus implementation to avoid using internal classes + */ +public class CDTStatusInfo implements IStatus { + private String text; + private int code; + + public CDTStatusInfo() {this(OK, null); } + public CDTStatusInfo(int _code, String _text) { + text= _text; + code= _code; + } + public IStatus[] getChildren() { return new IStatus[0];} + public int getCode() { return code; } + public Throwable getException() { return null; } + public String getMessage() { return text; } + public String getPlugin() { return CUIPlugin.PLUGIN_ID; } + public int getSeverity() { return code; } + public boolean isMultiStatus() { return false; } + public boolean isOK() { return (code == OK); } + public boolean matches(int mask) { return (code & mask) != 0; } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java new file mode 100644 index 00000000000..438ed766c25 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.newui; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +/** + * see org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter + */ +public class TypedCDTViewerFilter extends ViewerFilter { + + private Class[] types; + + public TypedCDTViewerFilter(Class[] _types) { types= _types; } + /** + * @see ViewerFilter#select + */ + public boolean select(Viewer viewer, Object parent, Object element) { + for (int i= 0; i < types.length; i++) { + if (types[i].isInstance(element)) return true; + } + return false; + } +}