use of org.python.pydev.shared_core.image.IImageDescriptor in project Pydev by fabioz.
the class ImageCache method getDescriptor.
/**
* like get, but returns ImageDescription instead of image
*/
@Override
public IImageDescriptor getDescriptor(String key) {
ImageDescriptor desc;
synchronized (descriptorLock) {
desc = descriptorHash.get(key);
if (desc == null) {
URL url;
try {
url = new URL(baseURL, key);
desc = ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {
Log.log("ERROR: Missing image: " + key);
desc = ImageDescriptor.getMissingImageDescriptor();
}
descriptorHash.put(key, desc);
}
}
final ImageDescriptor computed = desc;
return new IImageDescriptor() {
@Override
public Object getImageDescriptor() {
return computed;
}
};
}
use of org.python.pydev.shared_core.image.IImageDescriptor in project Pydev by fabioz.
the class SyncSystemModulesManager method updateStructures.
/**
* Here we'll update the tree structure to be shown to the user with the changes (root).
* The managerToNameToInfo structure has the information on the interpreter manager and related
* interpreter infos for which the changes should be checked.
*/
public void updateStructures(IProgressMonitor monitor, final DataAndImageTreeNode root, ManagerInfoToUpdate managerToNameToInfo, CreateInterpreterInfoCallback callback) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
IImageCache imageCache = SharedCorePlugin.getImageCache();
if (imageCache == null) {
imageCache = new IImageCache() {
@Override
public IImageHandle getStringDecorated(String key, String stringToAddToDecoration) {
return null;
}
@Override
public IImageHandle getImageDecorated(String key, String decoration, int decorationLocation, String secondDecoration, int secondDecorationLocation) {
return null;
}
@Override
public IImageHandle getImageDecorated(String key, String decoration, int decorationLocation) {
return null;
}
@Override
public IImageHandle getImageDecorated(String key, String decoration) {
return null;
}
@Override
public IImageDescriptor getDescriptor(String projectIcon) {
return null;
}
@Override
public IImageHandle get(String key) {
return null;
}
};
}
for (Tuple<IInterpreterManager, IInterpreterInfo> infos : managerToNameToInfo.getManagerAndInfos()) {
IInterpreterManager manager = infos.o1;
IInterpreterInfo internalInfo = infos.o2;
String executable = internalInfo.getExecutableOrJar();
IInterpreterInfo newInterpreterInfo = callback.createInterpreterInfo(manager, executable, monitor);
if (newInterpreterInfo == null) {
continue;
}
DefaultPathsForInterpreterInfo defaultPaths = new DefaultPathsForInterpreterInfo();
OrderedSet<String> newEntries = new OrderedSet<String>(newInterpreterInfo.getPythonPath());
newEntries.removeAll(internalInfo.getPythonPath());
// Iterate over the new entries to suggest what should be added (we already have only what's not there).
for (Iterator<String> it = newEntries.iterator(); it.hasNext(); ) {
String entryInPythonpath = it.next();
if (!defaultPaths.selectByDefault(entryInPythonpath) || !defaultPaths.exists(entryInPythonpath)) {
// Don't suggest the addition of entries in the workspace or entries which do not exist.
it.remove();
}
}
// Iterate over existing entries to suggest what should be removed.
OrderedSet<String> removedEntries = new OrderedSet<String>();
List<String> pythonPath = internalInfo.getPythonPath();
for (String string : pythonPath) {
if (!new File(string).exists()) {
// Only suggest a removal if it was removed from the filesystem.
removedEntries.add(string);
}
}
if (newEntries.size() > 0 || removedEntries.size() > 0) {
DataAndImageTreeNode<IInterpreterInfo> interpreterNode = new DataAndImageTreeNode<IInterpreterInfo>(root, internalInfo, imageCache.get(UIConstants.PY_INTERPRETER_ICON));
for (String s : newEntries) {
new DataAndImageTreeNode(interpreterNode, new PythonpathChange(s, true), imageCache.get(UIConstants.LIB_SYSTEM));
}
for (String s : removedEntries) {
new DataAndImageTreeNode(interpreterNode, new PythonpathChange(s, false), imageCache.get(UIConstants.REMOVE_LIB_SYSTEM));
}
}
}
}
use of org.python.pydev.shared_core.image.IImageDescriptor in project Pydev by fabioz.
the class PyEdit method updateForceTabsMessage.
public void updateForceTabsMessage() {
boolean forceTabs = getIndentPrefs().getForceTabs();
IImageCache imageCache = SharedUiPlugin.getImageCache();
IImageDescriptor desc;
if (forceTabs) {
desc = imageCache.getDescriptor(UIConstants.FORCE_TABS_ACTIVE);
} else {
desc = imageCache.getDescriptor(UIConstants.FORCE_TABS_INACTIVE);
}
IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
if (statusLine != null) {
statusLine.setMessage(false, forceTabs ? "Forcing tabs" : "Not forcing tabs.", ImageCache.asImageDescriptor(desc).createImage());
}
}
Aggregations