Changeset 3143 for DataCleaner/trunk


Ignore:
Timestamp:
02/07/12 21:10:16 (4 months ago)
Author:
kasper
Message:

Moved filter icons to match class names instead of having rules built into IconUtils?

Location:
DataCleaner/trunk/core/src/main
Files:
1 added
2 edited
7 moved

Legend:

Unmodified
Added
Removed
  • DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/panels/MaxRowsFilterShortcutPanel.java

    r2616 r3143  
    5252 * @author Kasper SÞrensen 
    5353 */ 
    54 public class MaxRowsFilterShortcutPanel extends DCPanel implements FilterJobBuilderPresenter { 
     54public class MaxRowsFilterShortcutPanel extends DCPanel implements 
     55                FilterJobBuilderPresenter { 
    5556 
    5657        public static final String FILTER_NAME = "Limit analysis (Max rows)"; 
     
    8081        } 
    8182 
    82         public MaxRowsFilterShortcutPanel(AnalysisJobBuilder analysisJobBuilder, FilterJobBuilder<?, ?> filterJobBuilder) { 
     83        public MaxRowsFilterShortcutPanel(AnalysisJobBuilder analysisJobBuilder, 
     84                        FilterJobBuilder<?, ?> filterJobBuilder) { 
    8385                super(); 
    8486                _analysisJobBuilder = analysisJobBuilder; 
     
    116118                                if (selected) { 
    117119                                        _analysisJobBuilder.addFilter(maxRowsFilterJobBuilder); 
    118                                         _analysisJobBuilder.setDefaultRequirement(maxRowsFilterJobBuilder, ValidationCategory.VALID); 
     120                                        _analysisJobBuilder.setDefaultRequirement( 
     121                                                        maxRowsFilterJobBuilder, ValidationCategory.VALID); 
    119122                                } else { 
    120123                                        _analysisJobBuilder.removeFilter(maxRowsFilterJobBuilder); 
     
    135138                                                        fjb.setConfiguredProperty("Max rows", maxRows); 
    136139                                                } catch (NumberFormatException e) { 
    137                                                         WidgetUtils.showErrorMessage("Cannot read number", 
    138                                                                         "The entered value could not be read as a number.", e); 
     140                                                        WidgetUtils 
     141                                                                        .showErrorMessage( 
     142                                                                                        "Cannot read number", 
     143                                                                                        "The entered value could not be read as a number.", 
     144                                                                                        e); 
    139145                                                } 
    140146                                        } 
     
    144150 
    145151                setLayout(new FlowLayout(FlowLayout.LEFT)); 
    146                 add(new JLabel(ImageManager.getInstance().getImageIcon(IconUtils.MAX_ROWS_IMAGEPATH))); 
     152                final String imagePath = IconUtils.getImagePathForClass(MaxRowsFilter.class); 
     153                add(new JLabel(ImageManager.getInstance().getImageIcon( 
     154                                imagePath))); 
    147155                add(_checkBox); 
    148156                add(_prefixLabel); 
     
    160168                        // Lazy initializing getter (to postpone the call to 
    161169                        // DCConfiguration. 
    162                         _maxRowsFilterJobBuilder = new FilterJobBuilder<MaxRowsFilter, ValidationCategory>(_analysisJobBuilder, 
    163                                         _analysisJobBuilder.getConfiguration().getDescriptorProvider() 
    164                                                         .getFilterBeanDescriptorForClass(MaxRowsFilter.class)); 
     170                        _maxRowsFilterJobBuilder = new FilterJobBuilder<MaxRowsFilter, ValidationCategory>( 
     171                                        _analysisJobBuilder, _analysisJobBuilder 
     172                                                        .getConfiguration() 
     173                                                        .getDescriptorProvider() 
     174                                                        .getFilterBeanDescriptorForClass( 
     175                                                                        MaxRowsFilter.class)); 
    165176                        _maxRowsFilterJobBuilder.setName(FILTER_NAME); 
    166177                } 
  • DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/util/IconUtils.java

    r3033 r3143  
    101101        public static final String ANALYZER_IMAGEPATH = "images/component-types/analyzer.png"; 
    102102        public static final String FILTER_IMAGEPATH = "images/component-types/filter.png"; 
    103         public static final String MAX_ROWS_IMAGEPATH = "images/component-types/type_max_rows.png"; 
    104  
    105         private static final ImageManager _imageManager = ImageManager.getInstance(); 
     103 
     104        private static final ImageManager _imageManager = ImageManager 
     105                        .getInstance(); 
    106106 
    107107        private IconUtils() { 
     
    109109        } 
    110110 
    111         public static Icon getDescriptorIcon(ComponentDescriptor<?> descriptor, int newWidth) { 
    112                 final ClassLoader classLoader = descriptor.getComponentClass().getClassLoader(); 
     111        public static Icon getDescriptorIcon(ComponentDescriptor<?> descriptor, 
     112                        int newWidth) { 
     113                final ClassLoader classLoader = descriptor.getComponentClass() 
     114                                .getClassLoader(); 
    113115                String imagePath = getDescriptorImagePath(descriptor, classLoader); 
    114116                return _imageManager.getImageIcon(imagePath, newWidth, classLoader); 
     
    131133        public static Icon getComponentCategoryIcon(ComponentCategory category) { 
    132134                Class<? extends ComponentCategory> categoryClass = category.getClass(); 
    133                 final ClassLoader classLoader = categoryClass.getClassLoader(); 
    134                 final String bundledIconPath = categoryClass.getName().replaceAll("\\.", "/") + ".png"; 
    135                 final URL url = ResourceManager.getInstance().getUrl(bundledIconPath, classLoader); 
     135 
     136                final String bundledIconPath = getImagePathForClass(categoryClass); 
    136137 
    137138                final int totalSize = ICON_SIZE_MEDIUM; 
    138139                final Image decoration; 
    139140                final int decorationSize = ICON_SIZE_SMALL; 
    140                 if (url == null) { 
     141                if (bundledIconPath == null) { 
    141142                        decoration = null; 
    142143                } else { 
    143                         decoration = _imageManager.getImage(bundledIconPath, decorationSize, classLoader); 
    144                 } 
    145  
    146                 final Image folderIcon = _imageManager.getImage("images/filetypes/folder.png", totalSize); 
     144                        final ClassLoader classLoader = categoryClass.getClassLoader(); 
     145                        decoration = _imageManager.getImage(bundledIconPath, 
     146                                        decorationSize, classLoader); 
     147                } 
     148 
     149                final Image folderIcon = _imageManager.getImage( 
     150                                "images/filetypes/folder.png", totalSize); 
    147151 
    148152                if (decoration == null) { 
     
    150154                } 
    151155 
    152                 final BufferedImage bufferedImage = new BufferedImage(totalSize, totalSize, BufferedImage.TYPE_INT_ARGB); 
     156                final BufferedImage bufferedImage = new BufferedImage(totalSize, 
     157                                totalSize, BufferedImage.TYPE_INT_ARGB); 
    153158                bufferedImage.getGraphics().drawImage(folderIcon, 0, 0, null); 
    154                 bufferedImage.getGraphics().drawImage(decoration, totalSize - decorationSize, totalSize - decorationSize, null); 
     159                bufferedImage.getGraphics().drawImage(decoration, 
     160                                totalSize - decorationSize, totalSize - decorationSize, null); 
    155161                return new ImageIcon(bufferedImage); 
    156162        } 
    157163 
    158         protected static String getDescriptorImagePath(ComponentDescriptor<?> descriptor, ClassLoader classLoader) { 
     164        public static String getImagePathForClass(Class<?> cls) { 
     165                return getImagePathForClass(cls, cls.getClassLoader()); 
     166        } 
     167 
     168        public static String getImagePathForClass(Class<?> cls, 
     169                        ClassLoader classLoader) { 
     170                final String iconPath = cls.getName().replaceAll("\\.", "/") + ".png"; 
     171                final URL url = ResourceManager.getInstance().getUrl(iconPath, 
     172                                classLoader); 
     173                if (url == null) { 
     174                        return null; 
     175                } 
     176                return iconPath; 
     177        } 
     178 
     179        protected static String getDescriptorImagePath( 
     180                        ComponentDescriptor<?> descriptor, ClassLoader classLoader) { 
    159181                final Class<?> componentClass = descriptor.getComponentClass(); 
    160                 final String bundledIconPath = componentClass.getName().replaceAll("\\.", "/") + ".png"; 
    161                 final URL url = ResourceManager.getInstance().getUrl(bundledIconPath, classLoader); 
    162                 if (url != null) { 
     182                final String bundledIconPath = getImagePathForClass(componentClass, 
     183                                classLoader); 
     184                if (bundledIconPath != null) { 
    163185                        return bundledIconPath; 
    164186                } 
    165187 
    166                 if (!descriptor.getComponentClass().getPackage().getName().startsWith("org.eobjects")) { 
     188                if (!descriptor.getComponentClass().getPackage().getName() 
     189                                .startsWith("org.eobjects")) { 
    167190                        // plugins get a special icon 
    168191                        return "images/component-types/plugin.png"; 
     
    173196                if (descriptor instanceof BeanDescriptor) { 
    174197                        BeanDescriptor<?> beanDescriptor = (BeanDescriptor<?>) descriptor; 
    175                         Set<ComponentCategory> categories = beanDescriptor.getComponentCategories(); 
     198                        Set<ComponentCategory> categories = beanDescriptor 
     199                                        .getComponentCategories(); 
    176200                        displayName = beanDescriptor.getDisplayName().toLowerCase(); 
    177201                        if (categories.contains(new WriteDataCategory())) { 
     
    197221                        imagePath = "images/component-types/type_validate.png"; 
    198222                } 
    199                 if (displayName.indexOf("internet") != -1 || displayName.indexOf("url") != -1) { 
     223                if (displayName.indexOf("internet") != -1 
     224                                || displayName.indexOf("url") != -1) { 
    200225                        imagePath = "images/component-types/type_internet.png"; 
    201226                } 
    202                 if (displayName.indexOf("identity") != -1 || displayName.indexOf("name") != -1) { 
     227                if (displayName.indexOf("identity") != -1 
     228                                || displayName.indexOf("name") != -1) { 
    203229                        imagePath = "images/component-types/type_identity.png"; 
    204230                } 
    205                 if (displayName.indexOf("string") != -1 || displayName.indexOf("word") != -1 || displayName.indexOf("token") != -1 
     231                if (displayName.indexOf("string") != -1 
     232                                || displayName.indexOf("word") != -1 
     233                                || displayName.indexOf("token") != -1 
    206234                                || displayName.indexOf("whitespace") != -1) { 
    207235                        imagePath = "images/component-types/type_string.png"; 
    208236                } 
    209                 if (displayName.indexOf("time") != -1 || displayName.indexOf("date") != -1) { 
     237                if (displayName.indexOf("time") != -1 
     238                                || displayName.indexOf("date") != -1) { 
    210239                        imagePath = "images/component-types/type_time.png"; 
    211240                } 
     
    225254                        imagePath = "images/component-types/type_compare.png"; 
    226255                } 
    227                 if (displayName.indexOf("sound") != -1 || displayName.indexOf("phonetic") != -1) { 
     256                if (displayName.indexOf("sound") != -1 
     257                                || displayName.indexOf("phonetic") != -1) { 
    228258                        imagePath = "images/component-types/type_sound.png"; 
    229259                } 
    230                 if (displayName.indexOf("pattern") != -1 || displayName.indexOf("expression") != -1 
     260                if (displayName.indexOf("pattern") != -1 
     261                                || displayName.indexOf("expression") != -1 
    231262                                || displayName.indexOf("regex") != -1) { 
    232263                        imagePath = "images/component-types/type_expression.png"; 
     
    269300                if (displayName.equals("date gap analyzer")) { 
    270301                        imagePath = "images/component-types/type_date_gap_analyzer.png"; 
    271                 } 
    272                 if (displayName.equals("number range")) { 
    273                         imagePath = "images/component-types/type_number_range.png"; 
    274                 } 
    275                 if (displayName.equals("equals")) { 
    276                         imagePath = "images/component-types/type_equals.png"; 
    277                 } 
    278                 if (displayName.equals("max rows")) { 
    279                         imagePath = MAX_ROWS_IMAGEPATH; 
    280                 } 
    281                 if (displayName.equals("not null")) { 
    282                         imagePath = "images/component-types/type_not_null.png"; 
    283                 } 
    284                 if (displayName.equals("string length range")) { 
    285                         imagePath = "images/component-types/type_string_length_range.png"; 
    286                 } 
    287                 if (displayName.equals("string value range")) { 
    288                         imagePath = "images/component-types/type_string_value_range.png"; 
    289                 } 
    290                 if (displayName.equals("single word")) { 
    291                         imagePath = "images/component-types/type_single_word.png"; 
    292302                } 
    293303                if (displayName.equals("pattern finder")) { 
     
    318328                } else if (datastore instanceof JdbcDatastore) { 
    319329                        JdbcDatastore jdbcDatastore = (JdbcDatastore) datastore; 
    320                         if ("jdbc:hsqldb:res:orderdb;readonly=true".equals(jdbcDatastore.getJdbcUrl())) { 
     330                        if ("jdbc:hsqldb:res:orderdb;readonly=true".equals(jdbcDatastore 
     331                                        .getJdbcUrl())) { 
    321332                                imagePath = "images/datastore-types/orderdb.png"; 
    322333                        } else { 
    323334                                String driverClass = jdbcDatastore.getDriverClass(); 
    324335                                if (!StringUtils.isNullOrEmpty(driverClass)) { 
    325                                         DatabaseDriverDescriptor driver = DatabaseDriverCatalog.getDatabaseDriverByDriverClassName(driverClass); 
     336                                        DatabaseDriverDescriptor driver = DatabaseDriverCatalog 
     337                                                        .getDatabaseDriverByDriverClassName(driverClass); 
    326338                                        if (driver != null) { 
    327339                                                imagePath = driver.getIconImagePath(); 
Note: See TracChangeset for help on using the changeset viewer.