Changeset 3033 for DataCleaner
- Timestamp:
- 01/15/12 20:47:02 (4 months ago)
- Location:
- DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner
- Files:
-
- 4 edited
-
util/AnalysisRunnerSwingWorker.java (modified) (2 diffs)
-
util/IconUtils.java (modified) (6 diffs)
-
windows/ResultListPanel.java (modified) (2 diffs)
-
windows/ResultWindow.java (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/util/AnalysisRunnerSwingWorker.java
r2920 r3033 148 148 149 149 @Override 150 public void errorInTransformer(AnalysisJob job, final TransformerJob transformerJob, InputRow row, final Throwable throwable) { 150 public void errorInTransformer(AnalysisJob job, final TransformerJob transformerJob, InputRow row, 151 final Throwable throwable) { 151 152 _progressInformationPanel.addUserLog("An error occurred in the transformer: " + LabelUtils.getLabel(transformerJob), 152 153 throwable, true); … … 180 181 public void explorerSuccess(AnalysisJob job, ExplorerJob explorerJob, AnalyzerResult result) { 181 182 _progressInformationPanel.addUserLog("Explorer '" + LabelUtils.getLabel(explorerJob) + "' finished"); 183 _resultWindow.addResult(explorerJob, result); 182 184 } 183 185 -
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/util/IconUtils.java
r2837 r3033 43 43 import org.eobjects.analyzer.connection.XmlDatastore; 44 44 import org.eobjects.analyzer.descriptors.BeanDescriptor; 45 import org.eobjects.analyzer.descriptors.ComponentDescriptor; 45 46 import org.eobjects.analyzer.descriptors.FilterBeanDescriptor; 46 47 import org.eobjects.analyzer.descriptors.TransformerBeanDescriptor; … … 108 109 } 109 110 110 public static Icon getDescriptorIcon( BeanDescriptor<?> descriptor, int newWidth) {111 public static Icon getDescriptorIcon(ComponentDescriptor<?> descriptor, int newWidth) { 111 112 final ClassLoader classLoader = descriptor.getComponentClass().getClassLoader(); 112 113 String imagePath = getDescriptorImagePath(descriptor, classLoader); … … 114 115 } 115 116 116 public static Icon getDescriptorIcon( BeanDescriptor<?> descriptor) {117 public static Icon getDescriptorIcon(ComponentDescriptor<?> descriptor) { 117 118 return getDescriptorIcon(descriptor, ICON_SIZE_MEDIUM); 118 119 } … … 155 156 } 156 157 157 protected static String getDescriptorImagePath( BeanDescriptor<?> descriptor, ClassLoader classLoader) {158 protected static String getDescriptorImagePath(ComponentDescriptor<?> descriptor, ClassLoader classLoader) { 158 159 final Class<?> componentClass = descriptor.getComponentClass(); 159 160 final String bundledIconPath = componentClass.getName().replaceAll("\\.", "/") + ".png"; … … 168 169 } 169 170 170 Set<ComponentCategory> categories = descriptor.getComponentCategories(); 171 if (categories.contains(new WriteDataCategory())) { 172 return "images/component-types/type_output_writer.png"; 171 final String displayName; 172 173 if (descriptor instanceof BeanDescriptor) { 174 BeanDescriptor<?> beanDescriptor = (BeanDescriptor<?>) descriptor; 175 Set<ComponentCategory> categories = beanDescriptor.getComponentCategories(); 176 displayName = beanDescriptor.getDisplayName().toLowerCase(); 177 if (categories.contains(new WriteDataCategory())) { 178 return "images/component-types/type_output_writer.png"; 179 } 180 } else { 181 displayName = ""; 173 182 } 174 183 … … 182 191 } 183 192 184 String displayName = descriptor.getDisplayName().toLowerCase();185 193 if (displayName.indexOf("boolean") != -1) { 186 194 imagePath = "images/component-types/type_boolean.png"; -
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/windows/ResultListPanel.java
r2352 r3033 29 29 30 30 import org.eobjects.analyzer.beans.api.Renderer; 31 import org.eobjects.analyzer.descriptors. AnalyzerBeanDescriptor;32 import org.eobjects.analyzer.job. AnalyzerJob;31 import org.eobjects.analyzer.descriptors.ComponentDescriptor; 32 import org.eobjects.analyzer.job.ComponentJob; 33 33 import org.eobjects.analyzer.result.AnalyzerResult; 34 34 import org.eobjects.analyzer.result.renderer.RendererFactory; … … 70 70 } 71 71 72 public void addResult(final AnalyzerJob analyzerJob, final AnalyzerResult result) {73 final AnalyzerBeanDescriptor<?> descriptor = analyzerJob.getDescriptor();72 public void addResult(final ComponentJob componentJob, final AnalyzerResult result) { 73 final ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); 74 74 final Icon icon = IconUtils.getDescriptorIcon(descriptor, IconUtils.ICON_SIZE_LARGE); 75 75 76 final String resultLabel = LabelUtils.getLabel( analyzerJob);76 final String resultLabel = LabelUtils.getLabel(componentJob); 77 77 78 78 final JXTaskPane taskPane = WidgetFactory.createTaskPane(resultLabel, icon); -
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/windows/ResultWindow.java
r2486 r3033 28 28 import java.util.HashMap; 29 29 import java.util.Map; 30 import java.util.Map.Entry; 30 31 31 32 import javax.inject.Inject; 32 33 import javax.inject.Provider; 34 import javax.swing.Icon; 33 35 import javax.swing.ImageIcon; 34 36 import javax.swing.JComponent; … … 37 39 import org.eobjects.analyzer.configuration.AnalyzerBeansConfiguration; 38 40 import org.eobjects.analyzer.connection.Datastore; 41 import org.eobjects.analyzer.descriptors.ComponentDescriptor; 39 42 import org.eobjects.analyzer.job.AnalysisJob; 40 import org.eobjects.analyzer.job.AnalyzerJob; 43 import org.eobjects.analyzer.job.ComponentJob; 44 import org.eobjects.analyzer.result.AnalysisResult; 41 45 import org.eobjects.analyzer.result.AnalyzerResult; 42 46 import org.eobjects.analyzer.result.renderer.RendererFactory; … … 49 53 import org.eobjects.datacleaner.panels.ProgressInformationPanel; 50 54 import org.eobjects.datacleaner.util.AnalysisRunnerSwingWorker; 55 import org.eobjects.datacleaner.util.IconUtils; 51 56 import org.eobjects.datacleaner.util.ImageManager; 52 57 import org.eobjects.datacleaner.util.WidgetUtils; 53 58 import org.eobjects.datacleaner.widgets.result.DCRendererInitializer; 54 59 import org.eobjects.datacleaner.widgets.tabs.CloseableTabbedPane; 55 56 60 import org.eobjects.metamodel.schema.Table; 57 61 … … 63 67 64 68 private final CloseableTabbedPane _tabbedPane = new CloseableTabbedPane(); 65 private final Map< Table, ResultListPanel> _resultPanels = new HashMap<Table, ResultListPanel>();69 private final Map<Object, ResultListPanel> _resultPanels = new HashMap<Object, ResultListPanel>(); 66 70 private final AnalysisJob _job; 67 71 private final AnalyzerBeansConfiguration _configuration; … … 71 75 private final AnalysisRunnerSwingWorker _worker; 72 76 77 /** 78 * 79 * @param configuration 80 * @param job 81 * either this or result must be available 82 * @param result 83 * either this or job must be available 84 * @param jobFilename 85 * @param windowContext 86 * @param rendererInitializerProvider 87 */ 73 88 @Inject 74 protected ResultWindow(AnalyzerBeansConfiguration configuration, AnalysisJob job,75 @Nullable @JobFilename String jobFilename, WindowContext windowContext,89 protected ResultWindow(AnalyzerBeansConfiguration configuration, @Nullable AnalysisJob job, 90 @Nullable AnalysisResult result, @Nullable @JobFilename String jobFilename, WindowContext windowContext, 76 91 Provider<DCRendererInitializer> rendererInitializerProvider) { 77 92 super(windowContext); … … 81 96 _rendererFactory = new RendererFactory(configuration.getDescriptorProvider(), rendererInitializerProvider.get()); 82 97 83 _progressInformationPanel = new ProgressInformationPanel(); 84 _tabbedPane.addTab("Progress information", imageManager.getImageIcon("images/model/progress_information.png"), 85 _progressInformationPanel); 86 _tabbedPane.setUnclosableTab(0); 87 88 _worker = new AnalysisRunnerSwingWorker(_configuration, _job, this, _progressInformationPanel); 89 90 _progressInformationPanel.addStopActionListener(new ActionListener() { 91 @Override 92 public void actionPerformed(ActionEvent e) { 93 _worker.cancelIfRunning(); 94 } 95 }); 98 if (result == null) { 99 // set up a progress information panel, and run the job in a swing 100 // worker 101 _progressInformationPanel = new ProgressInformationPanel(); 102 _tabbedPane.addTab("Progress information", imageManager.getImageIcon("images/model/progress_information.png"), 103 _progressInformationPanel); 104 _tabbedPane.setUnclosableTab(0); 105 106 _worker = new AnalysisRunnerSwingWorker(_configuration, _job, this, _progressInformationPanel); 107 108 _progressInformationPanel.addStopActionListener(new ActionListener() { 109 @Override 110 public void actionPerformed(ActionEvent e) { 111 _worker.cancelIfRunning(); 112 } 113 }); 114 } else { 115 // don't add the progress information, simply render the job asap 116 _progressInformationPanel = null; 117 _worker = null; 118 119 Map<ComponentJob, AnalyzerResult> map = result.getResultMap(); 120 for (Entry<ComponentJob, AnalyzerResult> entry : map.entrySet()) { 121 ComponentJob componentJob = entry.getKey(); 122 AnalyzerResult analyzerResult = entry.getValue(); 123 124 addResult(componentJob, analyzerResult); 125 } 126 } 96 127 } 97 128 … … 101 132 102 133 private void addTableResultPanel(final Table table) { 103 final String tableName = table.getName();134 final String name = table.getName(); 104 135 final ResultListPanel panel = new ResultListPanel(_rendererFactory, _progressInformationPanel); 105 final ImageIcon tableIcon = imageManager.getImageIcon("images/model/table.png");136 final ImageIcon icon = imageManager.getImageIcon("images/model/table.png"); 106 137 _resultPanels.put(table, panel); 107 138 SwingUtilities.invokeLater(new Runnable() { 108 139 @Override 109 140 public void run() { 110 _tabbedPane.addTab( tableName, tableIcon, panel);141 _tabbedPane.addTab(name, icon, panel); 111 142 if (_tabbedPane.getTabCount() == 2) { 112 143 // switch to the first available result panel … … 115 146 } 116 147 }); 148 } 149 150 private void addDescriptorResultPanel(ComponentDescriptor<?> descriptor) { 151 final ResultListPanel panel = new ResultListPanel(_rendererFactory, _progressInformationPanel); 152 final String name = descriptor.getDisplayName(); 153 final Icon icon = IconUtils.getDescriptorIcon(descriptor); 154 _resultPanels.put(descriptor, panel); 155 SwingUtilities.invokeLater(new Runnable() { 156 @Override 157 public void run() { 158 _tabbedPane.addTab(name, icon, panel); 159 if (_tabbedPane.getTabCount() == 2) { 160 // switch to the first available result panel 161 _tabbedPane.setSelectedIndex(1); 162 } 163 } 164 }); 165 } 166 167 private ResultListPanel getDescriptorResultPanel(ComponentDescriptor<?> descriptor) { 168 synchronized (_resultPanels) { 169 if (!_resultPanels.containsKey(descriptor)) { 170 addDescriptorResultPanel(descriptor); 171 } 172 return _resultPanels.get(descriptor); 173 } 117 174 } 118 175 … … 126 183 } 127 184 128 public void addResult(Table table, AnalyzerJob analyzerJob, AnalyzerResult result) { 185 public void addResult(ComponentJob componentJob, AnalyzerResult result) { 186 ComponentDescriptor<?> descriptor = componentJob.getDescriptor(); 187 ResultListPanel resultListPanel = getDescriptorResultPanel(descriptor); 188 resultListPanel.addResult(componentJob, result); 189 } 190 191 public void addResult(Table table, ComponentJob componentJob, AnalyzerResult result) { 129 192 ResultListPanel resultListPanel = getTableResultPanel(table); 130 resultListPanel.addResult( analyzerJob, result);193 resultListPanel.addResult(componentJob, result); 131 194 } 132 195
Note: See TracChangeset
for help on using the changeset viewer.
