mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
bug 279502: User friendly icons for Paths&Symbols
This commit is contained in:
parent
f6d3c6295b
commit
7eb5d01ded
11 changed files with 379 additions and 77 deletions
|
@ -36,8 +36,11 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
@Override
|
||||
protected final boolean isFile() {
|
||||
public final boolean isFile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public abstract class ACPathEntry extends ACSettingEntry
|
||||
implements ICPathEntry {
|
||||
public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry {
|
||||
// IPath fFullPath;
|
||||
// IPath fLocation;
|
||||
// private IPath fPath;
|
||||
|
@ -68,7 +67,10 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
return null;
|
||||
}
|
||||
|
||||
protected abstract boolean isFile();
|
||||
/**
|
||||
* @since 5.4
|
||||
*/
|
||||
public abstract boolean isFile();
|
||||
|
||||
@Override
|
||||
public IPath getLocation() {
|
||||
|
|
|
@ -56,30 +56,31 @@ public abstract class ACSettingEntry implements ICSettingEntry {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other){
|
||||
if(other == this)
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if(!(other instanceof ACSettingEntry))
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
ACSettingEntry e = (ACSettingEntry)other;
|
||||
|
||||
if(getKind() != e.getKind())
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
if(fFlags != e.fFlags)
|
||||
ACSettingEntry other = (ACSettingEntry) obj;
|
||||
if (fFlags != other.fFlags)
|
||||
return false;
|
||||
|
||||
if(!fName.equals(e.fName))
|
||||
if (fName == null) {
|
||||
if (other.fName != null)
|
||||
return false;
|
||||
} else if (!fName.equals(other.fName))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return getKind() + fFlags + fName.hashCode();
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + fFlags;
|
||||
result = prime * result + ((fName == null) ? 0 : fName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,15 +35,28 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!super.equals(other))
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
return fValue.equals(((CMacroEntry)other).fValue);
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CMacroEntry other = (CMacroEntry) obj;
|
||||
if (fValue == null) {
|
||||
if (other.fValue != null)
|
||||
return false;
|
||||
} else if (!fValue.equals(other.fValue))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + fValue.hashCode();
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((fValue == null) ? 0 : fValue.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/obj16/frameworks.png
Normal file
BIN
core/org.eclipse.cdt.ui/icons/obj16/frameworks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 521 B |
|
@ -0,0 +1,179 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010, 2012 Andrew Gvozdev 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:
|
||||
* Andrew Gvozdev - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.newui;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.viewers.IDecoration;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ACPathEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
/**
|
||||
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
|
||||
*/
|
||||
public class LanguageSettingsImages {
|
||||
/**
|
||||
* @return the base key for the image.
|
||||
*/
|
||||
private static String getImageKey(int kind, int flag, boolean isProjectRelative) {
|
||||
String imageKey = null;
|
||||
|
||||
boolean isWorkspacePath = (flag & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||
boolean isBuiltin = (flag & ICSettingEntry.BUILTIN) != 0;
|
||||
boolean isFramework = (flag & ICSettingEntry.FRAMEWORKS_MAC) != 0;
|
||||
|
||||
switch (kind) {
|
||||
case ICSettingEntry.INCLUDE_PATH:
|
||||
if (isWorkspacePath) {
|
||||
if (isProjectRelative) {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_PROJECT;
|
||||
} else {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE;
|
||||
}
|
||||
} else if (isFramework) {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_FRAMEWORKS_FOLDER;
|
||||
} else if (isBuiltin) {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM;
|
||||
} else {
|
||||
imageKey = CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER;
|
||||
}
|
||||
break;
|
||||
case ICSettingEntry.INCLUDE_FILE:
|
||||
imageKey = CDTSharedImages.IMG_OBJS_TUNIT_HEADER;
|
||||
break;
|
||||
case ICSettingEntry.MACRO:
|
||||
imageKey = CDTSharedImages.IMG_OBJS_MACRO;
|
||||
break;
|
||||
case ICSettingEntry.MACRO_FILE:
|
||||
imageKey = CDTSharedImages.IMG_OBJS_MACROS_FILE;
|
||||
break;
|
||||
case ICSettingEntry.LIBRARY_PATH:
|
||||
imageKey = CDTSharedImages.IMG_OBJS_LIBRARY_FOLDER;
|
||||
break;
|
||||
case ICSettingEntry.LIBRARY_FILE:
|
||||
imageKey = CDTSharedImages.IMG_OBJS_LIBRARY;
|
||||
break;
|
||||
}
|
||||
if (imageKey == null)
|
||||
imageKey = CDTSharedImages.IMG_OBJS_UNKNOWN_TYPE;
|
||||
return imageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns image for the given entry from internally managed repository including
|
||||
* necessary overlays.
|
||||
*
|
||||
* @param entry - language settings entry to get an image for.
|
||||
* @param projectName - pass project name if available. That lets put "project" metaphor
|
||||
* on the image. Pass {@code null} if no project name is available.
|
||||
* @param cfgDescription - configuration description of the entry.
|
||||
* @return the image for the entry with appropriate overlays.
|
||||
*/
|
||||
public static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
|
||||
int kind = entry.getKind();
|
||||
int flags = entry.getFlags();
|
||||
boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||
String path = entry.getName();
|
||||
boolean isProjectRelative = (projectName != null) && isWorkspacePath && path.startsWith(IPath.SEPARATOR + projectName + IPath.SEPARATOR);
|
||||
|
||||
String imageKey = getImageKey(kind, flags, isProjectRelative);
|
||||
if (imageKey != null) {
|
||||
if ((flags & ICSettingEntry.UNDEFINED) != 0) {
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, CDTSharedImages.IMG_OVR_INACTIVE, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
|
||||
if (entry instanceof ACPathEntry) {
|
||||
String overlayKey=null;
|
||||
IStatus status = getStatus(entry, cfgDescription);
|
||||
switch (status.getSeverity()) {
|
||||
case IStatus.ERROR:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_ERROR;
|
||||
break;
|
||||
case IStatus.WARNING:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
case IStatus.INFO:
|
||||
overlayKey = CDTSharedImages.IMG_OVR_WARNING;
|
||||
break;
|
||||
}
|
||||
return CDTSharedImages.getImageOverlaid(imageKey, overlayKey, IDecoration.BOTTOM_LEFT);
|
||||
}
|
||||
return CDTSharedImages.getImage(imageKey);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if the entry points to existing or accessible location.
|
||||
* @param entry - resolved entry
|
||||
*/
|
||||
private static boolean isLocationOk(ACPathEntry entry) {
|
||||
boolean exists = true;
|
||||
boolean isWorkspacePath = (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||
if (isWorkspacePath) {
|
||||
IPath path = new Path(entry.getValue());
|
||||
IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
|
||||
exists = (rc !=null) && rc.isAccessible();
|
||||
} else {
|
||||
String pathname = entry.getName();
|
||||
java.io.File file = new java.io.File(pathname);
|
||||
exists = file.exists();
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines status object for the status message line.
|
||||
*
|
||||
* @param entry - the entry to check status on.
|
||||
* @param cfgDescription - configuration description of the entry.
|
||||
* @return a status object defining severity and message.
|
||||
*/
|
||||
public static IStatus getStatus(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
|
||||
if (entry instanceof ACPathEntry) {
|
||||
if (!entry.isResolved()) {
|
||||
ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, cfgDescription);
|
||||
if (entries != null && entries.length > 0) {
|
||||
entry = entries[0];
|
||||
}
|
||||
}
|
||||
|
||||
ACPathEntry acEntry = (ACPathEntry)entry;
|
||||
String acEntryName = acEntry.getName();
|
||||
IPath path = new Path(acEntryName);
|
||||
if (!path.isAbsolute()) {
|
||||
return new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_UsingRelativePathsNotRecommended);
|
||||
}
|
||||
if (!isLocationOk(acEntry)) {
|
||||
if (acEntry.isFile()) {
|
||||
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FileDoesNotExist);
|
||||
} else {
|
||||
return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsImages_FolderDoesNotExist);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -186,6 +186,9 @@ public class Messages extends NLS {
|
|||
public static String IncludeTab_2;
|
||||
public static String IncludeTab_export;
|
||||
public static String IncludeTab_import;
|
||||
public static String LanguageSettingsImages_FileDoesNotExist;
|
||||
public static String LanguageSettingsImages_FolderDoesNotExist;
|
||||
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
|
||||
public static String LanguagesTab_0;
|
||||
public static String LanguagesTab_1;
|
||||
public static String LibraryPathTab_1;
|
||||
|
|
|
@ -166,6 +166,9 @@ IncludeDialog_0=Directory:
|
|||
IncludeDialog_1=File:
|
||||
IncludeDialog_2=Add to all configurations
|
||||
IncludeDialog_3=Add to all languages
|
||||
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
|
||||
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
|
||||
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
|
||||
LanguagesTab_0=Content type
|
||||
LanguagesTab_1=Language
|
||||
LibraryPathTab_1=Add...
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Andrew Gvozdev 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:
|
||||
* Andrew Gvozdev - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.newui;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CLabel;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
* A message line displaying a status.
|
||||
* See also org.eclipse.jface.dialogs.StatusDialog.MessageLine.
|
||||
*/
|
||||
public class StatusMessageLine {
|
||||
private CLabel fLabel;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parent - parent element.
|
||||
* @param style - the style of the control. Refer to {@link CLabel#CLabel(Composite, int)}.
|
||||
* @param span - how many columns it should span.
|
||||
*/
|
||||
public StatusMessageLine(Composite parent, int style, int span) {
|
||||
fLabel = new CLabel(parent, style);
|
||||
if (span!=1) {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
|
||||
gd.horizontalSpan = span;
|
||||
fLabel.setLayoutData(gd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an image associated with the status.
|
||||
*/
|
||||
private Image findImage(IStatus status) {
|
||||
if (status.isOK()) {
|
||||
return null;
|
||||
} else if (status.matches(IStatus.ERROR)) {
|
||||
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
|
||||
} else if (status.matches(IStatus.WARNING)) {
|
||||
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
|
||||
} else if (status.matches(IStatus.INFO)) {
|
||||
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign {@link IStatus} object to the message line. The status should provide
|
||||
* severity for the icon and message to display.
|
||||
*
|
||||
* @param status - status object for the message line.
|
||||
*/
|
||||
public void setErrorStatus(IStatus status) {
|
||||
if (status != null && !status.isOK()) {
|
||||
String message = status.getMessage();
|
||||
if (message != null && message.length() > 0) {
|
||||
fLabel.setText(message);
|
||||
fLabel.setImage(findImage(status));
|
||||
fLabel.layout();
|
||||
return;
|
||||
}
|
||||
}
|
||||
fLabel.setText(""); //$NON-NLS-1$
|
||||
fLabel.setImage(null);
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
*
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
*
|
||||
*
|
||||
* @since 5.3
|
||||
*/
|
||||
public class CDTSharedImages {
|
||||
|
@ -116,6 +116,8 @@ public class CDTSharedImages {
|
|||
public static final String IMG_OBJS_INCLUDES_FOLDER_WORKSPACE = "icons/obj16/wsp_includefolder.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = "icons/obj16/hfolder_quote_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = "icons/obj16/fldr_sys_obj.gif"; //$NON-NLS-1$
|
||||
/** @since 5.4 */
|
||||
public static final String IMG_OBJS_FRAMEWORKS_FOLDER = "icons/obj16/frameworks.png"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_MACROS_FILE= "icons/obj16/macros_file.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_LIBRARY_FOLDER= "icons/obj16/fldr_lib_obj.gif"; // $NON-NLS-1$ //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_ORDER = "icons/obj16/cp_order_obj.gif"; //$NON-NLS-1$
|
||||
|
@ -184,21 +186,21 @@ public class CDTSharedImages {
|
|||
public static final String IMG_OVR_ERROR = "icons/ovr16/error_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OVR_SETTING = "icons/ovr16/setting_nav.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OVR_INACTIVE = "icons/ovr16/inactive_co.gif"; //$NON-NLS-1$
|
||||
|
||||
|
||||
// Pin & Clone
|
||||
public static final String IMG_THREAD_SUSPENDED_R_PINNED = "icons/obj16/threads_obj_r.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_THREAD_SUSPENDED_G_PINNED = "icons/obj16/threads_obj_g.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_THREAD_SUSPENDED_B_PINNED = "icons/obj16/threads_obj_b.gif"; //$NON-NLS-1$
|
||||
|
||||
|
||||
public static final String IMG_THREAD_RUNNING_R_PINNED = "icons/obj16/thread_obj_r.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_THREAD_RUNNING_G_PINNED = "icons/obj16/thread_obj_g.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_THREAD_RUNNING_B_PINNED = "icons/obj16/thread_obj_b.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_THREAD_RUNNING_B_PINNED = "icons/obj16/thread_obj_b.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_CONTAINER_SUSPENDED_R_PINNED = "icons/obj16/debugts_obj_r.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_CONTAINER_SUSPENDED_G_PINNED = "icons/obj16/debugts_obj_g.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_CONTAINER_SUSPENDED_B_PINNED = "icons/obj16/debugts_obj_b.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_CONTAINER_RUNNING_R_PINNED = "icons/obj16/debugt_obj_r.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_CONTAINER_RUNNING_R_PINNED = "icons/obj16/debugt_obj_r.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_CONTAINER_RUNNING_G_PINNED = "icons/obj16/debugt_obj_g.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_CONTAINER_RUNNING_B_PINNED = "icons/obj16/debugt_obj_b.gif"; //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* Intel Corporation - initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Gvozdev
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.newui;
|
||||
|
||||
|
@ -18,6 +19,7 @@ import java.util.Comparator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.jface.viewers.IFontProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
|
@ -65,9 +67,10 @@ import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
|||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.MultiLanguageSetting;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.ui.CDTSharedImages;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
|
||||
import org.eclipse.cdt.internal.ui.newui.Messages;
|
||||
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
|
||||
|
||||
public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
||||
protected Table table;
|
||||
|
@ -77,6 +80,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
protected Button showBIButton;
|
||||
protected boolean toAllCfgs = false;
|
||||
protected boolean toAllLang = false;
|
||||
private StatusMessageLine fStatusLine;
|
||||
|
||||
/** @deprecated as of CDT 8.0. {@code linkStringListMode} is used instead. */
|
||||
@Deprecated
|
||||
protected Label lb1, lb2;
|
||||
|
@ -120,12 +125,6 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
private static final Comparator<Object> comp = CDTListComparator.getInstance();
|
||||
private static String selectedLanguage;
|
||||
|
||||
private final static Image IMG_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER);
|
||||
private final static Image IMG_INCLUDES_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
|
||||
private final static Image IMG_BUILTIN_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
|
||||
private final static Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE);
|
||||
private final static Image IMG_INCLUDES_FOLDER_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
|
||||
private final static Image IMG_MACRO = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO);
|
||||
private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 };
|
||||
|
||||
@Override
|
||||
|
@ -186,11 +185,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
});
|
||||
|
||||
tv.setLabelProvider(new RichLabelProvider());
|
||||
tv.setLabelProvider(new LanguageSettingsEntriesLabelProvider());
|
||||
|
||||
table.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateStatusLine();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
setColumnToFit();
|
||||
}});
|
||||
|
||||
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
|
||||
|
||||
showBIButton = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.GRAB_HORIZONTAL);
|
||||
gd = (GridData) showBIButton.getLayoutData();
|
||||
showBIButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -233,6 +235,17 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
updateData(getResDesc());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return selected entry when only one is selected or {@code null}.
|
||||
*/
|
||||
private ICLanguageSettingEntry getSelectedEntry() {
|
||||
int index = table.getSelectionIndex();
|
||||
if (index<0 || table.getSelectionIndices().length!=1)
|
||||
return null;
|
||||
|
||||
return (ICLanguageSettingEntry)(table.getItem(index).getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to display UI control for multiple configurations string list mode
|
||||
* (see Multiple Configurations Edit Preference page).
|
||||
|
@ -243,6 +256,14 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
stringListModeControl.updateStringListModeControl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays warning message - if any - for selected language settings entry.
|
||||
* Multiline selection is not supported.
|
||||
*/
|
||||
private void updateStatusLine() {
|
||||
fStatusLine.setErrorStatus(LanguageSettingsImages.getStatus(getSelectedEntry(), getResDesc().getConfiguration()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates state for all buttons
|
||||
* Called when table selection changes.
|
||||
|
@ -351,6 +372,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
}
|
||||
|
||||
updateStringListModeControl();
|
||||
updateStatusLine();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
@ -698,70 +720,63 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
|
|||
}
|
||||
|
||||
// Extended label provider
|
||||
private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
|
||||
public RichLabelProvider(){}
|
||||
private class LanguageSettingsEntriesLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
return getColumnImage(element, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
if (columnIndex > 0) return null;
|
||||
if (! (element instanceof ICLanguageSettingEntry)) return null;
|
||||
|
||||
ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
|
||||
if (le.getKind() == ICSettingEntry.MACRO)
|
||||
return IMG_MACRO;
|
||||
if ((le.getFlags() & ICSettingEntry.BUILTIN) != 0)
|
||||
return IMG_BUILTIN_FOLDER;
|
||||
|
||||
boolean isWorkspacePath = (le.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
|
||||
if (le.getKind() == ICSettingEntry.INCLUDE_PATH || le.getKind() == ICSettingEntry.INCLUDE_FILE) {
|
||||
if (isWorkspacePath)
|
||||
return IMG_INCLUDES_FOLDER_WORKSPACE;
|
||||
else
|
||||
return IMG_INCLUDES_FOLDER;
|
||||
} else {
|
||||
if (isWorkspacePath)
|
||||
return IMG_WORKSPACE;
|
||||
else
|
||||
return IMG_FOLDER;
|
||||
if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
|
||||
ICConfigurationDescription cfg = getResDesc().getConfiguration();
|
||||
IProject project = cfg.getProjectDescription().getProject();
|
||||
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName(), cfg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
return getColumnText(element, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (! (element instanceof ICLanguageSettingEntry)) {
|
||||
return (columnIndex == 0) ? element.toString() : EMPTY_STR;
|
||||
}
|
||||
ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
|
||||
if (columnIndex == 0) {
|
||||
String s = le.getName();
|
||||
if (exported.contains(resolve(le)))
|
||||
s = s + Messages.AbstractLangsListTab_ExportIndicator;
|
||||
return s;
|
||||
}
|
||||
if (le.getKind() == ICSettingEntry.MACRO) {
|
||||
if (element instanceof ICLanguageSettingEntry) {
|
||||
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
|
||||
switch (columnIndex) {
|
||||
case 1: return le.getValue();
|
||||
case 0:
|
||||
String name = entry.getName();
|
||||
if (exported.contains(resolve(entry)))
|
||||
name = name + Messages.AbstractLangsListTab_ExportIndicator;
|
||||
return name;
|
||||
case 1:
|
||||
if (entry.getKind() == ICSettingEntry.MACRO) {
|
||||
return entry.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} else if (columnIndex == 0) {
|
||||
return element.toString();
|
||||
}
|
||||
return EMPTY_STR;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Font getFont(Object element) {
|
||||
if (! (element instanceof ICLanguageSettingEntry)) return null;
|
||||
ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
|
||||
if (le.isBuiltIn()) return null; // built in
|
||||
if (le.isReadOnly()) // read only
|
||||
if (element instanceof ICLanguageSettingEntry) {
|
||||
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) element;
|
||||
if (entry.isBuiltIn())
|
||||
return null;
|
||||
if (entry.isReadOnly())
|
||||
return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
|
||||
// normal
|
||||
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ICLanguageSetting[] getLangSetting(ICResourceDescription rcDes) {
|
||||
|
|
Loading…
Add table
Reference in a new issue