Skip to content

Commit

Permalink
Update cnescatlab#32 Correction of imageaccess in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Waldmann committed Jul 5, 2017
1 parent b1d7bf0 commit 9987d48
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package fr.cnes.analysis.tools.ui.images;

import fr.cnes.analysis.tools.ui.Activator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class ImageFactory {

public static final String ENABLED = "./icons/enabled.png";
public static final String DISABLED = "./icons/disabled.png";
public static final String ERROR_VERY_SMALL = "./icons/logo-i-code-rouge-8x8.png";
public static final String ERROR_SMALL = "./icons/logo-i-code-rouge-16x16.png";
public static final String ERROR_MEDIUM = "./icons/logo-i-code-rouge-32x32.png";
public static final String ERROR_BIG = "./icons/logo-i-code-rouge-45x45.png";
public static final String INFO_VERY_SMALL = "./icons/logo-i-code-bleue-8x8.png";
public static final String INFO_SMALL = "./icons/logo-i-code-bleue-16x16.png";
public static final String INFO_MEDIUM = "./icons/logo-i-code-bleue-32x32.png";
public static final String INFO_BIG = "./icons/logo-i-code-bleue-45x45.png";
public static final String WARNING_VERY_SMALL = "./icons/logo-i-code-orange-8x8.png";
public static final String WARNING_SMALL = "./icons/logo-i-code-orange-16x16.png";
public static final String WARNING_MEDIUM = "./icons/logo-i-code-orange-32x32.png";
public static final String WARNING_BIG = "./icons/logo-i-code-orange-45x45.png";

public static ImageDescriptor getDescriptor(String pImageLocation) {
return AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, pImageLocation);
}

public static Image getImage(String pImageLocation) {
return AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, pImageLocation)
.createImage();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fr.cnes.analysis.tools.ui.Activator;
import fr.cnes.analysis.tools.ui.configurations.ConfigurationContainer;
import fr.cnes.analysis.tools.ui.configurations.ConfigurationService;
import fr.cnes.analysis.tools.ui.images.ImageFactory;
import fr.cnes.analysis.tools.ui.preferences.checkerstables.CheckerMetricTableViewer;
import fr.cnes.analysis.tools.ui.preferences.checkerstables.CheckerTableViewer;
import java.util.ArrayList;
Expand Down Expand Up @@ -132,8 +133,7 @@ public int compare(CheckerPreferencesContainer arg0,

final ExpandItem ruleExpandItem = new ExpandItem(expandBar, SWT.NONE, 0);
ruleExpandItem.setText("Rules");
ruleExpandItem.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"./icons/logo-i-code-rouge-16x16.png").createImage());
ruleExpandItem.setImage(ImageFactory.getImage(ImageFactory.ERROR_SMALL));
checkersTable = new CheckerTableViewer(checkersExpandBarContainer, rules);
ruleExpandItem
.setHeight(checkersExpandBarContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
Expand All @@ -144,8 +144,7 @@ public int compare(CheckerPreferencesContainer arg0,

final ExpandItem metricExpandItem = new ExpandItem(expandBar, SWT.NONE, 0);
metricExpandItem.setText("Metric");
metricExpandItem.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"./icons/logo-i-code-rouge-16x16.png").createImage());
metricExpandItem.setImage(ImageFactory.getImage(ImageFactory.ERROR_SMALL));
checkersMetricTable = new CheckerMetricTableViewer(metricsExpandBarContainer, metrics);
metricExpandItem
.setHeight(metricsExpandBarContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.cnes.analysis.tools.ui.preferences.checkerstables;

import fr.cnes.analysis.tools.ui.images.ImageService;
import fr.cnes.analysis.tools.ui.images.ImageFactory;
import fr.cnes.analysis.tools.ui.preferences.CheckerPreferencesContainer;
import fr.cnes.analysis.tools.ui.preferences.LanguagePreferencesContainer;
import fr.cnes.analysis.tools.ui.preferences.UserPreferencesService;
Expand Down Expand Up @@ -96,9 +96,9 @@ public Image getImage(Object element) {
Image image;
CheckerPreferencesContainer checker = (CheckerPreferencesContainer) element;
if (checker.isChecked()) {
image = ImageService.ENABLED;
image = ImageFactory.getImage(ImageFactory.ENABLED);
} else {
image = ImageService.DISABLED;
image = ImageFactory.getImage(ImageFactory.DISABLED);
}
return image;
}
Expand Down Expand Up @@ -181,14 +181,14 @@ public Image getImage(Object element) {
Image severityImage;
switch (checker.getSeverity()) {
case UserPreferencesService.PREF_SEVERITY_ERROR_VALUE:
severityImage = ImageService.ERROR_SMALL;
severityImage = ImageFactory.getImage(ImageFactory.ERROR_SMALL);
break;
case UserPreferencesService.PREF_SEVERITY_WARNING_VALUE:
severityImage = ImageService.WARNING_SMALL;
severityImage = ImageFactory.getImage(ImageFactory.WARNING_SMALL);
break;
case UserPreferencesService.PREF_SEVERITY_INFO_VALUE:
default:
severityImage = ImageService.INFO_SMALL;
severityImage = ImageFactory.getImage(ImageFactory.INFO_SMALL);
break;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.cnes.analysis.tools.ui.preferences.checkerstables;

import fr.cnes.analysis.tools.ui.images.ImageService;
import fr.cnes.analysis.tools.ui.images.ImageFactory;
import fr.cnes.analysis.tools.ui.preferences.CheckerPreferencesContainer;
import fr.cnes.analysis.tools.ui.preferences.LanguagePreferencesContainer;
import fr.cnes.analysis.tools.ui.preferences.UserPreferencesService;
Expand Down Expand Up @@ -30,14 +30,19 @@ public class CheckerTableViewer {

private TableViewer checkersTableViewer;
private CheckersFilter checkersFilter;

private Image infoImage;
private Image warningImage;
private Image errorImage;
private LanguagePreferencesContainer language;
private List<CheckerPreferencesContainer> inputs;

private boolean allEnabledChecked;

public CheckerTableViewer(Composite parent, List<CheckerPreferencesContainer> checkers) {
this.inputs = checkers;
infoImage = ImageFactory.getImage(ImageFactory.INFO_SMALL);
warningImage = ImageFactory.getImage(ImageFactory.WARNING_SMALL);
errorImage = ImageFactory.getImage(ImageFactory.ERROR_SMALL);
GridLayout layout = new GridLayout(2, false);
parent.setLayout(layout);
Label searchLabel = new Label(parent, SWT.NONE);
Expand Down Expand Up @@ -100,9 +105,9 @@ public Image getImage(Object element) {
Image image;
CheckerPreferencesContainer checker = (CheckerPreferencesContainer) element;
if (checker.isChecked()) {
image = ImageService.ENABLED;
image = ImageFactory.getImage(ImageFactory.ENABLED);
} else {
image = ImageService.DISABLED;
image = ImageFactory.getImage(ImageFactory.DISABLED);
}
return image;
}
Expand All @@ -127,6 +132,7 @@ public String getText(Object element) {
col = createTableViewerColumn(titles[3], bounds[3], 3);
col.setEditingSupport(new SeverityEditingSupport(pCheckersTableViewer));
col.setLabelProvider(new ColumnLabelProvider() {

@Override
public String getText(Object element) {
return ((CheckerPreferencesContainer) element).getSeverity();
Expand All @@ -138,14 +144,14 @@ public Image getImage(Object element) {
Image severityImage;
switch (checker.getSeverity()) {
case UserPreferencesService.PREF_SEVERITY_ERROR_VALUE:
severityImage = ImageService.ERROR_SMALL;
severityImage = errorImage;
break;
case UserPreferencesService.PREF_SEVERITY_WARNING_VALUE:
severityImage = ImageService.WARNING_SMALL;
severityImage = warningImage;
break;
case UserPreferencesService.PREF_SEVERITY_INFO_VALUE:
default:
severityImage = ImageService.INFO_SMALL;
severityImage = infoImage;
break;
}

Expand Down Expand Up @@ -173,7 +179,7 @@ private TableViewerColumn createEnabledViewerColumn(int bound, final int colNumb
final TableViewerColumn viewerColumn = new TableViewerColumn(this.checkersTableViewer,
SWT.CENTER);
final TableColumn column = viewerColumn.getColumn();
column.setImage(ImageService.DISABLED);
column.setImage(ImageFactory.getImage(ImageFactory.DISABLED));
column.setToolTipText("Check to select or unselect every rules in the table.");
column.setWidth(bound);
allEnabledChecked = false;
Expand All @@ -184,13 +190,13 @@ private TableViewerColumn createEnabledViewerColumn(int bound, final int colNumb
@Override
public void handleEvent(Event event) {
if (!allEnabledChecked) {
column.setImage(ImageService.ENABLED);
column.setImage(ImageFactory.getImage(ImageFactory.ENABLED));
for (CheckerPreferencesContainer checker : inputs) {
checker.setChecked(true);
}
allEnabledChecked = true;
} else {
column.setImage(ImageService.DISABLED);
column.setImage(ImageFactory.getImage(ImageFactory.DISABLED));
for (CheckerPreferencesContainer checker : inputs) {
checker.setChecked(false);
}
Expand Down

0 comments on commit 9987d48

Please sign in to comment.