Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

outline errors show in outline view

  • Loading branch information...
commit 897933d6a58c8a1d5bd6a7ee075164b220d52273 1 parent 9d58380
@JPMoresmau authored
View
40 ...sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
@@ -523,21 +523,9 @@ public OutlineResult outline(IFile file){
if (arr.length()>1){
JSONArray notes=arr.optJSONArray(1);
//notes.putAll(i.getNotes());
- boolean b=parseNotes(notes,null,new NoteFilter() {
-
- @Override
- public boolean accept(Note n) {
- return !n.getMessage().contains("not enabled");
- }
-
- /* (non-Javadoc)
- * @see net.sf.eclipsefp.haskell.buildwrapper.BWFacade.NoteFilter#getLogPrefix()
- */
- @Override
- public String getLogPrefix() {
- return "Outline: ";
- }
- });
+ List<Note> ns=new ArrayList<Note>();
+ boolean b=parseNotes(notes,null,ns);
+ or.setNotes(ns);
or.setBuildOK(b);
}
@@ -687,7 +675,7 @@ private boolean isOK(JSONArray notes){
return true;
}
- private boolean parseNotes(JSONArray notes,Set<IResource> ress,NoteFilter filter){
+ private boolean parseNotes(JSONArray notes,Set<IResource> ress,Collection<Note> collect){
boolean buildOK=true;
if (notes!=null){
try {
@@ -709,12 +697,13 @@ private boolean parseNotes(JSONArray notes,Set<IResource> ress,NoteFilter filter
Location loc=new Location(project, f, line, col, endline, endcol);
//ow.addMessage("\nCreated location: "+loc.getStartLine()+":"+loc.getStartColumn()+" to "+loc.getEndLine()+":"+loc.getEndColumn());
-
+ if (k.equals(Kind.ERROR)){
+ buildOK=false;
+ }
Note n=new Note(k,loc,o.getString("t"),"");
- if (filter==null || filter.accept(n)){
- if (k.equals(Kind.ERROR)){
- buildOK=false;
- }
+ if (collect!=null){
+ collect.add(n);
+ } else {
IResource res=project.findMember(f);
// linker errors may have full path
if (res==null){
@@ -737,9 +726,7 @@ private boolean parseNotes(JSONArray notes,Set<IResource> ress,NoteFilter filter
hasCabalProblems=true;
}
}
- } else if (k.equals(Kind.ERROR)){
- BuildWrapperPlugin.logError(filter.getLogPrefix()+n.toString(), null);
- }
+ }
}
} catch (JSONException je){
BuildWrapperPlugin.logError(BWText.process_parse_note_error, je);
@@ -1121,8 +1108,5 @@ public boolean isInTempFolder(IResource r){
return false;
}
- private interface NoteFilter{
- boolean accept(Note n);
- String getLogPrefix();
- }
+
}
View
8 ...f.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/JobFacade.java
@@ -216,20 +216,20 @@ protected IStatus run(IProgressMonitor monitor) {
// long t1=System.currentTimeMillis();
OutlineResult or=realFacade.outline(file);
//long t2=System.currentTimeMillis();
- if (!or.isEmpty() || or.isBuildOK()){
+ //if (!or.isEmpty() || or.isBuildOK()){
handler.handleOutline(or); // avoid removing all outline on error
- }
+ //}
//long t3=System.currentTimeMillis();
- if (or.isBuildOK()){
+ //if (or.isBuildOK()){
Collection<NameDef> ns=realFacade.build1(file);
if (ndhandler!=null){
ndhandler.handleNameDefs(ns);
}
- }
+ //}
//long t4=System.currentTimeMillis();
//,getBuildFlags:"+(t1-t0)
View
7 ...sefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/types/OutlineDef.java
@@ -31,7 +31,8 @@
INSTANCE,
FIELD,
CONSTRUCTOR,
- SPLICE
+ SPLICE,
+ ERROR
}
public static OutlineDefType parseType(JSONObject obj){
@@ -79,8 +80,8 @@ public int compare(OutlineDef o1, OutlineDef o2) {
* the comment or "" if none
*/
private String comment;
-
- public OutlineDef(String name, OutlineDefType type, Location loc, Location block) {
+ //Location block
+ public OutlineDef(String name, OutlineDefType type, Location loc) {
super();
this.name = name;
this.types.add(type);
View
21 ...fp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellEditor.java
@@ -10,6 +10,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -21,7 +22,9 @@
import net.sf.eclipsefp.haskell.buildwrapper.types.Location;
import net.sf.eclipsefp.haskell.buildwrapper.types.NameDef;
import net.sf.eclipsefp.haskell.buildwrapper.types.NameDefHandler;
+import net.sf.eclipsefp.haskell.buildwrapper.types.Note;
import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
+import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef.OutlineDefType;
import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineHandler;
import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineResult;
import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
@@ -153,7 +156,7 @@
@Override
public void handleOutline( final OutlineResult or ) {
- //if (!or.getOutlineDefs().isEmpty() || or.isBuildOK()){// avoid removing all outline on error
+ if (!or.getOutlineDefs().isEmpty() || or.isBuildOK()){// avoid removing all outline on error
if (outlinePage!=null){
outlinePage.setInput( or.getOutlineDefs() );
}
@@ -161,13 +164,23 @@ public void handleOutline( final OutlineResult or ) {
if (foldingStructureProvider!=null){
foldingStructureProvider.updateFoldingRegions( or.getOutlineDefs() );
}
- /*} else if (!or.isBuildOK() && or.getNotes()!=null && or.getNotes().size()>0){
+ } else if (!or.isBuildOK() && or.getNotes()!=null && or.getNotes().size()>0 &&
+ (lastOutlineResult==null || lastOutlineResult.isEmpty())){
+ List<OutlineDef> errorsOutline=new ArrayList<OutlineDef>();
for (Note n:or.getNotes()){
if (n.getKind().equals( Note.Kind.ERROR )){
- HaskellUIPlugin.log( n.toString(), IStatus.ERROR);
+ OutlineDef def=new OutlineDef(n.getMessage(),OutlineDefType.ERROR,n.getLocation()) ;
+ errorsOutline.add( def );
}
}
- }*/
+ if (outlinePage!=null){
+ outlinePage.setInput( errorsOutline);
+ }
+ lastOutlineResult=or;
+ if (foldingStructureProvider!=null){
+ foldingStructureProvider.updateFoldingRegions( Collections.<OutlineDef>emptyList() );
+ }
+ }
}
};
View
91 ...skell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/outline/OutlineLabelProvider.java
@@ -1,45 +1,46 @@
-package net.sf.eclipsefp.haskell.ui.internal.views.outline;
-
-import java.util.HashMap;
-import java.util.Map;
-import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
-import net.sf.eclipsefp.haskell.ui.util.HaskellUIImages;
-import net.sf.eclipsefp.haskell.ui.util.IImageNames;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * <p>Display OutlineDef objects for the outline tree</p>
- *
- * @author JP Moresmau
- */
-public class OutlineLabelProvider extends LabelProvider {
- private static Map<OutlineDef.OutlineDefType,String> imageKeysByType=new HashMap<OutlineDef.OutlineDefType, String>();
-
- static {
- imageKeysByType.put(OutlineDef.OutlineDefType.CLASS,IImageNames.CLASS_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.DATA,IImageNames.DATA_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.FUNCTION,IImageNames.FUNCTION_BINDING);
- imageKeysByType.put(OutlineDef.OutlineDefType.PATTERN,IImageNames.PATTERN_BINDING);
- imageKeysByType.put(OutlineDef.OutlineDefType.TYPE,IImageNames.TYPE_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.SYN,IImageNames.TYPE_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.INSTANCE,IImageNames.INSTANCE_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.FIELD,IImageNames.FIELD_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.CONSTRUCTOR_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.SPLICE,IImageNames.SPLICE_DECL);
- }
-
-
- @Override
- public Image getImage( final Object element ) {
- if (element instanceof OutlineDef){
-
- String key=imageKeysByType.get( ((OutlineDef )element).getTypes().iterator().next());
- if (key!=null){
- return HaskellUIImages.getImage( key );
- }
- }
- return super.getImage( element );
- }
-
-}
+package net.sf.eclipsefp.haskell.ui.internal.views.outline;
+
+import java.util.HashMap;
+import java.util.Map;
+import net.sf.eclipsefp.haskell.buildwrapper.types.OutlineDef;
+import net.sf.eclipsefp.haskell.ui.util.HaskellUIImages;
+import net.sf.eclipsefp.haskell.ui.util.IImageNames;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * <p>Display OutlineDef objects for the outline tree</p>
+ *
+ * @author JP Moresmau
+ */
+public class OutlineLabelProvider extends LabelProvider {
+ private static Map<OutlineDef.OutlineDefType,String> imageKeysByType=new HashMap<OutlineDef.OutlineDefType, String>();
+
+ static {
+ imageKeysByType.put(OutlineDef.OutlineDefType.CLASS,IImageNames.CLASS_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.DATA,IImageNames.DATA_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.FUNCTION,IImageNames.FUNCTION_BINDING);
+ imageKeysByType.put(OutlineDef.OutlineDefType.PATTERN,IImageNames.PATTERN_BINDING);
+ imageKeysByType.put(OutlineDef.OutlineDefType.TYPE,IImageNames.TYPE_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.SYN,IImageNames.TYPE_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.INSTANCE,IImageNames.INSTANCE_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.FIELD,IImageNames.FIELD_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.CONSTRUCTOR_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.SPLICE,IImageNames.SPLICE_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.ERROR,IImageNames.ERROR_OBJECT);
+ }
+
+
+ @Override
+ public Image getImage( final Object element ) {
+ if (element instanceof OutlineDef){
+
+ String key=imageKeysByType.get( ((OutlineDef )element).getTypes().iterator().next());
+ if (key!=null){
+ return HaskellUIImages.getImage( key );
+ }
+ }
+ return super.getImage( element );
+ }
+
+}
View
374 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/HaskellUIImages.java
@@ -1,188 +1,188 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.ui.util;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Bundle;
-
-/** <p>contains the image registry for images in the Haskell Ui plugin.</p>
- *
- * @author Leif Frenzel
- */
-public class HaskellUIImages implements IImageNames {
-
- private static ImageRegistry imageRegistry;
-
- private static ImageDescriptorRegistry imageDescriptorRegistry;
-
- /** <p>a table of all the <code>ImageDescriptor</code>s.</p> */
- private static Map<String, ImageDescriptor> imageDescriptors;
-
- private static URL baseUrl;
-
- static {
- String pathSuffix = "icons/"; //$NON-NLS-1$
- try {
- Bundle bundle = HaskellUIPlugin.getDefault().getBundle();
- baseUrl = new URL( bundle.getEntry( "/" ), pathSuffix ); //$NON-NLS-1$
- } catch( MalformedURLException e ) {
- // do nothing
- }
- }
-
- private final static String OBJECT = "obj16/"; // basic colors - size 16x16 //$NON-NLS-1$
- private final static String OVR = "ovr16/"; // basic colors - size 7x8 //$NON-NLS-1$
- private final static String ACTION = "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
- private final static String WIZARD = "wizban/"; // wizard banners //$NON-NLS-1$
- private final static String ACTION_E = "elcl16/"; //$NON-NLS-1$
- private final static String TOOLS = "etool16/"; //$NON-NLS-1$
- private final static String VIEW = "eview16/"; //$NON-NLS-1$
-
- private static void declareImages() {
- // objects
- declare( LAUNCH_TAB_ARGUMENTS, OBJECT + "arguments_tab.gif" ); //$NON-NLS-1$
- declare( LAUNCH_TAB_AUTOMATION, OBJECT + "automation_tab.gif" ); //$NON-NLS-1$
- declare( IMPORT_LIBRARY, OBJECT + "library.gif" ); //$NON-NLS-1$
- declare( SOURCE_FOLDER, OBJECT + "srcfolder_obj.gif" ); //$NON-NLS-1$
- declare( FOLDER, OBJECT + "fldr_obj.gif" ); //$NON-NLS-1$
- declare( SOURCE_FILE, OBJECT + "hsfile_obj.gif" ); //$NON-NLS-1$
- declare( LITERATE_SOURCE_FILE, OBJECT + "lhsfile_obj.gif" ); //$NON-NLS-1$
- declare( PROJECT_EXECUTABLE, OBJECT + "projexe.gif" ); //$NON-NLS-1$
- declare( HASKELL_PROJECT, OBJECT + "hsproject.gif" ); //$NON-NLS-1$
- declare( EXECUTABLE_STANZA, OBJECT + "executablestanza.gif" ); //$NON-NLS-1$
- declare( TESTSUITE_STANZA, OBJECT + "testsuitestanza.gif" ); //$NON-NLS-1$
- declare( LIBRARY_STANZA, OBJECT + "librarystanza.gif" ); //$NON-NLS-1$
- declare( GENERAL_STANZA, OBJECT + "generalstanza.gif" ); //$NON-NLS-1$
- declare( IF_STANZA, OBJECT + "if.gif" ); //$NON-NLS-1$
- declare( ELSE_STANZA, OBJECT + "else.gif" ); //$NON-NLS-1$
- declare( FLAG_STANZA, OBJECT + "flag.gif" ); //$NON-NLS-1$
- declare( TEMPLATE, OBJECT + "template.gif" ); //$NON-NLS-1$
- declare( SOURCEREP_STANZA, OBJECT + "sourcerepstanza.gif" ); //$NON-NLS-1$
- // decorators
- declare( SRC_FOLDER_DECORATOR, OVR + "sourceFolder.gif" ); //$NON-NLS-1$
- declare( ERROR_OVERLAY, OVR + "error_co.gif"); //$NON-NLS-1$
- declare( WARNING_OVERLAY, OVR + "warning_co.gif"); //$NON-NLS-1$
-
- // views
- declare( DEP_VIEW_IMPORTS, ACTION + "mdep_imports.gif" ); //$NON-NLS-1$
- declare( DEP_VIEW_IMPORTEDBY, ACTION + "mdep_importedby.gif" ); //$NON-NLS-1$
- declare( MB_VIEW_FLAT, ACTION + "mb_flat.gif" ); //$NON-NLS-1$
- declare( MB_VIEW_HIERARCHICAL, ACTION + "mb_hierarchical.gif" ); //$NON-NLS-1$
- declare( MB_VIEW_FILTER, ACTION + "mb_filter.gif" ); //$NON-NLS-1$
- declare( CO_VIEW_CLEAR, ACTION + "co_clear.gif" ); //$NON-NLS-1$
-
- // language element representation
- declare( HS_NAME, OBJECT + "hsname.gif" ); //$NON-NLS-1$
- declare( MODULE, OBJECT + "module.gif" ); //$NON-NLS-1$
- declare( IMPORT, OBJECT + "import.gif" ); //$NON-NLS-1$
- declare( IMPORT_GROUP, OBJECT + "importgroup.gif" ); //$NON-NLS-1$
- declare( EXPORT_GROUP, OBJECT + "exportgroup.gif" ); //$NON-NLS-1$
- declare( EXPORT_MODULE_CONTENT, OBJECT + "exportmodulecontent.gif" ); //$NON-NLS-1$
- declare( EXPORT_SPECIFICATION, OBJECT + "exportspecification.gif" ); //$NON-NLS-1$
- declare( PACKAGE, OBJECT + "package.gif" ); //$NON-NLS-1$
- declare( PACKAGE_CONF, OBJECT + "packageconf.gif" ); //$NON-NLS-1$
- declare( PACKAGE_FOLDER, OBJECT + "packagefolder.gif" ); //$NON-NLS-1$
- declare( HIDDEN_PACKAGE, OBJECT + "hiddenpackage.gif" ); //$NON-NLS-1$
- declare( FUNCTION_BINDING, OBJECT + "functionbinding.gif" ); //$NON-NLS-1$
- declare( PATTERN_BINDING, OBJECT + "patternbinding.gif" ); //$NON-NLS-1$
- declare( DATA_DECL, OBJECT + "datadecl.gif" ); //$NON-NLS-1$
- declare( CONSTRUCTOR_DECL, OBJECT + "constructordecl.gif" ); //$NON-NLS-1$
- declare( TYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
- declare( NEWTYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
- declare( TYPE_SIGNATURE, OBJECT + "typesig.gif" ); //$NON-NLS-1$
- declare( DEFAULT_DECL, OBJECT + "defaultdecl.gif" ); //$NON-NLS-1$
- declare( CLASS_DECL, OBJECT + "classdecl.gif" ); //$NON-NLS-1$
- declare( INSTANCE_DECL, OBJECT + "instancedecl.gif" ); //$NON-NLS-1$
- declare( INFIXNONE_DECL, OBJECT + "infixnone.gif" ); //$NON-NLS-1$
- declare( INFIXL_DECL, OBJECT + "infixl.gif" ); //$NON-NLS-1$
- declare( INFIXR_DECL, OBJECT + "infixr.gif" ); //$NON-NLS-1$
- declare( FIELD_DECL, OBJECT + "field_public_obj.gif") ; //$NON-NLS-1$
- declare( SPLICE_DECL, OBJECT + "thdecl.gif" ); //$NON-NLS-1$
- // wizard banners
- declare( NEW_PROJECT, WIZARD + "newhprj_wiz.png" ); //$NON-NLS-1$
- declare( NEW_MODULE, WIZARD + "newmodule.png" ); //$NON-NLS-1$
- declare( IMPORT_CABAL_PACKAGE, WIZARD + "impcprj_wiz.png" ); //$NON-NLS-1$
-
- declare(ACTION_SORT,ACTION_E+"alphab_sort_co.png"); //$NON-NLS-1$
- declare(IMPORT_REMOVE,OBJECT+"correction_delete_import.gif"); //$NON-NLS-1$
- declare(EXPORT_SRC,OBJECT+"export_src.gif"); //$NON-NLS-1$
- declare(HASKELL_MISC,TOOLS+"haskell_misc.gif"); //$NON-NLS-1$
-
- declare(HACKAGE_UPDATE,VIEW+"hackage_update.png");
- declare(HACKAGE_INSTALL,VIEW+"hackage_install.png");
- declare(SEARCH_LINE,OBJECT+"search_ref_obj.gif");
- }
-
- private final static void declare( final String key,
- final String path ) {
- ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
- try {
- desc = ImageDescriptor.createFromURL( makeIconFileURL( path ) );
- } catch( MalformedURLException mux ) {
- HaskellUIPlugin.log( "Problem loading image.", mux ); //$NON-NLS-1$
- }
- imageRegistry.put( key, desc );
- imageDescriptors.put( key, desc );
- }
-
- private static ImageRegistry getImageRegistry() {
- if( imageRegistry == null ) {
- initializeImageRegistry();
- }
- return imageRegistry;
- }
-
- public static ImageRegistry initializeImageRegistry() {
- imageRegistry = new ImageRegistry( HaskellUIPlugin.getStandardDisplay() );
- imageDescriptors = new HashMap<String, ImageDescriptor>( 30 );
- declareImages();
- return imageRegistry;
- }
-
- /** <p>returns the <code>Image<code> identified by the given key,
- * or <code>null</code> if it does not exist.</p> */
- public static Image getImage( final String key ) {
- return getImageRegistry().get( key );
- }
-
- /** <p>returns the <code>ImageDescriptor<code> identified by the given key,
- * or <code>null</code> if it does not exist.</p> */
- public static ImageDescriptor getImageDescriptor( final String key ) {
- if( imageDescriptors == null ) {
- initializeImageRegistry();
- }
- return imageDescriptors.get( key );
- }
-
- private static URL makeIconFileURL( final String iconPath )
- throws MalformedURLException {
- if( baseUrl == null ) {
- throw new MalformedURLException();
- }
- return new URL( baseUrl, iconPath );
- }
-
-
- // composite images
- ///////////////////
-
- public static Image getImage( final CompositeImageDescriptor imgDescriptor ) {
- if( imageDescriptorRegistry == null ) {
- imageDescriptorRegistry = new ImageDescriptorRegistry();
- }
- return imageDescriptorRegistry.get( imgDescriptor );
- }
-
- public static void disposeImageDescriptorRegistry() {
- if( imageDescriptorRegistry != null ) {
- imageDescriptorRegistry.dispose();
- }
- }
+// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
+package net.sf.eclipsefp.haskell.ui.util;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+
+/** <p>contains the image registry for images in the Haskell Ui plugin.</p>
+ *
+ * @author Leif Frenzel
+ */
+public class HaskellUIImages implements IImageNames {
+
+ private static ImageRegistry imageRegistry;
+
+ private static ImageDescriptorRegistry imageDescriptorRegistry;
+
+ /** <p>a table of all the <code>ImageDescriptor</code>s.</p> */
+ private static Map<String, ImageDescriptor> imageDescriptors;
+
+ private static URL baseUrl;
+
+ static {
+ String pathSuffix = "icons/"; //$NON-NLS-1$
+ try {
+ Bundle bundle = HaskellUIPlugin.getDefault().getBundle();
+ baseUrl = new URL( bundle.getEntry( "/" ), pathSuffix ); //$NON-NLS-1$
+ } catch( MalformedURLException e ) {
+ // do nothing
+ }
+ }
+
+ private final static String OBJECT = "obj16/"; // basic colors - size 16x16 //$NON-NLS-1$
+ private final static String OVR = "ovr16/"; // basic colors - size 7x8 //$NON-NLS-1$
+ private final static String ACTION = "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
+ private final static String WIZARD = "wizban/"; // wizard banners //$NON-NLS-1$
+ private final static String ACTION_E = "elcl16/"; //$NON-NLS-1$
+ private final static String TOOLS = "etool16/"; //$NON-NLS-1$
+ private final static String VIEW = "eview16/"; //$NON-NLS-1$
+
+ private static void declareImages() {
+ // objects
+ declare( LAUNCH_TAB_ARGUMENTS, OBJECT + "arguments_tab.gif" ); //$NON-NLS-1$
+ declare( LAUNCH_TAB_AUTOMATION, OBJECT + "automation_tab.gif" ); //$NON-NLS-1$
+ declare( IMPORT_LIBRARY, OBJECT + "library.gif" ); //$NON-NLS-1$
+ declare( SOURCE_FOLDER, OBJECT + "srcfolder_obj.gif" ); //$NON-NLS-1$
+ declare( FOLDER, OBJECT + "fldr_obj.gif" ); //$NON-NLS-1$
+ declare( SOURCE_FILE, OBJECT + "hsfile_obj.gif" ); //$NON-NLS-1$
+ declare( LITERATE_SOURCE_FILE, OBJECT + "lhsfile_obj.gif" ); //$NON-NLS-1$
+ declare( PROJECT_EXECUTABLE, OBJECT + "projexe.gif" ); //$NON-NLS-1$
+ declare( HASKELL_PROJECT, OBJECT + "hsproject.gif" ); //$NON-NLS-1$
+ declare( EXECUTABLE_STANZA, OBJECT + "executablestanza.gif" ); //$NON-NLS-1$
+ declare( TESTSUITE_STANZA, OBJECT + "testsuitestanza.gif" ); //$NON-NLS-1$
+ declare( LIBRARY_STANZA, OBJECT + "librarystanza.gif" ); //$NON-NLS-1$
+ declare( GENERAL_STANZA, OBJECT + "generalstanza.gif" ); //$NON-NLS-1$
+ declare( IF_STANZA, OBJECT + "if.gif" ); //$NON-NLS-1$
+ declare( ELSE_STANZA, OBJECT + "else.gif" ); //$NON-NLS-1$
+ declare( FLAG_STANZA, OBJECT + "flag.gif" ); //$NON-NLS-1$
+ declare( TEMPLATE, OBJECT + "template.gif" ); //$NON-NLS-1$
+ declare( SOURCEREP_STANZA, OBJECT + "sourcerepstanza.gif" ); //$NON-NLS-1$
+ // decorators
+ declare( SRC_FOLDER_DECORATOR, OVR + "sourceFolder.gif" ); //$NON-NLS-1$
+ declare( ERROR_OVERLAY, OVR + "error_co.gif"); //$NON-NLS-1$
+ declare( WARNING_OVERLAY, OVR + "warning_co.gif"); //$NON-NLS-1$
+ declare( ERROR_OBJECT, OBJECT + "error_obj.gif"); //$NON-NLS-1$
+ // views
+ declare( DEP_VIEW_IMPORTS, ACTION + "mdep_imports.gif" ); //$NON-NLS-1$
+ declare( DEP_VIEW_IMPORTEDBY, ACTION + "mdep_importedby.gif" ); //$NON-NLS-1$
+ declare( MB_VIEW_FLAT, ACTION + "mb_flat.gif" ); //$NON-NLS-1$
+ declare( MB_VIEW_HIERARCHICAL, ACTION + "mb_hierarchical.gif" ); //$NON-NLS-1$
+ declare( MB_VIEW_FILTER, ACTION + "mb_filter.gif" ); //$NON-NLS-1$
+ declare( CO_VIEW_CLEAR, ACTION + "co_clear.gif" ); //$NON-NLS-1$
+
+ // language element representation
+ declare( HS_NAME, OBJECT + "hsname.gif" ); //$NON-NLS-1$
+ declare( MODULE, OBJECT + "module.gif" ); //$NON-NLS-1$
+ declare( IMPORT, OBJECT + "import.gif" ); //$NON-NLS-1$
+ declare( IMPORT_GROUP, OBJECT + "importgroup.gif" ); //$NON-NLS-1$
+ declare( EXPORT_GROUP, OBJECT + "exportgroup.gif" ); //$NON-NLS-1$
+ declare( EXPORT_MODULE_CONTENT, OBJECT + "exportmodulecontent.gif" ); //$NON-NLS-1$
+ declare( EXPORT_SPECIFICATION, OBJECT + "exportspecification.gif" ); //$NON-NLS-1$
+ declare( PACKAGE, OBJECT + "package.gif" ); //$NON-NLS-1$
+ declare( PACKAGE_CONF, OBJECT + "packageconf.gif" ); //$NON-NLS-1$
+ declare( PACKAGE_FOLDER, OBJECT + "packagefolder.gif" ); //$NON-NLS-1$
+ declare( HIDDEN_PACKAGE, OBJECT + "hiddenpackage.gif" ); //$NON-NLS-1$
+ declare( FUNCTION_BINDING, OBJECT + "functionbinding.gif" ); //$NON-NLS-1$
+ declare( PATTERN_BINDING, OBJECT + "patternbinding.gif" ); //$NON-NLS-1$
+ declare( DATA_DECL, OBJECT + "datadecl.gif" ); //$NON-NLS-1$
+ declare( CONSTRUCTOR_DECL, OBJECT + "constructordecl.gif" ); //$NON-NLS-1$
+ declare( TYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
+ declare( NEWTYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
+ declare( TYPE_SIGNATURE, OBJECT + "typesig.gif" ); //$NON-NLS-1$
+ declare( DEFAULT_DECL, OBJECT + "defaultdecl.gif" ); //$NON-NLS-1$
+ declare( CLASS_DECL, OBJECT + "classdecl.gif" ); //$NON-NLS-1$
+ declare( INSTANCE_DECL, OBJECT + "instancedecl.gif" ); //$NON-NLS-1$
+ declare( INFIXNONE_DECL, OBJECT + "infixnone.gif" ); //$NON-NLS-1$
+ declare( INFIXL_DECL, OBJECT + "infixl.gif" ); //$NON-NLS-1$
+ declare( INFIXR_DECL, OBJECT + "infixr.gif" ); //$NON-NLS-1$
+ declare( FIELD_DECL, OBJECT + "field_public_obj.gif") ; //$NON-NLS-1$
+ declare( SPLICE_DECL, OBJECT + "thdecl.gif" ); //$NON-NLS-1$
+ // wizard banners
+ declare( NEW_PROJECT, WIZARD + "newhprj_wiz.png" ); //$NON-NLS-1$
+ declare( NEW_MODULE, WIZARD + "newmodule.png" ); //$NON-NLS-1$
+ declare( IMPORT_CABAL_PACKAGE, WIZARD + "impcprj_wiz.png" ); //$NON-NLS-1$
+
+ declare(ACTION_SORT,ACTION_E+"alphab_sort_co.png"); //$NON-NLS-1$
+ declare(IMPORT_REMOVE,OBJECT+"correction_delete_import.gif"); //$NON-NLS-1$
+ declare(EXPORT_SRC,OBJECT+"export_src.gif"); //$NON-NLS-1$
+ declare(HASKELL_MISC,TOOLS+"haskell_misc.gif"); //$NON-NLS-1$
+
+ declare(HACKAGE_UPDATE,VIEW+"hackage_update.png");
+ declare(HACKAGE_INSTALL,VIEW+"hackage_install.png");
+ declare(SEARCH_LINE,OBJECT+"search_ref_obj.gif");
+ }
+
+ private final static void declare( final String key,
+ final String path ) {
+ ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
+ try {
+ desc = ImageDescriptor.createFromURL( makeIconFileURL( path ) );
+ } catch( MalformedURLException mux ) {
+ HaskellUIPlugin.log( "Problem loading image.", mux ); //$NON-NLS-1$
+ }
+ imageRegistry.put( key, desc );
+ imageDescriptors.put( key, desc );
+ }
+
+ private static ImageRegistry getImageRegistry() {
+ if( imageRegistry == null ) {
+ initializeImageRegistry();
+ }
+ return imageRegistry;
+ }
+
+ public static ImageRegistry initializeImageRegistry() {
+ imageRegistry = new ImageRegistry( HaskellUIPlugin.getStandardDisplay() );
+ imageDescriptors = new HashMap<String, ImageDescriptor>( 30 );
+ declareImages();
+ return imageRegistry;
+ }
+
+ /** <p>returns the <code>Image<code> identified by the given key,
+ * or <code>null</code> if it does not exist.</p> */
+ public static Image getImage( final String key ) {
+ return getImageRegistry().get( key );
+ }
+
+ /** <p>returns the <code>ImageDescriptor<code> identified by the given key,
+ * or <code>null</code> if it does not exist.</p> */
+ public static ImageDescriptor getImageDescriptor( final String key ) {
+ if( imageDescriptors == null ) {
+ initializeImageRegistry();
+ }
+ return imageDescriptors.get( key );
+ }
+
+ private static URL makeIconFileURL( final String iconPath )
+ throws MalformedURLException {
+ if( baseUrl == null ) {
+ throw new MalformedURLException();
+ }
+ return new URL( baseUrl, iconPath );
+ }
+
+
+ // composite images
+ ///////////////////
+
+ public static Image getImage( final CompositeImageDescriptor imgDescriptor ) {
+ if( imageDescriptorRegistry == null ) {
+ imageDescriptorRegistry = new ImageDescriptorRegistry();
+ }
+ return imageDescriptorRegistry.get( imgDescriptor );
+ }
+
+ public static void disposeImageDescriptorRegistry() {
+ if( imageDescriptorRegistry != null ) {
+ imageDescriptorRegistry.dispose();
+ }
+ }
}
View
2  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/IImageNames.java
@@ -81,7 +81,7 @@
// overlays
String ERROR_OVERLAY = ID + ".ERROR_OVERLAY"; //$NON-NLS-1$
String WARNING_OVERLAY = ID + ".WARNING_OVERLAY"; //$NON-NLS-1$
-
+ String ERROR_OBJECT = ID + ".ERROR_OBJECT"; //$NON-NLS-1$
String ACTION_SORT = ID + ".ACTION_SORT"; //$NON-NLS-1$
String IMPORT_REMOVE = ID+".IMPORT_REMOVE"; //$NON-NLS-1$
Please sign in to comment.
Something went wrong with that request. Please try again.